Tested state changing
This commit is contained in:
parent
e8bc0903e6
commit
ea9c4054bd
@ -1,6 +1,6 @@
|
|||||||
#include "MainState.h"
|
#include "MainState.h"
|
||||||
|
|
||||||
void MainState::onEnter() {
|
void MainState::onEnter(Application* app) {
|
||||||
Log("MainState update!");
|
Log("MainState update!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
class MainState : public nf::IGamestate {
|
class MainState : public nf::IGamestate {
|
||||||
public:
|
public:
|
||||||
void onEnter() override;
|
void onEnter(Application* app) override;
|
||||||
void onExit() override;
|
void onExit() override;
|
||||||
|
|
||||||
void update() override;
|
void update() override;
|
||||||
|
@ -120,7 +120,7 @@ namespace nf {
|
|||||||
|
|
||||||
void Application::addIntroState() {
|
void Application::addIntroState() {
|
||||||
m_sIntro = new IntroGamestate;
|
m_sIntro = new IntroGamestate;
|
||||||
m_sIntro->onEnter();
|
m_sIntro->onEnter(this);
|
||||||
m_activeStates.push_back(m_sIntro);
|
m_activeStates.push_back(m_sIntro);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,9 +170,9 @@ namespace nf {
|
|||||||
|
|
||||||
LRESULT CALLBACK Application::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
LRESULT CALLBACK Application::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||||
Application* app = (Application*)GetProp(hWnd, L"App");
|
Application* app = (Application*)GetProp(hWnd, L"App");
|
||||||
|
//TODO: Dragging blocks thread
|
||||||
switch (uMsg) {
|
switch (uMsg) {
|
||||||
case WM_CREATE: {
|
case WM_CREATE: {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case WM_SYSKEYDOWN: {
|
case WM_SYSKEYDOWN: {
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
#include "IntroGamestate.h"
|
#include "IntroGamestate.h"
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
namespace nf {
|
namespace nf {
|
||||||
void IntroGamestate::onEnter() {
|
void IntroGamestate::onEnter(Application* app) {
|
||||||
Log("Intro onEnter!");
|
Log("Intro onEnter!");
|
||||||
|
m_app = app;
|
||||||
|
counter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntroGamestate::onExit() {
|
void IntroGamestate::onExit() {
|
||||||
@ -11,6 +14,10 @@ namespace nf {
|
|||||||
|
|
||||||
void IntroGamestate::update() {
|
void IntroGamestate::update() {
|
||||||
Log("Intro update!");
|
Log("Intro update!");
|
||||||
|
if (counter >= 120) {
|
||||||
|
m_app->changeState("Main State");
|
||||||
|
}
|
||||||
|
counter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntroGamestate::render() {
|
void IntroGamestate::render() {
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace nf {
|
namespace nf {
|
||||||
|
class Application;
|
||||||
|
|
||||||
class IGamestate {
|
class IGamestate {
|
||||||
public:
|
public:
|
||||||
virtual void onEnter() = 0;
|
virtual void onEnter(Application* app) = 0;
|
||||||
virtual void onExit() = 0;
|
virtual void onExit() = 0;
|
||||||
|
|
||||||
virtual void update() = 0;
|
virtual void update() = 0;
|
||||||
virtual void render() = 0;
|
virtual void render() = 0;
|
||||||
|
|
||||||
|
Application* m_app;
|
||||||
private:
|
private:
|
||||||
//Resource identifier?
|
//Resource identifier?
|
||||||
};
|
};
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
#include "IGamestate.h"
|
#include "IGamestate.h"
|
||||||
#include "Utility.h"
|
#include "Utility.h"
|
||||||
|
|
||||||
namespace nf {
|
namespace nf {
|
||||||
class IntroGamestate : public IGamestate {
|
class IntroGamestate : public IGamestate {
|
||||||
public:
|
public:
|
||||||
void onEnter() override;
|
void onEnter(Application* app) override;
|
||||||
void onExit() override;
|
void onExit() override;
|
||||||
|
|
||||||
void update() override;
|
void update() override;
|
||||||
void render() override;
|
void render() override;
|
||||||
private:
|
private:
|
||||||
|
int counter;
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -1,3 +1,5 @@
|
|||||||
//Master engine include (Is this even useful?)
|
//Master engine include (Is this even useful?)
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
|
||||||
|
using namespace nf;
|
Reference in New Issue
Block a user