Main Page   Compound List   File List   Compound Members   File Members  

Cgame Class Reference

List of all members.

Public Member Functions

 Cgame (const char *gamename, int new_screen_width, int new_screen_height, int random_number_seed)
int advance (uint32 keys, int32 joystick_x, int32 joystick_y)
 Advance the game one cycle.

void set_pause (bool new_paused)
 Pause or unpause the game.

bool get_pause (void)
 return the current pause status


Private Member Functions

void draw_all (void)
 Draw everything in the view to the screen buffer.


Private Attributes

int width
 The width of the game map in tiles.

int height
 The height of the game map in tiles.

int * map
 The game map. It is allocated and initialized in the constructor.

char name [32]
 The name of the game.

int screen_width
 The width of the screen, and the offscreen buffer.

int screen_height
 The height of the screen, and the offscreen buffer.

bool paused
 Paused games do not advance. They do redraw though.

int view_x
int view_y

Detailed Description

Everything needed for a game that scrolls a map. The map is drawn into an offscreen buffer, and later the visible portion of the buffer is drawn to the screen.

All functionality to run on a machine is provided by the Host API.


Constructor & Destructor Documentation

Cgame::Cgame const char *    new_name,
int    new_screen_width,
int    new_screen_height,
int    new_random_number_seed
 

Create a game sized for the screen.


Member Function Documentation

int Cgame::advance uint32    keys,
int32    joystick_x,
int32    joystick_y
 

Advance the game one cycle.

This performs the normal work to advance the game. It takes the input and updates the world. It then draws the results in an offscreen buffer. The offscreen buffer is copied to the screen at the start of the next cycle. By drawing at a consistent time interval the results appear smooth. Some input latency is added because the results appear one time period after the input is taken, but it is not noticeable.

Parameters:
keys  mask of keys currently pressed for this cycle
joystick_x  current joystick position
joystick_y  current joystick position

void Cgame::draw_all void    [private]
 

Draw everything in the view to the screen buffer.

The model is that the buffer is erased and then everything is drawn. An alternative model is to undraw the objects (by restoring saved pixels) and then drawing all again. The second is faster when the number of objects is small or the background is expensive to raw. The game could be tuned to switch between both, depending on which should be faster.

void Cgame::set_pause bool    new_pause
 

Pause or unpause the game.

The effect from pausing a games is noticeable until the game advances. A paused game ignores the input, and does not advance. It only redraws. A paused game also may display a message that it is paused, or it may display a game menu.


Member Data Documentation

int Cgame::view_x [private]
 

The view's top left is at a fixed point offset from the top left of the screen buffer. The coordinates are 10 * tile, meaning the fraction has a range of ten and represents a portion of a tile. So 25 is halfway in the third tile.


The documentation for this class was generated from the following file:
Generated on Thu Feb 27 13:15:52 2003 for CompatibleGame by doxygen1.3-rc3