Copy template

Goal: Create a copy of the project template
  1. Click this link to make a remix: PROJECT LINK

Initialize Game

Goal: Set up the starting background and show the title screen when the program runs.

Welcome to Jumping Bear! In this first step, configure what the player sees when clicking Run.

  1. Connect the "set background to" block under the "when run" block.
  2. Select the mountain forest landscape background from the dropdown.
  3. Add the "show title screen" block under the "set background to" block.
  4. Type "Jumping bear" into the "title" input.
  5. Type "Press \"A\" to start" into the "subtitle" input.
Tip: Make sure the title and subtitle match the capitalization and punctuation shown in the screenshot.
Check: Click Run. You should see the mountain forest background with the title "Jumping bear" and subtitle "Press \"A\" to start".
Initialize Game

Start Game on "A" Key Press

Goal: Reset the stage, initialize game variables, and spawn the bear and map when pressing A.

When the player presses the "a" key, hide the title screen, reset game variables, and start the first level.

  1. Drag out a "when [key] pressed" event block and select "a" from the dropdown.
  2. Connect the "hide title screen" block under the "when [a] pressed" block.
  3. Add the "remove [all sprites]" block under the "hide title screen" block.
  4. Add the "set background to" block and choose the meadow landscape with a tree.
  5. Add a "set [variable] to" block, select "gravity", and set it to 5.
  6. Add a "set [variable] to" block, select "jumped", and set it to 0.
  7. Add a "set [variable] to" block, select "level", and set it to 0.
  8. Add a "set [variable] to" block, select "subLevel", and set it to 0.
  9. Add the "createBear" function block under the variable blocks.
  10. Add the "createMap1" function block under the "createBear" block.
Tip: Initializing all variables to their starting values ensures the game resets properly every time it starts.
Check: Press the "a" key after running the program to verify the title screen hides, the meadow background appears, and the bear and map load.
Start Game on "A" Key Press

Create the Gravity Behavior

Goal: Define a custom gravityTurnedOn behavior that pulls the sprite downward and detects ground collisions.

To simulate gravity and platforms, create a behavior that constantly moves the sprite downward unless it is touching dirt or magic floor platforms.

  1. Open the Behaviors folder and create a new behavior named "gravityTurnedOn".
  2. Add a "move [sprite]" block inside the behavior.
  3. Set the sprite to "this sprite", distance to the "gravity" variable, and direction to "South". so that the sprite moves downward.
  4. Add an "if" Logic block with an "else if" branch under the move block.
  5. In the first condition slot, check if "[this sprite] is touching [dirt]" = true.
  6. Inside the first branch, add a "set [variable] to" block, choose "jumped", and set it to 0.
  7. Add a "move [sprite] [distance] pixels [direction]" block inside the first branch.
  8. Set the sprite to "this sprite", distance to "gravity", and direction to "North".
  9. In the "else if" condition slot, check if "[this sprite] is touching [magic floor]" = true.
  10. Inside the second branch, add a "set [variable] to" block, choose "jumped", and set it to 0.
  11. Add a "move [sprite] [distance] pixels [direction]" block inside the second branch.
  12. Set the sprite to "this sprite", distance to "gravity", and direction to "North".
Tip: Moving the sprite North when touching a platform offsets the downward gravity pull so the sprite stays on solid ground and resets the jumped variable.
Check: Verify your behavior checks collisions for both the dirt platform and the magic floor platform, resetting jumped to 0 each time.
Create the Gravity Behavior

Make the Bear Jump

Goal: Program the bear to jump upward when space is pressed if it is not already in the air.

Give the bear jumping abilities by checking the jumped variable whenever the player presses the space key.

  1. Drag out a "when [key] pressed" event block and select "space" from the dropdown.
  2. Connect an "if [condition] do" block under the "when [space] pressed" block.
  3. Set the if condition to check if "jumped" = 0.
  4. Inside the if block, add a "set [variable] to" block, choose "jumped", and set it to 1.
  5. Add a "move [sprite] [distance] pixels [direction]" block inside the if block.
  6. Select the bear sprite in the sprite slot.
  7. In the distance slot, insert a multiplication block and calculate "gravity" * 8.
  8. Set the direction dropdown to "North".
