Step 6: Moving and Resetting the Laser’s Position

Goal:


Lastly, let’s code the Laser in the game. It will be very similar to the code we just made for the Storm Trooper.

The Laser is actually an invisible sprite behind the Storm Trooper that will be cloned whenever we want to shoot the blaster.

The movement of the Laser will  start in the same position and move at the same speed as the Trooper.

Steps:

  1. Click on the “Laser” sprite
  2. Follow the same steps as the Trooper sprite for left and right arrow key movement
  3. From Events, place a when flag clicked block. In Motion, place a go to x/y block with the same coordinates as the Trooper
  4. From Looks, place a hide block

Code: