Game (Chili Framework)
The Game
class is where you put the code to make the game do the things. The predefined member functions UpdateModel()
and ComposeFrame()
are where you put your game logic and your rendering code, respectively. Game
is composed of the Graphics
object used for drawing and keeps a reference to the MainWindow
object to interface with the Windows system (which includes the keyboard and mouse inputs).
Contents
Members
ComposeFrame
void Game::ComposeFrame()
This is where you draw what is happening in the game's world on the screen so that the player will know what the fuck is going on. Try to avoid putting game logic here, and Chili will try to avoid putting his Möbius dildo up your butt.
UpdateModel
void Game::UpdateModel()
This is where you put the code for updating the game's internal simulated state. Read inputs, move shit, spawn shit, kill shit, it's all good. Just don't put any drawing code here or Chili will fuck you with his Möbius dildo. When you get a little more advanced, you'll want to measure the time between frames so you can step the game simulation forward at proportional rate.
Member variables
gfx
Graphics Game::gfx
The Graphics
object is embedded in Game
. Use it to make pretty drawings.
wnd
MainWindow& Game::gfx
Game
maintains a reference to the MainWindow
object so that you can get keyboard and mouse input (the Keyboard
and Mouse
objects are embedded in MainWindow
) and so that you can access certain Windows functionality (like checking if the window is minimized or displaying a message box).
Game (constructor)
Game::Game( class MainWindow& wnd )
Gets called when the Game
object is created and creates the Graphics
object. Put your initialization code here and it gets executed once at the start of the program. Good deal.
Game (destructor)
Game::~Game()
Gets called when the Game
object is destroyed and destroys the Graphics
object. Put your final dying statements here and they get executed once at the end of the program.