Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Game Class Reference

#include </home/clem/local/src/opie/noncore/games/kbill/Game.h>

Inheritance diagram for Game:

Inheritance graph
[legend]
Collaboration diagram for Game:

Collaboration graph
[legend]
List of all members.

Public Member Functions

int RAND (int lb, int ub)
int MAX (int x, int y)
int MIN (int x, int y)
int INTERSECT (int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2)
void setup_level (unsigned int lev)
void start (unsigned int lev)
void quit ()
void update_info ()
void update_score (int action)
void warp_to_level (unsigned int lev)
void button_press (int x, int y)
void button_release (int x, int y)
void update ()
void main (int argc, char **argv)
 Game (SFCave *p, int w, int h, int diff)
virtual ~Game ()
virtual void init ()
virtual void update (int state)
virtual void preDraw (SDL_Surface *)
virtual void draw (SDL_Surface *)
virtual void stateChanged (int from, int to)
void setReplay (bool val)
void handleKeys (SDL_KeyboardEvent &key)
string getGameName ()
int getDifficulty ()
string getGameDifficultyText ()
void setDifficulty (int diff)
void setDifficulty (string diff)
long getScore ()
long getHighScore ()
void increaseScore (long val)
void clearScore ()
bool gotHighScore ()
bool isReplayAvailable ()
TerraingetTerrain ()
PlayergetPlayer ()
void setSeed (int seed)
void loadReplay (string file)
void saveReplay (string file)

Static Public Member Functions

static GamecreateGame (SFCave *p, int w, int h, string game, string difficulty)

Public Attributes

unsigned score
unsigned level
unsigned iteration
Picture logo
int grabbed

Static Public Attributes

static const unsigned short scrwidth = 240
static const unsigned short scrheight = 290
static const int PLAYING = 1
static const int BETWEEN = 2
static const int END = 3
static const int WAITING = 4
static const int DEFAULTC = 0
static const int DOWNC = -1
static const int BUCKETC = -2
static const int ENDGAME = 200
static const int ENTERNAME = 201
static const int HIGHSCORE = 202
static const int SCORE = 203
static const int ENDLEVEL = -1
static const int BILLPOINTS = 5
static const int EMPTY = -2
static const int BUCKET = -1

Protected Attributes

string gameName
int thrustChannel
int difficulty
SFCaveparent
Terrainterrain
Playerplayer
int nrFrames
bool press
int sHeight
int sWidth
long score
long highScore
int currentSeed
list< int > replayList
list< int >::iterator replayIt
bool replay
string replayFile

Private Attributes

int state
int efficiency

Constructor & Destructor Documentation

Game::Game SFCave p,
int  w,
int  h,
int  diff
 

Definition at line 21 of file game.cpp.

References difficulty, parent, player, replay, replayIt, sHeight, sWidth, terrain, and thrustChannel.

Game::~Game  )  [virtual]
 

Definition at line 34 of file game.cpp.

References player, replayList, and terrain.


Member Function Documentation

void Game::button_press int  x,
int  y
 

Definition at line 80 of file Game.cc.

References Monster::AT, BUCKET, BUCKETC, Computer::busy, Monster::cargo, Monster::cels, Monster::clicked(), Bucket::clicked(), Monster::clickedstray(), Network::computers, Horde::dcels, DOWNC, Monster::DYING, grabbed, i, Monster::index, Horde::list, Horde::MAX_BILLS, Monster::OFF, PLAYING, UI::set_cursor(), Monster::state, state, Monster::STRAY, Monster::target_c, update_score(), Monster::x_offset, and Monster::y_offset.

Referenced by Field::mousePressEvent().

void Game::button_release int  x,
int  y
 

Definition at line 115 of file Game.cc.

References Cable::active, Network::base, BUCKET, Network::cables, Monster::cargo, Computer::compatible(), Network::computers, DEFAULTC, Spark::delay(), Cable::delay, EMPTY, grabbed, i, level, Horde::list, Network::ncables, Monster::OFF, Network::off, Library::OFF, Computer::oncomputer(), Cable::onspark(), Computer::os, PLAYING, UI::set_cursor(), Monster::state, state, Network::units, Network::win, and Library::WINGDOWS.

Referenced by Field::mouseReleaseEvent().

void Game::clearScore  )  [inline]
 

Definition at line 37 of file game.h.

References score.

Game * Game::createGame SFCave p,
int  w,
int  h,
string  game,
string  difficulty
[static]
 

Definition at line 317 of file game.cpp.

References g, and setDifficulty().

Referenced by SFCave::SFCave().

void Game::draw SDL_Surface *   )  [virtual]
 

Reimplemented in FlyGame, GatesGame, and SFCaveGame.

Definition at line 174 of file game.cpp.

References FontHandler::draw(), FONT_WHITE_TEXT, FontHandler::FontHeight(), SFCave::getFPS(), SFCave::getState(), highScore, parent, score, SFCave::showFPS(), STATE_CRASHED, Opie::Internal::string(), FontHandler::TextWidth(), and Opie::MM::x.

Referenced by SFCaveGame::draw(), GatesGame::draw(), FlyGame::draw(), and SFCave::handleGameState().

int Game::getDifficulty  )  [inline]
 

Definition at line 29 of file game.h.

References difficulty.

Referenced by SFCave::handleMenuSelect().

string Game::getGameDifficultyText  ) 
 

Definition at line 96 of file game.cpp.

References difficulty, MENU_DIFFICULTY_CUSTOM, MENU_DIFFICULTY_EASY, MENU_DIFFICULTY_HARD, MENU_DIFFICULTY_NORMAL, and Opie::Internal::string().

Referenced by init(), and stateChanged().

string Game::getGameName  )  [inline]
 

Definition at line 28 of file game.h.

References gameName.

Referenced by SFCave::handleMenuSelect(), init(), and stateChanged().

long Game::getHighScore  )  [inline]
 

Definition at line 35 of file game.h.

References highScore.

Referenced by stateChanged().

Player* Game::getPlayer  )  [inline]
 

Definition at line 42 of file game.h.

References player.

Referenced by SFCave::handleMenuSelect().

long Game::getScore  )  [inline]
 

Definition at line 34 of file game.h.

References score.

Terrain* Game::getTerrain  )  [inline]
 

Definition at line 41 of file game.h.

References terrain.

bool Game::gotHighScore  )  [inline]
 

Definition at line 38 of file game.h.

References highScore, and score.

Referenced by stateChanged().

void Game::handleKeys SDL_KeyboardEvent &  key  ) 
 

Definition at line 70 of file game.cpp.

References nrFrames, press, replay, and replayList.

Referenced by SFCave::handleEvents().

void Game::increaseScore long  val  )  [inline]
 

Definition at line 36 of file game.h.

References score.

void Game::init  )  [virtual]
 

Reimplemented in FlyGame, GatesGame, and SFCaveGame.

Definition at line 45 of file game.cpp.

References currentSeed, getGameDifficultyText(), getGameName(), highScore, Terrain::initTerrain(), SFCave::loadSetting(), nrFrames, parent, press, replay, replayIt, replayList, score, setSeed(), Opie::Internal::string(), and terrain.

Referenced by SFCave::handleGameState(), SFCaveGame::init(), GatesGame::init(), FlyGame::init(), and setDifficulty().

int Game::INTERSECT int  x1,
int  y1,
int  w1,
int  h1,
int  x2,
int  y2,
int  w2,
int  h2
 

Definition at line 24 of file Game.cc.

Referenced by Computer::find_stray(), Computer::setup(), and Monster::update_out().

bool Game::isReplayAvailable  )  [inline]
 

Definition at line 39 of file game.h.

References replayList.

Referenced by SFCave::handleMenuSelect().

void Game::loadReplay string  file  ) 
 

Definition at line 271 of file game.cpp.

References currentSeed, data, difficulty, in, parent, printf, replayList, SFCave::setMenuStatusText(), Opie::Internal::string(), and v.

Referenced by SFCave::handleMenuSelect().

void Game::main int  argc,
char **  argv
 

Definition at line 192 of file Game.cc.

References UI::clear(), UI::draw_centered(), UI::graph_init(), UI::initialize(), level, Picture::load(), UI::load_cursors(), Spark::load_pix(), Bucket::load_pix(), Network::load_pix(), Library::load_pix(), Horde::load_pix(), logo, UI::MainLoop(), UI::make_mainwin(), UI::make_windows(), MAX(), NULL, UI::refresh(), UI::set_pausebutton(), start(), state, and WAITING.

