Centralized game state structure.
More...
Centralized game state structure.
- Note
- IMPORTANT COMPILER PATTERN: Using a global struct with s16 types is the REQUIRED pattern for sprite coordinates in OpenSNES. The following patterns FAIL:
static u16 bx
Definition main.c:159
signed short s16
16-bit signed integer (-32768 to 32767)
Definition types.h:49
unsigned short u16
16-bit unsigned integer (0 to 65535)
Definition types.h:52
s16 player_y
Definition main.c:95
s16 player_x
Definition main.c:94
Per-player position state.
Definition main.c:95
This is due to a compiler quirk where separate static u16 variables generate different (broken) code compared to struct member access. See .claude/KNOWLEDGE.md for detailed documentation.
- See also
- animated_sprite example for reference implementation
◆ bg1_scroll_x
| s16 GameState::bg1_scroll_x |
BG1 horizontal scroll offset
◆ bg1_scroll_y
| s16 GameState::bg1_scroll_y |
BG1 vertical scroll offset
◆ bg2_scroll_x
| s16 GameState::bg2_scroll_x |
BG2 horizontal scroll offset (parallax)
◆ bg2_scroll_y
| s16 GameState::bg2_scroll_y |
BG2 vertical scroll offset
◆ player_x
Player X position (screen coords) - MUST be s16
◆ player_y
Player Y position (screen coords) - MUST be s16
The documentation for this struct was generated from the following file:
- /home/runner/work/opensnes/opensnes/examples/graphics/backgrounds/continuous_scroll/main.c