BARE2D
BARE2D::Screen Class Referenceabstract

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. More...

#include <Screen.hpp>

+ Collaboration diagram for BARE2D::Screen:

Public Member Functions

 Screen ()
 
virtual ~Screen ()
 
virtual void initScreen ()=0
 This is called once, at the start of the program, when the screen is added to the screen list. More...
 
virtual void destroyScreen ()=0
 Destroys the screen, called when the screen list is destroyed. More...
 
virtual void onEntry ()=0
 This is pretty close to the init function. It is called every time the screen is entered. More...
 
virtual void onExit ()=0
 This is close to the destroy function, but is only called when the screen is exited, not at the end of the program. More...
 
virtual void draw ()=0
 Draws anything and everything to the screen! More...
 
virtual void update (double dt)=0
 Updates all necessary things! More...
 
virtual int getNextScreenIndex () const =0
 Returns the index of the next screen. It is recommended to keep a file, say, ScreenIndices.h, where all indices are defined. More...
 
ScreenState getState ()
 

Protected Attributes

ScreenState m_screenState = ScreenState::RUNNING
 

Detailed Description

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.

Definition at line 16 of file Screen.hpp.

Constructor & Destructor Documentation

◆ Screen()

BARE2D::Screen::Screen ( )

Definition at line 5 of file Screen.cpp.

◆ ~Screen()

BARE2D::Screen::~Screen ( )
virtual

Definition at line 9 of file Screen.cpp.

Member Function Documentation

◆ destroyScreen()

virtual void BARE2D::Screen::destroyScreen ( )
pure virtual

Destroys the screen, called when the screen list is destroyed.

◆ draw()

virtual void BARE2D::Screen::draw ( )
pure virtual

Draws anything and everything to the screen!

◆ getNextScreenIndex()

virtual int BARE2D::Screen::getNextScreenIndex ( ) const
pure virtual

Returns the index of the next screen. It is recommended to keep a file, say, ScreenIndices.h, where all indices are defined.

Returns
Index of the next screen

Referenced by BARE2D::ScreenList::moveToNextScreen().

+ Here is the caller graph for this function:

◆ getState()

ScreenState BARE2D::Screen::getState ( )
Returns
Returns the current ScreenState

Definition at line 13 of file Screen.cpp.

References m_screenState.

◆ initScreen()

virtual void BARE2D::Screen::initScreen ( )
pure virtual

This is called once, at the start of the program, when the screen is added to the screen list.

Referenced by BARE2D::ScreenList::addScreen().

+ Here is the caller graph for this function:

◆ onEntry()

virtual void BARE2D::Screen::onEntry ( )
pure virtual

This is pretty close to the init function. It is called every time the screen is entered.

Referenced by BARE2D::ScreenList::moveToNextScreen(), and BARE2D::ScreenList::moveToPreviousScreen().

+ Here is the caller graph for this function:

◆ onExit()

virtual void BARE2D::Screen::onExit ( )
pure virtual

This is close to the destroy function, but is only called when the screen is exited, not at the end of the program.

Referenced by BARE2D::ScreenList::moveToNextScreen(), and BARE2D::ScreenList::moveToPreviousScreen().

+ Here is the caller graph for this function:

◆ update()

virtual void BARE2D::Screen::update ( double  dt)
pure virtual

Updates all necessary things!

Field Documentation

◆ m_screenState

ScreenState BARE2D::Screen::m_screenState = ScreenState::RUNNING
protected

Definition at line 64 of file Screen.hpp.

Referenced by getState().


The documentation for this class was generated from the following files: