Game Design & Development ยท Lesson 4

Build 2D Games Faster

Game Engines Kaplay Phaser 3 Sprites Scenes Physics

A game engine takes care of the repetitive code so you can spend more time making your game fun. Meet two browser-based enginesโ€”Kaplay and Phaserโ€”and decide which one fits your project.

Your mission Pick the best engine for a game idea and explain why.

Watch the engine do one frame of work

Predict: if a player has gravity but no solid collision response, will the floor stop it? Test below. Each click advances one slowed teaching frame (0.1 seconds).

The engine repeats this work
  1. Read the selected input.
  2. Update velocity and position.
  3. Resolve solid collisions.
  4. Draw the new state.

You still write the rules: what happens when a coin is collected, how to win, and what makes the game fun.

This is a simplified teaching model, not a running Kaplay or Phaser game. Real engines manage timing and their own update/physics order.

Test, compare, explainStep until the square lands. Reset, turn off โ€œSolid floor,โ€ and repeat. Then reset and turn off gravity. Explain which system changed each result. Use the browser game loop lesson to see the work an engine replaces.

Your route from idea to playable game

Use these lessons when you need the next skill. The tutorials teach game mechanics; adapt their rules to your chosen engine.

0The quick answer

For a first JavaScript prototype, Kaplay is a useful starting point. For a project built around tilemaps and scene organization, explore Phaser 3. Both can build substantial games; choose based on the features, examples, and code you understand.

Kaplay = easier startShorter code and quick prototypes
Phaser = more toolsMore setup, but room to build bigger

1What does a game engine do?

Think of a game engine as a toolbox for making games. It gives you ready-made code for jobs that almost every game needs.

  • Scenes โ€” switch between a menu, a level, and a game-over screen
  • Sprites โ€” show and animate characters, enemies, and items
  • Physics โ€” add gravity, speed, bouncing, and collisions
  • Controls โ€” read the keyboard, mouse, touchscreen, or gamepad
  • Sound โ€” play music and sound effects
  • Loading โ€” prepare images and sounds before the game begins
  • Camera โ€” follow the player, zoom, or shake after a big hit
Remember: Coding from scratch helps you learn how games work. An engine helps you make a bigger game faster. Both are useful skills.

2Meet Kaplay and Phaser

Both engines are free and work in a web browser. They can make the same kinds of 2D games, but they feel different to use.

Kaplay Beginner Friendly

  • Short, readable code
  • Add abilities like gravity as building blocks
  • Great for platformers and small arcade games
  • Fast setup for class projects and game jams

Phaser 3 Scene & Map Tools

  • Uses an organized scene system
  • Includes several physics choices
  • Strong tools for maps, effects, and cameras
  • Better for larger, more detailed games
FeatureKaplayPhaser 3
Setup timeโšก 1 lineโฑ 10 min
Learning curveโœ“ Gentleโš  Moderate
Physics qualityโš  Basic/Mediumโœ“ Advanced
Documentationโœ“ Goodโœ“ Excellent
Community sizeโš  Mediumโœ“ Large
Game Jam speedโœ“ Useful fitโœ“ Also possible
Large projectsโœ“ Also possibleโœ“ Useful fit

3How a scene starts and runs

A scene is one part of a game, such as the menu, a level, or the game-over screen. A common Phaser 3 scene uses these lifecycle methods (an optional init() can come first). Loading and setup happen when the scene starts; update repeats while it runs:

preload() Get images and
sounds ready
โ†’
create() Build the level
and add the player
โ†’
update() Repeat: move and
check collisions

Kaplay does these jobs too, but hides more of the setup. You create a scene, use add() to place objects, and Kaplay keeps the game running.

Every engine has the same three jobs: a place for the level's objects, setup that runs once, and an update that runs every frame. Pick engines below to see what each one calls them.

Quick checkWhich step repeats many times each second? Answer: update().

4Compare the code

These are partial API sketches, not complete playable games: the floor and collision setup are omitted. Switch tabs and match each instruction to the frame lab. Kaplay also needs setGravity() for falling; Phaser needs a floor collider or world bounds for blocked.down to become true.

// Kaplay โ€” minimal setup, very readable
kaplay();

scene("game", () => {
  // create a player with components
  const player = add([
    rect(32, 32),           // draw a 32ร—32 rectangle
    pos(200, 200),          // starting position
    color(BLUE),             // color it blue
    area(),                  // enable collision detection
    body(),                  // enable gravity/physics
    "player",               // tag for collision queries
  ]);

  // movement โ€” checked every frame automatically
  onKeyDown("left",  () => player.move(-200, 0));
  onKeyDown("right", () => player.move( 200, 0));
  onKeyPress("up",    () => player.jump());
});

go("game");
Code detectiveFind the starting position (200, 200) and movement speed 200 in both examples. Which version is easier for you to read?

5Four key words

๐Ÿง SpriteA 2D picture used for a player, enemy, coin, or other game object.
๐ŸŽž๏ธ Sprite sheetMany animation pictures packed into one image, like frames in a flipbook.
๐Ÿงฑ TilemapA level built from a grid of small reusable pictures called tiles.
โœจ TweenA smooth change over time, such as moving, fading, growing, or bouncing.
Try an exampleA coin slowly fades away after you collect it. That fade is a tween.

6Choose your engine

Choose based on your situation:

First time building a gameโ†’ Kaplay
Game Jam with 5-day limitโ†’ Kaplay
Platformer with levels and mapsโ†’ Explore Phaser 3; compare needed features
Want to build a portfolio pieceโ†’ Explore Phaser 3; compare needed features
Learning how game loops workโ†’ Build from scratch first
3D game ideaโ†’ Use a 3D engine instead
Smart first project: Start small. Catch, Dodge, Clicker, Maze, and Pong are all good choices. Get one fun action working before adding more features.
Exit ticketYour idea is a five-level platformer with a map and camera effects. Which engine would you choose, and what evidence from this page supports your choice?

Check the engine documentation

Follow the documentation for the version your project uses. This lesson compares Kaplayโ€™s component approach with Phaser 3 scenes.