The round: walk Kit to GOAL shards before the clock runs out. More...
#include <snes.h>#include <snes/input.h>#include <snes/text.h>#include <snes/vramqueue.h>#include <snes/debug.h>#include "res/field.inc"#include "res/cast.inc"#include "game.h"#include "screen.h"Macros | |
| #define | PLAYER_SPEED 2 |
Frames of res/cast.png: Kit 32x32 four a row, then the shard 16x16 | |
| #define | FRAME_DOWN 0 |
| #define | FRAME_RIGHT 10 |
| #define | FRAME_UP 5 |
| #define | TILE_SHARD 256 |
The field Kit's box may cover (inside the kerb, under the HUD) | |
| #define | PX_MAX 232 |
| #define | PX_MIN 16 |
| #define | PY_MAX 200 |
| #define | PY_MIN 32 |
Functions | |
| static void | drawHud (void) |
| Refresh the two HUD numbers (clear the field first so a shorter number never smears). | |
| static void | drawSprites (void) |
| Draw Kit and the shard; the box sits at Kit's feet. | |
| static u16 | kit_tile (u16 f) |
The OAM tile of Kit's frame f (32x32 frames are 4x4 tiles, rows 16 tiles wide). | |
| static void | placeShard (void) |
| Put the next shard of the table on the field. | |
| static void | playClose (void) |
| Close hook: the sprites and the HUD do not outlive the round. | |
| void | playRun (void) |
| One round: returns when the goal is reached or the clock is out. | |
| static void | update (u16 held) |
| One image of play. Flat u8/u16 only: no call through a pointer in the hot loop. | |
Variables | |
| static u8 | facing |
| static u8 | facing_left |
| static u8 | moving |
| u8 | play_px |
| Kit's pickup box (top-left corner). Named globals: the tests read them. | |
| u8 | play_py |
| u8 | play_secs |
| Seconds left, for the HUD. | |
| u8 | play_shards |
| Shards collected this round. | |
| u8 | play_sx |
| The current shard's box. | |
| u8 | play_sy |
| u16 | play_time |
| Frames since the round began. | |
| static const u8 | shard_pos [5 *2] |
| Where the shards appear, in order: x, y of the 8x8 pickup box. | |
| static u8 | tick |
The round: walk Kit to GOAL shards before the clock runs out.
The shards come in a fixed order (a table), not at random: a round is the same every time, which is what lets a test play it with a scripted pad.
| #define FRAME_DOWN 0 |
Kit walking down: frames 0-4
| #define FRAME_RIGHT 10 |
walking right: 10-14; left mirrored
| #define FRAME_UP 5 |
walking up: 5-9
| #define PLAYER_SPEED 2 |
| #define PX_MAX 232 |
| #define PX_MIN 16 |
| #define PY_MAX 200 |
| #define PY_MIN 32 |
| #define TILE_SHARD 256 |
the shard's frame k is tile 256 + 2k
|
static |
Refresh the two HUD numbers (clear the field first so a shorter number never smears).
|
static |
Draw Kit and the shard; the box sits at Kit's feet.
< the shard's frame k is tile 256 + 2k
The OAM tile of Kit's frame f (32x32 frames are 4x4 tiles, rows 16 tiles wide).
|
static |
Put the next shard of the table on the field.
|
static |
Close hook: the sprites and the HUD do not outlive the round.
| void playRun | ( | void | ) |
One round: returns when the goal is reached or the clock is out.
< the play square
< frames on the clock: 30 s at 60 Hz
< Kit walking down: frames 0-4
< shards to collect
< frames on the clock: 30 s at 60 Hz
< shards to collect
|
static |
One image of play. Flat u8/u16 only: no call through a pointer in the hot loop.
< walking right: 10-14; left mirrored
< walking right: 10-14; left mirrored
< walking up: 5-9
< Kit walking down: frames 0-4
< shards to collect
< shards to collect
|
static |
|
static |
|
static |
| u8 play_px |
Kit's pickup box (top-left corner). Named globals: the tests read them.
| u8 play_py |
| u8 play_secs |
Seconds left, for the HUD.
| u8 play_shards |
Shards collected this round.
| u8 play_sx |
The current shard's box.
| u8 play_sy |
| u16 play_time |
Frames since the round began.
|
static |
Where the shards appear, in order: x, y of the 8x8 pickup box.
|
static |