I am planning to make a Laser Squad clone and I think I have most of the aspects covered. But the major headache is the projectiles shot/thrown.

The easy way would be to figure out the probability of hit and just mark miss/hit. But I want to be able to have the projectile to hit something eventually (collateral damage!).

Currently everything is flat 2D tile map and there would be full (wall, door) and half height (desk, chair, window) obstacles.

My idea is to draw an imaginary line from the shooter to the target and add some horizontal&vertical error based on the player skills. Then I would trace the modified path until it hits something. This is basically what the original Laser Squad seems to do.

Can you recommend any algorithms or other approaches for this?


2 Answers 2


The idea you have is to raytrace into the scenery to see what it hits. This is viable because your game is (presumably) tile based. When the bullet starts, you must know its 3D position, even if it is fake. Once you know the direction of the bullet, you can use a Bresenham algorithm (more commonly used for line drawing) to see which squares the bullet will "touch". You can then do collision checking only for the objects touched by the Bresenham line.


  • Determine 3D starting position of bullet
  • Determine 3D direction of bullet
  • Determine in which square the bullet will land (if it hits nothing)
  • Draw a line (in data) with the direction of the bullet using Bresenham
  • For each square the bullet enters, check if the bullet hits anything

On my tiled shooter I basically start the projectile at the origin point with a given vector, that specifies its direction/velocity. On every move I test the distance to other actors and check if it's less than the projectile radius.

We also have projectiles that will spawn explosions. The explosions themselves are just like projectiles, with zero or very little reach but with larger radius.

  • \$\begingroup\$ You completely ignored collision \$\endgroup\$ Commented Jan 17, 2013 at 7:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .