I've added a few things to the top down shooter project. The first thing that I added was a bounding box to my whole sprite this will allowed me to use it as a hitbox. When the enemy fires at me if he hits the hit box anywhere then my player collision will be true.I also have another box thats red and that is the tile collision detection box.
Let me slow down for a second where did I get these colored boxes from, I have a library that I have built up over the years for anything that I feel like I could use in every game that I make and one of them is a utility class with a method that allows you to pass a rectangle too it and draw that rectangle with a transparent background and colored border of your choice.Also what size I want the border this really helps me visualize my collision boxes.With this it is pretty easy to draw my bounding boxes by just passing them to this static method which I call Drawborder().
So what I end up with is two rectangles in my player class one is the bounding box and the other is the tile collision box.The tile collision box is a little more complicated then the boundbox i'm not going to go though the whole process of how I got it but it consist of offsets and dividing the width
and some other stuff I would not let anybody feel like I did it the right way.
|Zombie Shooter Prototype|