Skip to main content

How to: Make a Minimap

Games often have a minimap to show a player what they might find beyond their immediate view. Minimaps often display a schematic view of the world, using icons or simple shapes to represent players and objects.

You can create a minimap in Easel by using a second camera. Spawn a globally-accessible entity to represent your minimap camera, giving it a name like Camera:Minimap. Then you can render some sprites into that camera specifically.

Use the Viewport function to place the minimap camera's view in a small rectangle in the corner of the screen.

Then you can use the Camera function to decide where the minimap camera should be looking. You could have it follow the player, for example.

pub category Category:Ship

pub const Camera:Minimap = Spawn

pub game fn World.Main(maxHumanPlayers=5) {
Viewport(scale=0.2, anchor=@(1,1), camera=Camera:Minimap)
SolidBackground(color=#111, camera=Camera:Minimap)

SpawnEachPlayer owner {
Spawn ship {
use body=ship
use radius=1

Body(pos=20*RandomVector)
PolygonCollider(category=Category:Ship, shape=Circle)

Camera(camera=Camera:Minimap)
ImageSprite(@ship.svg, ownerColor=true)
PolygonSprite(ownerColor=true, shape=Equilateral(numPoints=3), camera=Camera:Minimap)

on Pointer {
Heading = Angle(Pointer - Pos)
}
on ButtonDown(Click) {
behavior<thrust> on BeforePhysics {
Velocity += 0.5 * Heading.Direction
Spark(color=#f80, luminous=1, bloom=3)
}
}
on ButtonUp(Click) {
delete behavior<thrust>
}
}
}
}