BARE2D
Screen.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 namespace BARE2D {
4 
5  enum class ScreenState {
6  RUNNING,
10  };
11 
12  /**
13  * @class Screen
14  * @brief This is meant to be a parent for other, app-specific, screen classes, which is essentially where all game mechanics will "happen", so to speak. This class decides what happens on updates, draws, when to go to different screens, etc.
15  */
16  class Screen
17  {
18  public:
19  Screen();
20  virtual ~Screen();
21 
22  /**
23  * @brief This is called once, at the start of the program, when the screen is added to the screen list.
24  */
25  virtual void initScreen() = 0;
26 
27  /**
28  * @brief Destroys the screen, called when the screen list is destroyed.
29  */
30  virtual void destroyScreen() = 0;
31 
32  /**
33  * @brief This is pretty close to the init function. It is called every time the screen is entered.
34  */
35  virtual void onEntry() = 0;
36 
37  /**
38  * @brief This is close to the destroy function, but is only called when the screen is exited, not at the end of the program.
39  */
40  virtual void onExit() = 0;
41 
42  /**
43  * @brief Draws anything and everything to the screen!
44  */
45  virtual void draw() = 0;
46 
47  /**
48  * @brief Updates all necessary things!
49  */
50  virtual void update(double dt) = 0;
51 
52  /**
53  * @brief Returns the index of the next screen. It is recommended to keep a file, say, ScreenIndices.h, where all indices are defined.
54  * @return Index of the next screen
55  */
56  virtual int getNextScreenIndex() const = 0;
57 
58  /**
59  * @return Returns the current ScreenState
60  */
62 
63  protected:
65 
66 
67  };
68 
69 }
70 
BARE2D::Screen
This is meant to be a parent for other, app-specific, screen classes, which is essentially where all ...
Definition: Screen.hpp:16
BARE2D::Screen::getState
ScreenState getState()
Definition: Screen.cpp:13
BARE2D
Definition: App.cpp:13
BARE2D::Screen::m_screenState
ScreenState m_screenState
Definition: Screen.hpp:64
BARE2D::ScreenState::RUNNING
@ RUNNING
BARE2D::Screen::onEntry
virtual void onEntry()=0
This is pretty close to the init function. It is called every time the screen is entered.
BARE2D::ScreenState::CHANGE_NEXT
@ CHANGE_NEXT
BARE2D::Screen::update
virtual void update(double dt)=0
Updates all necessary things!
BARE2D::Screen::~Screen
virtual ~Screen()
Definition: Screen.cpp:9
BARE2D::Screen::draw
virtual void draw()=0
Draws anything and everything to the screen!
BARE2D::Screen::initScreen
virtual void initScreen()=0
This is called once, at the start of the program, when the screen is added to the screen list.
BARE2D::Screen::destroyScreen
virtual void destroyScreen()=0
Destroys the screen, called when the screen list is destroyed.
BARE2D::Screen::Screen
Screen()
Definition: Screen.cpp:5
BARE2D::ScreenState::CHANGE_PREV
@ CHANGE_PREV
BARE2D::ScreenState
ScreenState
Definition: Screen.hpp:5
BARE2D::ScreenState::EXIT_APPLICATION
@ EXIT_APPLICATION
BARE2D::Screen::onExit
virtual void onExit()=0
This is close to the destroy function, but is only called when the screen is exited,...
BARE2D::Screen::getNextScreenIndex
virtual int getNextScreenIndex() const =0
Returns the index of the next screen. It is recommended to keep a file, say, ScreenIndices....