Skip to main content
GameDev.net gamedev.net
🔒 Locked

2D collision detection problem.

Started by Jompe71 Apr 3, 2007 at 9:22 AM 1 replies 550+ views
Original Post
Jompe71
Jompe71
I'm writing a 2D collision detection class and need input on a problem. My class can handle tiles registered with a bounding box as either "blocking" or "affecting". This I thought would be smart if I had cases like fans, escalators, ladders etc. which affected the sprites somehow. HOW they where affecting is up to the game logic. The same goes for "blocking tiles"... Now my problem: I need some tiles to work on both, i.e. affecting AND blocking. The speciffic case is the ladder. It's climbable but not blocking if I lets say jump through it. On the other hand it's supposed to be blocking if I jump standing on top of it, but not climbing down on it. How is this "usually" handled ? I was thinking of putting affecting tiles in one lookup grid and blocking in another. Then I can look in each grid depending on the purpose. Anyone care to input ? Regards, Jompe
JohnBolton
JohnBolton
How about three lists -- blocking, affecting, and blocking/affecting? It isn't very scalable, but the alternative is to have a single list look at each element in it to see if it has the right property.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
Jompe71
Jompe71
I've actually gave it a 2nd thought. I think it's not the property of the tile (which in my case is only an numeric value).

Maybe I have to have different layers in the level format (Mine is at current only one). This give me the option to have tile blocking but fully transparent in the bottom layer. And affecting tiles on a second layer.
I think this will solve the ladder case...

The second option is to use the single list, but expand the tiles to hold more info.

BUT it's a java mobile game and the last thing I want to do is to turn it into more OOP logic. This will slow down the performance radically.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.