Skip to content
Tutorials Center
My learning

Topics

Lesson 36 of 36 ยท Projects and Practice

Phaser Practice Challenges

Ten Phaser practice challenges with hints and acceptance checks, plus runnable solutions for whack-a-mole and a tilemap treasure explorer.

Reading about game development is not the same as making games. The fastest way to become fluent is to build many small games, each one forcing you to use a few tools well. This lesson gives you ten challenges that are small enough to finish in an evening, each with a clear goal, the Phaser features you will need and a list of checks for knowing that it is really done. Two of them have complete, runnable solutions that you can read after you have tried them yourself.

A good method is to follow the three passes: first make it work with rectangles and circles (no art), then make it feel good (tweens, sound, feedback), and only then make it pretty. Almost every abandoned game project spent its time on art before the game was fun.

How to use these challenges

  1. Start from an empty page with the Phaser script tag and a scene class.
  2. Read the goal, then the hints. Try without looking at the solution.
  3. Check your work against the acceptance list, not against how it looks.
  4. When it works, change one rule (speed, size, scoring) and see how the game changes. Tuning teaches game feel.
  5. Keep your code. Later challenges reuse pieces of earlier ones.

The ten challenges

1. Whack-a-mole (solution below). A 3 by 3 grid of holes; moles pop up for a short time; click to score; 30-second timer; speed rises over time. Tools: timers, tweens, input, scene restart. Check: a mole that is clicked does not give points twice, the game ends at 30 seconds, and a second game starts clean.

2. Treasure explorer (solution below). A top-down map from text with walls, five chests, camera follow and a minimap. Tools: tilemap from data, collision, groups, overlaps, two cameras. Check: the player cannot walk through walls, chests disappear when collected, and the minimap shows the whole map.

3. Volume mixer. A settings scene with two sliders (music and effects) and a mute toggle, whose values are stored in the registry and in local storage. Tools: drag input, registry, save manager. Check: values survive a scene change and a page reload (when storage is available) and other scenes read them.

4. Endless runner. A character that jumps over obstacles that scroll in at increasing speed, over a parallax background; the score is distance. Tools: tile sprites, scroll factors, pooling, difficulty curve. Check: obstacle objects are reused (count them), the speed increase is capped, and a restart resets the speed.

5. Breakout. A paddle, a ball and rows of bricks. Bricks need one, two or three hits, and each one has a different color. Tools: Arcade physics bounce, colliders, groups, bodies. Check: the ball angle depends on where it hits the paddle, the ball never gets stuck horizontally, and the level can be won.

6. Snake on a tile grid. The snake moves one tile per step, grows when it eats, and dies when it hits itself or a wall. Use a tilemap layer for the drawing. Tools: putTileAt, timed events, keyboard input, arrays for the body. Check: reversing direction instantly is not allowed, food never appears on the snake, and the step speed rises with the length.

7. Typing game. Words fall from the top; the player types them to destroy them. Tools: text objects, keyboard keydown events, pools, difficulty. Check: partially typed words are highlighted, a typo resets the current word, and a missed word costs a life.

8. Pause and settings flow. A game with a title scene, a game scene, a pause overlay with resume, restart and settings, and a game over scene. Tools: scene launch, pause, resume, data passing. Check: pausing really freezes timers and tweens, and resume continues exactly where it stopped.

9. Particle fountain toy. Move the mouse to emit particles in changing colors, click for an explosion, and number keys to switch emitter presets (fire, snow, sparks). Tools: particle emitters, config objects, events. Check: only a few emitters exist (reuse them), and switching presets does not leak objects.

10. Make it mobile. Take any earlier game and make it playable on a phone: touch controls, FIT scaling, orientation handling, and a hosted production build. Tools: Scale Manager, multi-touch, Vite build, static hosting. Check: it plays on a real phone and you can send the link to a friend.

Solution to challenge 1: Whack-a-mole

Read the structure before the details. The game has three separate concerns: moles (each one is a circle that tweens out of a hole), a spawner (a timer that picks a free hole), and rules (score, time, game over). Keeping them separate makes it easy to tune.

Solution: whack-a-mole

Things to notice:

  • A mole is "up" from the moment it is chosen until its tween completes; the spawner only picks holes that are not up, so one hole never has two moles.
  • The flag hole.hit and the check at the top of whack stop a double score from two quick clicks.
  • Difficulty is a number between 0 and 1 (1 - timeLeft / TIME_LIMIT) fed through Phaser.Math.Linear. The same trick works for almost any ramp.
  • scene.restart() rebuilds everything, so the state reset happens in create(), exactly as in the scene architecture lesson.

Solution to challenge 2: Treasure explorer

This one combines most of the earlier chapters: a tilemap built from text, solid walls, a camera that follows the player, chests that are collected with an overlap, and a minimap. Move with the arrow keys or WASD.

Solution: treasure explorer with minimap

The maze rows are strings, the walls become tile index 1 with a single setCollision(1) call, and chests are a static group destroyed on overlap. The minimap is a second camera whose zoom is 150 / mapWidth, exactly as in the camera lesson. As an extension, make chests hold random coin values, add enemies that patrol the corridors, and add fog of war by drawing a dark tile layer that you clear around the player.

Stretching further

When these ten feel comfortable, go further in directions that match your goals:

  • Finish and publish one game. A small finished game teaches more than ten prototypes. Use Optimizing and Publishing Your Game.
  • Learn Tiled properly and build a full level with object layers (Maps from the Tiled Editor).
  • Add real art and sound: free asset packs, plus tools like Aseprite for pixel art and sfxr-style generators for sound effects.
  • Try a game jam. A 48-hour deadline with a theme is the best teacher of scope control.
  • Read other people's code. The official Phaser examples and open source games show patterns you will not invent alone.
  • Move to TypeScript and Vite for projects bigger than a few hundred lines (Vite, TypeScript and Project Structure).

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why build with rectangles and circles first?

    A placeholder prototype proves that the rules and feel work. Art comes after the game is fun.
  2. 2. In the whack-a-mole solution, what prevents two moles from appearing in the same hole?

    A hole is marked up from the moment it is chosen until its animation ends, and free holes are the only candidates.
  3. 3. How is the minimap created in the explorer solution?

    A small camera with a tiny zoom, centered on the map, shows the whole world.
  4. 4. What is a good way to ramp difficulty over time, as the mole game does?

    One progress value fed through a linear (or eased) mapping controls any number of settings consistently.

Summary

  • Practice with small, finishable games: prototype with shapes, then add feel, then art.
  • Whack-a-mole practices timers, tweens, input and restart-safe state.
  • The treasure explorer combines tilemaps, collision, groups, camera follow and a minimap.
  • Use a progress value with Phaser.Math.Linear for difficulty ramps, and test with acceptance checks instead of impressions.
  • Finish and publish a game: it teaches things that no tutorial can.

Next: Back to the Phaser tutorial