- Click this link to make a remix: PROJECT LINK
Copy template
Initialize Game
Welcome to Jumping Bear! In this first step, configure what the player sees when clicking Run.
- Connect the "set background to" block under the "when run" block.
- Select the mountain forest landscape background from the dropdown.
- Add the "show title screen" block under the "set background to" block.
- Type "Jumping bear" into the "title" input.
- Type "Press "A" to start" into the "subtitle" input.
Create Bear Function
Create a reusable function called createBear to spawn the player character with its initial position, size, and movement behaviors.
- Open the Functions category and create a new function named "createBear".
- Add a "make new [sprite] sprite at (x, y)" block inside the function.
- Select the bear sprite and set the coordinates to (123, 72).
- Add a "set [sprite] size to" block, select the bear sprite, and set the value to 30.
- Add a "sprite [sprite] begins" block, select the bear sprite, and choose the "gravityTurnedOn" behavior.
- Add another "sprite [sprite] begins" block, select the bear sprite, and choose the "moving with arrow keys" behavior.
Create Map 1
Create the first level environment with platforms for the bear to jump on, an animated magic floor, and an apple as the goal.
- Open the Functions category and create a new function named "createMap1".
- Add a "make [lava] sprites using grid" block to create the bottom hazard layer.
- Add a "make new [magic floor] sprite at (220, 146)" block.
- Add a "make [dirt] sprites using grid" block to create stepping platforms.
- Add a "make new [magic floor] sprite at (133, 248)" block.
- Add the "animateMagicFloor" function block under the magic floor block.
- Add a "make new [apple] sprite at (24, 317)" block.
- Add a "set [apple] size to" block and set the value to 50.
Start Game on "A" Key Press
When the player presses the "a" key, hide the title screen, reset game variables, and start the first level.
- Drag out a "when [key] pressed" event block and select "a" from the dropdown.
- Connect the "hide title screen" block under the "when [a] pressed" block.
- Add the "remove [all sprites]" block under the "hide title screen" block.
- Add the "set background to" block and choose the meadow landscape with a tree.
- Add a "set [variable] to" block, select "gravity", and set it to 5.
- Add a "set [variable] to" block, select "jumped", and set it to 0.
- Add a "set [variable] to" block, select "level", and set it to 0.
- Add a "set [variable] to" block, select "subLevel", and set it to 0.
- Add the "createBear" function block under the variable blocks.
- Add the "createMap1" function block under the "createBear" block.
Create the Gravity Behavior
To simulate gravity and solid platforms, create a behavior that moves the sprite downward unless it is touching dirt or magic floor platforms.
- Open the Behaviors category and create a new behavior named "gravityTurnedOn with: this sprite".
- Add a "move [this sprite] [gravity] pixels [South]" block inside the behavior.
- Add an "if [condition] do" block under the move block and click the plus icon to add an "else if" branch.
- In the first condition slot, check if "[this sprite] is touching [dirt] = true".
- Inside the first branch, add a "set [jumped] to 0" block.
- Add a "move [this sprite] [gravity] pixels [North]" block inside the first branch.
- In the else if condition slot, check if "[this sprite] is touching [magic floor] = true".
- Inside the second branch, add a "set [jumped] to 0" block.
- Add a "move [this sprite] [gravity] pixels [North]" block inside the second branch.
Jumping Mechanic on Space Pressed
Add controls to let the player jump by checking the jumped variable so the bear cannot jump repeatedly mid-air.
- Drag out a "when [key] pressed" event block and select "space" from the dropdown.
- Add an "if [condition] do" block inside the event.
- In the condition slot, check if "jumped = 0".
- Inside the do branch, add a "set [jumped] to 1" block.
- Add a "move [sprite] [distance] pixels [North]" block, selecting the bear sprite.
- Set the distance slot to "gravity x 8" using a math multiplication block.
Animate Magic Floor Function
Magic floors add dynamic platforming challenges by moving back and forth across the screen.
- Open the Functions category and create a new function named "animateMagicFloor".
- Add a "sprite [sprite] begins" block, select the magic floor sprite, and choose "swimming left and right".
- Add a "set [sprite] size to" block, select the magic floor sprite, and set the value to 50.
- Add a "set [sprite] speed to" block, select the magic floor sprite, and set the value to 5.
Game Over Function
Create a reusable loseGame function to notify the player when they touch a hazard or fail an objective.
- Open the Functions category and create a new function named "loseGame".
- Add a "set background to" block and choose the space night sky with stars and planets.
- Add the "show title screen" block under the background block.
- Type "You lose!" into the "title" input.
- Type "Press "A" to restart" into the "subtitle" input.
- Add the "remove [all sprites]" block under the title screen block.
- Add a "play sound" block and select "Alerts: playful_quirky_negative_game_cue_2".
Win Game Function
Create the winGame function to celebrate when the player completes all levels of the game.
- Open the Functions category and create a new function named "winGame".
- Add a "set background to" block and choose the rainbow hill landscape background.
- Add the "show title screen" block under the background block.
- Type "You win!" into the "title" input.
- Type "Press "A" to restart" into the "subtitle" input.
- Add the "remove [all sprites]" block under the title screen block.
Level Progression with Apples
The apple acts as the goal for each level. While Map 1 had step-by-step instructions and Map 3 is already provided for you, creating Map 2 is entirely up to your own creativity! Build an exciting obstacle layout for Level 2, then advance the level variable and load the next map when the bear reaches the apple.
- Drag out a "when [sprite] touches [sprite]" event block, choosing the bear and apple sprites.
- Connect the "play sound" block under the event and select "Achievements: vibrate_success_1_up".
- Add an "if [condition] do" block under the sound block and use the plus icon to add two "else if" branches.
- In the first condition slot, check if "level = 0".
- Inside the first branch, set "level" to 1.
- Add the "remove [all sprites]" block inside the first branch.
- Add the "createBear" function block inside the first branch.
- Create a new function named "createMap2" and design your own Level 2 map layout using your creativity with platforms, hazards, and collectibles (Map 1 had guided steps, and Map 3 is already done for you!). Then add the "createMap2" function block inside the first branch.
- In the second condition slot, check if "level = 1".
- Inside the second branch, set "level" to 2.
- Add the "remove [all sprites]" block inside the second branch.
- Add the "createBear" function block inside the second branch.
- Add the "createMap3" function block inside the second branch.
- In the third condition slot, check if "level = 2".
- Inside the third branch, add the "winGame" function block.
Collecting Coins and Sub-levels
Each coin collected within a level updates the layout by placing new dirt platforms and magic floors.
- Drag out a "when [sprite] touches [sprite]" event block, selecting the bear and coin sprites.
- Connect the "play sound" block under the event and select "Collect: collect_item_bling_1".
- Add a "remove [object]" block and select the coin sprite.
- Add an "if [condition] do" block with two "else if" branches.
- In the first condition slot, check if "subLevel = 0".
- Inside the first branch, add a "make [dirt] sprites using grid" block.
- Add a "make new [magic floor] sprite at (163, 131)" block.
- Add the "animateMagicFloor" function block.
- Add a "make new [coin] sprite at (382, 173)" block.
- Add a "set [coin] size to" block and set the size to 50.
- Add a "set [subLevel] to" block and set the value to 1.
- In the second condition slot, check if "subLevel = 1".
- Inside the second branch, add a "make [dirt] sprites using grid" block.
- Add a "make new [magic floor] sprite at (266, 187)" block.
- Add the "animateMagicFloor" function block.
- Add a "make new [coin] sprite at (26, 224)" block.
- Add a "set [coin] size to" block and set the size to 50.
- Add a "set [subLevel] to" block and set the value to 2.
- In the third condition slot, check if "subLevel = 2".
- Inside the third branch, add a "make [dirt] sprites using grid" block.
Hazard Detection
Add danger to the game by triggering a game over if the bear falls onto or touches a hazard.
- Drag out a "when [sprite] touches [sprite]" event block.
- Select the bear sprite in the first slot and the hazard block sprite in the second slot.
- Connect the "loseGame" function block inside the event.
🎉 Congratulations!
Next challenge!
- Update the map for level 3
- Create a double jump ability by allowing the bear to jump when jumped is less than 2.
- Add sound effects when the player jumps