Skip to main content
GameDev.net gamedev.net

PRO Tired of ads? Read GameDev.net ad-free and help keep the community independent with GameDev Pro — $3/month.

Perfect Circle

Perfect Circle

r1ckparker
r1ckparker's Journal · · 1 min read
3,372 0

Sin and Cos are a programmers best friend! I was looking at other games for inspiration and I saw this image from r-type


A circle of aliens spins around the player and you have to shoot them from the inside.

To calculate the points of a circle is quite easy, the calculation is -

x=(radius*cos(angle))
y=(radius*sin(angle))

Therefore I have an array of 10 objects which is calculated as follows -

cx=(230*cos(i*36))
cy=(230*sin(i*36))

230 pixels from the 'origin' and I have 10 objects - 360/10=36. I is incremented by 1 each step.

I now have a nice circle of aliens, I can increase the number by reducing the number 36. I can make the circle smaller or larger by increasing the radius.

The first level is more or less complete, with boss monster at the end. On to the second level!


Discussion

Loading comments...