diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index 571c1735..123439e7 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -18,6 +18,7 @@ #include "safemap.h" #include "Key.h" #include "Menu.h" +#include "State_GameRun.h" INCLUDE_EMITTER_LIST @@ -110,6 +111,11 @@ bool Crawler::OnUserCreate(){ InitializeClasses(); ChangePlayerClass(WARRIOR); //Warrior::ability4=Ranger::ability1; //Class ability swapping demonstration. + + GameState::states[States::GAME_RUN]=new State_GameRun(); + + GameState::ChangeState(States::GAME_RUN); + return true; } @@ -132,9 +138,11 @@ bool Crawler::OnUserUpdate(float fElapsedTime){ monstersToBeSpawned.clear(); UpdateBullets(fElapsedTime); UpdateCamera(fElapsedTime); + GameState::STATE->OnUserUpdate(this); RenderWorld(fElapsedTime); RenderHud(); RenderMenu(); + GameState::STATE->Draw(this); return true; } diff --git a/Crawler/Crawler.vcxproj b/Crawler/Crawler.vcxproj index 27b88b1c..4d6ce41e 100644 --- a/Crawler/Crawler.vcxproj +++ b/Crawler/Crawler.vcxproj @@ -271,6 +271,7 @@ + @@ -293,6 +294,7 @@ + diff --git a/Crawler/Crawler.vcxproj.filters b/Crawler/Crawler.vcxproj.filters index 732ddc70..e1fa89dd 100644 --- a/Crawler/Crawler.vcxproj.filters +++ b/Crawler/Crawler.vcxproj.filters @@ -46,6 +46,9 @@ {45ecf440-1472-4e9a-a4d9-e9eac538a2b0} + + {da28101e-32b6-4e32-a19a-e0d2636d5eea} + @@ -168,6 +171,12 @@ Source Files + + Header Files\Game States + + + Header Files\Game States + diff --git a/Crawler/GameState.h b/Crawler/GameState.h new file mode 100644 index 00000000..f1405704 --- /dev/null +++ b/Crawler/GameState.h @@ -0,0 +1,24 @@ +#pragma once +class Crawler; + +class State_GameRun; + +namespace States{ + enum State{ + GAME_RUN + }; +}; + +class GameState{ +public: + inline static GameState*STATE=nullptr; + inline static std::mapstates; + virtual void OnStateChange(GameState*prevState)=0; + virtual void OnUserUpdate(Crawler*game)=0; + virtual void Draw(Crawler*game)=0; + static inline void ChangeState(States::State newState){ + GameState*prevState=STATE; + STATE=states[newState]; + STATE->OnStateChange(prevState); + } +}; \ No newline at end of file diff --git a/Crawler/State_GameRun.h b/Crawler/State_GameRun.h new file mode 100644 index 00000000..31b45bc8 --- /dev/null +++ b/Crawler/State_GameRun.h @@ -0,0 +1,15 @@ +#pragma once + +#include "GameState.h" + +class State_GameRun:public GameState{ + inline virtual void OnStateChange(GameState*prevState)override{ + + }; + inline virtual void OnUserUpdate(Crawler*game)override{ + + }; + inline virtual void Draw(Crawler*game)override{ + + }; +}; \ No newline at end of file diff --git a/Crawler/Version.h b/Crawler/Version.h index fb342ad6..32727056 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -2,7 +2,7 @@ #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 0 -#define VERSION_BUILD 1761 +#define VERSION_BUILD 1765 #define stringify(a) stringify_(a) #define stringify_(a) #a