Skip to main content

Making a Simple Game - Part 1: Setting Up the Scene

In this six-part series you'll build Keepy Up, a small game where you tap a football to keep it in the air. Each part ends with something you can run, and by the end you'll have a finished game published to the web.

This is the finished game. Tap or click the ball to start:

The series covers:

  1. Setting up the scene (this part): the project, the stadium, the ball, the camera and the light.
  2. Lighting and materials: a sky that lights the scene, shadows, and a shinier ball.
  3. Making the ball move: your first two scripts.
  4. Game flow and scoring: a game script and a score on screen.
  5. Menu and game over screens: the rest of the user interface.
  6. Sound, particles and publishing: the finishing touches, then putting the game online.
Before you start
  • You need a free PlayCanvas account and a desktop browser.
  • If you have never used the Editor, work through Your First App first. It takes about 15 minutes and teaches the panels this series uses.
  • You can look at the finished project at any time to compare it with your own.

1. Fork the Starter Project​

The models, textures, sounds and font for the game are ready for you in a starter project. Forking it gives you your own copy to build on.

  1. Open the Keepy Up Starter project and select Fork Project.
  2. Name your copy Keepy Up and select Fork project.
  3. When your copy is ready, select Open project. The Editor opens in a new tab.

The Assets panel shows what you have to work with:

The Assets panel of the starter project, with six folders

FolderContents
ModelsThe football and the stadium
TexturesA sky image and a particle image
UIA ring to draw around the ball
SoundsA kick, a game over sound and a music loop
FontsThe font for the score and the titles
ScriptsEmpty. You'll write the scripts yourself

The scene, called Game, holds only a Camera and a Light.

2. Sharpen the Picture​

Phones and many laptops have screens with more than one physical pixel per CSS pixel. By default a PlayCanvas app ignores that and looks soft on them.

  1. Select the cog icon at the bottom of the toolbar to open the project's Settings in the Inspector.
  2. Expand Rendering and turn on Device Pixel Ratio, near the bottom of the section.

A new project already fills the browser window and matches its resolution, so there is nothing else to change here.

3. Add the Stadium​

When a model is imported, the Editor makes a template for it: a ready-made Entity that you can drop into a scene.

  1. In the Assets panel, open Models > Stadium.
  2. Find the stadium template. Four assets in this folder have almost the same name, and the template is the one with a diamond-shaped icon. Scroll down if you can't see it.
  3. Drag the template into the Hierarchy panel and drop it on Root.
  4. With the new Entity selected, change its Name in the Inspector to Stadium.

The stadium template in the Assets panel, next to the two stadium.glb assets and below the Stadium render asset

Its Position should be 0, 0, 0. The stadium is built so that its pitch is 7 units below that point, which puts the game's camera at about chest height.

To see the whole stadium, move the pointer over the Viewport and press F.

The Editor with the stadium selected in the Viewport

4. Add the Football​

  1. Open Models > Football and drag the football template, which has the same diamond-shaped icon, onto Root.
  2. Rename the Entity Football.
  3. Set its Position to 0, 0.7, 0 and its Scale to 1.2, 1.2, 1.2.

The Inspector for the Football entity, with its position and scale set

The panel at the top of the Inspector tells you that the Entity is an instance of a template, and counts the values you have changed as overrides. You can ignore it for this project.

5. Aim the Camera​

The game is played side on, with the camera looking straight at the ball.

  1. Select Camera in the Hierarchy.
  2. Set its Position to 0, 0, 12.4 and its Rotation to 0, 0, 0.
  3. In the Camera Component, set Field Of View to 45, Near Clip to 0.5 and Far Clip to 2000.

The Inspector for the Camera entity

Near Clip and Far Clip set the range of distances that the camera draws. This range covers the whole stadium with room to spare.

6. Turn the Light​

A directional light acts like the sun. Only its rotation matters, not its position.

  1. Select Light in the Hierarchy.
  2. Set its Rotation to 45, -40, 0, so that it shines from behind the camera and to its left.
  3. In the Light Component, set Intensity to 1.6, and set Color to a slightly warm white such as FFF7E6.

The Inspector for the Light entity

Check Your Progress​

Select Launch at the top right of the Viewport. Your game opens in a new tab and should look like this:

The game at the end of Part 1: the ball in front of the stadium, with a dark, empty sky

The ball hangs in front of the goal and nothing moves yet. The sky is dark because the scene has no sky, and the ball looks flat because the only light on it comes from one direction.

You fix both in Part 2: Lighting and Materials.