Tiled map editor integration with the map scrolling engine. More...
#include <snes.h>#include <snes/map.h>#include "res/tileslevel1.inc"#include "res/maplevel01.inc"Functions | |
| int | main (void) |
| Entry point — initialize hardware, load map, scroll with D-pad. | |
Variables | |
| s16 | focusx |
| 4bpp tileslevel1_tiles graphics (converted from tileslevel1.png) | |
Tiled map editor integration with the map scrolling engine.
Demonstrates how to use maps created in the Tiled editor (https://www.mapeditor.org/) with the OpenSNES map engine. The map is a large 224x30 tile level (1792x240 pixels) stored in ROM. The map engine streams the visible 32-tile window into VRAM as the camera scrolls, so only the on-screen portion uses VRAM at any time.
The Tiled workflow:
This example uses pre-converted binaries. The original Tiled source file (maplevel01.tmj) is included in res/ for reference.
Ported from PVSnesLib "tiled" example by alekmaul.
| int main | ( | void | ) |
Entry point — initialize hardware, load map, scroll with D-pad.
| s16 focusx |
4bpp tileslevel1_tiles graphics (converted from tileslevel1.png)
Tileset palette (3 palette banks x 16 colors = 96 bytes)
Full level tilemap — 224x30 tiles, 16-bit entries (from BG1.m16)
Metatile definitions — 4 tile indices per metatile (from .t16)
Tile collision attributes — one property byte per metatile (from .b16)
Focus-point X in map pixels — the point the camera FOLLOWS (your player's position), NOT a scroll origin. mapUpdateCamera() centers the view on it with boundary clamping; passing a view origin here shifts the whole level by half a screen (see map.h).