Log In  

Hello erreybuddy. I don't have a specific project I'm working on or anything, but it's been bothering me that I don't understand how this works. I do have a pixel that oscillates properly, but I do not understand my own code, so I don't know how to approach having the pixel start at a different point in the oscillation cycle, without the amplitude changing. Here's my current code.

f=0
function _update()
 f+=5
    y = sin((f)/100) * 8 +64
end

function _draw()
    cls()
    pset(64,y,7)
end

If any smarty-pantses could explain why this code works to me like I'm a child, or how to have the pixel start at another point along the wave without changing amplitude (the x and y values of the top and bottom of its current pattern of movement), that'd be great.

I do feel bad asking for something without contributing to the community. Hopefully someday I can give back a little. Thank you all.

P#46323 2017-11-15 14:44 ( Edited 2017-11-15 20:03)

that would be replacing f=0 with f=n where n is somewhere between 0 and 100. 25 is full up, 75 is full down.

P#46324 2017-11-15 14:52 ( Edited 2017-11-15 19:54)

@ultrabrite thank you for that and the quick reply. i'll take it from here

P#46325 2017-11-15 15:03 ( Edited 2017-11-15 20:03)

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-04-07 21:07 | 0.014s | 2097k | Q:14