Scrolling map with animated sprite character. More...
#include <snes.h>#include <snes/map.h>#include "res/tilesMario.inc"#include "res/mario.inc"#include "res/tiledMario.inc"Functions | |
| int | main (void) |
| Entry point — scrolling map with animated Mario. | |
Variables | |
| u16 | flip |
| Animation toggle (advance every other input frame). | |
| u16 | flipx |
| Horizontal flip flag (1 = facing left). | |
| u16 | frame |
| Current sprite tile number. | |
| u16 | frameidx |
| Current animation frame index (0-3). | |
| static const u8 | sprTiles [4] = {0, 2, 4, 6} |
| 4bpp tilesMario_tiles graphics | |
| u16 | xloc |
| Mario X position in map pixels. | |
| u16 | yloc |
| Mario Y position in map pixels. | |
Scrolling map with animated sprite character.
A large Tiled map scrolls as a Mario sprite moves left and right. The map engine streams only the visible tiles to VRAM, so the map can be much wider than the screen. The sprite animates between 4 walk frames and flips horizontally based on direction.
This is the stepping stone between "static background" and "continuous_scroll" — it teaches the map engine basics with a simple player character.
Ported from PVSnesLib "mapscroll" example by alekmaul.
| int main | ( | void | ) |
Entry point — scrolling map with animated Mario.
| u16 flip |
Animation toggle (advance every other input frame).
| u16 flipx |
Horizontal flip flag (1 = facing left).
| u16 frame |
Current sprite tile number.
| u16 frameidx |
Current animation frame index (0-3).
|
static |
4bpp tilesMario_tiles graphics
Tileset palette (3 banks x 16 colors)
Full level tilemap from tmx2snes
Metatile definitions
Tile collision attributes
16x16 Mario sprite tiles (4 animation frames)
Mario sprite palette
Walk frame tile offsets: each 16x16 sprite = 2 tiles in VRAM
| u16 xloc |
Mario X position in map pixels.
| u16 yloc |
Mario Y position in map pixels.