What is a geometry dash game on Scratch?

Comments · 355 Views

The geometry sprint game is a 2D game in which you must escape geometric-shaped obstacles by completing several levels.

Geometry Dash is a lot of fun to play! So today we're going to show you how to construct a Scratch geometry dash game. In the geometry dash game, players control one character's movement and navigate while avoiding obstacles like spikes and block collisions, which instantly kill the character. By the end of this article, you will have created your own Scratch-coded geometry dash game.

What is a geometry dash game on Scratch?

The geometry sprint game is a 2D game in which you must escape geometric-shaped obstacles by completing several levels.

Geometry Dash is a simple game to play. Depending on the platform, the game can be played with a touchscreen, keyboard, mouse, or controller.

The goal of the game is to finish each level by reaching the end. To have their player hop to escape obstacles, press the space key. The game will resume if the player collides with an obstacle.

See how to code a geometry dash game on Scratch

A geometric dash game will usually feature numerous stages. But, to keep things simple, we're not going to add any levels today. Let's get this party started! Go to the MIT Scratch website and create an account.

  1. Choose or design a backdrop

Because there is a blank backdrop by default, the first thing we need to do is construct your backdrop. Click on the round mountain symbol on the right side of the screen to choose/design your own backdrop.

Go ahead and pick a background. Click on the paintbrush if you want to create your own backdrop.

We've created two backdrops for this project. One is a basic background with a yellow route running through it. The second is for when the game is over.

  1. Design your sprite

We need to draw our sprites now that you have your backdrops ready. You can draw a new sprite by clicking the round blue color cat icon in the right bottom area. To draw your sprites, go ahead and use the paintbrush option.

We're going to draw two sprites for this game.

  • A square-shaped player is the first sprite. You can use your imagination to create your own player.
  • Triangle spikes/hurdles is the second sprite.
  • Draw 3-4 spike outfits as seen in the image above.
  1. Set the player position and make the player jump

Let's get started coding now that we've got everything ready! At the start, we'll fix the player's (sprite's) position. The player should then hop when we press the space key to avoid the spikes.

Select your player sprite and begin our code with the Event blocks' When flag clicked block, followed by the Looks blocks' Show block. Get the Point in Direction 90 block and the Motion blocks' x: -152 and y: -104 blocks from below.

Add a Forever block, and inside it, place the IF block from Control blocks to make your player jump every time you touch the space key. Place the key space pressed block from Sensing blocks inside the IF condition.

Place two Repeat 10 blocks from Control blocks one after the other inside the IF block. Place the turn clockwise 10 degrees block and the change y by 10 block from Motion blocks in the first Repeat block. Add the turn clockwise 10 degrees block and the change y by -10 block from Motion blocks to the second Repeat block.

Add one point in the direction 90 block from Motion blocks after the Repeat blocks.

  1. Reset the score and start making multiple spikes

Set the score variable to 0 and begin producing clones of the spikes sprite per second to start the score.

To do so, click on your spike sprite and start your code stack with the Event blocks' When flag clicked block. Then, from Variable blocks, add the set score to the 0 block. Add a hide block from the Looks blocks to the bottom to hide the original sprite.

Add a Forever block now. Create a clone of myself block and a wait 1 second block from Control blocks inside Forever.

  1. Make the spikes move on the pathway

Start your code with the When I start as a clone block from Control blocks and a Show block from Looks blocks to move the spikes along the pathway. To fix the starting position of the spikes, add the go to x: 170 y: -108 block from Motion blocks below. Now, from the Looks blocks, add the switch costumes to the costume 1 block. Add a pick random 1 to 3 block from the Operator blocks in lieu of costume1. We'll add glide 1 sec to the x:-280 y:y position block from Motion blocks to glide our spikes from left to right.

The sprite clone should vanish once it reaches its target location. Add delete the clone block from Control blocks at the end of the stack to destroy the clones.

  1. Score the points

Players will begin scoring points as soon as the game begins. The player will earn points until the spikes are touched.

As a result, we'll begin our code with the When flag clicked block from Event blocks. Add a Forever block underneath and a Repeat till block from Control blocks. We'll add a Touching players block from Sensing blocks to the repeat till condition.

Simply add a change score by 1 block from Variable blocks inside the repeat until block.

  1. When the player touches the spikes and the game ends

When the player reaches the spikes, the game is over. But first, we need to change the backdrop and halt all scripts.

Start your code stack with the When flag clicked block from Event blocks by clicking on the player sprite. From the Control blocks, add a forever and If block. Add a touching spikes block from Sensing blocks to the if condition.

Add a stop all block from Control blocks and a swap backdrop to backdrop2/game over block from Looks blocks inside if.

  1. Hide the sprite when the game ends

We need to hide our player sprite when the game is finished. To do so, we'll need to start our stack using the Event blocks' When backdrop moves to backdrop 2 block. Add a hide block from Looks blocks underneath that, as well as a play sound till done block from Sound blocks.

  1. Fun additional tasks

We've built a really simple geometric dash game here. In general, these games are never-ending, with a large number of levels to complete. You can add the following to your game to make it more interesting:

  • Various levels
  • Power boosters at the right time
  • Upgrades dependent on the score Different types of stumbling blocks
  • Increase the number of spikes/hurdles that occur.
  • Various world backdrops

Make a geometry dash game on Scratch

You've just made a fantastic Scratch geometry dash game! See how far you can get in your game. You learnt how to use basic blocks to make fantastic things in this tutorial. Scratch allows you to develop a wide range of projects.

Comments