Need advice on game design

I have a single player, multiple enemies, one main weapon with 3 optional weapons to be picked up along the way (used by both player and enemy) I need to figure out how I'll manage to keep track of all of the collisions on screen.

Right now, with only 2 players I had a base class handle all collision detection: collarea I was thinking of making another class, collisionhandler that will hold either a vector of collarea's for multiple bullets, grenades, rockets, etc. but I need to figure out how to communicate with the enemy class for collision detection.

I might add a pointer to collarea to collarea to make a linked list of collarea classes to run through. I also might have a class like such:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
enemy.cpp:
enemy::checkhits()
{
    int crashes[], num;
    collhandler->getcollisions(&crashes,&num);
    for(int i=0;i<enemies.size();i++)
    {
         int hit=0;
         enemy e = enemies[0]
         enemies.erase(0);
         for(int j=0;j<num;j++)
         {
            if(crashes[j]==i)
               hit=1;
         }
         if(!hit)
             enemies.push_back(e);
    }
}
rocket.cpp:
rocket::checkexplode()
{
   int crashes[],num;
   collhandler->getrockethits(crashes[],num,0)//0 for player, 1 for enemy
}
etc...


I'm not sure how scalable this is. I'm embarrassed this seems like such a simple design problem. Any ideas?
Here's a thought: I can reduce space and clock and processor usage by declaring 1 collarea per weapon for player and enemy, and all this will be in a struct:

1
2
3
4
5
6
 
collarea goodrocket, badrocket,etc;
struct weapon {
     float x,y,theta;
};
vector<struct weapon> gr,br,etc; //gr = "good rocket", etc 


yeah I'll think I'll do that. much smarter. But still need to figure out how to update info. Oh wait: void collisionhandler::updaterocket(int i,int x,int y,int theta,int good)
Nailed it. Sometimes you gotta write these things out. Even if only you are gonna look at it.
Topic archived. No new replies allowed.