PDA

View Full Version : Shooting, starfield, how?



Rulz
03-10-2002, 09:24 AM
I'm currently working on my first game(a semi-2d space shooter) in opengl and I am having some troubles

I was thinking to handle shooting, enemies, explosions, afterburner and so on with a particle engine.

I now have the afterburner quite good and i am about to start with shooting/scrolling starfield (whichever i get working first http://www.opengl.org/discussion_boards/ubb/smile.gif)and i have bumped into a few problems:

Shooting: I am having problems being able to actually shoot when control is pressed, i could use a similar technique to what i used in my afterburner but it would be like a machine gunm that would be hard to control, what i would like is a "one shot per press"

Starfield: The positioning of the stars so that they are within view, and also the scrolling i find hard

Thanks for your time, probably simple sulutions to both the problems

Furrage
03-11-2002, 05:45 AM
Shooting is more related to C/C++ than to OpenGL. Its controlled by the keystroke handler. When the shoot key is pressed, fire the shot and then set a state to say that the shot has been fired. When the key is released clear the state. Each time you're about to fire the shot test the state first. If it is set don't bother. This is necessary since you might get more than one keypressed event if you hold down a key, and you want the shot to be fired only the first time the event happens for a keypress.

The positioning of the star field will depend on how you translate it. Try nehe's website http://nehe.gamedev.net . It might have tutorials on the subject.

ppinter1
03-11-2002, 11:25 AM
I don't know if this helps, but you may want to check out http://p-squared.com/SpaceTime.php for an example.

The skymap is probably usable as is, and the animated starfield could be changed to shoot particle weapons very easily.

Also, SpaceTime uses my free 3DS mesh loader to import 3D Studio MAX artwork which may be useful to your game... dunno.

Complete source code is available for the price of a pint of Double Diamond, plus a tip for my buxom barmaid.

Cheers,
/p2