Map Editor for Top-Down Tiled View
This recipe shows a simple map editor for a top-down tiled view. This extends the recipe for
displaying a top-down tiled view with the ability to select a tile from the atlas texture and
draw that tile onto the map.
Live Demo
Controls
- Arrow keys - scroll the view
- Click upper left corner then drag to select a tile from the palette
- Click anywhere else on the view to draw that tile on the view
- Hold down 'r' and click and drag to drag out a rectangle of the same tile
Source Code
Exercises
- Extend the editor to support a "props" layer of tiles that is rendered on top of the
"ground" layer. Allow the transparent tiles in the tile atlas (the boats, bridges, market
stalls, etc.) to be added to the props layer.
- Add support for "auto-fringing". The user simply draws a block of grass, for example,
and the editor automatically surrounds it with the appropriate "fringe" tiles on the edges
and corners. For extra credit, support non-rectangular shapes. Note: you may want to put
the fringe tiles on a separate layer and recompute all fringes at once (on request).
Back to cookbook.