Responding to tile map collision in java

I was just wondering, what is the best way to respond to 2d tile map collision in java. I have the code setup so that when the Players Rectangle intersects with a Tiles Rectangle, which is part of a 2d array of Rectangles (Rectangle[][] collRects), the collision happens. I know how to set that up, but when i run the program and the Player collides with a tile, the Player moves along the edge of the inside tiles and eventually goes through the collision Rectangles. The way i am responding to collisions right now is: 1. I check with if statements which side of the tile the player collided with. 2. The Player has a speed variable, so i set to a value of zero on whatever axis the player was moving on before the collision. I guess what i am trying to say is, what is the best way to respond to a collision? Help would be greatly appreciated, thanks.
please provide more detail about the way your sprites move: do they move freely inside the map? do they move aligned to some sort of grid (pacman like)? how many sprites can you have posibly colliding at the same time? 10? 1000?

以上就是Responding to tile map collision in java的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