Add debug menu option, misc. tweaks

This commit is contained in:
2024-02-13 12:57:29 +01:00
parent dc140027ed
commit 1e20d307ea
7 changed files with 19 additions and 11 deletions

View File

@@ -93,7 +93,7 @@ ecs_entity_t placeBuilding(Game *game, BuildingType type,
Health health = { Health health = {
.startHP = 500.0f, .startHP = 500.0f,
.hp = 500.0f, .hp = 500.0f,
.lastChanged = 1000.0f, .lastChanged = -1000.0f,
}; };
switch (type) { switch (type) {
case BUILDING_KEEP: case BUILDING_KEEP:

View File

@@ -101,7 +101,7 @@ static ParticleEmitter GET_FIREBALL_EMITTER() {
.emitterLifetime = 2.0f, .emitterLifetime = 2.0f,
.data.minOffset = { -2.0f, -2.0f }, .data.minOffset = { -2.0f, -2.0f },
.data.maxOffset = { 2.0f, 2.0f }, .data.maxOffset = { 2.0f, 2.0f },
.data.emmitRate = 2.2f, .data.emmitRate = 3.2f,
.data.emmitVariance = 1.0f, .data.emmitVariance = 1.0f,
.data.emmitVarianceMin = 0.0f, .data.emmitVarianceMin = 0.0f,
.data.emmitVarianceMax = 1.0f, .data.emmitVarianceMax = 1.0f,

View File

@@ -74,7 +74,7 @@ ecs_entity_t entityCreateSoldier(const Position position, Player player, Game *g
ecs_set(ECS, e, Health, { ecs_set(ECS, e, Health, {
.startHP = 40.0f, .startHP = 40.0f,
.hp = 40.0f, .hp = 40.0f,
.lastChanged = -1.0f .lastChanged = -1000.0f
}); });
Unit *unit = ecs_get_mut(ECS, e, Unit); Unit *unit = ecs_get_mut(ECS, e, Unit);
unit->minDamage = 5.0f; unit->minDamage = 5.0f;
@@ -87,7 +87,7 @@ ecs_entity_t entityCreateWarrior(const Position position, Player player, Game *g
ecs_set(ECS, e, Health, { ecs_set(ECS, e, Health, {
.startHP = 80.0f, .startHP = 80.0f,
.hp = 80.0f, .hp = 80.0f,
.lastChanged = -1.0f .lastChanged = -1000.0f
}); });
Unit *unit = ecs_get_mut(ECS, e, Unit); Unit *unit = ecs_get_mut(ECS, e, Unit);
unit->minDamage = 8.0f; unit->minDamage = 8.0f;
@@ -109,7 +109,7 @@ ecs_entity_t entityCreateWorker(const Position position, Player player, Game *ga
ecs_set(ECS, e, Health, { ecs_set(ECS, e, Health, {
.startHP = 20.0f, .startHP = 20.0f,
.hp = 20.0f, .hp = 20.0f,
.lastChanged = -1.0f .lastChanged = -1000.0f
}); });
return e; return e;
@@ -123,7 +123,7 @@ ecs_entity_t entityCreateSwarmGoblin(const Position position, Player player, Gam
ecs_set(ECS, e, Health, { ecs_set(ECS, e, Health, {
.startHP = 40.0f, .startHP = 40.0f,
.hp = 40.0f, .hp = 40.0f,
.lastChanged = -1.0f .lastChanged = -1000.0f
}); });
Unit *unit = ecs_get_mut(ECS, e, Unit); Unit *unit = ecs_get_mut(ECS, e, Unit);
@@ -142,7 +142,7 @@ ecs_entity_t entityCreateSwarmOrc(const Position position, Player player, Game *
ecs_set(ECS, e, Health, { ecs_set(ECS, e, Health, {
.startHP = 80.0f, .startHP = 80.0f,
.hp = 80.0f, .hp = 80.0f,
.lastChanged = -1.0f .lastChanged = -1000.0f
}); });
Unit *unit = ecs_get_mut(ECS, e, Unit); Unit *unit = ecs_get_mut(ECS, e, Unit);

View File

@@ -27,6 +27,7 @@ typedef struct DrawData {
typedef struct Options { typedef struct Options {
// Video // Video
bool debugMenu;
bool fullscreen; bool fullscreen;
bool limitFps; bool limitFps;
// Audio // Audio
@@ -42,6 +43,7 @@ typedef struct GameData {
static GameData getDefaultGameData() { static GameData getDefaultGameData() {
return (GameData) { return (GameData) {
.options = { .options = {
.debugMenu = false,
.fullscreen = false, .fullscreen = false,
.limitFps = true, .limitFps = true,
.master = 0.5f, .master = 0.5f,

View File

@@ -766,6 +766,11 @@ void imguiRender(float dt, void *userData) {
Game *game = ecs_singleton_get_mut(ECS, Game); Game *game = ecs_singleton_get_mut(ECS, Game);
InputState *input = ecs_singleton_get_mut(ECS, InputState); InputState *input = ecs_singleton_get_mut(ECS, InputState);
if (!game->gameData.options.debugMenu) {
bzArrayClear(game->debug.inspecting);
return;
}
//igShowDemoWindow(NULL); //igShowDemoWindow(NULL);
igSetNextWindowSize((ImVec2){300, 400}, ImGuiCond_FirstUseEver); igSetNextWindowSize((ImVec2){300, 400}, ImGuiCond_FirstUseEver);

View File

@@ -445,8 +445,9 @@ void drawSettingsUI(Game *game, f32 dt) {
static GameData gameData = {}; static GameData gameData = {};
if (game->screenPrevFrame != SCREEN_SETTINGS) if (game->screenPrevFrame != SCREEN_SETTINGS)
gameData = game->gameData; gameData = game->gameData;
uiSettingsLabel("Video"); uiSettingsLabel("Game");
uiSettingsCheckbox("Fullscreen", &gameData.options.fullscreen); //uiSettingsCheckbox("Fullscreen", &gameData.options.fullscreen);
uiSettingsCheckbox("Debug Mode", &gameData.options.debugMenu);
uiSettingsCheckbox("Limit FPS", &gameData.options.limitFps); uiSettingsCheckbox("Limit FPS", &gameData.options.limitFps);
//uiSettingsCheckbox("V-Sync", &opts.vsync); //uiSettingsCheckbox("V-Sync", &opts.vsync);

View File

@@ -204,12 +204,12 @@ void setupSystems() {
ECS_SYSTEM(ECS, renderDebugPath, EcsOnUpdate, Path); ECS_SYSTEM(ECS, renderDebugPath, EcsOnUpdate, Path);
ECS_SYSTEM(ECS, renderColliders, EcsOnUpdate, Position, HitBox); ECS_SYSTEM(ECS, renderColliders, EcsOnUpdate, Position, HitBox);
ECS_SYSTEM(ECS, renderOrientationDirection, EcsOnUpdate, Position, Orientation); //ECS_SYSTEM(ECS, renderOrientationDirection, EcsOnUpdate, Position, Orientation);
ECS_SYSTEM(ECS, delayDeleteUpdate, EcsOnUpdate, DelayDelete); ECS_SYSTEM(ECS, delayDeleteUpdate, EcsOnUpdate, DelayDelete);
renderDebugPathSystem = renderDebugPath; renderDebugPathSystem = renderDebugPath;
renderOrientDirSystem = renderOrientationDirection; //renderOrientDirSystem = renderOrientationDirection;
renderCollidersSystem = renderColliders; renderCollidersSystem = renderColliders;
//ecs_enable(ECS, renderOrientDirSystem, false); //ecs_enable(ECS, renderOrientDirSystem, false);