Geometry Dash – "How to make a Scratch Game"
Introduction to Creating a Scratch Game like Geometry Dash
In this section, Griff Batch introduces the tutorial on creating a scratch game similar to Geometry Dash. The focus is on drawing the classic Geometry Dash character and using Scratch's block coding language to bring it to life.
Drawing the Classic Geometry Dash Character
- Use the rectangle tool in Scratch's costume editor to draw the classic Geometry Dash character.
- Choose a yellow fill with a black border of width four pixels.
- Zoom in until you can see the center point of the drawing canvas and start drawing from there.
- Hold down the shift key while dragging to create a perfect square shape.
- Check the size of the costume and aim for a 34 by 34 pixel size.
- Drag the entire shape and let it snap to the center point on the canvas for smooth rotation later on.
Adding Music to the Game
In this section, Griff Batch explains how to add music to the game using Scratch's sound options. He also demonstrates how to import music from other Scratch projects.
Using Scratch's Sound Options
- Click into the sounds tab and choose a sound option under "Choose a sound."
- Filter by loops and select an energetic dance track that has some punch.
- Add coding blocks under "when flag clicked" and "forever" categories to play and loop the selected sound.
Importing Music from Other Projects
- Open another Scratch window and search for "Geometry Dash music" in the Scratch search bar.
- Find a project that contains desired music, open your backpack, drag and drop the music track into your current project.
- Update your code blocks to use imported music instead of default sounds.
Adding Jumping Scripts
In this section, Griff Batch demonstrates how to add basic jumping scripts to the game using Scratch's coding blocks.
- Use the "when space key pressed" event to trigger a jump.
- Create a short animation by changing the y-coordinate of the player sprite upwards by 10 pixels, repeated 10 times.
- Duplicate the script and change the y-coordinate to move the sprite downwards by 10 pixels, creating a jumping effect.
- Test the jumping animation by pressing the space bar.
Renaming Sprite and Designing Level
In this section, Griff Batch renames the player sprite and starts designing a Geometry Dash level in Scratch.
- Rename "Sprite1" to "Player."
- Click into the stage sprite and choose or draw other fancy backdrops for your level design.
The transcript does not provide timestamps for every section.
Creating the Floor Sprite
In this section, the instructor explains how to create a floor sprite using the rectangle tool and set its properties.
Creating the Floor Sprite
- Use the rectangle tool to draw a new sprite for the floor.
- Choose a vivid purple color with increased saturation and slightly darker shade.
- Set the border width of the rectangle to zero.
- Ensure that the edges of the rectangle are left as a solid color.
Positioning and Aligning Sprites
The instructor demonstrates how to position and align sprites accurately on the stage view.
Positioning and Aligning Sprites
- To avoid seams showing up later, overlap each edge of the floor sprite slightly.
- Drag sprites around on the stage view or use X and Y controls below to accurately position them at (0, 0).
- Hold down ALT key while dragging a shape to quickly create copies.
- Hold down SHIFT + 2 to horizontally align new shapes with initial shape.
Decorating the Level Further
The instructor encourages adding more visual elements to decorate the level.
Decorating the Level Further
- Add more vivid rectangles or other shapes as desired for decoration.
- Use ALT key + drag to quickly create copies of shapes.
- Use ALT key + SHIFT + drag to maintain horizontal alignment with initial shape.
Adding a White Line Across Top of Floor
The instructor demonstrates how to add a white line across the top of the floor sprite.
Adding a White Line Across Top of Floor
- Use the line tool with width set to 4 pixels.
- Hold down SHIFT key while drawing to keep it horizontal.
- Draw a straight line across just below the top edge of the floor sprite.
- Use selection tool and arrow keys to nudge the line into the correct position.
Adjusting Sprite Position and Scrolling
The instructor explains how to adjust sprite position and enable scrolling for the floor sprite.
Adjusting Sprite Position and Scrolling
- Sprites cannot be moved in full-screen mode, so click back inside the editor.
- Drag the sprites until they sit nicely on the floor, preferably towards the left side of the screen.
- Name the floor sprite as "level" and go to its coding tab.
- In a scrolling game, instead of moving the player forever, move the level sprite by changing its X position.
- Set X position change to negative values (e.g., -2) for smooth leftward movement.
- Reset level sprite's position before starting the game using "go to X: 0 Y: 0" block.
Overcoming Sprite Fencing Issue
The instructor addresses an issue where the level sprite gets stuck at the left edge of the screen.
Overcoming Sprite Fencing Issue
- When scrolling left forever, notice that level sprite gets stuck at left edge due to sprite fencing in Scratch.
- To overcome this issue, draw a long rectangle below the visible area of canvas in costume editor.
- Make sure this extra width extends beyond both left and right edges of visible level area.
- This allows sprites to move further off-screen than they otherwise could.
Creating Infinite Level Illusion with Clones
The instructor suggests using clones to create an illusion of an infinite level without using multiple large sprites.
Creating Infinite Level Illusion with Clones
- Instead of lining up multiple large sprites for an entire level, use clones to cycle two sprites repeatedly.
- Understand that Scratch's screen is 480 pixels wide.
- When a level sprite moves left by -480, move it back to the right by 960 to complete the effect.
- Use a conditional if block with a less than check for X position of the sprite.
- If X position is less than -480, move it back to the right by 960.
- This creates a smooth scrolling effect with just two sprites.
Creating a Second Level Sprite Using Clones
The instructor explains how to create a second level sprite using clones.
Creating a Second Level Sprite Using Clones
- Name the first costume of the level sprite as "level 1.1".
- Duplicate the costume and name it as "level 1.2" for the second costume.
- Draw a small square at the top of the second costume to differentiate it from the first one.
- Separate off the forever loop script but keep it handy for later use.
- Use "create clone of myself" block under control category to create a clone of the sprite.
Hiding the Original Sprite
In order to simplify the scrolling process, it is recommended to hide the original sprite before creating clones. The clone sprite should be shown before it starts scrolling.
Hiding the Original Sprite
- Add a "hide" block before creating the clone.
- Show the clone sprite before it starts scrolling.
Adding a Second Clone
Adding a second clone is easy. Make sure that the first clone switches to costume level 1.1 before being cloned. The second clone should start on costume two and be positioned 480 pixels to the right of the first level sprite.
Adding a Second Clone
- Switch the first clone to use costume level 1.1 prior to cloning.
- Set the second clone's costume to two.
- Position the second clone 480 pixels to the right of the first level sprite.
Creating an Infinite Scrolling Background
By using clones, an infinite scrolling background can be created with both costumes of this level cycling around forever.
Creating an Infinite Scrolling Background
- Create a clone of yourself.
- Test by clicking on the green flag.
- The background will now scroll infinitely with both costumes cycling around.
Adding Obstacles - Ground Spike
To make it feel like a real game, obstacles such as ground spikes can be added. These spikes can be drawn as black squares and then modified into triangles for aesthetics.
Ground Spike Obstacle
- Draw a black square for the spike using shift for perfect shape.
- Set its X and Y position to (0, 0).
- Use shaping tool to delete one corner and create a triangle.
- Adjust the rotation to 45-degree angles using the shift key.
- Reduce the width and add a white border with a width of 4 pixels.
Differentiating Hazardous Parts
To differentiate hazardous parts, such as spikes, from the rest of the level, change their color to a very pale yellow with slightly higher saturation.
Differentiating Hazardous Parts
- Change the spike outline color to a very pale yellow with slightly higher saturation.
- This will help differentiate hazardous parts from other elements in the level.
Detecting Collisions with Hazards
To detect when the player touches a hazardous part of the level, use a unique color for collision detection. In this case, a specific shade of yellow is used for spikes.
Detecting Collisions with Hazards
- Set up collision detection by selecting "when flag clicked" hat block.
- Use "wait until touching color" block to detect collisions with spikes.
- Ensure that the spike is visible on stage for accurate collision detection.
Handling Visibility and Positioning Issues
To address visibility and positioning issues, make sure that the spike remains visible on stage and set its X position back to zero after creating clones. Additionally, automate setting X position to zero by using "go to XY (0, 0)" after creating each clone.
Handling Visibility and Positioning Issues
- Make sure that the spike is visible on stage by setting its visibility.
- Set its X position back to zero after creating clones.
- Automate setting X position to zero by using "go to XY (0, 0)" after creating each clone.
Ending the Game on Collision
When a collision occurs, end the game by stopping all scripts. This can be achieved by using a "stop all" block when the player collides with a hazardous part.
Ending the Game on Collision
- Use a "when flag clicked" hat block to start the game.
- Add a "stop all" block within the "when touching color" event for collisions with spikes.
- This will end the game when a collision occurs.
Preventing Clones from Disappearing
Instead of deleting all clones and ending the game, stop scrolling of the level while allowing other scripts to continue running. This can be done by controlling scrolling using a variable named "scroll speed".
Preventing Clones from Disappearing
- Create a variable named "scroll speed" to control scrolling.
- Set it to -10 at the beginning of the game.
- Use this variable to scroll both level and player sprites.
- Stop other scripts in player sprite only, allowing level scrolling to continue.
- Gradually decrease scroll speed until it reaches zero for smooth deceleration.
Stopping Player Movement After Impact
To stop player movement after impact, ensure that the player starts at their current position and use scroll speed variable to control their movement along with the level. The collision will carry them back along with the level.
Stopping Player Movement After Impact
- Set player's initial position using "go to XY" block with current X and Y coordinates.
- Within repeat 10 loop after game over, scroll player using scroll speed variable.
- The collision will carry them back along with the level, stopping their movement.
The remaining part of the transcript is not included in the provided text.
New Section
The speaker discusses the process of playing a script while the animation is slowed down and suggests adding new level costumes to make the game more interesting.
Playing Scripts and Adding Level Costumes
- The speaker suggests starting to play a script before it finishes, right after stopping other scripts.
- They mention that the current level is too boring with just a single repeating Spike character.
- The idea of adding new level costumes and including them in the scrolling scenes sequence is proposed.
- However, at present, only two costumes are repeating in the sequence.
- To overcome this limitation, they suggest skipping forward by two costumes when cycling back to the level sprite.
- By working as a pair, two clone sprites can recreate any arbitrary long level design.
New Section
The speaker demonstrates how to implement skipping forward by two costumes and showcases its effectiveness in creating seamless patterns.
Implementing Skipping Forward by Two Costumes
- After changing X by 960, they skip forward by two costumes using "next costume" blocks.
- They test if it works by observing the appearance of three spikes before the pattern repeats seamlessly.
- This technique allows for easy building up and extension of levels.
New Section
The speaker mentions upcoming exciting features in future episodes such as moving particles, improved jumping with player rotation, multi-level platforms, collision detection, and resolution. They encourage viewers to like their video and subscribe to their channel for more content.
Exciting Features Ahead
- The speaker highlights upcoming features like moving particles, improved jumping with player rotation, multi-level platforms, collision detection, and resolution.
- They express enthusiasm about these additions making the game even more awesome.
- Viewers are encouraged to like the video and subscribe to the channel for more content.
New Section
The speaker concludes the video by thanking viewers for watching and encourages them to share their progress and creativity in the comments section or through the official Scratch studio linked below the video.
Conclusion and Call to Action
- The speaker expresses gratitude to viewers for watching.
- They encourage viewers to share their progress and creativity in the comments section.
- Viewers are invited to join the official Scratch studio linked below the video.
- The video ends with a positive message, wishing everyone a great week ahead.