Copy template

Goal: Create a copy of the project template
  1. Click this link to make a remix: PROJECT LINK

Set Up the Game

Goal: Create the title screen and initialize the game variables.
  1. Place a "set background to" block under the "when run" block and select a background image.
  2. Add a "show title screen" block under the background block.
  3. Set the title to "Crossbow defence" and the subtitle to "Press "A" to start".
  4. Drag out a "set hasStartGame to" block to the bottom of the "when run" block and set the value to "false".

Handle Start Input

Goal: Create an event that starts the game when the "A" key is pressed.
  1. Drag out a "when" block, change the input to "a", and set it to "pressed".
  2. Add an "if" block inside the event.
  3. Place a "hasStartGame = false" block into the "if" condition.
  4. Add a "startGame" block inside the "do" section of the "if" block.

Move the Crossbow

Goal: Make the player able to move the crossbow left and right.
  1. Add two "while" blocks to your workspace.
  2. Change the first "while" block to "left" and "pressed".
  3. Attach a "moveCrossbowLeft" block inside the "left" while block.
  4. Change the second "while" block to "right" and "pressed".
  5. Attach a "moveCrossbowRight" block inside the "right" while block.

Shoot Arrows

Goal: Allow the player to shoot arrows by pressing the spacebar.
  1. Drag out a "when" block, set it to "space" and "pressed".
  2. Add a "shootArrow" block inside the event.

Monsters Attack

Goal: Handle what happens when a monster touches the wall.
  1. Add a "when" block set to when an orange monster sprite "touches" the wall.
  2. Inside the block, drag a "remove" "subject" block (the monster).
  3. Add a "spawnEnemy" block.
  4. Add a "play sound" block and set it to "Explosion: playful_game_explosion_5".
  5. Add a "change" "wall hp" block by "-1".
  6. Add an "if" block with a condition "wall hp = 0".
  7. Inside the "if" block, add a "gameOver" block.

Score and Difficulty

Goal: Handle what happens when an arrow hits a monster.
  1. Add a "when" block set to when an arrow "touches" an orange monster.
  2. Add a "play sound" block and set it to "Hits: retro_game_simple_impact_3".
  3. Add two "remove" blocks: one for the "object" (the monster) and one for the "subject" (the arrow).
  4. Add a "spawnEnemy" block.
  5. Add a "change" "arrows" block by "2".
  6. Add a "change" "enemySpeed" block by "1".
  7. Add a "change" "score" block by "1".

🎉 Congratulations!

Congratulations! You've built your own Crossbow Defence game.
🏆

Next challenge!

Next challenge ideas:
  1. Add different types of monsters with different speeds.
  2. Create a power-up that makes the player invincible for a few seconds.
  3. Create a heart item that increases player health when shot.
🚀