61 lines
1.5 KiB
C
61 lines
1.5 KiB
C
#ifndef _AKGL_GAME_H_
|
|
#define _AKGL_GAME_H_
|
|
|
|
#include <stdint.h>
|
|
#include "types.h"
|
|
#include <SDL3_mixer/SDL_mixer.h>
|
|
#include "tilemap.h"
|
|
|
|
#define AKGL_GAME_AUDIO_TRACK_BGM 1
|
|
#define AKGL_GAME_AUDIO_MAX_TRACKS 64
|
|
|
|
#define AKGL_TIME_ONESEC_NS 1000000000
|
|
#define AKGL_TIME_ONESEC_MS 1000000
|
|
|
|
/* ==================== GAME STATE VARIABLES =================== */
|
|
|
|
typedef struct {
|
|
float32_t w;
|
|
float32_t h;
|
|
SDL_Texture *texture;
|
|
} akgl_Frame;
|
|
|
|
typedef struct {
|
|
int32_t flags;
|
|
} akgl_GameState;
|
|
|
|
typedef struct {
|
|
char version[32];
|
|
char name[256];
|
|
char uri[256];
|
|
int16_t screenwidth;
|
|
int16_t screenheight;
|
|
akgl_GameState state;
|
|
int16_t fps;
|
|
SDL_Time gameStartTime;
|
|
SDL_Time lastIterTime;
|
|
SDL_Time lastFPSTime;
|
|
int16_t framesSinceUpdate;
|
|
} akgl_Game;
|
|
|
|
extern SDL_Window *window;
|
|
extern SDL_Renderer *renderer;
|
|
extern akgl_Tilemap gamemap;
|
|
extern MIX_Audio *bgm;
|
|
extern MIX_Mixer *akgl_mixer;
|
|
extern MIX_Track *akgl_tracks[AKGL_GAME_AUDIO_MAX_TRACKS];
|
|
extern SDL_FRect camera;
|
|
extern akgl_Game game;
|
|
|
|
#define AKGL_BITMASK_HAS(x, y) (x & y) == y
|
|
#define AKGL_BITMASK_ADD(x, y) x |= y
|
|
#define AKGL_BITMASK_DEL(x, y) x &= ~(y)
|
|
#define AKGL_BITMASK_CLEAR(x) x = 0;
|
|
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_game_init();
|
|
void akgl_game_updateFPS();
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_game_save(char *fpath);
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_game_load(char *fpath);
|
|
|
|
#endif //_AKGL_GAME_H_
|