Log In  

Cart #34754 | 2017-01-02 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
15

Cart #34745 | 2017-01-02 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
15

Cart #34666 | 2017-01-01 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
15

Cart #34663 | 2017-01-01 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
15

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.

P#34664 2017-01-01 11:01 ( Edited 2017-09-12 14:33)

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.

P#34698 2017-01-01 20:22 ( Edited 2017-01-02 01:22)

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

P#34746 2017-01-02 12:36 ( Edited 2017-01-02 17:36)

Thanks! That's great.

P#34757 2017-01-02 15:14 ( Edited 2017-01-02 20:14)

Hurrah! I'm glad you like it! :D

P#34809 2017-01-02 23:18 ( Edited 2017-01-03 04:18)

Glad you threw this together. I too am mathematically challenged and you just can't do demoscene stuff without SINE and COSINE. ;.;

P#44116 2017-09-12 10:33 ( Edited 2017-09-12 14:33)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-29 14:47:20 | 0.014s | Q:27