[java] drawing sprites

Started by
11 comments, last by Sqorgar 18 years, 8 months ago
I've found that collision detection works best as part of a sprite in some situations, while not in others. For instance, moving a character around in a 3D space would likely be most simple using a standard cylinder no matter what animation he is in. However, the collision for things like bullets require much more precision and are dependant on the current pose.

I've never bothered to implement it (I exclusively work on 2D games at low resolution, so complex collision detection has never been a problem) but I've always wanted to make a sprite system where each sprite had multiple collision zones, so that swinging a sword would move the "to-hit" zone around with the animation. It was something that I wanted to link with my composite sprite system to allow characters to equip different sized swords to swing around, but even then it is more complex when a simple length variable would work just as well. But I'm one of those engine guys who likes to decouple everything and make 10,000 classes when I only need 3.

Such a system would be more difficult to implement than just rendering sprites, so my recommendation is, because you are making a bomberman clone, just use a simple rect or circle at the feet by character and leave the collision stuff out of sprite altogether. You just don't have complicated enough collisions in that sort of game to justify the development of such a complex system. In fact, unless you are using a large sprite fighting game like Street Fighter II, I don't think you'll need anything more complicated for any 2D games.
--Sqorgarhttp://gamebastard.blogspot.com
Advertisement
yea at the moment i am using a rect and it works fine by the looks of things.

link to game if you're interested

Still early stages though.What I'm struggling with though is the bomb collision detection when it explodes. If I check the collision detection inside the bomb sprite I need to pass a reference of the tilemap/game sprites and then check if the flames hit any of them. Giving the bomb a reference to the tilemap just seems a bit odd to me and I was wondering if it was the correct way of approaching this.

At the moment the only collision detection I have done is for the player and I did that outside of the player class as part of the game loop, this again was so I didnt have to give the player a reference to the tilemap. Any suggestions?
-----------------[ serafin studios ]
When I created a bomberman game, oh so many moons ago, I used a sort of meta-tilemap to deal with the explosions. Nearly all the logic that goes on in a game like that happens on a tile basis. The metamap kept track of basically the explodable blocks, bombs, and flame - with timers for each to handle animations. Only the two actors were specifically sprites. Then with each actor, just check to see if the tile they are standing in is currently a flame metatile and boom.

Using flame sprites can have certain advantages by not being linked to tile boundaries, but if it was good enough for every Bomberman game ever made, it was good enough for me :)

But as for your question, most actors have some sort of reference to their environment. Allowing the bomb to see the tilemap is not that absurd a proposition.
--Sqorgarhttp://gamebastard.blogspot.com

This topic is closed to new replies.

Advertisement