Hello, everyone! I've come to a point that I'm stuck on, and I'm not sure how to continue from here. Currently I'm making a 2D side-scroller with large-ish sprites (64x64 up to 128x128) and I need a few forms of collision detection. I need at least one for collision with projectiles, and one for collision with environments. I know that pixel-perfect is time-consuming, so what would be the next-best thing?

Busy between school, work, life, games, programming and general screwing around.If you'd like some pixel art for your game, send me a PM, i'll see what I can do.Current project: http://elementalwarblog.wordpress.com/

I used regular Rectangle's for collisions with projectiles. Then some points around the character for environment-collisions. I wrote up an article about it here.

In my game, each sprite/entity then has an array of inner Rectangle's. So if, a projectile's Rectangle collides with the outer Rectangle of an entity, I check which of the inner Rectangles (if any) it is colliding with, and deal damage and so forth accordingly. Then I check for projectile-collisions with the terrain.

if u look the implementation of the intersects method of the rect class you will see that i just a check between the basic variables of the two rect to chek, for my there are not difference between proiectiles and environments, both are Entity so use this method.

Just for optimize and control the collision i have one list that contain all the shot of the enemy versus the playerand i verify the collision hire between player and enemy shotand i have another list that contain all the environment and ther i verify the collision between player and environment elementsfinally i have one for the enemy and i use it to verify player proiectiles versus enemy and enemy to player collisions

Java2D? Or some other library? And why would you need two systems of detection?

I'm using Slick2D, and I need one system for collision with the world (which uses tiles) and one for getting hit by other player's attacks. I was thinking of using rectangles overlapping certain parts of the body for attacks, but for collision with walls that doesn't make much sense... also, just to give you an idea of what the character looks like: and when he's running:(arms are rendered in-game)

Busy between school, work, life, games, programming and general screwing around.If you'd like some pixel art for your game, send me a PM, i'll see what I can do.Current project: http://elementalwarblog.wordpress.com/

I used regular Rectangle's for collisions with projectiles. Then some points around the character for environment-collisions. I wrote up an article about it here.

In my game, each sprite/entity then has an array of inner Rectangle's. So if, a projectile's Rectangle collides with the outer Rectangle of an entity, I check which of the inner Rectangles (if any) it is colliding with, and deal damage and so forth accordingly. Then I check for projectile-collisions with the terrain.

The only problem with this is the actual size of the current character(s). Their legs will clip through walls if I make the hitbox too small, and will be able to stand on air if it's too big. How should I approach it in this case?

Busy between school, work, life, games, programming and general screwing around.If you'd like some pixel art for your game, send me a PM, i'll see what I can do.Current project: http://elementalwarblog.wordpress.com/

As I've also described in the article, I used just 1 point for the bottom, to get around the issue of standing in the air. I also wrote that I'd recommend that you use 2, like the Sonic-drawing. The spread between these two points is quite up to you, and leaves you with complete control of how much overlap you want to allow. So you won't have the problem you're describing.

You shouldn't factor in the legs when choosing a width for the collision rectangle. It won't matter much either way, though. People don't care whether 3 frames of an animation cut through the tiles of the map. And if you choose to factor in the entire width of the animation, it might leave the player being stopped unnaturally far from walls. Choose some median, or forget about the legs. People won't care either way. Even though you might

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org