summaryrefslogtreecommitdiff
path: root/src/game.h
blob: b0307a1d83881a75e02ee5a3d55ab1079eed352a (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
#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 );