Tested state changing
This commit is contained in:
parent
e8bc0903e6
commit
ea9c4054bd
@ -1,6 +1,6 @@
|
||||
#include "MainState.h"
|
||||
|
||||
void MainState::onEnter() {
|
||||
void MainState::onEnter(Application* app) {
|
||||
Log("MainState update!");
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
class MainState : public nf::IGamestate {
|
||||
public:
|
||||
void onEnter() override;
|
||||
void onEnter(Application* app) override;
|
||||
void onExit() override;
|
||||
|
||||
void update() override;
|
||||
|
@ -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: {
|
||||
|
@ -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() {
|
||||
|
@ -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?
|
||||
};
|
||||
|
@ -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;
|
||||
};
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
//Master engine include (Is this even useful?)
|
||||
|
||||
#include "Application.h"
|
||||
#include "Application.h"
|
||||
|
||||
using namespace nf;
|
Reference in New Issue
Block a user