1

I'm a litte confused, because I wanted to create the clone of a 2D game where you ride a tank and your bullets can bounce from the walls, which have irregular shapes (I will paste a link for the example at the end of my post). And now I'm stuck on collision detection for "weird shapes", because I don't know what technique would be the best. I have read about "Bezier curve", "Bresenham algorithm", "pixel perfect collision" and few other, but I still feel that I coplicate this too much and I believe that there must be a simpler solution, but I don't see it. So could you advice me what should I use, if I want to have a ball bouncing from any shape?

Here is the video of the game, which I want to copy: https://youtu.be/dqDIXLvKfVY I'm sorry for the quality, my phone isn't there best device for recording videos :P

PS This game is called "action for 2-4 players" - you can search it on youtube if you want a video with better quality. :)

  • I would use the generate a pixel matrix thing. When the main level is rendered, also render a scaled down monochrome version for collision detection (check if it is white, open or black solid.) – Evan Carslake Apr 01 '15 at 15:35
  • Thanks for reply! :) I tried to use your method, but I can't figure out how to calculate normal vector in this type of collisions. For straight lines or simple curves it is easy, but what if I had more complex shapes? I have no idea how to do this that it was "fair" for the player. – user3324794 Apr 02 '15 at 09:30
  • With your black and white copy of the map, black being fully filled shapes (of absolutely anything and everything.) White being able to move. Then for a really basic collision test, you use the `players (x, y + height) and players (x + width, y + height)`, use those 2 concordant and check if they are black/ white. Both white good, can move, a black, and its solid (can't move.) I could maybe draw up a picture - what language are you using? – Evan Carslake Apr 02 '15 at 16:28
  • Yeah, this part seems easy to me. I know how to check for collisions. The problem starts when I want to find a normal vector in the place of collision. I need it so my "bullet" could bounce off this solid object. I'm using c++ right now, but java is fine too. :) – user3324794 Apr 03 '15 at 21:14
  • I sketched some ideas but I couldn't get a correct one. I couldn't find it on google, either. The simple idea is if they collide at (x, y) find the slope of (the bullet) and the slope of what it hit. To find those slopes you would find + - 1 to either x or y. From there you know the slope of what you hit, and the slope of the shape that it collided into. Then you have both slopes and from there figure out the angle it would deflect. – Evan Carslake Apr 03 '15 at 21:44
  • Just searched and maybe this will help: http://www.wildbunny.co.uk/blog/2011/12/14/how-to-make-a-2d-platform-game-part-2-collision-detection/ – Evan Carslake Apr 03 '15 at 21:51

0 Answers0