Sun & Moon Movement

Posted by Thomas Mosey on Game Development See other posts from Game Development or by Thomas Mosey
Published on 2014-06-01T14:10:33Z Indexed on 2014/06/01 15:57 UTC
Read the original article Hit count: 277

Filed under:
|
|

I'm creating a 2D HTML5 Canvas Game and am stuck on how to go about animating my Sun & Moon. The current setup is basically setting the moon at -1024 on the X-axis and the sun at 0 and animating them at 1 pixel a second. My canvas width is 1024 pixels and whenever the sun/moons X position crosses over the width of the canvas, it's X position is then set to -1024 to repeat the animation.

What I am trying to do is get it to sync up with my day/night cycles. Each day is 10000 ticks long (A tick being added every frame) with Day/Night being 50% each (5000 ticks each). What I am trying to calculate is what I'll need to add to the X position of each per frame to get the sun from an X of 0 to 1024 after 5000 ticks/frames.

Any help is appreciated.

© Game Development or respective owner

Related posts about 2d

Related posts about mathematics