2D platform game (2D World)
Easy · Build a level with ground, coins and a flag, make the hero run, jump and grab coins, with background music.
Interactive tutorial: the editor checks each step by itself.
- Add the "2D World" extension. The Extensions button opens the list and the extension blinks: click "Add".
- In the 2D World category, click "Open the 2D World editor". Choose "Complete Platform Level" and click Save.
- Choose the hero sprite in the list below the stage.
- In Events, drag "when green flag clicked" to the code area.
- In 2D World, snap "camera follow" (choose your sprite) and "turn on gravity with force 1" under the flag.
- In Control, snap a "forever" and, inside it, an "if … then" with "key right arrow pressed?" (Sensing). Inside the "if", put "change x by 5" (Motion).
- Do the same for the left arrow with "change x by -5".
- To jump: another "if" with "key space pressed?" and, inside, "jump with force 14" (2D World).
- Coins: drag "when I touch the coin block" (2D World) and snap "erase the coin blocks I am touching" and "play sound" (Sound).
- Music! In the Sound category, snap "play background music … on loop" under the flag and pick a track (♫).
- Click the green flag, click the stage and play: arrows to walk and space to jump!
- Challenge: "when I touch the flag block" + "play sound level complete" + "say I won!". (challenge)
The blocks of the finished program
• evt_bandeira
• mun_seguir
• mun_gravidade [G: 1]
• som_fundo [SOM: trilha aventura 8-bit]
• ctl_sempre
• ctl_se [COND: (sen_tecla)]
• mov_mudar_x [DX: 5]
• ctl_se [COND: (sen_tecla)]
• mov_mudar_x [DX: -5]
• ctl_se [COND: (sen_tecla)]
• mun_pular [F: 14]
• mun_quando_tocar [BLOCO: moeda]
• mun_pegar [BLOCO: moeda]
• som_tocar [SOM: moeda]