SHADE_Y3/SHADE_Engine/src/FRC/SHFramerateController.h

62 lines
2.0 KiB
C
Raw Normal View History

2022-09-14 22:00:00 +08:00
/*********************************************************************
* \file SHFramerateController.h
* \author Ryan Wang Nian Jing
* \brief Declaration for the framerate controller
* Handles changing of scenes and manages loop (timestep, etc.)
*
* \copyright Copyright (c) 2022 DigiPen Institute of Technology. Reproduction
or disclosure of this file or its contents without the prior written
consent of DigiPen Institute of Technology is prohibited.
*********************************************************************/
#ifndef SH_FRAMERATECONTROLLER_H
#define SH_FRAMERATECONTROLLER_H
#pragma once
#include "../Scene/SHScene.h"
namespace SHADE
{
class SHFramerateController
{
private:
//scene pointers
static SHScene* previousScene;
static SHScene* currentScene;
static SHScene* nextScene;
//Flags
//Whether the flag has been raised for the game to be quit
static bool toQuit;
//Whether the flag has been raised for the current scene to restart
static bool toRestart;
public:
//Fixed timestep value for physics. Default at 1/100th of a second.
//Should be lower than the variable refresh rate
static double fixedTimestep;
//Scene Manager Loop
//This loop is vital to the game because it runs for as long as the game
//runs. Before entering, initialise vital systems for game. After exiting,
//free these vital systems before finishing the main() function and
//terminating the game
//Parameter of firstScene is what scene the game should start with
static void Run(SHScene* firstScene);
//Set the flag to restart the current game scene
static inline void RestartScene() { toRestart = true; }
//Set the flag to halt running of the scene manager and quit the game
static inline void QuitGame() { toQuit = true; }
//Set the next scene to be excuted
//This will tell the scene manager to
//halt execution of the current scene and prepare
//execution of the next
static inline void SetNextScene(SHScene* const next) { nextScene = next; }
};
}
#endif