i have a variable that goes up like a timer, and i need to use it to make another variable that goes like…

in a zig-zag motion. i need it. right now.
i have a variable that goes up like a timer, and i need to use it to make another variable that goes like…

in a zig-zag motion. i need it. right now.
If you want to do it using only “regular math”:
With a little bit of experimentation, I was able to get this:
Unfortunately, I can’t find sin in blockssin is available in blocks; pi is exposed in the arcade-sprite-utils extension.
Using a piece-wise function, I was able to get this:
It should be easy to implement in blocks, as mod is in blocks. (as the remainder of [ num ] / [ num ])
Share link to the equations: https://www.desmos.com/calculator/skuazm3gad

oh boy do we got sine’s
@UnsignedArduino and how do I turn this into blocks?
@urassari like this?
or if you really want it to be linear:
Here’s what I did:
Had to modify the equations a bit to not use negative mod: (still exactly the same output) (as it’s funky in JavaScript)
@UnsignedArduino I’m so tired of my brain trying to understand how am I going to implement this to my game. https://arcade.makecode.com/S43710-98942-32379-76387 here is the game. Just… Fix it. Because I can’t.
What have you tried? I don’t see an obvious place to put it.
i fixed it.
here set the variable’s y to 2 *(((y1 / 2) * (x / x1 % 2)) - (y1 * (Math.floor(x/x1) % 2))) / (-1) ** Math.floor(x / x1);
were x = time since game start / speed
x1 is the horizontal distance between peek’s
y1 is the height the peek’s
in total i made 3 versions that work