Circular Motion
BlitzMax Forums/BlitzMax Beginners Area/Circular Motion
| ||
Hi all, The concept of what I'm after is pretty simple, but I'm struggling implementing it. I guess I need to read up on how cos / tan / sin etc really works mathematically. Anyhow, what I'm after, is for a simple sprite / icon to rotate in a circular motion (let's say the centre of a 1024x768 screen would be the centre point. Then, when the user hits a key (spacebar) the icon stops moving in a circular fashion, but then moves from the point where it was stopped to the centre of the 'circle' (screen) and back out again until the user hits another key. You might be able to gather from this that I'm working on a darts-type game (not regular darts!) I won't post any code yet, because I've been through so many variations of trial and error, it'd almost be pointless! :) Any help would be greatfully received. |
| ||
To plot a circle, you use X=Cos(Angle)*Radius Y=Sin(Angle)*Radius Change the angle to make it rotate in a circular motion. Angle is 0 when it is right or east. Change the radius to make it move toward and away from the centre of the circle. If you want to position it in the centre of the screen, then you would just add 512 to the x coordinate and 384 to the y coordinate. |
| ||
Thanks Gabriel - that looks a lot succinct and simpler than any of the methods I attempted. Will give it a try when I get out of the office! ;) |
| ||
If you want to position it in the centre of the screen, then you would just add 512 to the x coordinate and 384 to the y coordinate. Or use SetOrigin 512,384 |
| ||
Or use SetOrigin 512,384 But that will affect all other drawing operations until you use SetOrigin 0,0 to reset it. |