diff --git a/Game/src/Game.cpp b/Game/src/Game.cpp index 9fdcbee..bd648f7 100644 --- a/Game/src/Game.cpp +++ b/Game/src/Game.cpp @@ -7,7 +7,7 @@ int main(int argc, char* argv[]) { //app.setWindowIcon(...); // app.setWindowCursor(...); - MainState* test = new MainState(&app); + MainState* test = new MainState; app.addState(test, "Main State"); app.addDefaultState("Main State"); diff --git a/Game/src/MainState.cpp b/Game/src/MainState.cpp index bbabee9..6872c7a 100644 --- a/Game/src/MainState.cpp +++ b/Game/src/MainState.cpp @@ -1,11 +1,5 @@ #include "MainState.h" -MainState::MainState(nf::Application* app) : - Gamestate(app) -{ - -} - void MainState::onEnter() { Log("MainState onEnter!"); diff --git a/Game/src/include/MainState.h b/Game/src/include/MainState.h index 15c6cc1..1111322 100644 --- a/Game/src/include/MainState.h +++ b/Game/src/include/MainState.h @@ -3,8 +3,6 @@ class MainState : public nf::Gamestate { public: - MainState(nf::Application* app); - void onEnter() override; void update(double deltaTime) override; diff --git a/NothinFancy/src/Application.cpp b/NothinFancy/src/Application.cpp index d5fbb60..6a0e6ab 100644 --- a/NothinFancy/src/Application.cpp +++ b/NothinFancy/src/Application.cpp @@ -280,7 +280,8 @@ namespace nf { } void Application::startIntroState() { - m_sIntro = new IntroGamestate(this); + m_sIntro = new IntroGamestate; + m_sIntro->setup(this); m_currentState = m_sIntro; m_currentState->onEnter(); } @@ -295,6 +296,7 @@ namespace nf { if (m_renderer->isFadeOutComplete()) { m_currentState->onExit(); m_currentState = m_states[m_nextState]; + m_currentState->setup(this); m_currentState->onEnter(); m_renderer->setFade(true, false, false); m_stateChange = false; diff --git a/NothinFancy/src/Gamestate.cpp b/NothinFancy/src/Gamestate.cpp index addc579..c57c8f9 100644 --- a/NothinFancy/src/Gamestate.cpp +++ b/NothinFancy/src/Gamestate.cpp @@ -4,10 +4,16 @@ #include "Utility.h" namespace nf { - Gamestate::Gamestate(Application* app) : - camera(app) + Gamestate::Gamestate() : + app(nullptr), + camera(nullptr) { + + } + + void Gamestate::setup(Application* app) { this->app = app; + camera = new Camera(this->app); } void Gamestate::onEnter() { @@ -19,7 +25,7 @@ namespace nf { } Camera* Gamestate::getCamera() { - return &camera; + return camera; } void Gamestate::render(Renderer& renderer) { diff --git a/NothinFancy/src/IntroGamestate.cpp b/NothinFancy/src/IntroGamestate.cpp index 2a585ff..6807ccf 100644 --- a/NothinFancy/src/IntroGamestate.cpp +++ b/NothinFancy/src/IntroGamestate.cpp @@ -5,18 +5,13 @@ #include "Input.h" namespace nf { - IntroGamestate::IntroGamestate(Application* app) : - Gamestate(app), - m_counter(0) - { - } - void IntroGamestate::onEnter() { Log("Intro onEnter!"); logoTex.create(BaseAssets::logo, Vec2(0.0, 0.0)); logoTex.centered(true, true); text.create("(C) Grayson Riffe 2021", Vec2(0.01, 0.025), Vec3(0.8)); text.setScale(0.6); + m_counter = 0; } void IntroGamestate::update(double deltaTime) { diff --git a/NothinFancy/src/include/Gamestate.h b/NothinFancy/src/include/Gamestate.h index d686046..66f7d4c 100644 --- a/NothinFancy/src/include/Gamestate.h +++ b/NothinFancy/src/include/Gamestate.h @@ -4,13 +4,15 @@ namespace nf { class Application; class Renderer; - + class Camera; class Gamestate { public: - Gamestate(Application* app); - Gamestate() = delete; + Gamestate(); + Gamestate(const Gamestate& other) = delete; + void setup(Application* app); + virtual void onEnter(); virtual void update(double deltaTime); @@ -20,6 +22,6 @@ namespace nf { virtual void onExit(); protected: Application* app; - Camera camera; + Camera* camera; }; } \ No newline at end of file diff --git a/NothinFancy/src/include/IntroGamestate.h b/NothinFancy/src/include/IntroGamestate.h index 7ec4d2e..c7cccf0 100644 --- a/NothinFancy/src/include/IntroGamestate.h +++ b/NothinFancy/src/include/IntroGamestate.h @@ -6,8 +6,6 @@ namespace nf { class IntroGamestate : public Gamestate { public: - IntroGamestate(Application* app); - void onEnter() override; void update(double deltaTime) override;