Playing Geometry Dash is incredibly thrilling! Today, we’ll guide you through the process of creating your own Geometry Dash game using Scratch. In this game, players steer a character through a series of challenges, dodging hazards like spikes and blocks that can eliminate the character on contact. By the conclusion of this straightforward, step-by-step tutorial, you and your child will have crafted a unique Geometry Dash game using Scratch programming.

Enroll your child in our acclaimed live online Scratch classes, led by experts, to help them develop even more amazing games. We offer Scratch Ninja for Grades 2-5 and Accelerated Scratch for Grades 5-9, crafted by professionals from Google, Stanford, and MIT. Experience our free introductory Scratch class with no risk involved.

What is a Geometry Dash game created on Scratch?

Geometry Dash is a two-dimensional game where players navigate through various levels, avoiding obstacles shaped like geometric figures.

Playing Geometry Dash is quite straightforward. Depending on the platform, you can use a touchscreen, keyboard, mouse, or controller to enjoy the game.

The goal of the game is to finish a level by reaching the endpoint. Use the spacebar to make your character leap over obstacles. If your character collides with an obstacle, the game will reset.

Create a Geometry Dash-style game using Scratch.

A standard Geometry Dash game usually features several levels. However, to keep things straightforward today, we won’t be incorporating any levels. Let’s dive in! Visit the MIT Scratch website and log in.

1. Select or create a background.

The initial step is to set up your backdrop, as it starts off as a blank canvas. To select or design a backdrop of your choice, simply click on the circular mountain icon located on the right side of the screen, which will enable you to pick your backdrop.

Create a background setting.

Feel free to select a background. Alternatively, if you’d like to create a custom backdrop, just click on the paintbrush icon.

We have created two distinct backdrops. The first features a solid color with a yellow pathway. The second backdrop represents the Game Over scenario.

Yellow-themed backdrop in Scratch programming.End of the game.

2. Create your sprite design.

With your backdrops prepared, it’s time to create your sprites. In the bottom right corner, you’ll find a circular blue cat icon that lets you add a new sprite. Click on the paintbrush tool to start drawing your sprites.

In this game, we will create two sprites.

  • The initial sprite is a player in the form of a square. Feel free to unleash your imagination and create a unique player of your own design.

Player with a square shape

  • The second sprite features triangular spikes or obstacles.

Pyramid point

Create 3-4 outfits for spikes, similar to the ones depicted in the image above.

3. Create a variable to tally the points.

Navigate to the Variable blocks section and establish a variable called score to store the scores.

4. Position the player and initiate a jump.

With everything prepared, it’s time to start coding! We’ll start by setting the player’s (sprite’s) position initially. Then, when the spacebar is pressed, the player will jump to evade the spikes.

Choose your player sprite and begin your coding by using the When flag clicked block found in the Event category. Next, drag the Show block from the Looks category. Below that, add the Point in direction 90 block and the goto x: -152 and y: -104 block from the Motion category.

To ensure your character leaps each time the spacebar is pressed, incorporate a Forever block, and within it, insert an IF block from the Control category. Inside the IF condition, add the space key pressed block from the Sensing category.

Within the IF statement, insert two consecutive Repeat 10 blocks from the Control category. In the initial Repeat block, include the turn clockwise 10 degrees block along with the change y by 10 block from the Motion category. In the subsequent Repeat block, incorporate the turn clockwise 10 degrees block and the change y by -10 block from the Motion category.

Following the Repeat blocks, insert a point in the direction of the 90-degree block from the Motion category.

Creating a Geometry Dash game.

5. Clear the score and begin generating several spikes.

To begin tracking the score, we must initialize the score variable at 0 and begin generating clones of the spikes sprite at one-second intervals.

To accomplish this, select your spike sprite and initiate your code sequence with the “When flag clicked” block found in the Event category. Next, incorporate the “set score to 0” block from the Variable category. Below that, include a “hide” block from the Looks category to conceal the original sprite.

Next, insert a Forever block. Within the Forever block, include a “create clone of myself” block along with a “wait 1 second” block from the Control category.

Create a geometry-based challenge.

6. Animate the spikes along the path.

To reposition the spikes along the path, begin your script with the “When I start as a clone” block found in the Control category, then incorporate a “Show” block from the Looks category. Next, insert the “go to x: 170 y: -108” block from the Motion category to establish the initial location of the spikes. Following that, add the “switch costumes to costume 1” block from the Looks category. Replace “costume 1” with a “pick random 1 to 3” block from the Operators category. Finally, to animate the spikes moving from left to right, include the “glide 1 sec to x: -280 y: y position” block from the Motion category.

