šŸ•¹ļø

Creating a Scratch Platformer Engine

May 22, 2025

Griffpatch's Scratch Platformer Tutorial

Introduction

  • Griffpatch introduces the "Classic Scratch Platformer" project.
  • Focus on simple platforming, wall sliding, moving platforms, and level navigation.
  • Aim: Create a foundation for personalizing game style.

Getting Started

  • Start by remixing the starter project which includes necessary costumes.
  • Emphasis on using simple costumes for effective platforming scripts.
  • Create a new costume centered on the canvas for proper alignment.
  • Rename sprite to "Player."

Creating the Level

  • Use backdrops for level creation.
  • Draw a straight floor line using the rectangle tool.
  • Add stairs and a floating platform for testing.

Gravity Implementation

  • Use a forever loop with a "When green flag clicked" block for gravity.
  • Create a variable "speed y" to track player's speed.
  • Set initial speed to 0 and change it by -1 each loop.
  • Adjust player's position using speed y for a realistic fall.

Ground Collisions

  • Detect collisions using "IF touching color".
  • Move player back by changing y by -speed y to undo the overlap.
  • Use repeat until loop to ensure the player is positioned correctly.

Creating the "Fix Overlap" Block

  • Custom block to manage player overlap when colliding with ground.
  • Use "Run without screen refresh" to improve performance and appearance.

Gravity and Jumping

  • Create a "GRAVITY" variable to manage falling speed.
  • Implement jumping with "IF up arrow pressed" and set "speed y" to a positive number.

Walking and Horizontal Movement

  • Introduce "speed x" for horizontal movement.
  • Implement left and right movement with arrow keys.
  • Manage acceleration and deceleration with resistance factor.

Horizontal Collisions

  • Implement similar collision detection for horizontal movement.
  • Use small step movements to detect and manage collisions efficiently.

Fine-tuning the Physics

  • Introduce "falling" variable to manage jumping mechanics more effectively.
  • Utilize "coyote jump" technique to improve gameplay experience.

Customization of Physics

  • Adjust variables like GRAVITY, JUMP FORCE, ACCELERATION, and RESISTANCE to customize game feel.

Conclusion

  • Next episode will include multiple screens, sprite vs color collisions, and sloping inclines.
  • Future plans: wall jumps and moving platforms.
  • Encourage viewers to like, subscribe, and support the channel.

This guide provides a step-by-step process of building a simple yet effective platforming engine in Scratch, offering room for modification and personalization as the game develops.