BlocosIA Wiki Editor

Tank that aims with the mouse

Advanced · Use the Vehicles and Combat extension: the sprite smoothly turns to the mouse and drives with the arrows.

Interactive tutorial: the editor checks each step by itself.

  1. Add the "Vehicles and Combat" extension.
  2. Choose a sprite and drag "when green flag clicked" with a "forever" below.
  3. Inside the "forever", put "smoothly turn toward mouse pointer".
  4. Click the flag and move the mouse around the stage: the sprite turns slowly until it aims.
  5. Put in the "forever" an "if key up arrow pressed?" with "drive: move 3 steps and turn 0 degrees" inside.
  6. Open Costumes > Edit in painter > "Image points" tool (P key) and create a point named "tip" at the front of the sprite.
  7. Create a "Bullet" sprite and, on the main sprite, use "create clone of Bullet at my point tip pointing my direction" when space is pressed.
  8. Challenge: open the "Tank battle" example (Examples) and see the turret ATTACHED to the chassis with "attach my position to point…". (challenge)

Open in the editor