Referenced by main().

int Game::MAX int  x,
int  y
 

Definition at line 16 of file Game.cc.

Referenced by Horde::between(), Spark::delay(), main(), and Cable::update().

int Game::MIN int  x,
int  y
 

Definition at line 20 of file Game.cc.

Referenced by Horde::launch(), Horde::max_at_once(), Network::on(), Horde::on(), Network::setup(), and Monster::step_size().

void Game::preDraw SDL_Surface *   )  [virtual]
 

Definition at line 170 of file game.cpp.

Referenced by SFCaveGame::draw(), GatesGame::draw(), and FlyGame::draw().

void Game::quit  ) 
 

Definition at line 48 of file Game.cc.

int Game::RAND int  lb,
int  ub
 

Definition at line 12 of file Game.cc.

Referenced by Computer::determineOS(), Monster::enter(), Monster::get_border(), Horde::launch(), Computer::setup(), Cable::setup(), and Monster::update_in().

void Game::saveReplay string  file  ) 
 

Definition at line 233 of file game.cpp.

References currentSeed, difficulty, out, parent, printf, replayList, SFCave::setMenuStatusText(), Opie::Internal::string(), and val.

Referenced by SFCave::handleMenuSelect().

void Game::setDifficulty string  diff  ) 
 

Definition at line 112 of file game.cpp.

References difficulty, init(), MENU_DIFFICULTY_CUSTOM, MENU_DIFFICULTY_EASY, MENU_DIFFICULTY_HARD, and MENU_DIFFICULTY_NORMAL.

void Game::setDifficulty int  diff  ) 
 

Definition at line 126 of file game.cpp.

References difficulty, and init().

Referenced by createGame(), and SFCave::handleMenuSelect().

void Game::setReplay bool  val  )  [inline]
 

Definition at line 25 of file game.h.

References replay.

Referenced by SFCave::handleGameState().

void Game::setSeed int  seed  ) 
 

Definition at line 224 of file game.cpp.

References currentSeed, NULL, and PutSeed().

Referenced by init(), and SFCave::SFCave().

void Game::setup_level unsigned int  lev  ) 
 

Definition at line 31 of file Game.cc.

References DEFAULTC, efficiency, EMPTY, grabbed, iteration, level, UI::set_cursor(), Network::setup(), and Horde::setup().

Referenced by start(), update(), and warp_to_level().

void Game::start unsigned int  lev  ) 
 

Definition at line 40 of file Game.cc.

References PLAYING, UI::restart_timer(), score, UI::set_pausebutton(), setup_level(), and state.

Referenced by main(), KBill::NewGame(), and warp_to_level().

void Game::stateChanged int  from,
int  to
[virtual]
 

Definition at line 205 of file game.cpp.

References getGameDifficultyText(), getGameName(), getHighScore(), gotHighScore(), parent, SoundHandler::playSound(), printf, SFCave::saveSetting(), SND_EXPLOSION, STATE_CRASHING, SoundHandler::stopSound(), and Opie::Internal::string().

Referenced by SFCave::changeState().

void Game::update int  state  )  [virtual]
 

Reimplemented in FlyGame, GatesGame, and SFCaveGame.

Definition at line 132 of file game.cpp.

References SFCave::changeState(), highScore, nrFrames, parent, player, SoundHandler::playSound(), press, replay, replayIt, replayList, score, SND_THRUST, STATE_CRASHED, STATE_CRASHING, STATE_PLAYING, SoundHandler::stopSound(), thrustChannel, and Player::updateCrashing().

void Game::update  ) 
 

Definition at line 150 of file Game.cc.

References Network::base, BETWEEN, UI::clear(), Horde::draw(), Network::draw(), Bucket::draw(), UI::draw_centered(), END, ENDGAME, ENDLEVEL, HIGHSCORE, iteration, UI::kill_timer(), level, logo, Network::off, Horde::off_screen, Horde::on_screen, PLAYING, UI::popup_dialog(), UI::refresh(), SCORE, score, UI::set_pausebutton(), setup_level(), state, Network::toasters(), Horde::update(), Network::update(), update_info(), update_score(), UI::update_scorebox(), and WAITING.

Referenced by SFCave::handleGameState(), Field::Timer(), SFCaveGame::update(), GatesGame::update(), and FlyGame::update().

void Game::update_info  ) 
 

Definition at line 53 of file Game.cc.

References Network::base, UI::draw_str(), efficiency, level, Network::off, Horde::off_screen, Horde::on_screen, score, scrheight, str, Network::units, and Network::win.

Referenced by update().

void Game::update_score int  action  ) 
 

Definition at line 62 of file Game.cc.

References BILLPOINTS, efficiency, ENDLEVEL, iteration, level, and score.

Referenced by button_press(), and update().

void Game::warp_to_level unsigned int  lev  ) 
 

Definition at line 69 of file Game.cc.

References level, PLAYING, setup_level(), start(), and state.


Member Data Documentation

const int Game::BETWEEN = 2 [static]
 

Definition at line 18 of file Game.h.

Referenced by update().

const int Game::BILLPOINTS = 5 [static]
 

Definition at line 32 of file Game.h.

Referenced by update_score().

const int Game::BUCKET = -1 [static]
 

Definition at line 35 of file Game.h.

Referenced by button_press(), button_release(), and Bucket::draw().

const int Game::BUCKETC = -2 [static]
 

Definition at line 24 of file Game.h.

Referenced by button_press(), and UI::set_cursor().

int Game::currentSeed [protected]
 

Definition at line 71 of file game.h.

Referenced by init(), loadReplay(), saveReplay(), and setSeed().

const int Game::DEFAULTC = 0 [static]
 

Definition at line 22 of file Game.h.

Referenced by button_release(), UI::set_cursor(), and setup_level().

int Game::difficulty [protected]
 

Definition at line 55 of file game.h.

Referenced by FlyGame::FlyGame(), Game(), GatesGame::GatesGame(), getDifficulty(), getGameDifficultyText(), SFCaveGame::init(), GatesGame::init(), FlyGame::init(), loadReplay(), saveReplay(), setDifficulty(), and SFCaveGame::SFCaveGame().

const int Game::DOWNC = -1 [static]
 

Definition at line 23 of file Game.h.

Referenced by button_press(), and UI::set_cursor().

int Game::efficiency [private]
 

Definition at line 8 of file Game.h.

Referenced by setup_level(), update_info(), and update_score().

const int Game::EMPTY = -2 [static]
 

Definition at line 34 of file Game.h.

Referenced by button_release(), and setup_level().

const int Game::END = 3 [static]
 

Definition at line 19 of file Game.h.

Referenced by update().

const int Game::ENDGAME = 200 [static]
 

Definition at line 26 of file Game.h.

Referenced by UI::popup_dialog(), and update().

const int Game::ENDLEVEL = -1 [static]
 

Definition at line 31 of file Game.h.

Referenced by update(), and update_score().

const int Game::ENTERNAME = 201 [static]
 

Definition at line 27 of file Game.h.

Referenced by UI::popup_dialog().

string Game::gameName [protected]
 

Definition at line 51 of file game.h.

Referenced by FlyGame::FlyGame(), GatesGame::GatesGame(), getGameName(), and SFCaveGame::SFCaveGame().

int Game::grabbed
 

Definition at line 12 of file Game.h.

Referenced by button_press(), button_release(), Bucket::draw(), Monster::draw_stray(), and setup_level().

long Game::highScore [protected]
 

Definition at line 68 of file game.h.

Referenced by draw(), FlyGame::FlyGame(), GatesGame::GatesGame(), getHighScore(), gotHighScore(), init(), SFCaveGame::SFCaveGame(), and update().

const int Game::HIGHSCORE = 202 [static]
 

Definition at line 28 of file Game.h.

Referenced by UI::popup_dialog(), and update().

unsigned Game::iteration
 

Definition at line 10 of file Game.h.

Referenced by setup_level(), Horde::update(), update(), and update_score().

unsigned Game::level
 

Definition at line 10 of file Game.h.

Referenced by button_release(), main(), Monster::move(), Network::setup(), Horde::setup(), Cable::setup(), setup_level(), Horde::update(), update(), Cable::update(), update_info(), update_score(), and warp_to_level().

Picture Game::logo
 

Definition at line 11 of file Game.h.

Referenced by main(), and update().

int Game::nrFrames [protected]
 

Definition at line 61 of file game.h.

