Hey everyone, I am creating a 2D top down shooter but am having trouble with collision detection.
I am at the point in the game where the player can shoot but bullet to environment collision isnt going so well. So far I have it so that the parts of the tilemap that entities can collide with are stored in an arraylist of Rectangles representing those cells, and am seeing if the bullet rectangles intersect with them, and if they do, i remove the bullet.
However the problem comes in when the bullets move really fast like they should, even when they move fairly slow actually, but basically what happens is the bullets go through the walls, so if an enemy is on the other side of the wall, it still has a chance of being hit.
I heard from others that for things like this I should use raycasting, however I am not really sure where to start with that. I know that the point of raycasting is to draw a line going from the tip of the gun, toward the direction its facing, and seeing if it every collides with any of Rectangles, or “forbidden” tiles. However I am not sure about how to go about implementing this.
Also, if i do implement this, I wouldnt need bullets right? Just a flash at the muzzle and maybe a collision drawing, but nothing in between since the bullets would be moving so fast, im sure thats just prefrence though…
Links, help, or anything is appreciated 
