Sign in to follow this  
Xrid3r

openGL - game problem

Recommended Posts

Xrid3r    100
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 this post


Link to post
Share on other sites
karwosts    840
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 this post


Link to post
Share on other sites
szecs    2990
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 this post


Link to post
Share on other sites
eskimo456    100
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 this post


Link to post
Share on other sites
jyk    2094
Quote:
Original post by marius1930
Unless 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.

Share this post


Link to post
Share on other sites

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

Sign in to follow this