OpenSNES
Modern Open-Source SNES Development SDK
Loading...
Searching...
No Matches
GameState Struct Reference

Centralized game state structure. More...

Public Attributes

s16 bg1_scroll_x
s16 bg1_scroll_y
s16 bg2_scroll_x
s16 bg2_scroll_y
Entity bullets [8]
Entity enemies [8]
u8 fire_cd
u16 frame
s16 player_x
s16 player_y
u16 prng
u16 scroll_y

Detailed Description

Centralized game state structure.

Coordinates are s16 because the scroll thresholds subtract and compare them: a signed type keeps "left of the threshold" a plain <. (This comment used to claim that separate static u16 coordinates were miscompiled and that the struct was REQUIRED. That described a compiler of early 2026; examples/input/move_sprite moves a sprite from plain u16 locals and its luna manifest pins the motion to the pixel.)

See also
animated_sprite example for reference implementation

Member Data Documentation

◆ 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

◆ bullets

Entity GameState::bullets[8]

◆ enemies

Entity GameState::enemies[8]

◆ fire_cd

u8 GameState::fire_cd

◆ frame

u16 GameState::frame

◆ player_x

s16 GameState::player_x

Player X position (screen coords)

◆ player_y

s16 GameState::player_y

Player Y position (screen coords)

◆ prng

u16 GameState::prng

◆ scroll_y

u16 GameState::scroll_y

The documentation for this struct was generated from the following files:
  • /home/runner/work/opensnes/opensnes/examples/games/shmup_1942/main.c
  • /home/runner/work/opensnes/opensnes/examples/scrolling/continuous_scroll/main.c