Added default gamestate and gamestate vectors; Minor fixes and refacorings

This commit is contained in:
grayson committed 2021-08-17 14:07:59 -05:00
1 parent b1f6a2b317
commit e540c19860
11 files changed
+95 -47

No files matched your search

+13 -5
View File
@@ -1,5 +1,6 @@
#pragma once
#include "Config.h"
#include "IntroGamestate.h"
#include <Windows.h>
#include <chrono>
#include <vector>
@@ -13,16 +14,18 @@ namespace nf {
void setWindowIcon(HANDLE hIcon);
void setWindowCursor(HCURSOR hCursor);
void startLoop();
void addState(IGamestate* in);
void addDefaultState(IGamestate* in);
void run();
void showWindow(bool show);
Config& getConfig();
int getFPS();
const Config& getConfig() const;
int getFPS() const;
~Application();
private:
void registerWindowClass();
void toggleFullscreen();
RECT getWindowRect();
RECT getWindowRect() const;
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
@@ -33,6 +36,7 @@ namespace nf {
HINSTANCE m_hInst;
LPCWSTR m_wclassName;
HWND m_window;
LONG m_defaultWindowStyle;
WINDOWPLACEMENT m_wndPlacement;
HDC m_hdc;
HGLRC m_hglrc;
@@ -47,6 +51,10 @@ namespace nf {
const double m_minFrametime = 1.0 / m_targetFPS;
int m_FPS;
//Inactive states states to potentially be loaded during the Application's lifetime
std::vector<IGamestate*> m_states;
//The currently active and loaded states where the top-most is the current one
std::vector<IGamestate*> m_activeStates;
IntroGamestate* m_sIntro;
};
}
-13
View File
@@ -1,13 +0,0 @@
#pragma once
namespace nf {
class Gamestate {
public:
Gamestate();
virtual void onEnter();
virtual void onExit();
private:
//Resource stuff
};
}
+14
View File
@@ -0,0 +1,14 @@
#pragma once
namespace nf {
class IGamestate {
public:
virtual void onEnter() = 0;
virtual void onExit() = 0;
virtual void update() = 0;
virtual void render() = 0;
private:
//Resource identifier?
};
}
+14
View File
@@ -0,0 +1,14 @@
#include "IGamestate.h"
namespace nf {
class IntroGamestate : public IGamestate {
public:
void onEnter() override;
void onExit() override;
void update() override;
void render() override;
private:
};
}