Jump to content
  • Advertisement
Sign in to follow this  
deonbotha

[java] bomberman collision

This topic is 4827 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm working on a bomberman clone which can be seen [ here ] and have a question about the player tile collision. At the moment the player sprite is 16 x 24. whereas the space the player can travel between tiles is 16 x 16. When the collision detection I'm using asks for the player height I specifically say its 16 instead of 24 so that the player can actually move around, with the head overlapping at the top. The problem is that movement is tricky and its hard to move between some tiles as the player has to be in the 'pixel perfect' position to actually fit through the tiles. If you play the game a bit you'll see what I mean. I can make it really easy to move between the tiles by specifying the player width and height to be around 14 pixels, however when I draw the sprite then it overlaps horizontally by 2 pixels and also the player can move 2 pixels to high. How should I go about making it easy for the player to move around but still draw the sprite correctly?

Share this post


Link to post
Share on other sites
Advertisement
Well, don't let him move 1 pixel at a time, but each time he moves, he has to move like 4 pixels at a time (you'll smooth that out ofcourse).. That way he can quite easily move..

Share this post


Link to post
Share on other sites
sorry maybe i wasn't too clear, I'm not bothered with the speed at which he moves at the moment, rather the fact that its very hard to fit between the tiles. or am I understanding you wrong?

Share this post


Link to post
Share on other sites
I think you misunderstood me as well... He'll still move at the same speed, but even if you release the key after two pixels, he'll continue until he reaches the fourth.. That way, it should be quite easy to see/know when you can move in between the tiles.. :)

Share this post


Link to post
Share on other sites
Well, there are two ways to address this.

1. The first option is an auto centering effect. When the player stops pressing a direction the avatar doesn't just stop, it determines which tile it is inside and only stops competely once centered. Obviously this changes the control a little, as you lose the judgement call required to make sure you are placed cleanly in a tile as the game does that for you. I actually prefer this.

2. The other option is to effectively curve the corners of your blocks, which is what Bomberman does. Notice that pushing into the corner of a solid tile actually sees the avatar slide around the corner a little. You'llbasically need to detect how close to the corner the player is when pushing against a solid block. The closer they are, the more you push them away from the center of that tile at a right angle.


Hmmm, I guess that might be a little hard to understand, it certainly isn't easy to explain but either one of those will solve the problem, it's a matter of preference.

Hope thats of some use.

Share this post


Link to post
Share on other sites
How about using a circle as the collision 'box' for the blocking tiles? So if a blocking tile is at x,y, then give it a radius of the box's width / 2, and then do collison using that radius. Basically each blocking tile is really a circle.

Share this post


Link to post
Share on other sites
Wouldnt that mean you would actually be able to move into the tile slightly at the edges because even though the collision for the tile is being handled as a circle, the tile image is essentially a square? I got it working though as a square, I used ghosted method #2. You can check it out in action here. what you think?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!