When the sprite clone arrives at its specified location, it should vanish. To remove the clones, include the “delete the clone” block from the Control category at the end of the sequence.

Code surges to advance.

7. Accumulate the points.

Once the game begins, participants will begin accumulating points. Points will continue to be earned until the player makes contact with the spikes.

To begin our code, we will initiate the stack using the “When flag clicked” block found in the Event category. Below that, we will insert a Forever block along with a Repeat until block from the Control category. For the condition in the Repeat until block, we will include a “Touching players” block from the Sensing category.

Within the repeat until loop, simply incorporate a block from the Variable section to increase the score by 1.

Earn the points.

8. The game concludes when the player comes into contact with the spikes.

The game concludes when the player makes contact with the spikes. However, prior to that, it’s necessary to change the background and halt all the scripts.

Select the player sprite and initiate your code sequence by using the “When flag clicked” block found in the Event category. Next, incorporate a “forever” block and an “If” block from the Control category. Within the “If” condition, insert a “touching spikes” block from the Sensing category.

Within the “if” statement, incorporate a “switch backdrop” command to change to “backdrop2” or the “game over” backdrop from the Looks category, along with a “stop all” command from the Control category.

The game concludes.

9. Conceal the sprite once the game concludes.

At the conclusion of the game, it’s necessary to conceal our player sprite. To achieve this, we should initiate our stack with the “When backdrop changes to backdrop 2” block found in the Event category. Below this, we will include a “hide” block from the Looks category, followed by a “play sound ____ until finished” block from the Sound category.

Conceal the sprite.

Frequent Problems and Glitches in Our Geometry Dash Game Guide and Their Solutions

Developing a Geometry Dash-style game in Scratch can be an enjoyable and imaginative endeavor, but you may face a few typical challenges during the process. Here are some tips to assist you in resolving these issues:

1. Character Sprite Fails to Jump Correctly

  • Problem: The character sprite fails to jump or the jump lacks fluidity.
  • To resolve the issue, make sure the “when space key pressed” block is situated within the “forever” loop and is correctly nested within the “if” statement. Verify that there are two “repeat 10” blocks within the “if” statement, and that each “repeat” block includes both the “turn clockwise 10 degrees” and “change y by” blocks. Additionally, confirm that the “point in direction 90” block is correctly placed after the “repeat” blocks.

2. Spikes Not Displaying or Shifting

  • Problem: The spikes are either not visible on the display or are not traversing the path.
  • Solution: Confirm that the “when I start as a clone” block is properly configured for the spike sprite. Ensure that the spike sprite’s starting position is defined using the “go to x: 170 y: -108” block. It is important to position the “show” block after the initial position block to ensure the spike is visible. Verify that the “glide 1 sec to x: -280 y: y position” block is correctly arranged to facilitate the spike’s movement across the screen. Lastly, ensure that the “delete this clone” block is placed at the end of the sequence to eliminate the spike after it reaches the designated endpoint.

3. Score Not Refreshing

  • Problem: The score fails to refresh when the player successfully dodges the spikes.
  • To resolve the issue, make sure to initialize the score variable to 0 at the beginning of the game using the “set score to 0” block. Confirm that the “change score by 1” block is placed within the “repeat until” block, ensuring that the condition for the “repeat until” block is accurately set to detect when the player sprite is touched. Additionally, ensure that the “forever” loop encompasses the “repeat until” block to allow for continuous monitoring and updating of the score.

4. Game Fails to Conclude When Character Collides with Spikes

  • Problem: The game continues even after the player character collides with the spikes.
  • Solution: Verify that the “touching spikes” block is properly situated within the “if” statement inside the “forever” loop for the player sprite. Make sure that the “switch backdrop to backdrop2/game over” block and the “stop all” block are accurately placed within the “if” statement to change to the game over backdrop and halt all scripts when the player collides with the spikes.

5. Player Character Sprite Remains Visible After Game Over

  • Problem: The player character sprite remains visible after the game concludes.
  • Solution: Confirm that the block for “when backdrop changes to backdrop2” is properly configured for the player sprite. Make sure the “hide” block is positioned right after this event block to conceal the player sprite. Furthermore, verify that the “play sound ____ until done” block is correctly arranged to play a sound at the conclusion of the game.