Tip: Setting jumped to 1 prevents the player from jumping repeatedly while already in the air.
Check: Press the space key while running the game. The bear should leap upward by gravity multiplied by 8 pixels.
Make the Bear Jump

Level Progression with Apples

Goal: Play a celebration sound and advance through levels 1, 2, or win the game when touching an apple.

The apple acts as the goal for each level. Advance the level variable and load the next map when the bear reaches it.

  1. Drag out a "when [sprite] touches [sprite]" event block, choosing the bear and apple sprites.
  2. Connect the "play sound" block under the event and select "Achievements: vibrate_success_1_up".
  3. Add an "if [condition] do" block under the sound block and use the plus icon to add two "else if" branches.
  4. In the first condition slot, check if "level" = 0.
  5. Inside the first branch, set "level" to 1.
  6. Add the "remove [all sprites]" block inside the first branch.
  7. Add the "createBear" function block inside the first branch.
  8. Add the "createMap2" function block inside the first branch.
  9. In the second condition slot, check if "level" = 1.
  10. Inside the second branch, set "level" to 2.
  11. Add the "remove [all sprites]" block inside the second branch.
  12. Add the "createBear" function block inside the second branch.
  13. Add the "createMap3" function block inside the second branch.
  14. In the third condition slot, check if "level" = 2.
  15. Inside the third branch, add the "winGame" function block.
Tip: Always remove all sprites before spawning new ones to clear old platforms and items.
Check: Move the bear into an apple. Listen for the achievement sound and verify that the next level loads.
Level Progression with Apples

Collecting Coins and Sub-levels

Goal: Collect coins to update platforms, animate magic floors, and spawn new coins across sub-levels.

Each coin collected within a level updates the layout by placing new dirt platforms and magic floors.

  1. Drag out a "when [sprite] touches [sprite]" event block, selecting the bear and coin sprites.
  2. Connect the "play sound" block under the event and select "Collect: collect_item_bling_1".
  3. Add a "remove [object]" block and select the coin sprite.
  4. Add an "if [condition] do" block with two "else if" branches.
  5. In the first condition slot, check if "subLevel" = 0.
  6. Inside the first branch, add a "make [dirt] sprites using grid" block.
  7. Add a "make new [magic floor] sprite at (163, 131)" block.
  8. Add the "animateMagicFloor" function block.
  9. Add a "make new [coin] sprite at (382, 173)" block.
  10. Add a "set [coin] size to" block and set the size to 50.
  11. Add a "set [subLevel] to" block and set the value to 1.
  12. In the second condition slot, check if "subLevel" = 1.
  13. Inside the second branch, add a "make [dirt] sprites using grid" block.
  14. Add a "make new [magic floor] sprite at (266, 187)" block.
  15. Add the "animateMagicFloor" function block.
  16. Add a "make new [coin] sprite at (26, 224)" block.
  17. Add a "set [coin] size to" block and set the size to 50.
  18. Add a "set [subLevel] to" block and set the value to 2.
  19. In the third condition slot, check if "subLevel" = 2.
  20. Inside the third branch, add a "make [dirt] sprites using grid" block.
Tip: Notice how each subLevel sets up the next platform puzzle and repositions the coin.
Check: Touch a coin with the bear. The bling sound should play, the coin should disappear, and new platforms should appear.
Collecting Coins and Sub-levels

Hazard Detection

Goal: End the game when the bear touches the hazard block.

Add danger to the game by triggering a game over if the bear falls onto or touches a hazard.

  1. Drag out a "when [sprite] touches [sprite]" event block.
  2. Select the bear sprite in the first slot and the hazard block sprite in the second slot.
  3. Connect the "loseGame" function block inside the event.
Tip: Make sure the hazard block sprite matches the brown hazard block used across your level maps.
Check: Have the bear touch the hazard block to verify that the loseGame function triggers.
Hazard Detection

🎉 Congratulations!

Congratulations! You built a complete jumping bear platformer with multiple levels, dynamic sub-levels, jump mechanics, custom gravity physics, and hazard detection!
🏆

Next challenge!

  1. Update the map for level 2
  2. Create a double jump ability by allowing the bear to jump when jumped is less than 2.
  3. Add sound effects when the player jumps
🚀
×
Zoomed view