Coding is a type of computer programming that allows us to communicate with computers. Code tells a computer what to do, and writing code is similar to writing a set of instructions.
Text-based coding and block-based coding are the two main types of coding. Both have advantages, but block-based coding is especially useful for teaching coding to children.
Scratch is a well-known block-based coding platform with a community of millions of coders and creators. It enables children to create a wide range of games, animations, and other projects.
A space adventure game in Scratch is one of the many interesting games that Scratchers can create.
If you are someone who is interested in such games you’ve come to the right place. Just read on and you’ll find all the information on how to create an adventure game on Scratch.
What is Scratch Programming?
Scratch is the world’s largest coding community for children and a coding language with a simple visual interface that allows young people to create digital stories, games, and animations.
Scratch promotes computational thinking and problem-solving skills; creative teaching and learning; self-expression and collaboration; and equity in computing. Therefore, Scratch coding for kids helps to improve their skills.
I’ve outlisted some of the importance and advantages of scratch programming below;
- Scratch coding is fun, and interactive, and enables kids to trigger their creative side.
- Sharpens analytical skills and logic.
- Aesthetically appealing.
- Easy to understand.
- Stepping stone to high-level programming.
Project Explanation
The project we have created here is a Space adventure game.
What is an adventure game?
An adventure game is a video game in which the player assumes the role of a protagonist in an interactive story driven by exploration and/or puzzle-solving.
Adventure games contain a variety of puzzles, decoding messages, finding and using items, opening locked doors, or finding and exploring new locations.
How to create a Space Adventure game in Scratch
So let’s get right into creating our Space adventure game.
Step 1: Adding Sprites
- To add the sprites click on the choose sprites (cat icon) on the right corner of the page
- Go to sprites and choose a rocket.
- Go to Choose sprite, select Paint, and paint the asteroid.
Step 2: Backdrops
- Choose the backdrop stars.
- Finally, draw the Game Over backdrop for the second backdrop.
Step 3: Coding
Now let’s start the coding for Rocket sprite.
- Drag the When clicked option from events which is the starting block also known as a run block.
- Then drag Switch backdrop from looks to switch the backdrop to Stars.
- Set the X position for the rocket to be placed permanently from the motion block.
- Drag play sound and add a sound of your choice for when the rocket moves.
- Set mouse to Y for the rocket to move according to the Y position of the mouse.
- Place all these blocks under the Repeat until block as it should repeat until Rocket touches the asteroid.
- Drag If () then condition block from control to place the condition. Add a different sound for the Rocket touching the asteroid from the sound block and switch the backdrop to Game Over backdrop to stop the game.
- Drag the stop-all block from the control block to stop the Game. With this, we complete the coding for the Rocket.
Now let’s start the coding for Asteroid Sprite
- First Create the variables called Point and Speed. The point is for storing the score values and speed is to increase or decrease the speed of the rocket. Set the values of Points and speed to 0.
- Then drag the go-to XY option from the motion block to set the position of the asteroid.
- Drag repeat until from control block and touching block rocket from sensing. Inside repeat until block add change X by with the variable speed to change the speed (variable) of the X position (left to right position) of the asteroid.
- Inside the repeat until add if() then condition from control block. If its X position (from motion block) is less than some -250 (-x position), then set x (from motion block) position to 250 to start the asteroid from the left of the x position. Then set y (from motion block) position (from up to down position) randomly from 180 to -180 (from Y to –Y).
- Finally, change the speed by 1 and -1 accordingly. Then change the Point by 1 to get the score.
Step 4: In the end, click the green flag run button to play the code. To stop the code use the nearby red button.If you want to see this complete project in Scratch, click here!
Conclusion
Finally, we created and ran a large number of Scratch scripts, and by doing so, you learned how to program in the Scratch programming language.
You should have learned a lot of advanced programming concepts by doing this, such as variables, conditions, control, motion (position changing), and sensing.
Learn Scratch at BrightChamps with its specially designed curriculum that makes learning programming easy for students in Grade 1-12.
BrightChamps also teaches a variety of other programs that help kids build a foundation in computer programming through activities, interactive lessons, and other means.
Elevate your child’s learning journey with BrightChamps, the leading EdTech company offering a transformative blend of robotics, financial education, and coding courses.
To get your hands on more such articles, educational content, and free resources on coding for kids, robotics courses for kids, game development, etc., check out the BrightCHAMPS Blog Page now!
Frequently Asked Questions (FAQs)
Repeat Until block is used to keep the process going until the condition is satisfied. It’s from the control block.
Set x is a motion block variable that is used to set the sprite’s x location.
Variables are used to hold values such as scores, points, and so on. They are similar to storage containers that are used to store items.
The sprites will move according to the position of the mouse in the Y direction, which is up and down in this case.
If () then block is a control block. If its condition is true, the blocks held inside it will run, and then the script involved will continue. If the condition is false, the scripts inside the block will be ignored.