Platformer with diagonal slope collision detection.
Demonstrates the object engine's objCollidMapWithSlopes() function for handling diagonal terrain in a tile-based platformer. The SNES has no hardware support for collision, so slope detection is done in software by reading tile attribute tables that encode slope angles per tile (flat, 45-degree, half-slopes).
Uses the full OpenSNES game stack: map engine for scrolling, object engine for entity management, and dynamic sprite engine for animated character rendering. Mario walks, jumps, and slides on slopes with gravity-based physics.
Port of the PVSnesLib slopemario example by Nub1604.
- SNES Concepts
- Mode 1 with BG1 (tileset) and OBJ (sprites)
- Map engine with tile attribute tables (collision properties per tile)
- Slope collision: objCollidMapWithSlopes() for diagonal terrain
- Object engine: entity lifecycle, update callbacks, physics
- Dynamic sprite engine: animated 16x16 sprite with frame management
- SC_64x32 tilemap for horizontally-scrolling levels
- What to Observe
- Mario walks and jumps across terrain with diagonal slopes
- Character follows slope surfaces smoothly (no stair-stepping)
- Camera tracks Mario's position with map scrolling
- Gravity pulls Mario down when airborne
- Modules Used
- console, sprite, sprite_dynamic, sprite_lut, dma, input, background, map, object
- See also
- map.h, object.h, sprite.h, background.h
Main entry point – slope collision platformer demo.
Initializes the map engine with slope-aware collision data, registers the Mario object type, loads map and object layers, and enters the game loop. The main loop pipeline is:
- mapUpdate() – prepare new tile columns during active display
- objUpdateAll() – run physics and collision for all entities
- oamInitDynamicSpriteEndFrame() – finalize sprite tile queue
- WaitForVBlank + mapVblank + oamVramQueueUpdate – flush to VRAM
objCollidMapWithSlopes() is called internally by Mario's update callback to handle diagonal terrain traversal.
- Returns
- 0 (never reached – infinite game loop)