Space Fighter
A "shmup" game for Computer Programming C++
Loading...
Searching...
No Matches
KatanaEngine::Game Class Referenceabstract

Base class for all games. Provides graphics initialization, game loop, and rendering code. Inherit from this class when creating your own game. More...

#include <Game.h>

Inheritance diagram for KatanaEngine::Game:

Public Member Functions

 Game ()
 
virtual ~Game ()
 
virtual int Run ()
 Runs the game instance.
 
virtual std::string GetName () const =0
 Gets the name of the game.
 
virtual ResourceManagerGetResourceManager () const
 Gets a pointer to the ResourceManager, for loading and managing resources.
 
virtual ScreenManagerGetScreenManager () const
 Gets a pointer to the ScreenManager, for managing game screens.
 
virtual SpriteBatchGetSpriteBatch () const
 Gets a pointer to the SpriteBatch, for rendering.
 
virtual void LoadContent (ResourceManager &resourceManager)
 Called when resources need to be loaded.
 
virtual void UnloadContent ()
 Called when resources need to be unloaded. Override this method to unload any game-specific resources.
 
virtual void Update (const GameTime &gameTime)
 Called when the game has determined that game logic needs to be processed.
 
virtual void Draw (SpriteBatch &spriteBatch)
 Called when the game determines it is time to draw a frame.
 
virtual void Quit ()
 Quits the game.
 

Static Public Member Functions

static int GetScreenWidth ()
 Gets the screen width in pixels.
 
static int GetScreenHeight ()
 Gets the screen width in pixels.
 
static Vector2 GetScreenCenter ()
 Gets the screen size in pixels.
 

Protected Member Functions

virtual void SetResourceDirectory (const std::string &path)
 Sets the location of the directory where the game's resources are stored.
 
virtual void SetTargetFramesPerSecond (int const frames)
 Sets the target frame rate for the game.
 
virtual void SetFrameCounterFont (Font *pFont)
 Sets the font for the frame counter.
 
virtual void InitializeScreenManager ()
 Initializes the game's ScreenManager.
 
virtual void DisplayFrameRate ()
 Displays the game's current frame rate.
 
virtual void SetFullScreen (bool isFullScreen)
 Sets the game to display in fullscreen mode.
 
virtual void SetOpenGLFlag ()
 Sets the OpenGL flag, which forces OpenGL rendering.
 
virtual void ResetGameTime ()
 Resets the game's timing values.
 

Static Protected Member Functions

static void SetScreenResolution (int width, int height)
 Sets the screen resolution.
 
static void SetWindowTitle (std::string title)
 Sets the title of the game window.
 

Detailed Description

Base class for all games. Provides graphics initialization, game loop, and rendering code. Inherit from this class when creating your own game.

Definition at line 21 of file Game.h.

Constructor & Destructor Documentation

◆ Game()

KatanaEngine::Game::Game ( )

Definition at line 26 of file Game.cpp.

◆ ~Game()

KatanaEngine::Game::~Game ( )
virtual

Definition at line 59 of file Game.cpp.

Member Function Documentation

◆ DisplayFrameRate()

void KatanaEngine::Game::DisplayFrameRate ( )
protectedvirtual

Displays the game's current frame rate.

Definition at line 195 of file Game.cpp.

◆ Draw()

void KatanaEngine::Game::Draw ( SpriteBatch & spriteBatch)
virtual

Called when the game determines it is time to draw a frame.

Parameters
spriteBatchA reference to the game's sprite batch, used for rendering.

Reimplemented in SpaceFighter.

Definition at line 78 of file Game.cpp.

◆ GetName()

virtual std::string KatanaEngine::Game::GetName ( ) const
pure virtual

Gets the name of the game.

Returns
The name of the game.

Implemented in SpaceFighter.

◆ GetResourceManager()

virtual ResourceManager * KatanaEngine::Game::GetResourceManager ( ) const
inlinevirtual

Gets a pointer to the ResourceManager, for loading and managing resources.

Returns
A pointer to the game's ResourceManager instance.

Definition at line 52 of file Game.h.

◆ GetScreenCenter()

static Vector2 KatanaEngine::Game::GetScreenCenter ( )
inlinestatic

Gets the screen size in pixels.

Returns
A Point representing the width and height of the screen.

Definition at line 44 of file Game.h.

◆ GetScreenHeight()

static int KatanaEngine::Game::GetScreenHeight ( )
inlinestatic