6. Overlapping Spikes or Those That Do Not Vanish

  • Problem: The spikes either overlap or fail to vanish upon reaching the end of the path.
  • Solution: Make sure the timing and placement of the spikes are properly configured. Confirm that the “create clone of myself” block is located within the “forever” loop and is accompanied by a suitable “wait 1 second” block to avoid overlapping spikes. Additionally, ensure that the “delete this clone” block is positioned at the conclusion of the spike’s movement script to eliminate spikes after they have completed their path.

Essential Programming Principles in the Geometry Dash Game Guide

1. Graphics

  • What Are They? : Sprites refer to the characters or items within your Scratch project that you can manipulate and animate. Each sprite can possess various costumes and scripts linked to it.
  • In the tutorial, the player, spikes, and various other game components are represented as sprites. These sprites are created and programmed to engage with one another throughout the game.

2. Backgrounds

  • What Are They? : Backdrops serve as the visual backgrounds for your Scratch project. They establish the atmosphere for your game and can be altered to represent various states or levels.
  • In the tutorial, distinct backgrounds are employed for both the primary gameplay and the game over screen, offering visual cues for the player.

3. Factors

  • What Are They? : Variables serve as containers for data that your project can utilize and alter. They can store numerical values, strings, or various other forms of information.
  • In the tutorial, a variable called “score” is established to monitor the player’s points, which rise as they successfully navigate around obstacles.

4. Occasions

  • What Are They? : Events refer to actions that activate particular scripts. For instance, initiating the game by clicking the green flag or using keyboard inputs to manipulate sprites.
  • In the tutorial, event blocks such as “when the flag is clicked” and “when the spacebar is pressed” initiate the game, reset the score, and enable the player to jump.

5. Regulation Sections

  • What Are They? : Control blocks regulate the execution of scripts within your project. They encompass loops, conditional expressions, and event handlers.
  • In the tutorial, control structures such as “forever,” “if,” “repeat,” and “repeat until” are utilized to establish ongoing game loops, evaluate conditions, and oversee the interactions among sprites.

6. Movement Segments

  • What are they? Motion blocks are responsible for managing the movement of sprites. They can alter a sprite’s location, orientation, and velocity.
  • In the tutorial, motion commands such as “go to x: y:”, “glide to x: y:”, and “change y by” are utilized to set the player’s location and to maneuver the spikes across the display.

7. Appearance Blocks

  • What Are They? : Appearance blocks manage how sprites and backgrounds are displayed. They can alter costumes, change backgrounds, reveal or conceal sprites, and perform various other functions.
  • In the tutorial, blocks such as “switch backdrop to,” “show,” and “hide” are utilized to alter the visual aspects of the game, manage the visibility of sprites, and generate visual effects.

8. Detection Modules

  • What Are They? : Sensing blocks are capable of identifying different conditions and interactions within your project. They can detect touch, colors, distances, and a variety of other factors.
  • In the tutorial, sensing blocks such as “touching color” and “key pressed” are utilized to identify when the player sprite comes into contact with the spikes or when the player hits the spacebar to perform a jump.

9. Operators

  • What are they? Operators carry out mathematical calculations, evaluate logical conditions, and handle data in multiple ways.
  • Application in the Tutorial: Functions such as “pick random” are utilized to introduce an element of chance to the game, for example, by randomly choosing outfits for the spikes.

10. Replication

  • What is it? Cloning enables the generation of duplicates of a sprite that can function autonomously from the original. Each duplicate can possess its own scripts and behaviors.
  • In the tutorial, cloning is employed to generate several instances of the spike sprite, which traverse the screen, serving as obstacles that the player must dodge.

Creative Ways to Personalize Your Geometry Dash Experience

The Geometry Dash game we’ve developed is quite simple. Typically, these types of games are endless, featuring numerous levels to enjoy. To enhance the excitement of your game, consider incorporating:

  • Various tiers
  • Prompt energy enhancers
  • Additional enhancements determined by the score.
  • Various types of obstacles
  • Enhance the occurrence of spikes or obstacles.
  • Diverse global backgrounds

You may find this video on creating a Geometry Dash game interesting as well:

Engaging Valentine

Valentine’s Day Programming Project: Scratch Candy Heart Message Creator

Imagine being able to design a virtual message creator to share messages with your friends online! In this tutorial for a Scratch Valentine’s Day project, we will guide you through the process of building a Candy Heart Message Generator using Scratch.