# openGL - game problem

This topic is 2751 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi you guys!

I have been working with a little game in openGL for a while and things have worked out pretty well until now..
It's like the classic game spaceinvaders.. You see I'm using c++ and Codeblocks as IDE. and I've tried to make a spaceship that you can rotate and move in the rotated direction. I've also tried to make a weapon to the ship..

Hope someone of you can tell me about or give me somewhere i can read about the general structure of this two things.

~Xrid3r

##### Share on other sites
This really isn't anything to do with opengl, but more of a game design question. OpenGL renders meshes to the screen, and has nothing to do with input controls or "making a weapon".

##### Share on other sites
That sounds more like Asteroids than Space Invaders.

What part do you need help with exactly?

##### Share on other sites
My opinion (sometimes I feel I'm alone with this):

A very important thing in game programming and programming in general:
There's no "weapon" there's no "spaceship". There's only the code. It is very important to understand. If you can define the behaviour of the "weapon" in detail (what you expect it to do), you almost did the job.

And to learn this: you have to struggle with it alone.

##### Share on other sites
Hi i'm assuming your fairly new to this to.

In order to rotate an object in openGL or most other languages (I think). You have to use trigonometry.

If you convert the angle into radiens. You can then multiply this by a speed to get the spaceship to accelerate and move in the direction you wish.
To convert to radiens you take your (angle/360 * 2 * pi)

You can multiply this by sin or cos (which gives you a number between 1 and -1)

then multiply this by the speed for movement.

For example if you want your spaceship to turn 180 degrees the Z would be -1 with trig. if the speed is 5 5*-1 is -5 allowing your ship to move backwards.

Hope this helps I would look at http://www.silverlightbuzz.com/2009/03/29/rotation-controlled-direction-using-trigonometry-and-radians-in-silverlight/

for a quick overview of this

Hope this helps

##### Share on other sites
Quote:
 Original post by eskimo456To convert to radiens you take your (angle/360 * 2 * pi)

Unless im totally off here, OpenGL uses degrees not radians.

##### Share on other sites
Quote:
 Original post by marius1930Unless im totally off here, OpenGL uses degrees not radians.
There's a couple of deprecated OpenGL convenience functions that use degrees (e.g. glRotate*()), but generally speaking, using OpenGL in no way means you have to use degrees in your own code.

1. 1
2. 2
3. 3
4. 4
Rutin
17
5. 5

• 11
• 31
• 12
• 12
• 11
• ### Forum Statistics

• Total Topics
631409
• Total Posts
2999927
×