Gets the screen width in pixels.

Returns
The width in pixels.

Definition at line 40 of file Game.h.

◆ GetScreenManager()

virtual ScreenManager * KatanaEngine::Game::GetScreenManager ( ) const
inlinevirtual

Gets a pointer to the ScreenManager, for managing game screens.

Returns
A pointer to the game's ScreenManager instance.

Definition at line 56 of file Game.h.

◆ GetScreenWidth()

static int KatanaEngine::Game::GetScreenWidth ( )
inlinestatic

Gets the screen width in pixels.

Returns
The width in pixels.

Definition at line 36 of file Game.h.

◆ GetSpriteBatch()

virtual SpriteBatch * KatanaEngine::Game::GetSpriteBatch ( ) const
inlinevirtual

Gets a pointer to the SpriteBatch, for rendering.

Returns
A pointer to the game's SpriteBatch instance.

Definition at line 60 of file Game.h.

◆ InitializeScreenManager()

virtual void KatanaEngine::Game::InitializeScreenManager ( )
inlineprotectedvirtual

Initializes the game's ScreenManager.

Definition at line 108 of file Game.h.

◆ LoadContent()

virtual void KatanaEngine::Game::LoadContent ( ResourceManager & resourceManager)
inlinevirtual

Called when resources need to be loaded.

Parameters
resourceManagerA reference to the game's resource manager, used for loading and managing game assets (resources).

Reimplemented in SpaceFighter.

Definition at line 65 of file Game.h.

◆ Quit()

virtual void KatanaEngine::Game::Quit ( )
inlinevirtual

Quits the game.

Definition at line 80 of file Game.h.

◆ ResetGameTime()

virtual void KatanaEngine::Game::ResetGameTime ( )
inlineprotectedvirtual

Resets the game's timing values.

Definition at line 120 of file Game.h.

◆ Run()

int KatanaEngine::Game::Run ( )
virtual

Runs the game instance.

Returns
Error code for exit status.

Definition at line 86 of file Game.cpp.

◆ SetFrameCounterFont()

virtual void KatanaEngine::Game::SetFrameCounterFont ( Font * pFont)
inlineprotectedvirtual

Sets the font for the frame counter.

Parameters
pFontA pointer to the font.

Definition at line 105 of file Game.h.

◆ SetFullScreen()

virtual void KatanaEngine::Game::SetFullScreen ( bool isFullScreen)
inlineprotectedvirtual

Sets the game to display in fullscreen mode.

Definition at line 114 of file Game.h.

◆ SetOpenGLFlag()

virtual void KatanaEngine::Game::SetOpenGLFlag ( )
inlineprotectedvirtual

Sets the OpenGL flag, which forces OpenGL rendering.

Definition at line 117 of file Game.h.

◆ SetResourceDirectory()

virtual void KatanaEngine::Game::SetResourceDirectory ( const std::string & path)
inlineprotectedvirtual

Sets the location of the directory where the game's resources are stored.

Parameters
pathThe relative path to the resource directory.

Definition at line 97 of file Game.h.

◆ SetScreenResolution()

static void KatanaEngine::Game::SetScreenResolution ( int width,
int height )
inlinestaticprotected

Sets the screen resolution.

Parameters
widthThe width of the screen in pixels.
heightThe height of the screen in pixels.

Definition at line 88 of file Game.h.

◆ SetTargetFramesPerSecond()

void KatanaEngine::Game::SetTargetFramesPerSecond ( int const frames)
protectedvirtual

Sets the target frame rate for the game.

Parameters
framesThe target number of frames per second.

Definition at line 243 of file Game.cpp.

◆ SetWindowTitle()

static void KatanaEngine::Game::SetWindowTitle ( std::string title)
inlinestaticprotected

Sets the title of the game window.

Parameters
titleThe window title.
Remarks
If the window title is not set, the game's name will be displayed in the title.

Definition at line 93 of file Game.h.

◆ UnloadContent()

virtual void KatanaEngine::Game::UnloadContent ( )
inlinevirtual

Called when resources need to be unloaded. Override this method to unload any game-specific resources.

Definition at line 69 of file Game.h.

◆ Update()

void KatanaEngine::Game::Update ( const GameTime & gameTime)
virtual

Called when the game has determined that game logic needs to be processed.

Parameters
gameTimeA reference to the game time object.

Definition at line 70 of file Game.cpp.


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