Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm currently in the process of making a top-down shooter for my programming class, and one idea I had, but don't exactly know how to implement is image rotation in order to spin the object continuously. What I have are spaceships, and right now all they do is face one static direction. All I want is to have them non-stop spinning at a rate that people can see (not so fast that it looks like a blur). I've seen some code about rotating by a certain degree, etc; but no constant rotations. I'm not too sure how to go about this, but any help would be appreciated greatly.

Also, I'm using C# and Visual Studio 2010.

share|improve this question
If you have seen code about rotating, you can use this, but always in your update method, update angle, which you are using for rotation. For example: increase angle with some constant and if angle is more then 360° (2*pi), just subtract 360°. – zacharmarz Oct 24 '11 at 8:16
Since I don't know what exactly you're using for graphics, I can't say for sure. But if you're using XNA and drawing your sprites with SpriteBatch then SpriteBatch.Draw() allows you to rotate sprites. Then you'd just have to have some Rotation property which you increase every update (wrap after 360) – Mike C Oct 24 '11 at 9:35

how to implement is image rotation in order to spin the object continuously

If you use XNA it's quite simple: Update and Draw methods will be called continuosly at the frame rate interval.

Have a look here. The only things you need to do are:

  1. Get the input inside your Update(GameTime gameTime) method and update a use a variable to store the rotation angle relative to the texture you want to rotate
  2. Use SpriteBatch.Draw() method specifying the rotation angle and the origin of the rotation.
share|improve this answer
Finally i found you, Heisenbug, was beginning to think you didn't exist at all! :) – George Duckett Oct 26 '11 at 7:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.