Create & Learn
Background

Try Knight vs Dragon: Beach Battle for fun Scratch Project!

Knight vs Dragon: Beach Battle

Platform: Scratch
Level: beginner

In this game, the Knight starts at one side of the beach, and the Dragon randomly moves around the stage. The Knight can use arrow keys to move and press the space bar to swing his sword. Each time the sword touches the Dragon, the score increases by 1. The Dragon makes a funny sound whenever it gets hit and changes its costume to show it is 'hurt' for a moment before resuming its random movement. This project teaches students about simple motion, using conditionals to check for collisions, and playing sounds.

Backdrop And Sprite Images For The Project

background
background
1024 x 1024
Dragon
Dragon
1024 x 1024
Knight
Knight
1024 x 1024

Knight vs Dragon: Beach Battle: Solution Outline

These are the high level steps to create this project. Try to create the project on your own first as much as possible, before checking the detailed solution samples below.

  1. Create the Knight and Dragon sprites and set their initial positions.
  2. Program the Knight to move with arrow keys and swing the sword with the space bar.
  3. Make the Dragon move randomly around the stage.
  4. Detect collision between the Knight's sword and the Dragon, and update the score.
  5. Display the score on the screen.

Knight vs Dragon: Beach Battle Sample Solutions

This section provides detailed, step-by-step instructions on how to build the project. There are many ways to create a project, so feel free to explore different approaches. Please note that these instructions are Al-generated, so errors may occur and the coding blocks may not map to Scratch exactly. But it should serve as very valuable references. Stay attentive as you follow along, and enjoy!

Create the Knight and Dragon sprites and set their initial positions.

First, choose or create the Knight and Dragon sprites from the Scratch library. Place the Knight on one side of the stage (e.g., left side) and the Dragon randomly on the stage. This sets up the initial scene for the game.

Program the Knight to move with arrow keys and swing the sword with the space bar.

Use the 'when key pressed' blocks to allow the Knight to move left, right, up, and down with the arrow keys. Use the 'when space key pressed' block to make the Knight swing his sword. This can be done by switching to a sword-swinging costume or playing a sword-swinging animation.

Make the Dragon move randomly around the stage.

Use a 'forever' loop to make the Dragon move randomly. You can use the 'glide' block to make it move to random positions on the stage continuously.

Detect collision between the Knight's sword and the Dragon, and update the score.

Use an 'if' block to check if the Knight's sword is touching the Dragon. If true, increase the score by 1, play a funny sound, and change the Dragon's costume to show it is hurt for a short time.

Display the score on the screen.

Create a variable named 'score' and display it on the screen. Initialize it to 0 at the start of the game. This keeps track of how many times the Knight hits the Dragon.

Common Potential Issues in Knight vs Dragon: Beach Battle Project

It is common to have bugs in the code. Here are some of issues you might run into.

  • Ensure the Dragon's movement is not too fast or too slow, which can make the game either too difficult or too easy.
  • Make sure the Knight's sword swing is properly aligned with the collision detection to accurately register hits.
  • Check that the sound and costume change for the Dragon occur only when it is actually hit by the sword, not just when the Knight is near.

Extra Challenges For Knight vs Dragon: Beach Battle

  • Add a timer to the game to see how many times the Knight can hit the Dragon in a set amount of time.
  • Introduce a new character or obstacle that the Knight must avoid while trying to hit the Dragon.

Learn Scratch Coding Skills

Enroll your child in award-winning online Scratch coding classes led live by experts and designed by professionals from Google, Stanford, and MIT.

Scratch Junior
Scratch Junior
Grades K-2
Start coding with ScratchJr, and make interactive stories and games
Scratch Ninja
Free Intro
Scratch Ninja
Grades 2-6
Code games and animations with Scratch coding, beginner to advanced levels
Accelerated Scratch
Free Intro
Accelerated Scratch
Grades 5-9
Fast-paced introduction to Scratch coding: build games, stories, and animations
Intermediate Game Building with Scratch
Intermediate Game Building with Scratch
Grades 3-6
Code a new fun Scratch game every week

Explore More Fun Scratch Practice

The challenge continues: Enjoy even more Scratch tutorials dreamed up by other students or use your imagination to make your own!

Develop My Own Idea

Find Best Classes For Your Child

Explore your child's grade level to find computer science classes and learning pathways that set your student up for success.