Ever wanted some thing to orbit around a object?
Like a moon orbiting around a planet?
Well, thats what we're going to make in this tutorial.
Now, fire up Game Maker and creat a new object and a room.
Thats all we need. No sprites or more objects.
Add a creation event to the object and put this code inside a script:
You can change the distance and orbspeed to whatever you want, but you ought to keep it like this untill we are done.
Add the following code to the step event:
In this script we simply add the orbspeed to the orbstep.
lengthdir_x calculates the x position the moon should be drawn at.
lengthdir_y is of course the same as lengthdir_x. but returns y.
And finally, put this in the draw event:
You can of course draw sprites or whatever at those positions.
Now, put the object in the middle of the room and hit F5.
You see ?
That wasnt very hard, right?
Want to get in touch? Got some feedback for me? or a couple of requests? Follow me at twitter: