The goal of this tutorial is to teach learners how to design and program a simple SpaceWar-style game using Scratch, where players control a spaceship, avoid or destroy enemies, and score points. Throughout the tutorial, learners will:
Understand basic Scratch concepts like sprites, costumes, and backdrops.
Use motion and control blocks to move the spaceship and fire projectiles.
Create interactive enemy behaviors and collision detection.
Add sound effects, scoring, and game-over conditions.
Develop problem-solving and logical thinking through game development.
By the end, learners will have a fully functional 2D space shooter game they can play, customize, and share!
We are going to program a Space War with the Scratch software in which we are a ship in space which must destroy meteorites. The longer you hold on, the more points you earn.
Go to Upload Backdrop to add space image.
Choose space image for game background:
We obtain the background containing the image of space.
The library gathers all the sprites created by Scratch.
Click on the Choose sprite icon.
Clicking the “Import Sprite” button should take you to the Sprite menu, a library of different sprites you can use in the program.
Click on the Rocketship sprite and the Scratch will create it as a new sprite in your game.
Insert these program blocks in the code area of the cannon sprite which allows the racket to be directed to the left or to the right using the two arrows (right and left) on the keyboard.
Add these two blocks that hide the Rocketship sprite if it receives a message from an enemy sprite (i.e. if the Rocketship sprite is hit by the enemy sprite).
Here is the final program for the Rocketship sprite:
The missile sprite is launched by the Rocketship sprite to destroy the meteorite (enemy sprite).
Go to the new sprites section and select the paint icon.
Draw the missile sprite using the drawing editor.
Added code to missile sprite
All on board we must create clones of the missile sprite thanks to this block
Here is the first part of the missile sprite program which allows you to create copies of the missile sprite when you press hard on the space key on the keyboard.
To fire the Rocketship sprite missile upwards:
Position the missile clones on the Rocketship
We display the clones of the missile sprite on the stage
Aim the missile sprite clones upwards to destroy enemies.
We hide the clones of the missile sprite when they touch the edges of the scene or the enemy sprite
The enemy sprite is going to feature two costumes:
the enemy sprite
the explosion sprite
Go to Upload Sprite to add the image of the enemy.
Choose the enemy image:
Go to the enemy sprite’s costume to add the second explosion costume
Choose the explosion image :
We get an enemy sprite with two costumes, one of which represents an explosion.
Added code to enemy sprite
The enemy sprite moves in a line up and down. If hit by a missile, it will be destroyed. Then the enemy sprite starts moving up and down again.
If the enemy sprite touches the ‘Rocketship’ spaceship or the edge of the stage, the game is over.
On board, we must create the variable score.
The set score to 0 block is executed when the green flag is clicked.
Then we switch the enemy sprite to the enemy costume.
Then, we randomly position the enemy sprite.
The rest of the program is inserted into the repeat forever block:
We move the enemy sprite from top to bottom:
If the enemy sprite is hit by the missile:
We switch the enemy sprite to the explosion costume.
we increment the score variable by 1
the enemy sprite is repositioned randomly.
we switch the enemy sprite to the first costume to restart the game.
If the enemy sprite hits the Rocketship or the edge of the stage:
we send a message to the Rocketship sprite:
we switch the enemy sprite to the explosion costume.
the message ‘Game Over’ is displayed on the stage
We stop all the scripts to finish the game
Here is the final program for the enemy sprite:
Educational robotics refers to the use of robots and robotics technology to promote learning in educational settings. It involves the integration of technology, engineering, and computer science into the classroom, allowing students to engage in hands-on, project-based learning experiences.
In this context, our website represents an excellent resource for parents, teachers and children who wish to discover robotics.
Zaouiet Kontech-Jemmel-Monastir-Tunisia
+216 92 886 231
medaliprof@gmail.com
Robotic site created by MedAli-Teacher info