Rewrote Gamestate to be a class instead of an interface; Added layers

This commit is contained in:
grayson committed 2021-08-25 02:58:25 -05:00
1 parent 2f4e0ebfac
commit e35688373e
15 files changed
+155 -70

No files matched your search

+6 -5
View File
@@ -17,7 +17,8 @@ namespace nf {
void setWindowIcon(HANDLE hIcon);
void setWindowCursor(HCURSOR hCursor);
void addState(IGamestate* state, const std::string& stateName);
Renderer* getRenderer() const;
void addState(Gamestate* state, const std::string& stateName);
void addDefaultState(const std::string& stateName);
void run();
void changeState(const std::string& stateName);
@@ -59,11 +60,11 @@ namespace nf {
//Inactive states to potentially be active during the Application's lifetime
//Mapped to const char* to be referenced later in the frontend
std::unordered_map<std::string, IGamestate*> m_states;
IntroGamestate* m_sIntro;
IGamestate* m_DefaultState;
std::unordered_map<std::string, Gamestate*> m_states;
Gamestate* m_sIntro;
Gamestate* m_DefaultState;
bool m_defaultStateAdded;
IGamestate* m_currentState;
Gamestate* m_currentState;
bool m_stateChange;
std::string m_nextState;
+10 -2
View File
@@ -1,12 +1,20 @@
#pragma once
#include "VertexArray.h"
#include "Shader.h"
#include "IndexBuffer.h"
namespace nf {
class Drawable {
enum class DrawableType {
NF_GAME, NF_UI
};
public:
Drawable();
~Drawable();
private:
virtual DrawableType identity();
~Drawable();
protected:
//TODO: Add VAO, Shader, index buffer, etc.
};
}
+24
View File
@@ -0,0 +1,24 @@
#pragma once
namespace nf {
class Application;
class Renderer;
class Gamestate {
public:
Gamestate(Application* app);
Gamestate() = delete;
Gamestate(const Gamestate& other) = delete;
virtual void onEnter();
virtual void update(double deltaTime);
virtual void render();
virtual void onExit();
protected:
Application* m_app;
Renderer* m_renderer;
//Resource identifier?
};
}
-18
View File
@@ -1,18 +0,0 @@
#pragma once
namespace nf {
class Application;
class IGamestate {
public:
virtual void onEnter(Application* app) = 0;
virtual void onExit() = 0;
virtual void update() = 0;
virtual void render() = 0;
Application* m_app;
private:
//Resource identifier?
};
}
+9 -6
View File
@@ -1,16 +1,19 @@
#pragma once
#include "IGamestate.h"
#include "Gamestate.h"
namespace nf {
class IntroGamestate : public IGamestate {
class IntroGamestate : public Gamestate {
public:
void onEnter(Application* app) override;
void onExit() override;
IntroGamestate(Application* app);
void update() override;
void onEnter() override;
void update(double deltaTime) override;
void render() override;
void onExit() override;
private:
int counter;
int m_counter;
//TODO: Flesh out intro gamestate
};
}
+2
View File
@@ -11,6 +11,8 @@ namespace nf {
public:
Renderer(Application* app);
void render(const Drawable& in);
void doFrame();
~Renderer();