Jump to content


Interfacing problem


1 reply to this topic

#1 gardon

    Valued Member

  • Members
  • PipPipPip
  • 282 posts

Posted 10 September 2006 - 08:06 PM

Stupid question, but I need some help.

I'm trying to decide how to detect collision, and overall object interaction. As of right now, I have the following format of classes:

Code:

CEngine    ->CResourceManager---------------------------
            ->CTimer                                       
            ->CIncludes
            ->CObject        ------->CItem
                              ------>CCharacter    -------->CPlayer
                                                  -------->CEnemy
  

What this basically means is that CEngine handles the application, CResource manages the resources (images and things used for associating classes with their respectible bitmaps), and CObject has two branches:

CItem (not yet used further, but will contain pick-up items (health, etc.) and static objects (maybe trees, and stuff) )
CCharacter which is the adult class for CPlayer and CEnemy.

Now my question is: if I have the input done in CEngine, I can easily pass it to the CObjects (by calling Update and passing in the input, or whatever) and update them.

HOwever, if something so deep, such as CEnemy, is updated with, say, a gunshot somewhere on screen, how can I come back and check the player to see if he has been hit?

The only real thing I can think of would be to store all information regarding objects on screen to the Resource Manager, and then updating everything again.


Or is there a better way?

Thanks,

Jason

#2 Ed Mack

    Senior Member

  • Members
  • PipPipPipPip
  • 1239 posts

Posted 10 September 2006 - 10:35 PM

Whoever shot the bullet could just ask the collision detection system if the bullet hit anything, and if it did contact that object and tell it that it has been shot. That said, there are millions of answers, and what suits your system is something only you can know)

You could use messaging system for this (and lots of other bits of game logic), so the shooter can send a message to the named victim, the victim can send a message `I am dead' to all, and then other characters can react to that.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users