Archived

This topic is now archived and is closed to further replies.

spillsome

shoot 'em up and missile

Recommended Posts

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

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites
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 somewhere

list<missile> missile_list;

// in WndProc

case KEYDOWN:
switch ( wParam )
{
case VK_SPACE:
missile_list.push_back(missile(player.x, player.y));
break;
}
break;

// then somewhere in Game_Main or whatever

list<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_Shutdown

missile_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!"

Share this post


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

Share this post


Link to post
Share on other sites