shoot 'em up and missile

Started by
7 comments, last by spillsome 22 years, 8 months ago
I''m currently developing a shoot''em up (vertical scrolling) in directX 8 kind of gigawings on the dreamcast or silpheed on the ps2 ! I can move my spaceship and I have some aliens moving on the screen. My question is : Now, i want a missile to launch each time I press the space key. How can i do that. Do I have to put each missile in its own thread....i can not figure out. thanks for your help
Advertisement
Well...how are you moving the ship and aliens?

For missles, you can just create a missile, add it to a list, and just update the list every ''frame'' and draw them accordingly...check for collision, etc...

G''luck,
-Alamar
I have a list for the aliens.

Should I add the missiles to the list when i hit the space key ?

it is not clear in my mind

thanks

Like Alamar said. The method I used was when my App had detected input for firing it would add a struct to my list that represented the missile.
Yeah, I would add them to your list. I would use this for everything that could be added or deleted during runtime (like missiles, enemies, etc.).
I tried using multiple lists once, didn't like the results.

"A man can't just sit around." 'Lawn Chair' Larry Walters (1982)

Edited by - Tracy on July 26, 2001 3:32:10 PM

Edited by - Tracy on July 26, 2001 3:33:54 PM
"A man can't just sit around." 'Lawn Chair' Larry Walters (1982)
I am currently making a 3d shooter like you describe but with multiple camera angles that can be changed in the script for the level (top down, behind, side view, etc) kind if like Einhander for the PS. Anyway, I made a 2 player ship dueling game back in high school and I made a linked list for all of the projectiles, that way you could just traverse the list, updating positions, checking for collisions and displaying for each node / bullet in the list.

Brian Hlubocky
hlubocky@uiuc.edu
Here''s some code to gnaw on.
  // we''ll assume that you have a missile structure somewhere// that has a constructor that takes an x and a y for// the missile''s position.// declare this global somewherelist<missile> missile_list;// in WndProccase KEYDOWN:    switch ( wParam )    {    case VK_SPACE:        missile_list.push_back(missile(player.x, player.y));        break;    }    break;// then somewhere in Game_Main or whateverlist<missile>::iterator i;for ( i = missile_list.begin(); i != missile_list.end(); i++ ){    // update missile coordinates or whatever...    // and if you need to delete a missile, just use:    missile_list.erase(i);}// and in Game_Shutdownmissile_list.clear();  


I like STL too much.

-----------------
The Goblin (madgob@aol.com)
-----------------
"Before critisizing somebody, walk a mile in their shoes. That way, when you do critisize them, not only will you be a mile away, but you''ll also have their shoes!"
- The Goblin (madgob@aol.com)
Spillsome,

The easiest thing is to have lists which represent things on the screen. Enemies, Weapons, etc. are all stored in the list, and every frame, check what each element on the screen is supposed to do (ie, run each element''s Action Function which takes care of the movement, etc.).
Somewhere in your main loop, check for Input, and if it is Space, you''ll need to do 2 important things: 1, Check if enough time has elapsed so you can fire a missile (you don''t want to fire a missile every frame. The missile needs a refire rate), and 2, If enough time has elapsed, add the missile to the list, given the starting X,Y coords.

Hope that helps.

Nutts

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

Thank you very much to all of you

I will try as soon as i get back home !!


long life to gamedev.net


Have you been looking at the MVC (Model-View-Controller) pattern yet. I think this is what you''re actually looking for.

This topic is closed to new replies.

Advertisement