No longer need to specify an application when creating a game state
This commit is contained in:
1 parent
b1efc4934e
commit
6e3a576fef
8 files changed
+20
-25
No files matched your search
@@ -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