XNA Creators Club Online
Page 1 of 1 (2 items)
Sort Posts: Previous Next

Collision detection

Last post 11/2/2009 10:35 PM by PinoEire. 1 replies.
  • 11/2/2009 10:14 PM

    Collision detection

    Hi!
    I'm new to these forums so I thought it would be polite to start with a hello.

    Anyway, I'm designing a game, and by that I mean, I have opened up C#, had a friend of mine play artist and doodle up some sprite sheets for me. And I'm trying to focus on keeping a solid Objected Oriented design in my game. So I have a basic class for an animated character, one for a human character and a Game Component holding everything together. I can implement a background, and background objects, but I don't know how would be the best way to implement the collision detection between the background objects and the animated characters without it being a mess. Should I be adding another class to override the first one(Animated character class), to implement collision detection in the Update()?

    I can add collision detection, I just am having trouble trying to do it in an organized fashion...

    Does anyone have any tips or tricks to how they design their class Hierarchy?
  • 11/2/2009 10:35 PM In reply to

    Re: Collision detection

    Hi Anthony,

    there are many different approaches to this, I can tell the one I prefer to use. I have a collection containing references to all the collision-enabled objects in my world. A method List<ICollisionEnabledObject> GetNearbyObjects(ICollisionEnabledObject obj) allows me to have the objects around me within a defined InfluenceRadius (property in my ICollisionEnabledObject interface). In the Update of my ObjectComponent (the one I use to define any object in my games) if the object is collision-enabled I get the neerby objects list and check for collisions. I have two kind of collision-enabled objects: ActiveObject and PassiveObject. Only the ActiveObject performs the collision check.

    I hope the above can be a good pointer ;)

    Cheers,
    Pino
Page 1 of 1 (2 items) Previous Next