No longer need to specify an application when creating a game state
This commit is contained in:
parent
b1efc4934e
commit
6e3a576fef
@ -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");
|
||||
|
||||
|
@ -1,11 +1,5 @@
|
||||
#include "MainState.h"
|
||||
|
||||
MainState::MainState(nf::Application* app) :
|
||||
Gamestate(app)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MainState::onEnter() {
|
||||
Log("MainState onEnter!");
|
||||
|
||||
|
@ -3,8 +3,6 @@
|
||||
|
||||
class MainState : public nf::Gamestate {
|
||||
public:
|
||||
MainState(nf::Application* app);
|
||||
|
||||
void onEnter() override;
|
||||
|
||||
void update(double deltaTime) override;
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
};
|
||||
}
|
@ -6,8 +6,6 @@
|
||||
namespace nf {
|
||||
class IntroGamestate : public Gamestate {
|
||||
public:
|
||||
IntroGamestate(Application* app);
|
||||
|
||||
void onEnter() override;
|
||||
|
||||
void update(double deltaTime) override;
|
||||
|
Reference in New Issue
Block a user