# A Heart of Cosines Blocks

**URL:** https://forum.makecode.com/t/a-heart-of-cosines-blocks/6791
**Category:** Arcade
**Tags:** graphics-and-math, game
**Created:** [March 16, 2021, 3:34am UTC](https://forum.makecode.com/t/a-heart-of-cosines-blocks/6791 "2021-03-16T03:34:03Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![NxNMatrixGL](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/nxnmatrixgl/32/2553_2.png) [@NxNMatrixGL](https://forum.makecode.com/u/NxNMatrixGL)
#### Post date: [March 16, 2021, 3:34am UTC](https://forum.makecode.com/t/a-heart-of-cosines-blocks/6791/1 "2021-03-16T03:34:03Z")

</div>

> **[A Heart of Cosines Blocks](https://arcade.makecode.com/58114-81223-69737-25712)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

I first learned of this wonderful heart equation 5 years ago on Google+. Read about it here on this blog [post](https://walkingrandomly.com/?s=heart).

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.

---

<div class="post-metadata">

### Author: ![eanders](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/eanders/32/3134_2.png) [@eanders](https://forum.makecode.com/u/eanders)
#### Post date: [March 16, 2021, 4:15pm UTC](https://forum.makecode.com/t/a-heart-of-cosines-blocks/6791/2 "2021-03-16T16:15:41Z")

</div>

Very cool!

---

<div class="post-metadata">

### Author: ![kwx](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kwx/32/1545_2.png) [@kwx](https://forum.makecode.com/u/kwx)
#### Post date: [March 16, 2021, 4:59pm UTC](https://forum.makecode.com/t/a-heart-of-cosines-blocks/6791/3 "2021-03-16T16:59:49Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![NxNMatrixGL](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/nxnmatrixgl/32/2553_2.png) [@NxNMatrixGL](https://forum.makecode.com/u/NxNMatrixGL)
#### Post date: [March 16, 2021, 5:30pm UTC](https://forum.makecode.com/t/a-heart-of-cosines-blocks/6791/4 "2021-03-16T17:30:24Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![NxNMatrixGL](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/nxnmatrixgl/32/2553_2.png) [@NxNMatrixGL](https://forum.makecode.com/u/NxNMatrixGL)
#### Post date: [March 16, 2021, 5:30pm UTC](https://forum.makecode.com/t/a-heart-of-cosines-blocks/6791/5 "2021-03-16T17:30:26Z")

</div>

> **[A Heart of Cosines Blocks](https://arcade.makecode.com/59589-99197-15867-89561)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

- Added the pressed events to the A & B buttons.

---

<div class="post-metadata">

### Author: ![kwx](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kwx/32/1545_2.png) [@kwx](https://forum.makecode.com/u/kwx)
#### Post date: [March 16, 2021, 6:01pm UTC](https://forum.makecode.com/t/a-heart-of-cosines-blocks/6791/6 "2021-03-16T18:01:01Z")

</div>

I filed [https://github.com/microsoft/pxt-arcade/issues/3288](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.)

---

<div class="post-metadata">

### Author: ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)
#### Post date: [March 16, 2021, 6:03pm UTC](https://forum.makecode.com/t/a-heart-of-cosines-blocks/6791/7 "2021-03-16T18:03:13Z")

</div>

> [@kwx](#):
>
> 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.

I responded over on the github issue, but there is a way to do this currently: in the controller extension  
 ![image](https://user-images.githubusercontent.com/5615930/111357231-5d88a100-8646-11eb-81c0-0adebd204ed5.png)  
there’s a block to set the delay / interval for repeat, and setting delay to 0 should behave as you want.  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/e/e8ec5f293327001f22f22cf6fcd6b602422af969.png)  
And here’s an example: [https://makecode.com/\_Vvuasy3UXLwD](https://makecode.com/_Vvuasy3UXLwD)

---

<div class="post-metadata">

### Author: ![NxNMatrixGL](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/nxnmatrixgl/32/2553_2.png) [@NxNMatrixGL](https://forum.makecode.com/u/NxNMatrixGL)
#### Post date: [March 17, 2021, 2:54pm UTC](https://forum.makecode.com/t/a-heart-of-cosines-blocks/6791/8 "2021-03-17T14:54:27Z")

</div>

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.
