Your first game: a coin collector
In this walkthrough you make a game where a character runs, jumps and collects coins. It takes about 15 minutes. If you would rather see it finished, open the Platformer example under Explore examples: it is the same game.
1. Create the project
On the Start page, click New, choose Landscape 720p and click Create.
2. Add the objects
In the Project panel, under Object types, click Add object and create three Sprites:
| Name | What for |
|---|---|
Player |
The character you control. |
Ground |
Platforms it stands on. |
Coin |
Items to collect. |
In each sprite, click Add a sprite and pick an image from your computer (or draw one with Edit with Piskel). Then drag each object into the layout: the Player near the top, the Ground at the bottom and a few Coins scattered around.
3. Add behaviors
Behaviors give objects ready-made movement. Double-click the Player, open the Behaviors tab and click Add a behavior (the most used ones are under Movement and Attributes):
- On the
Player: Platform. It now walks with the arrow keys and jumps with the up arrow. - On the
Ground: Solid, so the character can stand on it.
Click Preview. You can already walk and jump, with no events at all.
4. Create the score variable
Under Global variables, add a number variable called Score, initial value 0. See Variables.
5. Collect the coins
Open the event sheet and create this event:
| Conditions | Actions |
|---|---|
Player Collision with Coin |
Coin Delete · Change variable value Score add 1 |
Preview again: touching a coin makes it vanish and the score goes up. To show the score on screen, see Text and score.
6. Restart when falling
If the player falls off the map, restart the level:
| Conditions | Actions |
|---|---|
Player Y position > 800 |
Change layout to the same layout |
What next?
- Show the score: Text and score.
- Add sounds: Sounds and music.
- Make more levels: Multiple layouts.
- Publish to the gallery: Export and publish.