Merge branch 'master' of github.com:tollyx/dungeon
This commit is contained in:
commit
1505a13c99
28 changed files with 409 additions and 146 deletions
|
@ -116,6 +116,7 @@
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="src\Logger.cpp" />
|
||||||
<ClCompile Include="src\LuaHandler.cpp" />
|
<ClCompile Include="src\LuaHandler.cpp" />
|
||||||
<ClCompile Include="src\Shader.cpp" />
|
<ClCompile Include="src\Shader.cpp" />
|
||||||
<ClCompile Include="src\Actor.cpp" />
|
<ClCompile Include="src\Actor.cpp" />
|
||||||
|
@ -131,7 +132,6 @@
|
||||||
<ClCompile Include="src\ExploreNode.cpp" />
|
<ClCompile Include="src\ExploreNode.cpp" />
|
||||||
<ClCompile Include="src\FieldOfView.cpp" />
|
<ClCompile Include="src\FieldOfView.cpp" />
|
||||||
<ClCompile Include="src\FleeNode.cpp" />
|
<ClCompile Include="src\FleeNode.cpp" />
|
||||||
<ClCompile Include="src\Gamestate.cpp" />
|
|
||||||
<ClCompile Include="src\Goblin.cpp" />
|
<ClCompile Include="src\Goblin.cpp" />
|
||||||
<ClCompile Include="src\HealFriendNode.cpp" />
|
<ClCompile Include="src\HealFriendNode.cpp" />
|
||||||
<ClCompile Include="src\Hero.cpp" />
|
<ClCompile Include="src\Hero.cpp" />
|
||||||
|
@ -139,11 +139,11 @@
|
||||||
<ClCompile Include="src\IfNotSeeEnemyNode.cpp" />
|
<ClCompile Include="src\IfNotSeeEnemyNode.cpp" />
|
||||||
<ClCompile Include="src\IfSeeEnemyNode.cpp" />
|
<ClCompile Include="src\IfSeeEnemyNode.cpp" />
|
||||||
<ClCompile Include="src\IfSeeFriendNode.cpp" />
|
<ClCompile Include="src\IfSeeFriendNode.cpp" />
|
||||||
<ClCompile Include="src\imgui.cpp" />
|
<ClCompile Include="src\imgui\imgui.cpp" />
|
||||||
<ClCompile Include="src\imgui_demo.cpp" />
|
<ClCompile Include="src\imgui\imgui_demo.cpp" />
|
||||||
<ClCompile Include="src\imgui_draw.cpp" />
|
<ClCompile Include="src\imgui\imgui_draw.cpp" />
|
||||||
<ClCompile Include="src\imgui_impl_sdl_gl3.cpp" />
|
<ClCompile Include="src\imgui\imgui_impl_sdl_gl3.cpp" />
|
||||||
<ClCompile Include="src\imgui_user.cpp" />
|
<ClCompile Include="src\imgui\imgui_user.cpp" />
|
||||||
<ClCompile Include="src\Input.cpp" />
|
<ClCompile Include="src\Input.cpp" />
|
||||||
<ClCompile Include="src\Main.cpp" />
|
<ClCompile Include="src\Main.cpp" />
|
||||||
<ClCompile Include="src\Mapgen.cpp" />
|
<ClCompile Include="src\Mapgen.cpp" />
|
||||||
|
@ -156,9 +156,11 @@
|
||||||
<ClCompile Include="src\Shaman.cpp" />
|
<ClCompile Include="src\Shaman.cpp" />
|
||||||
<ClCompile Include="src\Tilemap.cpp" />
|
<ClCompile Include="src\Tilemap.cpp" />
|
||||||
<ClCompile Include="src\SpriteAtlas.cpp" />
|
<ClCompile Include="src\SpriteAtlas.cpp" />
|
||||||
|
<ClCompile Include="src\Time.cpp" />
|
||||||
<ClCompile Include="src\WanderNode.cpp" />
|
<ClCompile Include="src\WanderNode.cpp" />
|
||||||
<ClCompile Include="src\World.cpp" />
|
<ClCompile Include="src\World.cpp" />
|
||||||
<ClCompile Include="src\TileSet.cpp" />
|
<ClCompile Include="src\TileSet.cpp" />
|
||||||
|
<ClCompile Include="src\statemachine\StateStack.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="src\Item.h" />
|
<ClInclude Include="src\Item.h" />
|
||||||
|
@ -178,7 +180,6 @@
|
||||||
<ClInclude Include="src\ExploreNode.h" />
|
<ClInclude Include="src\ExploreNode.h" />
|
||||||
<ClInclude Include="src\FieldOfView.h" />
|
<ClInclude Include="src\FieldOfView.h" />
|
||||||
<ClInclude Include="src\FleeNode.h" />
|
<ClInclude Include="src\FleeNode.h" />
|
||||||
<ClInclude Include="src\Gamestate.h" />
|
|
||||||
<ClInclude Include="src\gitparams.h" />
|
<ClInclude Include="src\gitparams.h" />
|
||||||
<ClInclude Include="src\Goblin.h" />
|
<ClInclude Include="src\Goblin.h" />
|
||||||
<ClInclude Include="src\HealFriendNode.h" />
|
<ClInclude Include="src\HealFriendNode.h" />
|
||||||
|
@ -187,11 +188,11 @@
|
||||||
<ClInclude Include="src\IfNotSeeEnemyNode.h" />
|
<ClInclude Include="src\IfNotSeeEnemyNode.h" />
|
||||||
<ClInclude Include="src\IfSeeEnemyNode.h" />
|
<ClInclude Include="src\IfSeeEnemyNode.h" />
|
||||||
<ClInclude Include="src\IfSeeFriendNode.h" />
|
<ClInclude Include="src\IfSeeFriendNode.h" />
|
||||||
<ClInclude Include="src\imconfig.h" />
|
<ClInclude Include="src\imgui\imconfig.h" />
|
||||||
<ClInclude Include="src\imgui.h" />
|
<ClInclude Include="src\imgui\imgui.h" />
|
||||||
<ClInclude Include="src\imgui_impl_sdl_gl3.h" />
|
<ClInclude Include="src\imgui\imgui_impl_sdl_gl3.h" />
|
||||||
<ClInclude Include="src\imgui_internal.h" />
|
<ClInclude Include="src\imgui\imgui_internal.h" />
|
||||||
<ClInclude Include="src\imgui_user.h" />
|
<ClInclude Include="src\imgui\imgui_user.h" />
|
||||||
<ClInclude Include="src\Input.h" />
|
<ClInclude Include="src\Input.h" />
|
||||||
<ClInclude Include="src\Logger.h" />
|
<ClInclude Include="src\Logger.h" />
|
||||||
<ClInclude Include="src\Mapgen.h" />
|
<ClInclude Include="src\Mapgen.h" />
|
||||||
|
@ -203,16 +204,18 @@
|
||||||
<ClInclude Include="src\Rng.h" />
|
<ClInclude Include="src\Rng.h" />
|
||||||
<ClInclude Include="src\Shaman.h" />
|
<ClInclude Include="src\Shaman.h" />
|
||||||
<ClInclude Include="src\Stats.h" />
|
<ClInclude Include="src\Stats.h" />
|
||||||
<ClInclude Include="src\stb_rect_pack.h" />
|
<ClInclude Include="src\imgui\stb_rect_pack.h" />
|
||||||
<ClInclude Include="src\stb_textedit.h" />
|
<ClInclude Include="src\imgui\stb_textedit.h" />
|
||||||
<ClInclude Include="src\stb_truetype.h" />
|
<ClInclude Include="src\imgui\stb_truetype.h" />
|
||||||
<ClInclude Include="src\Tilemap.h" />
|
<ClInclude Include="src\Tilemap.h" />
|
||||||
<ClInclude Include="src\SpriteAtlas.h" />
|
<ClInclude Include="src\SpriteAtlas.h" />
|
||||||
|
<ClInclude Include="src\Time.h" />
|
||||||
<ClInclude Include="src\vec2i.h" />
|
<ClInclude Include="src\vec2i.h" />
|
||||||
<ClInclude Include="src\WanderNode.h" />
|
<ClInclude Include="src\WanderNode.h" />
|
||||||
<ClInclude Include="src\wglew.h" />
|
<ClInclude Include="src\wglew.h" />
|
||||||
<ClInclude Include="src\World.h" />
|
<ClInclude Include="src\World.h" />
|
||||||
<ClInclude Include="src\TileSet.h" />
|
<ClInclude Include="src\TileSet.h" />
|
||||||
|
<ClInclude Include="src\statemachine\StateStack.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
|
|
@ -54,9 +54,6 @@
|
||||||
<ClCompile Include="src\FleeNode.cpp">
|
<ClCompile Include="src\FleeNode.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\Gamestate.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\Goblin.cpp">
|
<ClCompile Include="src\Goblin.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -78,21 +75,6 @@
|
||||||
<ClCompile Include="src\IfSeeFriendNode.cpp">
|
<ClCompile Include="src\IfSeeFriendNode.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\imgui.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\imgui_demo.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\imgui_draw.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\imgui_impl_sdl_gl3.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\imgui_user.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\Input.cpp">
|
<ClCompile Include="src\Input.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -144,6 +126,30 @@
|
||||||
<ClCompile Include="src\LuaHandler.cpp">
|
<ClCompile Include="src\LuaHandler.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\statemachine\StateStack.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Logger.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\imgui\imgui.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\imgui\imgui_demo.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\imgui\imgui_draw.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\imgui\imgui_impl_sdl_gl3.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\imgui\imgui_user.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Time.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="src\Actor.h">
|
<ClInclude Include="src\Actor.h">
|
||||||
|
@ -188,9 +194,6 @@
|
||||||
<ClInclude Include="src\FleeNode.h">
|
<ClInclude Include="src\FleeNode.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\Gamestate.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\gitparams.h">
|
<ClInclude Include="src\gitparams.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -215,21 +218,6 @@
|
||||||
<ClInclude Include="src\IfSeeFriendNode.h">
|
<ClInclude Include="src\IfSeeFriendNode.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\imconfig.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\imgui.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\imgui_impl_sdl_gl3.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\imgui_internal.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\imgui_user.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\Input.h">
|
<ClInclude Include="src\Input.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -260,15 +248,6 @@
|
||||||
<ClInclude Include="src\Stats.h">
|
<ClInclude Include="src\Stats.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\stb_rect_pack.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\stb_textedit.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\stb_truetype.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\Tilemap.h">
|
<ClInclude Include="src\Tilemap.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -302,5 +281,35 @@
|
||||||
<ClInclude Include="src\LuaHandler.h">
|
<ClInclude Include="src\LuaHandler.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\statemachine\StateStack.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\imgui\imconfig.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\imgui\imgui.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\imgui\imgui_impl_sdl_gl3.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\imgui\imgui_internal.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\imgui\imgui_user.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\imgui\stb_rect_pack.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\imgui\stb_textedit.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\imgui\stb_truetype.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\Time.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
38
src/App.cpp
38
src/App.cpp
|
@ -9,11 +9,12 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <kaguya/kaguya.hpp>
|
#include <kaguya/kaguya.hpp>
|
||||||
#include "Renderer.h"
|
#include "Renderer.h"
|
||||||
#include "imgui.h"
|
#include "imgui/imgui.h"
|
||||||
#include "Input.h"
|
#include "Input.h"
|
||||||
#include "Gamestate.h"
|
|
||||||
#include "PlayState.h"
|
#include "PlayState.h"
|
||||||
#include "LuaHandler.h"
|
#include "LuaHandler.h"
|
||||||
|
#include "Time.h"
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
Uint64 perfFreq;
|
Uint64 perfFreq;
|
||||||
double currTime() {
|
double currTime() {
|
||||||
|
@ -108,12 +109,8 @@ int App::start() {
|
||||||
double accumulator = dt;
|
double accumulator = dt;
|
||||||
|
|
||||||
bool show_log = false;
|
bool show_log = false;
|
||||||
bool running = true;
|
running = true;
|
||||||
Gamestate* nextstate = nullptr;
|
statestack.push(std::unique_ptr<IState>(new PlayState(this)));
|
||||||
|
|
||||||
current = new PlayState();
|
|
||||||
current->init(this);
|
|
||||||
current->load();
|
|
||||||
|
|
||||||
while (running) {
|
while (running) {
|
||||||
double newTime = currTime();
|
double newTime = currTime();
|
||||||
|
@ -122,19 +119,12 @@ int App::start() {
|
||||||
frametime = 1.0/30;
|
frametime = 1.0/30;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextstate != nullptr) {
|
|
||||||
current->quit();
|
|
||||||
delete current;
|
|
||||||
current = nextstate;
|
|
||||||
current->init(this);
|
|
||||||
current->load();
|
|
||||||
}
|
|
||||||
|
|
||||||
currentTime = newTime;
|
currentTime = newTime;
|
||||||
accumulator += frametime;
|
accumulator += frametime;
|
||||||
|
|
||||||
SDL_Event ev{};
|
SDL_Event ev{};
|
||||||
ImGuiIO &io = ImGui::GetIO();
|
ImGuiIO &io = ImGui::GetIO();
|
||||||
|
|
||||||
renderer->ImguiNewFrame();
|
renderer->ImguiNewFrame();
|
||||||
while (SDL_PollEvent(&ev)) {
|
while (SDL_PollEvent(&ev)) {
|
||||||
//renderer->ImguiProcessEvents(&ev);
|
//renderer->ImguiProcessEvents(&ev);
|
||||||
|
@ -154,31 +144,31 @@ int App::start() {
|
||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEMOTION:
|
||||||
if (!io.WantCaptureMouse) {
|
if (!io.WantCaptureMouse) {
|
||||||
InputEvent inputEvent = input->set_mouse_pos(ev.motion.x, ev.motion.y, ev.motion.xrel, ev.motion.yrel);
|
InputEvent inputEvent = input->set_mouse_pos(ev.motion.x, ev.motion.y, ev.motion.xrel, ev.motion.yrel);
|
||||||
current->inputevent(&inputEvent);
|
statestack.input(inputEvent);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
if (!io.WantCaptureMouse) {
|
if (!io.WantCaptureMouse) {
|
||||||
InputEvent inputEvent = input->set_mouse_button(ev.button.button, ev.button.x, ev.button.y, true);
|
InputEvent inputEvent = input->set_mouse_button(ev.button.button, ev.button.x, ev.button.y, true);
|
||||||
current->inputevent(&inputEvent);
|
statestack.input(inputEvent);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEBUTTONUP:
|
case SDL_MOUSEBUTTONUP:
|
||||||
if (!io.WantCaptureMouse) {
|
if (!io.WantCaptureMouse) {
|
||||||
InputEvent inputEvent = input->set_mouse_button(ev.button.button, ev.button.x, ev.button.y, false);
|
InputEvent inputEvent = input->set_mouse_button(ev.button.button, ev.button.x, ev.button.y, false);
|
||||||
current->inputevent(&inputEvent);
|
statestack.input(inputEvent);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
if (!io.WantCaptureKeyboard) {
|
if (!io.WantCaptureKeyboard) {
|
||||||
InputEvent inputEvent = input->set_key(ev.key.keysym.sym, (SDL_Keymod) ev.key.keysym.mod, true);
|
InputEvent inputEvent = input->set_key(ev.key.keysym.sym, (SDL_Keymod) ev.key.keysym.mod, true);
|
||||||
current->inputevent(&inputEvent);
|
statestack.input(inputEvent);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
if (!io.WantCaptureKeyboard){
|
if (!io.WantCaptureKeyboard){
|
||||||
InputEvent inputEvent = input->set_key(ev.key.keysym.sym, (SDL_Keymod) ev.key.keysym.mod, false);
|
InputEvent inputEvent = input->set_key(ev.key.keysym.sym, (SDL_Keymod) ev.key.keysym.mod, false);
|
||||||
current->inputevent(&inputEvent);
|
statestack.input(inputEvent);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
|
@ -189,13 +179,13 @@ int App::start() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (running && accumulator >= dt) {
|
while (running && accumulator >= dt) {
|
||||||
nextstate = current->update(dt);
|
statestack.update(dt);
|
||||||
input->new_frame();
|
input->new_frame();
|
||||||
|
Time::tick_timers(dt);
|
||||||
accumulator -= dt;
|
accumulator -= dt;
|
||||||
}
|
}
|
||||||
renderer->Clear();
|
renderer->Clear();
|
||||||
current->draw(accumulator / dt);
|
statestack.draw();
|
||||||
renderer->Present();
|
renderer->Present();
|
||||||
SDL_Delay(1);
|
SDL_Delay(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
#ifndef DUNGEON_APP_H
|
#ifndef DUNGEON_APP_H
|
||||||
#define DUNGEON_APP_H
|
#define DUNGEON_APP_H
|
||||||
|
|
||||||
class Gamestate;
|
#include "statemachine/StateStack.h"
|
||||||
|
|
||||||
class Renderer;
|
class Renderer;
|
||||||
class Input;
|
class Input;
|
||||||
|
|
||||||
|
@ -14,9 +15,10 @@ class Input;
|
||||||
#define ADD_QUOTES(s) ADD_QUOTES_HELPER(s)
|
#define ADD_QUOTES(s) ADD_QUOTES_HELPER(s)
|
||||||
|
|
||||||
class App {
|
class App {
|
||||||
|
bool running = true;
|
||||||
public:
|
public:
|
||||||
const char* version = ADD_QUOTES(GIT_CUR_COMMIT);
|
const char* version = ADD_QUOTES(GIT_CUR_COMMIT);
|
||||||
Gamestate* current;
|
StateStack statestack;
|
||||||
Renderer* renderer;
|
Renderer* renderer;
|
||||||
Input* input;
|
Input* input;
|
||||||
bool init();
|
bool init();
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
//
|
|
||||||
// Created by Adrian on 2017-09-19.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "Gamestate.h"
|
|
||||||
#include "App.h"
|
|
||||||
|
|
||||||
void Gamestate::init(App *app) {
|
|
||||||
this->app = app;
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
//
|
|
||||||
// Created by Adrian on 2017-09-19.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef DUNGEON_GAMESTATE_H
|
|
||||||
#define DUNGEON_GAMESTATE_H
|
|
||||||
|
|
||||||
class App;
|
|
||||||
struct InputEvent;
|
|
||||||
|
|
||||||
class Gamestate {
|
|
||||||
protected:
|
|
||||||
App* app;
|
|
||||||
public:
|
|
||||||
virtual ~Gamestate() = default;
|
|
||||||
void init(App* app);
|
|
||||||
virtual void load() = 0;
|
|
||||||
virtual Gamestate* update(double delta) = 0;
|
|
||||||
virtual void draw(double delta) = 0;
|
|
||||||
virtual void quit() = 0;
|
|
||||||
virtual void inputevent(InputEvent* event) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif //DUNGEON_GAMESTATE_H
|
|
39
src/Logger.cpp
Normal file
39
src/Logger.cpp
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
#include "Logger.h"
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include <io.h>
|
||||||
|
|
||||||
|
Log::LogLevel log_level = Log::LogLevel::Warning;
|
||||||
|
|
||||||
|
void Log::set_log_level(LogLevel level) {
|
||||||
|
log_level = level;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Log::error(string tag, string message) {
|
||||||
|
if (log_level <= LogLevel::Error) {
|
||||||
|
printf("[ERR] <%s> %s\n", tag, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Log::warning(string tag, string message) {
|
||||||
|
if (log_level <= LogLevel::Warning) {
|
||||||
|
printf("[WRN] <%s> %s\n", tag, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Log::info(string tag, string message) {
|
||||||
|
if (log_level <= LogLevel::Info) {
|
||||||
|
printf("[INF] <%s> %s\n", tag, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Log::debug(string tag, string message) {
|
||||||
|
if (log_level <= LogLevel::Debug) {
|
||||||
|
printf("[DBG] <%s> %s\n", tag, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Log::trace(string tag, string message) {
|
||||||
|
if (log_level <= LogLevel::Trace) {
|
||||||
|
printf("[TRC] <%s> %s\n", tag, message);
|
||||||
|
}
|
||||||
|
}
|
22
src/Logger.h
22
src/Logger.h
|
@ -1,5 +1,23 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace Logger {
|
namespace Log {
|
||||||
|
using std::string;
|
||||||
|
|
||||||
}
|
enum LogLevel {
|
||||||
|
Error,
|
||||||
|
Warning,
|
||||||
|
Info,
|
||||||
|
Debug,
|
||||||
|
Trace,
|
||||||
|
};
|
||||||
|
|
||||||
|
void set_log_level(LogLevel level);
|
||||||
|
//void enable_log_to_file(bool enable);
|
||||||
|
//void set_log_path(string path);
|
||||||
|
void error(string tag, string message);
|
||||||
|
void warning(string tag, string message);
|
||||||
|
void info(string tag, string message);
|
||||||
|
void debug(string tag, string message);
|
||||||
|
void trace(string tag, string message);
|
||||||
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include "SpriteAtlas.h"
|
#include "SpriteAtlas.h"
|
||||||
#include "Mapgen.h"
|
#include "Mapgen.h"
|
||||||
#include "FieldOfView.h"
|
#include "FieldOfView.h"
|
||||||
#include "imgui.h"
|
#include "imgui/imgui.h"
|
||||||
#include "Hero.h"
|
#include "Hero.h"
|
||||||
#include "Goblin.h"
|
#include "Goblin.h"
|
||||||
#include "Shaman.h"
|
#include "Shaman.h"
|
||||||
|
@ -23,13 +23,14 @@ InputAction player_action;
|
||||||
TileSet tileset;
|
TileSet tileset;
|
||||||
LuaHandler handler;
|
LuaHandler handler;
|
||||||
|
|
||||||
void PlayState::load() {
|
void PlayState::enter() {
|
||||||
SDL_LogVerbose(SDL_LOG_CATEGORY_SYSTEM, "Creating ascii tileset...\n");
|
SDL_LogVerbose(SDL_LOG_CATEGORY_SYSTEM, "Creating ascii tileset...\n");
|
||||||
ascii = new SpriteAtlas(app->renderer, "./assets/12x12.bmp", 192, 192, 12, 12);
|
ascii = new SpriteAtlas(app->renderer, "./assets/12x12.bmp", 192, 192, 12, 12);
|
||||||
SDL_LogVerbose(SDL_LOG_CATEGORY_SYSTEM, "Created ascii tileset.\n");
|
SDL_LogVerbose(SDL_LOG_CATEGORY_SYSTEM, "Created ascii tileset.\n");
|
||||||
|
|
||||||
handler.load_module("data", &tileset);
|
handler.load_module("data", &tileset);
|
||||||
|
|
||||||
|
// TODO: Load all this from Lua
|
||||||
app->input->bind_key(SDLK_ESCAPE, ACTION_ESCAPE_MENU);
|
app->input->bind_key(SDLK_ESCAPE, ACTION_ESCAPE_MENU);
|
||||||
|
|
||||||
// Movement: keypad
|
// Movement: keypad
|
||||||
|
@ -71,6 +72,10 @@ void PlayState::load() {
|
||||||
new_game();
|
new_game();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlayState::PlayState(App * app) {
|
||||||
|
this->app = app;
|
||||||
|
}
|
||||||
|
|
||||||
void PlayState::new_game() {
|
void PlayState::new_game() {
|
||||||
player_action = ACTION_NONE;
|
player_action = ACTION_NONE;
|
||||||
|
|
||||||
|
@ -104,7 +109,7 @@ void PlayState::new_game() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Gamestate *PlayState::update(double delta) {
|
StateResult PlayState::update(float delta) {
|
||||||
while (!is_player_turn || player_action != ACTION_NONE) {
|
while (!is_player_turn || player_action != ACTION_NONE) {
|
||||||
std::vector<Actor*>* actors = tilemap->get_actor_list();
|
std::vector<Actor*>* actors = tilemap->get_actor_list();
|
||||||
Actor* actor = actors->at(current_entity_index);
|
Actor* actor = actors->at(current_entity_index);
|
||||||
|
@ -128,14 +133,17 @@ Gamestate *PlayState::update(double delta) {
|
||||||
if (tilemap->get_tile(pos.x, pos.y).has_tag("exit")) {
|
if (tilemap->get_tile(pos.x, pos.y).has_tag("exit")) {
|
||||||
current_level++;
|
current_level++;
|
||||||
tilemap = &world.GetMap(current_level, tileset);
|
tilemap = &world.GetMap(current_level, tileset);
|
||||||
return nullptr;
|
return StateResult::None();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return nullptr;
|
return StateResult::None();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: player_action = ACTION_NONE; SDL_LogVerbose(SDL_LOG_CATEGORY_SYSTEM, "Turn aborted: no player action.\n"); return nullptr; // abort turn
|
default:
|
||||||
|
player_action = ACTION_NONE;
|
||||||
|
SDL_LogVerbose(SDL_LOG_CATEGORY_SYSTEM, "Turn aborted: no player action.\n");
|
||||||
|
return StateResult::None(); // abort turn
|
||||||
}
|
}
|
||||||
if (dir != vec2i(0,0)) {
|
if (dir != vec2i(0,0)) {
|
||||||
if (!actor->move(dir.x, dir.y, tilemap)) {
|
if (!actor->move(dir.x, dir.y, tilemap)) {
|
||||||
|
@ -152,7 +160,7 @@ Gamestate *PlayState::update(double delta) {
|
||||||
if(!attacked) {
|
if(!attacked) {
|
||||||
SDL_LogVerbose(SDL_LOG_CATEGORY_SYSTEM, "Turn aborted: invalid player action.\n");
|
SDL_LogVerbose(SDL_LOG_CATEGORY_SYSTEM, "Turn aborted: invalid player action.\n");
|
||||||
player_action = ACTION_NONE;
|
player_action = ACTION_NONE;
|
||||||
return nullptr; // unable to move and nothing to attack == abort turn
|
return StateResult::None(); // unable to move and nothing to attack == abort turn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,10 +181,10 @@ Gamestate *PlayState::update(double delta) {
|
||||||
fov.calc(player_actor->get_position(), 6);
|
fov.calc(player_actor->get_position(), 6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return StateResult::None();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayState::draw(double delta) {
|
void PlayState::draw() {
|
||||||
if (debug) {
|
if (debug) {
|
||||||
{
|
{
|
||||||
ImGui::BeginMainMenuBar();
|
ImGui::BeginMainMenuBar();
|
||||||
|
@ -286,17 +294,17 @@ void PlayState::draw(double delta) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayState::quit() {
|
void PlayState::exit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayState::inputevent(InputEvent *event) {
|
void PlayState::input(InputEvent &event) {
|
||||||
if (event->type == INPUT_KEY_EVENT && event->pressed) {
|
if (event.type == INPUT_KEY_EVENT && event.pressed) {
|
||||||
switch (event->action) {
|
switch (event.action) {
|
||||||
case ACTION_TOGGLE_DEBUG: debug = !debug; break;
|
case ACTION_TOGGLE_DEBUG: debug = !debug; break;
|
||||||
case ACTION_RESET: new_game(); break;
|
case ACTION_RESET: new_game(); break;
|
||||||
case ACTION_ESCAPE_MENU: break; // TODO
|
case ACTION_ESCAPE_MENU: break; // TODO
|
||||||
case ACTION_NONE: break;
|
case ACTION_NONE: break;
|
||||||
default: player_action = event->action; break;
|
default: player_action = event.action; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Gamestate.h"
|
#include "statemachine/StateStack.h"
|
||||||
#include "Tilemap.h"
|
#include "Tilemap.h"
|
||||||
#include "FieldOfView.h"
|
#include "FieldOfView.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
|
|
||||||
class SpriteAtlas;
|
class SpriteAtlas;
|
||||||
class Actor;
|
class Actor;
|
||||||
|
class App;
|
||||||
|
|
||||||
class PlayState : public Gamestate {
|
class PlayState : public IState {
|
||||||
SpriteAtlas* ascii;
|
SpriteAtlas* ascii;
|
||||||
World world;
|
World world;
|
||||||
Tilemap* tilemap;
|
Tilemap* tilemap;
|
||||||
|
@ -25,11 +26,14 @@ class PlayState : public Gamestate {
|
||||||
bool debug_settings = false;
|
bool debug_settings = false;
|
||||||
bool debug_disable_fov = false;
|
bool debug_disable_fov = false;
|
||||||
|
|
||||||
|
App* app;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
PlayState(App* app);
|
||||||
void new_game();
|
void new_game();
|
||||||
void load() override;
|
void enter() override;
|
||||||
Gamestate* update(double delta) override;
|
StateResult update(float delta) override;
|
||||||
void draw(double delta) override;
|
void draw() override;
|
||||||
void quit() override;
|
void exit() override;
|
||||||
void inputevent(InputEvent* event) override;
|
void input(InputEvent& event) override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "imgui.h"
|
#include "imgui/imgui.h"
|
||||||
#include "imgui_impl_sdl_gl3.h"
|
#include "imgui/imgui_impl_sdl_gl3.h"
|
||||||
#include <glm/gtx/transform.hpp>
|
#include <glm/gtx/transform.hpp>
|
||||||
#include <glm/matrix.hpp>
|
#include <glm/matrix.hpp>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
67
src/Time.cpp
Normal file
67
src/Time.cpp
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
#include "Time.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
std::vector<Time::Timer> timers;
|
||||||
|
|
||||||
|
void Time::Timer::tick(float dt) {
|
||||||
|
time_current += dt;
|
||||||
|
if (continuous) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
else if (time_current >= duration) {
|
||||||
|
callback();
|
||||||
|
if (loop && !is_finished()) {
|
||||||
|
count++;
|
||||||
|
time_current -= duration;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Time::Timer::is_finished() {
|
||||||
|
return (loop && count >= limit) || (!loop && time_current >= duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Time::tick_timers(float dt) {
|
||||||
|
for (int i = timers.size() - 1; i >= 0; i--) {
|
||||||
|
timers[i].tick(dt);
|
||||||
|
if (timers[i].is_finished()) {
|
||||||
|
timers.erase(timers.begin() + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Time::after(float seconds, TimerCallback callback) {
|
||||||
|
timers.emplace_back(Timer {
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
seconds,
|
||||||
|
callback,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void Time::every(float seconds, int limit, TimerCallback callback) {
|
||||||
|
timers.emplace_back(Timer{
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
limit,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
seconds,
|
||||||
|
callback,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void Time::during(float seconds, TimerCallback callback) {
|
||||||
|
timers.emplace_back(Timer{
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
seconds,
|
||||||
|
callback,
|
||||||
|
});
|
||||||
|
}
|
23
src/Time.h
Normal file
23
src/Time.h
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
namespace Time {
|
||||||
|
typedef std::function<void()> TimerCallback;
|
||||||
|
struct Timer {
|
||||||
|
bool loop;
|
||||||
|
bool continuous;
|
||||||
|
int limit;
|
||||||
|
int count;
|
||||||
|
float time_current;
|
||||||
|
float duration;
|
||||||
|
TimerCallback callback;
|
||||||
|
void tick(float dt);
|
||||||
|
bool is_finished();
|
||||||
|
};
|
||||||
|
|
||||||
|
void tick_timers(float dt);
|
||||||
|
void after(float seconds, TimerCallback callback);
|
||||||
|
void every(float seconds, int limit, TimerCallback callback);
|
||||||
|
void during(float seconds, TimerCallback callback);
|
||||||
|
}
|
69
src/statemachine/StateStack.cpp
Normal file
69
src/statemachine/StateStack.cpp
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
#include "StateStack.h"
|
||||||
|
|
||||||
|
void StateStack::update(float dt) {
|
||||||
|
update_state(stack.size() - 1, dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void StateStack::draw() {
|
||||||
|
draw_state(stack.size() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void StateStack::push(std::unique_ptr<IState> state) {
|
||||||
|
state->enter();
|
||||||
|
stack.emplace_back(std::move(state));
|
||||||
|
}
|
||||||
|
|
||||||
|
void StateStack::swap(std::unique_ptr<IState> state) {
|
||||||
|
pop();
|
||||||
|
push(std::move(state));
|
||||||
|
}
|
||||||
|
|
||||||
|
void StateStack::pop() {
|
||||||
|
stack.back()->exit();
|
||||||
|
stack.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
|
void StateStack::input(InputEvent & input_event) {
|
||||||
|
input_state(stack.size() - 1, input_event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void StateStack::draw_state(unsigned int i) {
|
||||||
|
IState &state = *stack[i];
|
||||||
|
if (state.should_draw_previous() && i > 0) {
|
||||||
|
draw_state(i - 1);
|
||||||
|
}
|
||||||
|
state.draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
void StateStack::update_state(unsigned int i, float dt) {
|
||||||
|
IState &state = *stack[i];
|
||||||
|
if (state.should_update_previous() && i > 0) {
|
||||||
|
update_state(i - 1, dt);
|
||||||
|
}
|
||||||
|
StateResult r = state.update(dt);
|
||||||
|
|
||||||
|
|
||||||
|
if (r.action != StateAction::None && i+1 != stack.size()) {
|
||||||
|
while (i < stack.size()) {
|
||||||
|
pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch (r.action) {
|
||||||
|
case StateAction::Pop:
|
||||||
|
pop();
|
||||||
|
case StateAction::Push:
|
||||||
|
push(std::move(r.state.value()));
|
||||||
|
case StateAction::Swap:
|
||||||
|
swap(std::move(r.state.value()));
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void StateStack::input_state(unsigned int i, InputEvent & input_event) {
|
||||||
|
IState &state = *stack[i];
|
||||||
|
if (state.should_update_previous() && i > 0) {
|
||||||
|
input_state(i - 1, input_event);
|
||||||
|
}
|
||||||
|
state.input(input_event);
|
||||||
|
}
|
66
src/statemachine/StateStack.h
Normal file
66
src/statemachine/StateStack.h
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <optional>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "../Input.h"
|
||||||
|
|
||||||
|
class StateStack;
|
||||||
|
class IState;
|
||||||
|
|
||||||
|
enum class StateAction {
|
||||||
|
None,
|
||||||
|
Push,
|
||||||
|
Pop,
|
||||||
|
Swap,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct StateResult {
|
||||||
|
StateResult(StateAction action, std::optional<std::unique_ptr<IState>> state) {
|
||||||
|
this->action = action;
|
||||||
|
this->state.swap(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
StateAction action;
|
||||||
|
std::optional<std::unique_ptr<IState>> state;
|
||||||
|
|
||||||
|
static StateResult None() {
|
||||||
|
return StateResult(StateAction::None, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static StateResult Pop() {
|
||||||
|
return StateResult(StateAction::Pop, nullptr);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class IState {
|
||||||
|
public:
|
||||||
|
IState() = default;
|
||||||
|
virtual ~IState() = default;
|
||||||
|
virtual void enter() = 0;
|
||||||
|
virtual void exit() = 0;
|
||||||
|
virtual StateResult update(float dt) = 0;
|
||||||
|
virtual bool should_update_previous() { return false; };
|
||||||
|
virtual void draw() = 0;
|
||||||
|
virtual bool should_draw_previous() { return false; };
|
||||||
|
virtual void input(InputEvent &const event) = 0;
|
||||||
|
virtual bool should_input_previous() { return false; };
|
||||||
|
};
|
||||||
|
|
||||||
|
class StateStack {
|
||||||
|
public:
|
||||||
|
StateStack() = default;
|
||||||
|
~StateStack() = default;
|
||||||
|
void update(float dt);
|
||||||
|
void draw();
|
||||||
|
void push(std::unique_ptr<IState> state);
|
||||||
|
void swap(std::unique_ptr<IState> state);
|
||||||
|
void pop();
|
||||||
|
void input(InputEvent& input_event);
|
||||||
|
private:
|
||||||
|
void draw_state(unsigned int i);
|
||||||
|
void update_state(unsigned int i, float dt);
|
||||||
|
void input_state(unsigned int i, InputEvent &input_event);
|
||||||
|
std::vector<std::unique_ptr<IState>> stack;
|
||||||
|
};
|
Loading…
Reference in a new issue