diff --git a/Game/src/MainState.cpp b/Game/src/MainState.cpp index 237f889..43ac4a5 100644 --- a/Game/src/MainState.cpp +++ b/Game/src/MainState.cpp @@ -1,6 +1,6 @@ #include "MainState.h" -void MainState::onEnter() { +void MainState::onEnter(Application* app) { Log("MainState update!"); } diff --git a/Game/src/include/MainState.h b/Game/src/include/MainState.h index aa2b6d8..bc41824 100644 --- a/Game/src/include/MainState.h +++ b/Game/src/include/MainState.h @@ -3,7 +3,7 @@ class MainState : public nf::IGamestate { public: - void onEnter() override; + void onEnter(Application* app) override; void onExit() override; void update() override; diff --git a/NothinFancy/src/Application.cpp b/NothinFancy/src/Application.cpp index 523a0e7..0e234d8 100644 --- a/NothinFancy/src/Application.cpp +++ b/NothinFancy/src/Application.cpp @@ -120,7 +120,7 @@ namespace nf { void Application::addIntroState() { m_sIntro = new IntroGamestate; - m_sIntro->onEnter(); + m_sIntro->onEnter(this); m_activeStates.push_back(m_sIntro); } @@ -170,9 +170,9 @@ namespace nf { LRESULT CALLBACK Application::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { Application* app = (Application*)GetProp(hWnd, L"App"); + //TODO: Dragging blocks thread switch (uMsg) { case WM_CREATE: { - return 0; } case WM_SYSKEYDOWN: { diff --git a/NothinFancy/src/IntroGamestate.cpp b/NothinFancy/src/IntroGamestate.cpp index eb7ed47..048f943 100644 --- a/NothinFancy/src/IntroGamestate.cpp +++ b/NothinFancy/src/IntroGamestate.cpp @@ -1,8 +1,11 @@ #include "IntroGamestate.h" +#include "Application.h" namespace nf { - void IntroGamestate::onEnter() { + void IntroGamestate::onEnter(Application* app) { Log("Intro onEnter!"); + m_app = app; + counter = 0; } void IntroGamestate::onExit() { @@ -11,6 +14,10 @@ namespace nf { void IntroGamestate::update() { Log("Intro update!"); + if (counter >= 120) { + m_app->changeState("Main State"); + } + counter++; } void IntroGamestate::render() { diff --git a/NothinFancy/src/include/IGamestate.h b/NothinFancy/src/include/IGamestate.h index 4aa36d7..f4f5e8f 100644 --- a/NothinFancy/src/include/IGamestate.h +++ b/NothinFancy/src/include/IGamestate.h @@ -1,13 +1,17 @@ #pragma once namespace nf { + class Application; + class IGamestate { public: - virtual void onEnter() = 0; + virtual void onEnter(Application* app) = 0; virtual void onExit() = 0; virtual void update() = 0; virtual void render() = 0; + + Application* m_app; private: //Resource identifier? }; diff --git a/NothinFancy/src/include/IntroGamestate.h b/NothinFancy/src/include/IntroGamestate.h index 9c3926d..808ff62 100644 --- a/NothinFancy/src/include/IntroGamestate.h +++ b/NothinFancy/src/include/IntroGamestate.h @@ -1,15 +1,16 @@ +#pragma once #include "IGamestate.h" #include "Utility.h" namespace nf { class IntroGamestate : public IGamestate { public: - void onEnter() override; + void onEnter(Application* app) override; void onExit() override; void update() override; void render() override; private: - + int counter; }; } \ No newline at end of file diff --git a/NothinFancy/src/include/NothinFancy.h b/NothinFancy/src/include/NothinFancy.h index 406a481..0eb00c9 100644 --- a/NothinFancy/src/include/NothinFancy.h +++ b/NothinFancy/src/include/NothinFancy.h @@ -1,3 +1,5 @@ //Master engine include (Is this even useful?) -#include "Application.h" \ No newline at end of file +#include "Application.h" + +using namespace nf; \ No newline at end of file