A Heart of Cosines Blocks

I first learned of this wonderful heart equation 5 years ago on Google+. Read about it here on this blog post.

Press A to increase the step size and B to decrease the step size of the Cosine plot. Enjoy and experiment with the beauty mathematics has to offer.

8 Likes

Very cool!

1 Like

Nice! A small suggestion, the A/B buttons currently only react to onRepeat, so you need to hold them down a while to get a change and it’s hard to give the parameters a small nudge.

This reminds me, would it make sense for Arcade to provide a combined event that is triggered on both first press and repeat? I find myself often repeating the same logic for both. Extracting the common code into a function helps but is a bit clunky.

1 Like

It would be nice to have a block to combine them. I didn’t realize I lost the small nudge. Yes, I will need to add the on-press event back.

1 Like
  • Added the pressed events to the A & B buttons.
2 Likes

I filed https://github.com/microsoft/pxt-arcade/issues/3288 asking for a “onPressOrRepeat” event handler choice. (The name isn’t very elegant, but ideally it should be clear what it does without needing separate explanations.)

3 Likes

I responded over on the github issue, but there is a way to do this currently: in the controller extension
image
there’s a block to set the delay / interval for repeat, and setting delay to 0 should behave as you want.
image
And here’s an example: https://makecode.com/_Vvuasy3UXLwD

2 Likes

I forgot about this option and I used it in the first game my son and I coded together. We learned about it from one of Peli’s live coding sessions.