🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Perfect Circle

posted in r1ckparker's Journal for project Psy
Published April 25, 2019
Advertisement

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

R-type.png.217a6f2b21c6d5099a7574d855eb999a.png

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!

 

1 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement