It took me a long time to figure this out, because I'm incredibly mathematically inept. I figured there might be others like me, so feel free to use this little function as you see fit :)
UPDATE: Added complexity to the function and added a rudimentary example on-screen.
Awesome, thanks for writing this up and putting it into a nice function. Like you, the math has been the most challenging part of Pico-8 making...it's been bits and pieces here and there.
Thanks, and you're welcome! :D
Also, the function has gotten an update:
It now takes a few more parameters, letting you draw a sine in a box and extrapolates the amplitude from its dimensions.
Now, aside from sine(), I've made draw_sine()
draw_sine(speed, phase, top-left corner, bottom-right corner, [wave colour, wave thickness, border colour, background colour] ) |
By replacing any of the colours with nil, they revert to their default values; the sinewave will be 7 (white), and the background and border will both not be rendered at all (making layering possible)
top-left corner and bottom-right corner are both {x, y} pixel-coordinates
Glad you threw this together. I too am mathematically challenged and you just can't do demoscene stuff without SINE and COSINE. ;.;
[Please log in to post a comment]