This repository was archived by the owner on Mar 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathsomething_game.hpp
More file actions
130 lines (108 loc) · 3.74 KB
/
something_game.hpp
File metadata and controls
130 lines (108 loc) · 3.74 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#ifndef SOMETHING_GAME_HPP_
#define SOMETHING_GAME_HPP_
#include "something_console.hpp"
#include "something_particles.hpp"
#include "something_texture.hpp"
#include "something_background.hpp"
#include "something_projectile.hpp"
#include "something_spike.hpp"
enum Debug_Toolbar_Button
{
DEBUG_TOOLBAR_TILES = 0,
DEBUG_TOOLBAR_DESTROYABLE,
DEBUG_TOOLBAR_HEALS,
DEBUG_TOOLBAR_ENEMIES,
DEBUG_TOOLBAR_DIRT,
DEBUG_TOOLBAR_GOLEM,
DEBUG_TOOLBAR_ICE_BLOCK,
DEBUG_TOOLBAR_ICE_ITEM,
DEBUG_TOOLBAR_ICE_GOLEM,
DEBUG_TOOLBAR_COUNT
};
const size_t ENEMY_ENTITY_INDEX_OFFSET = 1;
const size_t PLAYER_ENTITY_INDEX = 0;
const size_t ENTITIES_COUNT = 69;
const size_t PROJECTILES_COUNT = 69;
const size_t ITEMS_COUNT = 69;
const size_t SPIKES_COUNT = 69;
const size_t SPIKE_WAVES_CAPACITY = 69;
const size_t CAMERA_LOCKS_CAPACITY = 200;
const size_t ROOM_ROW_COUNT = 8;
const size_t FPS_BARS_COUNT = 256;
struct Game
{
bool quit;
bool debug;
bool step_debug;
bool bfs_debug;
bool fps_debug;
bool holding_down_mouse;
float frame_delays[FPS_BARS_COUNT];
size_t frame_delays_begin;
Vec2f collision_probe;
Vec2f mouse_position;
Maybe<Index<Projectile>> tracking_projectile;
Camera camera;
Sample_Mixer mixer;
const Uint8 *keyboard;
Popup popup;
// TODO(#178): disable game console in release mode
Console console;
Index<Sample_S16> kill_enemy_sample;
Bitmap_Font debug_font;
Toolbar debug_toolbar;
Entity entities[ENTITIES_COUNT];
Projectile projectiles[PROJECTILES_COUNT];
Spike spikes[SPIKES_COUNT];
Item items[ITEMS_COUNT];
Tile_Grid grid;
Recti camera_locks[CAMERA_LOCKS_CAPACITY];
size_t camera_locks_count;
float camera_shaking_timeout;
Background background;
Spike_Wave spike_waves[SPIKE_WAVES_CAPACITY];
// Camera utilities
void add_camera_lock(Recti rect);
void shake_camera(float duration);
// Whole Game State
void update(float dt);
void render(SDL_Renderer *renderer);
void handle_event(SDL_Event *event);
void render_debug_overlay(SDL_Renderer *renderer, size_t fps);
void render_fps_overlay(SDL_Renderer *renderer);
void noclip(bool on);
// Entities of the Game
void reset_entities();
void entity_shoot(Index<Entity> entity_index);
void entity_jump(Index<Entity> entity_index);
void entity_resolve_collision(Index<Entity> entity_index);
void spawn_entity_at(Entity entity, Vec2f pos);
void spawn_enemy_at(Vec2f pos);
void spawn_golem_at(Vec2f pos);
Vec2i where_entity_can_place_block(Index<Entity> index, bool *can_place = nullptr);
bool does_tile_contain_entity(Vec2i tile_coord);
void kill_entity(Entity *entity);
void drop_all_items_of_entity(Entity *entity);
void damage_entity(Entity *entity, int amount, Vec2f knockback);
void damage_radius(Vec2f center, float radius, Index<Entity> stomper);
// Spike
void spawn_spike(Spike spike);
void spawn_spike_wave(Vec2f pos, Vec2f dir);
// Projectiles of the Game
void spawn_projectile(Projectile projectile);
int count_alive_projectiles(void);
void render_projectiles(SDL_Renderer *renderer, Camera camera);
void update_projectiles(float dt);
Rectf hitbox_of_projectile(Index<Projectile> index);
Maybe<Index<Projectile>> projectile_at_position(Vec2f position);
void projectile_collision(Projectile *a, Projectile *b);
// Items of the Game
void spawn_item_at(Item item, Vec2f pos);
void spawn_health_at_mouse();
void spawn_dirt_block_item_at(Vec2f pos);
void spawn_dirt_block_item_at_mouse();
int get_rooms_count(void);
// Player related operations
void render_player_hud(SDL_Renderer *renderer);
};
#endif // SOMETHING_GAME_HPP_