Tested state changing

This commit is contained in:
Grayson Riffe (Laptop) 2021-08-18 14:26:12 -05:00
parent e8bc0903e6
commit ea9c4054bd
7 changed files with 23 additions and 9 deletions

View File

@ -1,6 +1,6 @@
#include "MainState.h"
void MainState::onEnter() {
void MainState::onEnter(Application* app) {
Log("MainState update!");
}

View File

@ -3,7 +3,7 @@
class MainState : public nf::IGamestate {
public:
void onEnter() override;
void onEnter(Application* app) override;
void onExit() override;
void update() override;

View File

@ -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: {

View File

@ -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() {

View File

@ -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?
};

View File

@ -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;
};
}

View File

@ -1,3 +1,5 @@
//Master engine include (Is this even useful?)
#include "Application.h"
#include "Application.h"
using namespace nf;