5 minutes
A soccer match needs a pitch. Right now the canvas is black. There is no grass, no goalposts, and no light to see by. Before anything can move, the pitch has to exist. You need something to look at first.
Five terms carry the whole course. An entity is a named thing in the world, like a wall, a light, or the ball. A component is data attached to an entity. A MeshPrimitive holds a shape and colour. A Goal holds a box. A System reads one kind of component every frame and acts on it. The World holds them all and ticks once per frame. A scene is a JSON file. It lists the starting entities and their components. You build this game by writing that file, not a render loop.
Scaffold a project with create-arcade. Then open the empty scene at src/scenes/soccer.json. Every component this course uses lives under src/components/. That is the path printed on each code chip below.
The scene file, lights, and camera
A scene file starts with a few headers and an entities map. Add the sun, the ambient fill light, and the overhead camera:
The DirectionalLight is the sun. It is one angled beam that lights up surfaces. Because shadowEnabled is true, it also casts shadows. The toSpec() method packs its fields into a renderer spec:
The HemisphericLight is the fill light. It is a soft glow from the sky, tinted by the ground. It keeps shadowed sides from turning pure black:
The ArcCamera sits almost straight overhead. alpha: -1.5708 is −π/2, which looks down the −Z axis. beta: 0.9 tips it forward off vertical. controlsEnabled: false locks the view, so a stray mouse drag can never move it. The System builds the camera through the adapter:
Continue reading
Unlock the Full Course
Every lesson, the runnable examples, and the finished build — yours to keep.