Referenced by handleKeys(), init(), SFCaveGame::update(), GatesGame::update(), FlyGame::update(), and update().

SFCave* Game::parent [protected]
 

Definition at line 57 of file game.h.

Referenced by SFCaveGame::draw(), GatesGame::draw(), draw(), Game(), SFCaveGame::init(), GatesGame::init(), FlyGame::init(), init(), loadReplay(), saveReplay(), stateChanged(), SFCaveGame::update(), GatesGame::update(), FlyGame::update(), and update().

Player* Game::player [protected]
 

Definition at line 59 of file game.h.

Referenced by SFCaveGame::checkCollisions(), GatesGame::checkCollisions(), FlyGame::checkCollisions(), SFCaveGame::draw(), GatesGame::draw(), FlyGame::draw(), FlyGame::FlyGame(), Game(), GatesGame::GatesGame(), getPlayer(), SFCaveGame::init(), GatesGame::init(), FlyGame::init(), SFCaveGame::SFCaveGame(), SFCaveGame::update(), GatesGame::update(), FlyGame::update(), update(), and ~Game().

const int Game::PLAYING = 1 [static]
 

Definition at line 17 of file Game.h.

Referenced by button_press(), button_release(), start(), update(), and warp_to_level().

bool Game::press [protected]
 

Definition at line 63 of file game.h.

Referenced by handleKeys(), init(), SFCaveGame::update(), GatesGame::update(), FlyGame::update(), and update().

bool Game::replay [protected]
 

Definition at line 75 of file game.h.

Referenced by Game(), handleKeys(), init(), setReplay(), and update().

string Game::replayFile [protected]
 

Definition at line 76 of file game.h.

list<int>::iterator Game::replayIt [protected]
 

Definition at line 74 of file game.h.

Referenced by Game(), init(), and update().

list<int> Game::replayList [protected]
 

Definition at line 73 of file game.h.

Referenced by handleKeys(), init(), isReplayAvailable(), loadReplay(), saveReplay(), update(), and ~Game().

long Game::score [protected]
 

Definition at line 67 of file game.h.

const int Game::SCORE = 203 [static]
 

Definition at line 29 of file Game.h.

Referenced by UI::popup_dialog(), and update().

unsigned Game::score
 

Definition at line 10 of file Game.h.

Referenced by clearScore(), draw(), getScore(), gotHighScore(), increaseScore(), init(), start(), SFCaveGame::update(), GatesGame::update(), FlyGame::update(), update(), update_info(), and update_score().

const unsigned short Game::scrheight = 290 [static]
 

Definition at line 15 of file Game.h.

Referenced by Field::Field(), Monster::get_border(), UI::graph_init(), Computer::setup(), update_info(), and Monster::update_out().

const unsigned short Game::scrwidth = 240 [static]
 

Definition at line 14 of file Game.h.

Referenced by Field::Field(), Monster::get_border(), UI::graph_init(), Computer::setup(), and Monster::update_out().

int Game::sHeight [protected]
 

Definition at line 65 of file game.h.

Referenced by Game(), and SFCaveGame::update().

int Game::state [private]
 

Definition at line 7 of file Game.h.

Referenced by button_press(), button_release(), main(), start(), update(), and warp_to_level().

int Game::sWidth [protected]
 

Definition at line 66 of file game.h.

Referenced by SFCaveGame::addBlock(), GatesGame::addGate(), and Game().

Terrain* Game::terrain [protected]
 

Definition at line 58 of file game.h.

Referenced by SFCaveGame::addBlock(), GatesGame::addGate(), SFCaveGame::checkCollisions(), GatesGame::checkCollisions(), FlyGame::checkCollisions(), SFCaveGame::draw(), GatesGame::draw(), FlyGame::draw(), FlyGame::FlyGame(), Game(), GatesGame::GatesGame(), getTerrain(), init(), SFCaveGame::SFCaveGame(), SFCaveGame::update(), GatesGame::update(), FlyGame::update(), and ~Game().

int Game::thrustChannel [protected]
 

Definition at line 53 of file game.h.

Referenced by Game(), and update().

const int Game::WAITING = 4 [static]
 

Definition at line 20 of file Game.h.

Referenced by main(), and update().


The documentation for this class was generated from the following files:
Generated on Sat Nov 5 17:33:35 2005 for OPIE by  doxygen 1.4.2