aboutsummaryrefslogtreecommitdiff
path: root/src/game.h
blob: a6ce2024753af7a7034493662fae23f7b3eb3bc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef PW_GAME_H
#define PW_GAME_H

#include <SDL3/SDL_events.h>
#include <SDL3/SDL_render.h>

#include "audio.h"
#include "cart.h"
#include "env.h"
#include "fb.h"
#include "input.h"
#include "pico8.h"
#include "player.h"
#include "scale.h"

/**
 * Executing PICO-8 game state.
 */
struct pw_game {
  struct w2c_pico8 instance;
  struct w2c_env *env;
  struct pw_framebuffer *fb;
  struct pw_audio *audio;
  struct pw_input *input;
  struct pw_cart *cart;
};

/**
 * Allocates and initializes the game state.
 */
struct pw_game *pw_game_init(SDL_Renderer *renderer, enum pw_scale_mode mode,
                             size_t memory);

/**
 * Frees the game state.
 */
void pw_game_free(struct pw_game *game);

/**
 * Starts a PICO-8 game.
 */
bool pw_game_start(struct pw_game *game, struct pw_players *players,
                   struct pw_cart *cart);

/**
 * Handles SDL events for game state.
 */
bool pw_game_event(struct pw_game *game, struct pw_players *players,
                   SDL_Event *event);

/**
 * Iterate a new frame for the game state.
 */
bool pw_game_iterate(struct pw_game *game, bool *shutdown);

/**
 * Renders the game state.
 */
bool pw_game_render(struct pw_game *game);

#endif