Difference between revisions of "Game (Chili Framework)"

From Chilipedia
Jump to: navigation, search
Line 2: Line 2:
  
 
== Members ==
 
== Members ==
 +
 +
=== ComposeFrame ===
 +
 +
<code>void Game::ComposeFrame()</code><br />
 +
 +
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 ===
 +
 +
<code>void Game::UpdateModel()</code><br />
 +
 +
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 ====
 +
<code>Graphics Game::gfx</code><br />
 +
 +
The <code>Graphics</code> object is embedded in <code>Game</code>. Use it to make pretty drawings.
 +
 +
==== wnd ====
 +
<code>MainWindow& Game::gfx</code><br />
 +
 +
<code>Game</code> maintains a reference to the <code>MainWindow</code> object so that you can get keyboard and mouse input (the <code>Keyboard</code> and <code>Mouse</code> objects are embedded in <code>MainWindow</code>) and so that you can access certain Windows functionality (like checking if the window is minimized or displaying a message box).
  
 
=== Game (constructor) ===
 
=== Game (constructor) ===
Line 7: Line 31:
 
<code>Game::Game( class MainWindow& wnd )</code><br />
 
<code>Game::Game( class MainWindow& wnd )</code><br />
  
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.
+
Gets called when the <code>Game</code> object is created and creates the <code>Graphics</code> object. Put your initialization code here and it gets executed once at the start of the program. Good deal.
 +
 
 +
=== Game (destructor) ===
 +
 
 +
<code>Game::~Game()</code><br />
 +
 
 +
Gets called when the <code>Game</code> object is destroyed and destroys the <code>Graphics</code> object. Put your final dying statements here and they get executed once at the end of the program.

Revision as of 13:40, 13 July 2016

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

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.