Ember is discontinued. It still works, but it gets no more updates or support. Back to uayi.org
Home · Terrified Gorillas · Glimmerwood · Starfall Hollow · ‹ Prev Next ›
Ember
Download

Making games

2D and 2.5D games

Ember is a 3D engine, and 2D games are 3D scenes seen straight on: flat pictures (sprites) in the X/Y plane, a camera without perspective, and physics that only moves in X and Y. The Blank 2D Platformer template has all of it set up.

Sprites

Add Component > Sprite puts a picture on an object.

Setting
Image any PNG under assets/ (the stock pixel art is in sprites/)
Size metres, times the object's scale
Pivot the point that sits at the object's position: centre, or bottom centre for characters
Tint, Brightness multiplies the picture; brightness above 1 glows
Flip X / Y mirror it (a character facing left)
Face the camera for 2.5D: the sprite turns to the camera and stays upright (trees, characters in a 3D world)
Pixel art sharp pixels when scaled up (off for painted art)
Lit by the scene take the sun's and sky's light instead of showing the exact colours
Repeat tile a single image (a long strip of ground)
Sprite sheet columns x rows of frames; an animation is a run of frames at a speed, looping or not

Sprites are drawn after the 3D world, sorted far to near, and write depth, so they sit correctly in front of and behind each other and 3D objects.

In scripts:

e:play_sprite(2, 4, 12)        -- frames 2..5 at 12 frames a second, looping (call it every update: it keeps playing)
e:play_sprite(8, 3, 10, false) -- once; e:sprite_finished() turns true at the end
e.sprite_frame = 6             -- show one frame (stops the animation)
e.flip_x = true
e:set_sprite{ texture = "sprites/hero.png", columns = 8 }
scene.spawn{ name = "Coin", position = vec3(3, 2, 0), sprite = { texture = "sprites/coin.png", columns = 6, frame_count = 6, fps = 10 } }

The editor's 2D view

The 2D button in the viewport toolbar switches the scene view to look straight at the X/Y plane without perspective: right- or middle-drag pans (exactly with the mouse), the wheel zooms, and the grid lies in the X/Y plane. Gizmos work as usual. A scene whose game camera is orthographic opens in the 2D view.

The camera

Camera > Projection > Orthographic removes perspective: things don't shrink with distance and View height is how many metres fit from the bottom of the screen to the top. Point the camera down -Z (rotation 0) at the X/Y plane. Scripts: camera.ortho_size = 14, camera:set_orthographic(true, 12). Orthographic cameras also suit isometric and strategy games (tilt the camera).

2D physics

Tick 2D physics on a dynamic collider: it moves only in X and Y and only spins around Z, so it never drifts out of the plane. With Lock rotation too it doesn't spin at all (characters). In scripts: add_collider{..., lock_2d = true}. Static ground needs nothing special: give it a box collider the size of its sprite (half_extents = half the sprite size, any depth).

Exact colours

Pixel art should look exactly like the file. Environment > Tone mapping > None shows colours as they are (no film curve, no automatic exposure), so a sprite's red is the red you drew.

2.5D

2.5D games are 3D worlds played along a line: the Blank 2.5D Platformer and Platform Hopper templates use the 3D animated character with 2D physics on its body (it can't leave the lane) and a side camera, with scenery placed behind the lane for depth. Sprites with Face the camera on mix 2D characters into a 3D world.

Ember 1.1 documentation. Found a mistake? The source of this page is site/docs/2d.md in the Ember source.