Level H Engine
State.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <SDL.h>
4 #include <string.h>
5 #include "../Core/WindowFrame.h"
6 
8 class StateManager;
9 
13 class State
14 {
15 public:
22  State(StateManager* stateManager, SDL_Window* window, std::string name);
23 
27  virtual ~State();
28 
33  virtual bool input() = 0;
34 
38  virtual void update() = 0;
39 
43  virtual void draw() = 0;
44 
49  SDL_Window* getWindow();
50 
55  std::string getName();
56 
60  void destroyState();
61 
62 protected:
66  SDL_Window* window;
68  std::string name;
70  bool destroyed;
71 };
bool destroyed
A boolean for if the state is destroyed.
Definition: State.h:70
Creates a State object to be inherited.
Definition: State.h:13
virtual void update()=0
A pure virtual function to update the State to allow the State to run.
Creates a StateManager object.
Definition: StateManager.h:9
StateManager * stateManager
A pointer to the state manager.
Definition: State.h:64
virtual bool input()=0
A pure virtual function to handle the user input for use with the State.
SDL_Window * window
The window to display to.
Definition: State.h:66
SDL_Window * getWindow()
Gets the window.
Definition: State.cpp:21
void destroyState()
A function to destroy all data in a state.
Definition: State.cpp:33
State(StateManager *stateManager, SDL_Window *window, std::string name)
Constructs a State object.
Definition: State.cpp:6
virtual ~State()
A virtual destructor for the State object.
Definition: State.cpp:17
std::string name
The state name.
Definition: State.h:68
std::string getName()
Gets the name of the state.
Definition: State.cpp:27
virtual void draw()=0
A pure virtual function to draw to the screen using the window.