← Yop2D

Your first platformer game

Beginner guide · no code

Français · English · العربية

In this tutorial you make a small platformer in about half an hour, without writing any code: a hero who runs and jumps, three pearls to collect, a turtle that walks back and forth on a block, and a score. If you get stuck, compare with the finished project (import it into Yop2D: its nodes are tidied up with frames and sticky notes that explain everything).

Screenshot of the platformer: the hero, pearls, a turtle on a block and the score at the top left
The finished game: the score is at the top left.
You need:
👉 The screenshots are in English. On your device the same buttons are written in the language of Yop2D, in the same place.

Step 1: the background, the ground and a block

  1. Tap Object (top left), then Image. The Yop2D Library opens: choose the Prehistory theme, the Backgrounds folder, then the jungle background. It places itself behind everything.
  2. Do Object → Image again and take a grass ground in Ground and platforms. Place it at the very bottom and stretch it across the screen. Name it sol in the inspector.
  3. Tap ⚙ Behavior (in the inspector) and choose Ground / wall: the hero will walk on it and not fall through.
  4. Add a small grass platform and place it higher, on the right, about 150 pixels above the ground. Give it the Ground / wall behavior too. Name it bloc.
Object behavior window of the ground object with "Ground / wall" selected
The "Ground / wall" behavior: the object does not move, you walk on it.
👉 The hero jumps about 200 pixels high: a block 150 pixels above the ground is easy to reach. If you place it higher, you will need another platform to climb.

Step 2: the hero

  1. Object → Image → Library, Prehistory theme, Characters folder. Choose the caveman with With its animations: the image and the animations (idle, walk…) are added at once. Put him on the ground and name him player.
  2. ⚙ Behavior → Platform character: he walks, jumps and falls.
  3. Add a Joystick at the bottom left and a round button at the bottom right for jumping. Select the joystick and, in the inspector, choose player in the Object to move field: without a target, the joystick does not know who to move. Then, in the hero's behavior window, choose the round button as the jump button. The guide Moving a character" explains the joystick and jumping.
Object behavior window of the player object with "Platform character" selected
The "Platform character" behavior for the hero.
Yop2D editor with markers: Object button, object list, Behavior card, Play button
The editor: 1 the Object button to add things, 2 the list of objects in the scene, 3 the Behavior card of the selected object, 4 the Play button.
👉 Tap Play (4) to try: the hero should walk, jump and stay on the ground. Tap ■ to go back to the editor.

Step 3: the patrolling turtle

  1. Object → Image → Library, Prehistory theme, Monsters folder: take the turtle and place it on the block. Name it tortue.
  2. ⚙ Behavior → Patrol (back and forth): it walks by itself one way then the other and turns around at the edge of the block. No node needed.
  3. In the inspector, For the nodes section, write the tag ennemi. You will need it in step 6.
Object behavior window of the turtle with "Patrol" selected
The "Patrol (back and forth)" behavior: perfect for an enemy.
👉 On the block, leave a little room on each side of the turtle: it turns around just before the edge.

Step 4: the three pearls

  1. Object → Image → Library, Prehistory theme, Objects folder: take the gold pearl. Place it within jumping reach, for example on the ground. Name it piece1.
  2. In the inspector, For the nodes section, write the tag piece (no accent, all lowercase).
  3. Tap Copy (at the top) twice: the copies appear near the original. Move them: one in the air above the ground, the last one above the block, high enough that the turtle cannot touch it. They keep the same tag piece.
Inspector of the pearl piece1 showing the tag piece
The tag piece on each pearl: one single rule will serve all three.
👉 A tag is a family name. Here the three pearls share the same one, so you only build the nodes once.

Step 5: the score

  1. In the left panel, Variables section, tap + and create a variable score: type integer, starting value 0, local to the scene.
  2. Object → Text: write Pièces : 0, put it at the top left and name it texteScore. To keep it readable, make it bigger (font size 60 to 70); if you put a small dark panel behind it, check that the text is in front (its Z must be higher than the panel's).
Left panel of the editor with the score variable and the plus button
The score variable (1) is created with the + button.

Step 6: the nodes

Now tell the game what happens when the hero touches something. Tap Blueprint (top right): the node screen opens. To place a node, open a category on the left and tap it; to connect two nodes, drag a wire from the output of the first to the input of the next.

  1. When the hero touches a pearl. Place the If object touches Tag event: Object A = player, Tag = piece. Connect, in order: Destroy Object (on The involved object, i.e. the pearl just touched), Add to Variable (variable score, value 1), then Modify Text (object texteScore, text written with the value ="Pièces : " + score, which shows the score).
  2. When the score reaches 3. Add a Condition node after it with =score >= 3. On its True output, connect: Modify Text (texteScore, text BRAVO), Wait (6 seconds) then Restart the scene.
  3. When the hero touches the turtle. A second If object touches Tag event: Object A = player, Tag = ennemi. After it: Screen flash, Small message at the bottom of the screen (a small "Ouch!" message), Wait (1 second) then Restart the scene.
  4. Stay inside the screen. A Every frame event connected to Clamp to screen (object player) keeps the hero from leaving the level.
Settings window of the "If an object touches a tag" node: Object A player, Tag piece
The event's settings window: 1 the object that touches (player), 2 the tag touched (piece).
Blueprint screen of the game: three groups of nodes in colored frames with sticky notes
The finished Blueprint: one frame per idea (pearls, enemy, stay inside the screen).
👉 In a node's window you do not have to type object names: tap them in the left list. Remember to save (💾) before going back to the editor.

Step 7: play!

Tap Play. Run, jump, collect the pearls: the text at the top left counts them. Climb onto the block to take the last pearl without touching the turtle. After three pearls, BRAVO appears, then the game restarts.

The game after three pearls: the text BRAVO at the top left
Three pearls collected: BRAVO.

Going further