Jump to content
  • Advertisement
  • entries
    48
  • comments
    57
  • views
    43547

Perfect Circle

Sign in to follow this  
r1ckparker

857 views

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!

 

Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!