Main Page | Namespace List | Class Hierarchy | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages

CGame Class Reference

#include <cgame.h>

Inheritance diagram for CGame:

Inheritance graph
[legend]
Collaboration diagram for CGame:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void run ()
void quit ()
CFontget_font_large ()
CFontget_font_small ()

Static Public Member Functions

void init (CSystemFactorySet *driver)
void deinit ()
CGameget_instance ()

Public Attributes

std::list< ITickable * > tickables
CFPSTimer timer

Protected Member Functions

virtual void do_draw (CSurface &surface, CRect &rect)
virtual void add_dirty_rect (const CRect &r)

Private Member Functions

virtual int do_handle_event (CEvent &event)

Detailed Description

This is a singleton class that represents the game application. It is the main object that orchestrates the processes of the game; sets up the display, draws frames, etc...

Definition at line 88 of file cgame.h.


Member Function Documentation

virtual void CGame::add_dirty_rect const CRect r  )  [inline, protected, virtual]
 

Add the given "dirty" rectangle to our list of rectangles to redraw.

Reimplemented from CComponent.

Definition at line 128 of file cgame.h.

void CGame::deinit  )  [static]
 

Static singleton deinitializer, to be called once at the end of program execution.

Definition at line 160 of file cgame.cpp.

void CGame::do_draw CSurface surface,
CRect rect
[protected, virtual]
 

Draws a black background rectangle in the given rectangle, so that when there's a dirty rectangle on the screen that needs to be redrawn, it is first overwritten by the background.

Todo:
Remove this method eventually; if the client wants a background color, they can just add a screen-sized CColoredPanel to the back of the CGame panel.

Reimplemented from CComponent.

Definition at line 37 of file cgame.cpp.

References CSurface::fill_rect().

Here is the call graph for this function:

int CGame::do_handle_event CEvent event  )  [private, virtual]
 

Template event handling method for the component. This is the method that does the event handling; the CComponent::handle_event() method mostly does some "housekeeping" tasks and then calls this method.

Reimplemented from CComponent.

Definition at line 59 of file cgame.cpp.

References CScreen::get_fullscreen_mode(), CSingletonManager< CVideoSystem >::get_instance(), CEvent::get_key_ascii_value(), CVideoSystem::get_screen(), CEvent::get_type(), CEvent::is_ctrl_pressed(), quit(), CScreen::set_fullscreen_mode(), CEvent::TYPE_APPLICATION_EXIT, and CEvent::TYPE_KEY_DOWN.

Here is the call graph for this function:

CFont* CGame::get_font_large  )  [inline]
 

Return the large font.

Todo:
This doesn't belong here. Implement a flyweight-pool based singleton as a resource manager or something.

Definition at line 148 of file cgame.h.

CFont* CGame::get_font_small  )  [inline]
 

Return the small font. See CGame::get_font_large() for more notes.

Definition at line 151 of file cgame.h.

CGame& CGame::get_instance  )  [inline, static]
 

Returns the singleton instance.

Definition at line 162 of file cgame.h.

void CGame::init CSystemFactorySet driver  )  [static]
 

Static singleton initializer, to be called once at the beginning of program execution.

Definition at line 155 of file cgame.cpp.

void CGame::quit  ) 
 

Tell the game to quit after it finishes drawing the current frame.

Definition at line 25 of file cgame.cpp.

void CGame::run  ) 
 

Run the game.

Definition at line 90 of file cgame.cpp.

References CSingletonManager< CEventSystem >::get_instance(), CEventSystem::get_next_event(), CFPSTimer::get_time_passed(), CPanel::handle_event(), CFPSTimer::restart(), tickables, timer, and CFPSTimer::update().

Here is the call graph for this function:


Member Data Documentation

std::list<ITickable *> CGame::tickables
 

The list of tickables that the game processes every frame.

Todo:
Encapsulate this as a private member...?

Definition at line 133 of file cgame.h.

CFPSTimer CGame::timer
 

The frames-per-second timer, as well as the game's general timer.

Definition at line 137 of file cgame.h.


The documentation for this class was generated from the following files:
Generated on Wed Aug 27 11:58:54 2003 for GFW by doxygen 1.3.3