From f8b92ce3aa08b1445c9f956d8166830946562d12 Mon Sep 17 00:00:00 2001 From: navewindre Date: Wed, 3 Sep 2025 20:10:09 +0200 Subject: a --- src/game.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/game.h (limited to 'src/game.h') diff --git a/src/game.h b/src/game.h new file mode 100644 index 0000000..b0307a1 --- /dev/null +++ b/src/game.h @@ -0,0 +1,60 @@ +#pragma once +#define IS_EDITOR 1 + +#include "game/assets.h" +#include "render/gl.h" +#include "render/gl_3d.h" + +#ifdef IS_EDITOR +#include "editor/editor.h" +#else +#include "gui.h" +#endif + +// HARDCODE BOSS +const U32 TICKS_PER_SEC = 64; +const F32 TICK_INTERVAL = 1.0f / (F32)TICKS_PER_SEC; + +typedef struct { + GL_SHADER_PROGRAM* gl2d; + GL_SHADER_PROGRAM* gl2d_texcoord; + + struct GL_3D* gl3d; +} GAME_SHADERS; + +typedef struct { + GL_BATCH3D* batch_3d; +} GAME_RENDER; + +typedef struct { + U8 ingame; + WORLD_MAP* map; + U64 last_tick; +} GAME_STATE; + +struct GAME_DATA { + GL_DATA* gl; + GAME_SHADERS shaders; + GAME_ASSETS assets; + + GAME_STATE state; + GAME_RENDER render; + +#ifdef IS_EDITOR + GAME_EDITOR* editor; +#endif +}; + +extern void ui_draw_background( GAME_DATA* game, VEC2 pos, VEC2 dim, F32 progress, CLR col ); + +extern GAME_DATA* game_init( GL_DATA* gl ); +extern void game_create_batches( GAME_DATA* game ); +extern void game_main_loop( GAME_DATA* game ); +extern void game_on_tick( GAME_DATA* game ); +extern void game_destroy( GAME_DATA* game ); + +// loads map and populates entities +extern WORLD_MAP* game_load_map( GAME_DATA* game, const char* mapname ); + +// unloads map and clears entity list including local player (no more level transitions can be made) +extern void game_unload_map( GAME_DATA* game ); -- cgit v1.2.3