Commit 4da24843 authored by alistert's avatar alistert

Doxygenated comments.

parent 1738194a
/* /**
* *
* OpenJazz.h * @file OpenJazz.h
* *
* Part of the OpenJazz project
*
* @section History
* 23rd August 2005: Created OpenJazz.h * 23rd August 2005: Created OpenJazz.h
* 31st January 2006: Created level.h from parts of OpenJazz.h * 31st January 2006: Created level.h from parts of OpenJazz.h
* 31st January 2006: Created player.h from parts of OpenJazz.h * 31st January 2006: Created player.h from parts of OpenJazz.h
...@@ -18,11 +21,9 @@ ...@@ -18,11 +21,9 @@
* 30th April 2010: Created util.h from parts of OpenJazz.h * 30th April 2010: Created util.h from parts of OpenJazz.h
* 30th April 2010: Created loop.h from parts of OpenJazz.h * 30th April 2010: Created loop.h from parts of OpenJazz.h
* *
* Part of the OpenJazz project * @section Licence
* * Copyright (c) 2005-2010 Alister Thomson
* *
* Copyright (c) 2005-2010 Alister Thomson
*
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0 * the GNU General Public License, version 2.0
* *
......
/* /**
* *
* baselevel.cpp * @file baselevel.cpp
*
* 30th March 2010: Created baselevel.cpp from parts of level.cpp and
* levelframe.cpp
* *
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* @section History
* 30th March 2010: Created baselevel.cpp from parts of level.cpp and
* levelframe.cpp
* *
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -18,9 +19,7 @@ ...@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Deals with functionality common to ordinary levels and bonus levels. * Deals with functionality common to ordinary levels and bonus levels.
* *
*/ */
...@@ -40,6 +39,9 @@ ...@@ -40,6 +39,9 @@
#include "loop.h" #include "loop.h"
/**
* Create a new base level
*/
BaseLevel::BaseLevel () { BaseLevel::BaseLevel () {
// Arbitrary initial value // Arbitrary initial value
...@@ -59,6 +61,9 @@ BaseLevel::BaseLevel () { ...@@ -59,6 +61,9 @@ BaseLevel::BaseLevel () {
} }
/**
* Destroy base level
*/
BaseLevel::~BaseLevel () { BaseLevel::~BaseLevel () {
stopMusic(); stopMusic();
...@@ -70,6 +75,13 @@ BaseLevel::~BaseLevel () { ...@@ -70,6 +75,13 @@ BaseLevel::~BaseLevel () {
} }
/**
* Play a cutscene.
*
* @param file File name of the cutscene to be played
*
* @return Error code
*/
int BaseLevel::playScene (char* file) { int BaseLevel::playScene (char* file) {
Scene* scene; Scene* scene;
...@@ -97,6 +109,9 @@ int BaseLevel::playScene (char* file) { ...@@ -97,6 +109,9 @@ int BaseLevel::playScene (char* file) {
} }
/**
* Perform timing calculations.
*/
void BaseLevel::timeCalcs () { void BaseLevel::timeCalcs () {
// Calculate smoothed fps // Calculate smoothed fps
...@@ -142,6 +157,11 @@ void BaseLevel::timeCalcs () { ...@@ -142,6 +157,11 @@ void BaseLevel::timeCalcs () {
} }
/**
* Display on-screen statistics.
*
* @param bg Palette index of the statistics box(es)
*/
void BaseLevel::drawStats (unsigned char bg) { void BaseLevel::drawStats (unsigned char bg) {
int count, width; int count, width;
...@@ -205,6 +225,15 @@ void BaseLevel::drawStats (unsigned char bg) { ...@@ -205,6 +225,15 @@ void BaseLevel::drawStats (unsigned char bg) {
} }
/**
* Process iteration.
*
* @param menu Whether or not the level menu should be displayed
* @param option Selected menu uption
* @param message Whether or not the "paused" message is being displayed
*
* @return Error code
*/
int BaseLevel::loop (bool& menu, int& option, bool& message) { int BaseLevel::loop (bool& menu, int& option, bool& message) {
int ret; int ret;
...@@ -311,6 +340,9 @@ int BaseLevel::loop (bool& menu, int& option, bool& message) { ...@@ -311,6 +340,9 @@ int BaseLevel::loop (bool& menu, int& option, bool& message) {
} }
/**
* Add extra time.
*/
void BaseLevel::addTimer () { void BaseLevel::addTimer () {
unsigned char buffer[MTL_L_PROP]; unsigned char buffer[MTL_L_PROP];
...@@ -336,6 +368,11 @@ void BaseLevel::addTimer () { ...@@ -336,6 +368,11 @@ void BaseLevel::addTimer () {
} }
/**
* Set the level stage.
*
* @param newStage New level stage
*/
void BaseLevel::setStage (LevelStage newStage) { void BaseLevel::setStage (LevelStage newStage) {
unsigned char buffer[MTL_L_STAGE]; unsigned char buffer[MTL_L_STAGE];
...@@ -358,6 +395,11 @@ void BaseLevel::setStage (LevelStage newStage) { ...@@ -358,6 +395,11 @@ void BaseLevel::setStage (LevelStage newStage) {
} }
/**
* Determine the current level stage.
*
* @return The current level stage.
*/
LevelStage BaseLevel::getStage () { LevelStage BaseLevel::getStage () {
return stage; return stage;
......
/* /**
* *
* baselevel.h * @file baselevel.h
*
* 30th March 2010: Created baselevel.h from parts of level.h
* *
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* @section History
* 30th March 2010: Created baselevel.h from parts of level.h
* *
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -39,18 +40,21 @@ ...@@ -39,18 +40,21 @@
// Enums // Enums
/// Level type
enum LevelType { enum LevelType {
LT_LEVEL, LT_BONUS, LT_JJ2LEVEL LT_LEVEL, LT_BONUS, LT_JJ2LEVEL
}; };
/// Which stats to display on-screen
enum LevelStats { enum LevelStats {
S_PLAYERS = 1, S_SCREEN = 2 S_PLAYERS = 1, S_SCREEN = 2
}; };
/// Level stage
enum LevelStage { enum LevelStage {
LS_NORMAL = 0, LS_SUDDENDEATH = 1, LS_END = 2 LS_NORMAL = 0, LS_SUDDENDEATH = 1, LS_END = 2
...@@ -63,23 +67,27 @@ enum LevelStage { ...@@ -63,23 +67,27 @@ enum LevelStage {
class File; class File;
class Sprite; class Sprite;
/// Base class for all level classes
class BaseLevel { class BaseLevel {
private: private:
SetupMenu setupMenu; SetupMenu setupMenu; ///< Setup menu to run on the player's command
protected: protected:
PaletteEffect* paletteEffects; PaletteEffect* paletteEffects; ///< Palette effects in use while playing the level
SDL_Color palette[256]; SDL_Color palette[256]; ///< Palette in use while playing the level
int sprites; int sprites; ///< The number of sprite that have been loaded
unsigned int tickOffset, prevStepTicks, prevTicks, ticks; unsigned int tickOffset; ///< Level time offset from system time
unsigned int endTime; unsigned int prevStepTicks; ///< Time the last step started
float smoothfps; unsigned int prevTicks; ///< Time the last visual update started
int items; unsigned int ticks; ///< Current time
bool multiplayer; unsigned int endTime; ///< Tick at which the level will end
bool paused; float smoothfps; ///< Smoothed FPS counter
LevelStage stage; int items; ///< Number of items to be collected
int stats; bool multiplayer; ///< Whether or not this is a multiplayer game
bool paused; ///< Whether or not the level is paused
LevelStage stage; ///< Level stage
int stats; ///< Which statistics to display on-screen, see #LevelStats
int playScene (char* file); int playScene (char* file);
void timeCalcs (); void timeCalcs ();
...@@ -100,8 +108,8 @@ class BaseLevel { ...@@ -100,8 +108,8 @@ class BaseLevel {
// Variables // Variables
EXTERN BaseLevel* baseLevel; EXTERN BaseLevel* baseLevel; ///< Current level
EXTERN fixed viewX, viewY; EXTERN fixed viewX, viewY; ///< Level viewing co-ordinates
#endif #endif
/* /**
* *
* bonus.cpp * @file bonus.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 23rd August 2005: Created bonus.c * 23rd August 2005: Created bonus.c
* 3rd February 2009: Renamed bonus.c to bonus.cpp * 3rd February 2009: Renamed bonus.c to bonus.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -18,9 +19,7 @@ ...@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Deals with the loading, running and freeing of bonus levels. * Deals with the loading, running and freeing of bonus levels.
* *
*/ */
...@@ -416,10 +415,13 @@ bool Bonus::checkMask (fixed x, fixed y) { ...@@ -416,10 +415,13 @@ bool Bonus::checkMask (fixed x, fixed y) {
} }
/**
* Interpret data received from client/server
*
* @param buffer Received data
*/
void Bonus::receive (unsigned char* buffer) { void Bonus::receive (unsigned char* buffer) {
// Interpret data received from client/server
switch (buffer[1]) { switch (buffer[1]) {
case MT_L_PROP: case MT_L_PROP:
......
/* /**
* *
* bonus.h * @file bonus.h
* *
* Part of the OpenJazz project
*
* @section History
* 3rd February 2009: Created bonus.h * 3rd February 2009: Created bonus.h
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2009-2010 Alister Thomson * Copyright (c) 2009-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -42,10 +43,11 @@ ...@@ -42,10 +43,11 @@
// Datatype // Datatype
/// JJ1 bonus level grid element
typedef struct { typedef struct {
unsigned char tile; // Indexes the tile set unsigned char tile; ///< Indexes the tile set
unsigned char event; unsigned char event; ///< Event type
} BonusGridElement; } BonusGridElement;
...@@ -54,17 +56,18 @@ typedef struct { ...@@ -54,17 +56,18 @@ typedef struct {
class Font; class Font;
/// JJ1 bonus level
class Bonus : public BaseLevel { class Bonus : public BaseLevel {
private: private:
SDL_Surface* tileSet; SDL_Surface* tileSet; ///< Tile images
SDL_Surface* background; SDL_Surface* background; ///< Background image
Font* font; Font* font; ///< On-screen message font
Sprite* spriteSet; Sprite* spriteSet; ///< Sprite images
Anim animSet[BANIMS]; Anim animSet[BANIMS]; ///< Animations
BonusGridElement grid[BLH][BLW]; BonusGridElement grid[BLH][BLW]; ///< Level grid
char mask[60][64]; // At most 60 tiles, all with 8 * 8 masks char mask[60][64]; ///< Tile masks (at most 60 tiles, all with 8 * 8 masks)
fixed direction; fixed direction; ///< Player's direction
int loadSprites (); int loadSprites ();
int loadTiles (char* fileName); int loadTiles (char* fileName);
......
/* /**
* *
* clientgame.cpp * @file clientgame.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 18th July 2009: Created clientgame.cpp from parts of game.cpp * 18th July 2009: Created clientgame.cpp from parts of game.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -38,6 +39,11 @@ ...@@ -38,6 +39,11 @@
#include <string.h> #include <string.h>
/**
* Create game client
*
* @param address Address of the server to which to connect
*/
ClientGame::ClientGame (char* address) { ClientGame::ClientGame (char* address) {
unsigned char buffer[BUFFER_LENGTH]; unsigned char buffer[BUFFER_LENGTH];
...@@ -229,6 +235,9 @@ ClientGame::ClientGame (char* address) { ...@@ -229,6 +235,9 @@ ClientGame::ClientGame (char* address) {
} }
/**
* Disconnect and destroy client
*/
ClientGame::~ClientGame () { ClientGame::~ClientGame () {
net->close(sock); net->close(sock);
...@@ -242,6 +251,13 @@ ClientGame::~ClientGame () { ...@@ -242,6 +251,13 @@ ClientGame::~ClientGame () {
} }
/**
* Set the next level and receive level data from server
*
* @param fileName The file name of the next level
*
* @return Error code
*/
int ClientGame::setLevel (char* fileName) { int ClientGame::setLevel (char* fileName) {
int ret; int ret;
...@@ -291,6 +307,11 @@ int ClientGame::setLevel (char* fileName) { ...@@ -291,6 +307,11 @@ int ClientGame::setLevel (char* fileName) {
} }
/**
* Send data to server
*
* @param buffer Data to send. First byte indicates length.
*/
void ClientGame::send (unsigned char* buffer) { void ClientGame::send (unsigned char* buffer) {
net->send(sock, buffer); net->send(sock, buffer);
...@@ -300,6 +321,13 @@ void ClientGame::send (unsigned char* buffer) { ...@@ -300,6 +321,13 @@ void ClientGame::send (unsigned char* buffer) {
} }
/**
* Game iteration
*
* @param ticks Current time
*
* @return Error code
*/
int ClientGame::step (unsigned int ticks) { int ClientGame::step (unsigned int ticks) {
unsigned char sendBuffer[BUFFER_LENGTH]; unsigned char sendBuffer[BUFFER_LENGTH];
...@@ -505,6 +533,11 @@ int ClientGame::step (unsigned int ticks) { ...@@ -505,6 +533,11 @@ int ClientGame::step (unsigned int ticks) {
} }
/**
* Ask server to award team a point
*
* @param team Team to receive point
*/
void ClientGame::score (unsigned char team) { void ClientGame::score (unsigned char team) {
unsigned char buffer[MTL_G_SCORE]; unsigned char buffer[MTL_G_SCORE];
...@@ -520,19 +553,21 @@ void ClientGame::score (unsigned char team) { ...@@ -520,19 +553,21 @@ void ClientGame::score (unsigned char team) {
} }
/**
* Ask server to approve new checkpoint
*
* @param gridX X-coordinate (in tiles) of the checkpoint
* @param gridY Y-coordinate (in tiles) of the checkpoint
*/
void ClientGame::setCheckpoint (unsigned char gridX, unsigned char gridY) { void ClientGame::setCheckpoint (unsigned char gridX, unsigned char gridY) {
unsigned char buffer[MTL_G_CHECK]; unsigned char buffer[MTL_G_CHECK];
if (mode) { buffer[0] = MTL_G_CHECK;
buffer[1] = MT_G_CHECK;
buffer[0] = MTL_G_CHECK; buffer[2] = gridX;
buffer[1] = MT_G_CHECK; buffer[3] = gridY;
buffer[2] = gridX; send(buffer);
buffer[3] = gridY;
send(buffer);
}
return; return;
......
/* /**
* *
* game.cpp * @file game.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 9th March 2009: Created game.cpp from parts of menu.cpp and level.cpp * 9th March 2009: Created game.cpp from parts of menu.cpp and level.cpp
* 3rd June 2009: Created network.cpp from parts of game.cpp * 3rd June 2009: Created network.cpp from parts of game.cpp
* 18th July 2009: Created servergame.cpp from parts of game.cpp * 18th July 2009: Created servergame.cpp from parts of game.cpp
* 18th July 2009: Created clientgame.cpp from parts of game.cpp * 18th July 2009: Created clientgame.cpp from parts of game.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -41,6 +42,9 @@ ...@@ -41,6 +42,9 @@
#include <string.h> #include <string.h>
/**
* Create base game
*/
Game::Game () { Game::Game () {
levelFile = NULL; levelFile = NULL;
...@@ -52,6 +56,12 @@ Game::Game () { ...@@ -52,6 +56,12 @@ Game::Game () {
} }
/**
* Create a new game
*
* @param firstLevel File name of the first level to play
* @param gameDifficulty Difficulty setting
*/
Game::Game (char *firstLevel, int gameDifficulty) { Game::Game (char *firstLevel, int gameDifficulty) {
levelFile = createString(firstLevel); levelFile = createString(firstLevel);
...@@ -70,6 +80,9 @@ Game::Game (char *firstLevel, int gameDifficulty) { ...@@ -70,6 +80,9 @@ Game::Game (char *firstLevel, int gameDifficulty) {
} }
/**
* Destroy game
*/
Game::~Game () { Game::~Game () {
if (levelFile) delete[] levelFile; if (levelFile) delete[] levelFile;
...@@ -82,6 +95,13 @@ Game::~Game () { ...@@ -82,6 +95,13 @@ Game::~Game () {
} }
/**
* Create a new game mode
*
* @param modeType The mode to create
*
* @return The new game mode (NULL on failure)
*/
GameMode* Game::createMode (GameModeType modeType) { GameMode* Game::createMode (GameModeType modeType) {
switch (modeType) { switch (modeType) {
...@@ -113,6 +133,11 @@ GameMode* Game::createMode (GameModeType modeType) { ...@@ -113,6 +133,11 @@ GameMode* Game::createMode (GameModeType modeType) {
} }
/**
* Get the game's mode
*
* @return The game's mode
*/
GameMode* Game::getMode () { GameMode* Game::getMode () {
return mode; return mode;
...@@ -120,6 +145,13 @@ GameMode* Game::getMode () { ...@@ -120,6 +145,13 @@ GameMode* Game::getMode () {
} }
/**
* Set the next level
*
* @param fileName The file name of the next level
*
* @return Error code
*/
int Game::setLevel (char *fileName) { int Game::setLevel (char *fileName) {
if (levelFile) delete[] levelFile; if (levelFile) delete[] levelFile;
...@@ -132,6 +164,11 @@ int Game::setLevel (char *fileName) { ...@@ -132,6 +164,11 @@ int Game::setLevel (char *fileName) {
} }
/**
* Play the game
*
* @return Error code
*/
int Game::play () { int Game::play () {
Planet* planet; Planet* planet;
...@@ -326,10 +363,13 @@ int Game::play () { ...@@ -326,10 +363,13 @@ int Game::play () {
} }
/**
* Move the viewport towards the exit sign
*
* @param change Distance to move
*/
void Game::view (int change) { void Game::view (int change) {
// Move the viewport towards the exit sign
if (TTOF(checkX) > viewX + (canvasW << 9) + change) viewX += change; if (TTOF(checkX) > viewX + (canvasW << 9) + change) viewX += change;
else if (TTOF(checkX) < viewX + (canvasW << 9) - change) viewX -= change; else if (TTOF(checkX) < viewX + (canvasW << 9) - change) viewX -= change;
...@@ -341,6 +381,11 @@ void Game::view (int change) { ...@@ -341,6 +381,11 @@ void Game::view (int change) {
} }
/**
* No data is sent in single-player mode
*
* @param buffer Data that will not be sent. First byte indicates length.
*/
void Game::send (unsigned char *buffer) { void Game::send (unsigned char *buffer) {
// Do nothing // Do nothing
...@@ -350,6 +395,13 @@ void Game::send (unsigned char *buffer) { ...@@ -350,6 +395,13 @@ void Game::send (unsigned char *buffer) {
} }
/**
* Game iteration
*
* @param ticks Current time
*
* @return Error code
*/
int Game::step (unsigned int ticks) { int Game::step (unsigned int ticks) {
// Do nothing // Do nothing
...@@ -359,6 +411,11 @@ int Game::step (unsigned int ticks) { ...@@ -359,6 +411,11 @@ int Game::step (unsigned int ticks) {
} }
/**
* Assign point to team
*
* @param team Team to receive point
*/
void Game::score (unsigned char team) { void Game::score (unsigned char team) {
// Do nothing // Do nothing
...@@ -368,6 +425,12 @@ void Game::score (unsigned char team) { ...@@ -368,6 +425,12 @@ void Game::score (unsigned char team) {
} }
/**
* Set the checkpoint
*
* @param gridX X-coordinate (in tiles) of the checkpoint
* @param gridY Y-coordinate (in tiles) of the checkpoint
*/
void Game::setCheckpoint (unsigned char gridX, unsigned char gridY) { void Game::setCheckpoint (unsigned char gridX, unsigned char gridY) {
checkX = gridX; checkX = gridX;
...@@ -378,6 +441,11 @@ void Game::setCheckpoint (unsigned char gridX, unsigned char gridY) { ...@@ -378,6 +441,11 @@ void Game::setCheckpoint (unsigned char gridX, unsigned char gridY) {
} }
/**
* Make a player restart the level from the beginning/last checkpoint
*
* @param player Player to reset
*/
void Game::resetPlayer (Player *player) { void Game::resetPlayer (Player *player) {
player->reset(checkX, checkY); player->reset(checkX, checkY);
...@@ -387,6 +455,13 @@ void Game::resetPlayer (Player *player) { ...@@ -387,6 +455,13 @@ void Game::resetPlayer (Player *player) {
} }
/**
* Re-create a player's level player
*
* @param player Player to reset
* @param levelType Type of level (and, consequently, type of level player)
* @param anims New level player's animations
*/
void Game::resetPlayer (Player *player, LevelType levelType, Anim** anims) { void Game::resetPlayer (Player *player, LevelType levelType, Anim** anims) {
Anim* pAnims[PANIMS]; Anim* pAnims[PANIMS];
......
/* /**
* *
* game.h * @file game.h
* *
* Part of the OpenJazz project
*
* @section History
* 2nd March 2009: Created network.h from parts of OpenJazz.h * 2nd March 2009: Created network.h from parts of OpenJazz.h
* 9th February 2009: Renamed network.h to game.h * 9th February 2009: Renamed network.h to game.h
* 2nd August 2009: Created gamemode.h from parts of game.h * 2nd August 2009: Created gamemode.h from parts of game.h
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -82,15 +83,18 @@ ...@@ -82,15 +83,18 @@
class Anim; class Anim;
class File; class File;
/// Handling for single-player games and base class for multiplayer game handling classes
class Game { class Game {
protected: protected:
GameMode* mode; GameMode* mode; ///< Mode-specific management
char* levelFile; char* levelFile; ///< Current level's file name
int difficulty; int difficulty; ///< Difficulty setting (0 = easy, 1 = medium, 2 = hard, 3 = turbo (hard in JJ2 levels))
unsigned int sendTime, checkTime; unsigned int sendTime; ///< The next time data will be sent
unsigned char checkX, checkY; unsigned int checkTime; ///< The next time a connection/disconnection will be dealt with
unsigned char checkX; ///< X-coordinate of the level checkpoint
unsigned char checkY; ///< Y-coordinate of the level checkpoint
Game (); Game ();
...@@ -113,21 +117,22 @@ class Game { ...@@ -113,21 +117,22 @@ class Game {
}; };
/// Game handling for multiplayer servers
class ServerGame : public Game { class ServerGame : public Game {
private: private:
int clientStatus[MAX_CLIENTS]; /* int clientStatus[MAX_CLIENTS]; /**< Array of client statuses
-2: Connected and operational -2: Connected and operational
-1: Not connected -1: Not connected
>=0: Number of bytes of the level that have been sent */ >=0: Number of bytes of the level that have been sent */
int clientPlayer[MAX_CLIENTS]; int clientPlayer[MAX_CLIENTS]; ///< Array of client player indexes
int clientSock[MAX_CLIENTS]; int clientSock[MAX_CLIENTS]; ///< Array of client sockets
unsigned char recvBuffers[MAX_CLIENTS][BUFFER_LENGTH]; unsigned char recvBuffers[MAX_CLIENTS][BUFFER_LENGTH]; ///< Array of buffers containing data received from clients
int received[MAX_CLIENTS]; int received[MAX_CLIENTS]; ///< Array containing the amount of data received from each client
unsigned char *levelData; unsigned char *levelData; ///< Contents of the current level file
int levelSize; int levelSize; ///< Size of the current level file
int sock; int sock; ///< Server socket
public: public:
ServerGame (GameModeType mode, char *firstLevel, int gameDifficulty); ServerGame (GameModeType mode, char *firstLevel, int gameDifficulty);
...@@ -141,16 +146,17 @@ class ServerGame : public Game { ...@@ -141,16 +146,17 @@ class ServerGame : public Game {
}; };
/// Game handling for multiplayer clients
class ClientGame : public Game { class ClientGame : public Game {
private: private:
File *file; File *file; ///< File to which the incoming level will be written
unsigned char recvBuffer[BUFFER_LENGTH]; unsigned char recvBuffer[BUFFER_LENGTH]; ///< Buffer containing data received from server
int received; int received; ///< Amount of data received from server
int clientID; int clientID; ///< Client's index on the server
int maxPlayers; int maxPlayers; ///< The maximum number of players in the game
int sock; int sock; ///< Client socket
public: public:
ClientGame (char *address); ClientGame (char *address);
...@@ -167,7 +173,7 @@ class ClientGame : public Game { ...@@ -167,7 +173,7 @@ class ClientGame : public Game {
// Variable // Variable
EXTERN Game *game; EXTERN Game *game; ///< Current game
#endif #endif
/* /**
* *
* gamemode.cpp * @file gamemode.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 2nd August 2009: Created gamemode.cpp from parts of servergame.cpp * 2nd August 2009: Created gamemode.cpp from parts of servergame.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -28,6 +29,14 @@ ...@@ -28,6 +29,14 @@
#include "player/levelplayer.h" #include "player/levelplayer.h"
/**
* Outcome of player being hit
*
* @param source Player responsible for the hit
* @param victim Player victim of the hit
*
* @return Whether or not the hit should result in energy loss (true)
*/
bool GameMode::hit (Player *source, Player *victim) { bool GameMode::hit (Player *source, Player *victim) {
return true; return true;
...@@ -35,6 +44,14 @@ bool GameMode::hit (Player *source, Player *victim) { ...@@ -35,6 +44,14 @@ bool GameMode::hit (Player *source, Player *victim) {
} }
/**
* Outcome of player being killed
*
* @param source Player responsible for the kill
* @param victim Player victim of the kill
*
* @return Whether or not the player should be be killed (true)
*/
bool GameMode::kill (Player *source, Player *victim) { bool GameMode::kill (Player *source, Player *victim) {
if (source && (victim == localPlayer)) game->score(source->getTeam()); if (source && (victim == localPlayer)) game->score(source->getTeam());
...@@ -44,6 +61,15 @@ bool GameMode::kill (Player *source, Player *victim) { ...@@ -44,6 +61,15 @@ bool GameMode::kill (Player *source, Player *victim) {
} }
/**
* Outcome of level being completed
*
* @param player Player that has completed level
* @param gridX X-coordinate (in tiles) of finishing position
* @param gridY Y-coordinate (in tiles) of finishing position
*
* @return Whether or not the end-of-level signpost should be destroyed (true)
*/
bool GameMode::endOfLevel (Player *player, unsigned char gridX, unsigned char gridY) { bool GameMode::endOfLevel (Player *player, unsigned char gridX, unsigned char gridY) {
game->setCheckpoint(gridX, gridY); game->setCheckpoint(gridX, gridY);
...@@ -55,6 +81,9 @@ bool GameMode::endOfLevel (Player *player, unsigned char gridX, unsigned char gr ...@@ -55,6 +81,9 @@ bool GameMode::endOfLevel (Player *player, unsigned char gridX, unsigned char gr
} }
/**
* Outcome of time running out
*/
void GameMode::outOfTime () { void GameMode::outOfTime () {
return; return;
...@@ -62,6 +91,11 @@ void GameMode::outOfTime () { ...@@ -62,6 +91,11 @@ void GameMode::outOfTime () {
} }
/**
* Get the game mode type
*
* @return Game mode type (M_SINGLE)
*/
GameModeType SingleGameMode::getMode () { GameModeType SingleGameMode::getMode () {
return M_SINGLE; return M_SINGLE;
...@@ -69,6 +103,11 @@ GameModeType SingleGameMode::getMode () { ...@@ -69,6 +103,11 @@ GameModeType SingleGameMode::getMode () {
} }
/**
* Choose a team for a new player
*
* @return New player's team (0)
*/
unsigned char SingleGameMode::chooseTeam () { unsigned char SingleGameMode::chooseTeam () {
return 0; return 0;
...@@ -76,6 +115,11 @@ unsigned char SingleGameMode::chooseTeam () { ...@@ -76,6 +115,11 @@ unsigned char SingleGameMode::chooseTeam () {
} }
/**
* Draw the player's team's score (not in single-player mode)
*
* @param font Font to use to draw score
*/
void SingleGameMode::drawScore (Font* font) { void SingleGameMode::drawScore (Font* font) {
return; return;
...@@ -83,6 +127,11 @@ void SingleGameMode::drawScore (Font* font) { ...@@ -83,6 +127,11 @@ void SingleGameMode::drawScore (Font* font) {
} }
/**
* Choose a team for a new player
*
* @return New player's team (0)
*/
unsigned char CooperativeGameMode::chooseTeam () { unsigned char CooperativeGameMode::chooseTeam () {
// All players are on the same team // All players are on the same team
...@@ -92,6 +141,11 @@ unsigned char CooperativeGameMode::chooseTeam () { ...@@ -92,6 +141,11 @@ unsigned char CooperativeGameMode::chooseTeam () {
} }
/**
* Draw the player's team's score (not in cooperative mode)
*
* @param font Font to use to draw score
*/
void CooperativeGameMode::drawScore (Font* font) { void CooperativeGameMode::drawScore (Font* font) {
// Do nothing // Do nothing
...@@ -101,6 +155,11 @@ void CooperativeGameMode::drawScore (Font* font) { ...@@ -101,6 +155,11 @@ void CooperativeGameMode::drawScore (Font* font) {
} }
/**
* Choose a team for a new player
*
* @return New player's team (unique)
*/
unsigned char FreeForAllGameMode::chooseTeam () { unsigned char FreeForAllGameMode::chooseTeam () {
// Every player is on a separate team // Every player is on a separate team
...@@ -123,6 +182,11 @@ unsigned char FreeForAllGameMode::chooseTeam () { ...@@ -123,6 +182,11 @@ unsigned char FreeForAllGameMode::chooseTeam () {
} }
/**
* Draw the player's team's score
*
* @param font Font to use to draw score
*/
void FreeForAllGameMode::drawScore (Font* font) { void FreeForAllGameMode::drawScore (Font* font) {
font->showNumber(localPlayer->teamScore, 64, 4); font->showNumber(localPlayer->teamScore, 64, 4);
...@@ -132,6 +196,11 @@ void FreeForAllGameMode::drawScore (Font* font) { ...@@ -132,6 +196,11 @@ void FreeForAllGameMode::drawScore (Font* font) {
} }
/**
* Choose a team for a new player
*
* @return New player's team (0 or 1)
*/
unsigned char TeamGameMode::chooseTeam () { unsigned char TeamGameMode::chooseTeam () {
// Players are split between two teams // Players are split between two teams
...@@ -158,6 +227,11 @@ unsigned char TeamGameMode::chooseTeam () { ...@@ -158,6 +227,11 @@ unsigned char TeamGameMode::chooseTeam () {
} }
/**
* Draw the player's team's score
*
* @param font Font to use to draw score
*/
void TeamGameMode::drawScore (Font* font) { void TeamGameMode::drawScore (Font* font) {
font->showNumber(localPlayer->teamScore, 64, 4); font->showNumber(localPlayer->teamScore, 64, 4);
...@@ -167,6 +241,11 @@ void TeamGameMode::drawScore (Font* font) { ...@@ -167,6 +241,11 @@ void TeamGameMode::drawScore (Font* font) {
} }
/**
* Get the game mode type
*
* @return Game mode type (M_COOP)
*/
GameModeType CoopGameMode::getMode () { GameModeType CoopGameMode::getMode () {
return M_COOP; return M_COOP;
...@@ -174,6 +253,11 @@ GameModeType CoopGameMode::getMode () { ...@@ -174,6 +253,11 @@ GameModeType CoopGameMode::getMode () {
} }
/**
* Get the game mode type
*
* @return Game mode type (M_BATTLE)
*/
GameModeType BattleGameMode::getMode () { GameModeType BattleGameMode::getMode () {
return M_BATTLE; return M_BATTLE;
...@@ -181,6 +265,11 @@ GameModeType BattleGameMode::getMode () { ...@@ -181,6 +265,11 @@ GameModeType BattleGameMode::getMode () {
} }
/**
* Get the game mode type
*
* @return Game mode type (M_TEAMBATTLE)
*/
GameModeType TeamBattleGameMode::getMode () { GameModeType TeamBattleGameMode::getMode () {
return M_TEAMBATTLE; return M_TEAMBATTLE;
...@@ -188,6 +277,11 @@ GameModeType TeamBattleGameMode::getMode () { ...@@ -188,6 +277,11 @@ GameModeType TeamBattleGameMode::getMode () {
} }
/**
* Get the game mode type
*
* @return Game mode type (M_RACE)
*/
GameModeType RaceGameMode::getMode () { GameModeType RaceGameMode::getMode () {
return M_RACE; return M_RACE;
...@@ -195,6 +289,14 @@ GameModeType RaceGameMode::getMode () { ...@@ -195,6 +289,14 @@ GameModeType RaceGameMode::getMode () {
} }
/**
* Outcome of player being hit
*
* @param source Player responsible for the hit
* @param victim Player victim of the hit
*
* @return Whether or not the hit should result in energy loss (false)
*/
bool RaceGameMode::hit (Player *source, Player *victim) { bool RaceGameMode::hit (Player *source, Player *victim) {
return false; return false;
...@@ -202,6 +304,15 @@ bool RaceGameMode::hit (Player *source, Player *victim) { ...@@ -202,6 +304,15 @@ bool RaceGameMode::hit (Player *source, Player *victim) {
} }
/**
* Outcome of level being completed
*
* @param player Player that has completed level
* @param gridX X-coordinate (in tiles) of finishing position
* @param gridY Y-coordinate (in tiles) of finishing position
*
* @return Whether or not the end-of-level signpost should be destroyed (false)
*/
bool RaceGameMode::endOfLevel (Player *player, unsigned char gridX, unsigned char gridY) { bool RaceGameMode::endOfLevel (Player *player, unsigned char gridX, unsigned char gridY) {
if (player == localPlayer) game->score(localPlayer->getTeam()); if (player == localPlayer) game->score(localPlayer->getTeam());
......
/* /**
* *
* gamemode.h * @file gamemode.h
* *
* Part of the OpenJazz project
*
* @section History
* 2nd August 2009: Created gamemode.h from parts of game.h * 2nd August 2009: Created gamemode.h from parts of game.h
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -34,6 +35,7 @@ ...@@ -34,6 +35,7 @@
// Enum // Enum
/// Game mode identifier
enum GameModeType { enum GameModeType {
M_SINGLE = 0, M_COOP = 1, M_BATTLE = 2, M_TEAMBATTLE = 3, M_RACE = 4 M_SINGLE = 0, M_COOP = 1, M_BATTLE = 2, M_TEAMBATTLE = 3, M_RACE = 4
...@@ -45,7 +47,8 @@ enum GameModeType { ...@@ -45,7 +47,8 @@ enum GameModeType {
class Font; class Font;
class Player; class Player;
/// Game mode base class
class GameMode { class GameMode {
public: public:
...@@ -58,7 +61,8 @@ class GameMode { ...@@ -58,7 +61,8 @@ class GameMode {
virtual void outOfTime (); virtual void outOfTime ();
}; };
/// Single-player game mode
class SingleGameMode : public GameMode { class SingleGameMode : public GameMode {
public: public:
...@@ -68,6 +72,7 @@ class SingleGameMode : public GameMode { ...@@ -68,6 +72,7 @@ class SingleGameMode : public GameMode {
}; };
/// Co-operative game mode base class
class CooperativeGameMode : public GameMode { class CooperativeGameMode : public GameMode {
public: public:
...@@ -76,6 +81,7 @@ class CooperativeGameMode : public GameMode { ...@@ -76,6 +81,7 @@ class CooperativeGameMode : public GameMode {
}; };
/// Free-for-all game mode base class
class FreeForAllGameMode : public GameMode { class FreeForAllGameMode : public GameMode {
public: public:
...@@ -84,6 +90,7 @@ class FreeForAllGameMode : public GameMode { ...@@ -84,6 +90,7 @@ class FreeForAllGameMode : public GameMode {
}; };
/// Team-based game mode base class
class TeamGameMode : public GameMode { class TeamGameMode : public GameMode {
public: public:
...@@ -92,6 +99,7 @@ class TeamGameMode : public GameMode { ...@@ -92,6 +99,7 @@ class TeamGameMode : public GameMode {
}; };
/// Co-operative game mode
class CoopGameMode : public CooperativeGameMode { class CoopGameMode : public CooperativeGameMode {
public: public:
...@@ -99,30 +107,33 @@ class CoopGameMode : public CooperativeGameMode { ...@@ -99,30 +107,33 @@ class CoopGameMode : public CooperativeGameMode {
}; };
/// Battle game mode
class BattleGameMode : public FreeForAllGameMode { class BattleGameMode : public FreeForAllGameMode {
private: private:
int targetKills; int targetKills; ///< Number of kills required for a player to win
public: public:
GameModeType getMode (); GameModeType getMode ();
}; };
/// Team battle game mode
class TeamBattleGameMode : public TeamGameMode { class TeamBattleGameMode : public TeamGameMode {
private: private:
int targetKills; int targetKills; ///< Number of kills required for a team to win
public: public:
GameModeType getMode (); GameModeType getMode ();
}; };
/// Race game mode
class RaceGameMode : public FreeForAllGameMode { class RaceGameMode : public FreeForAllGameMode {
private: private:
int targetLaps; int targetLaps; ///< Number of laps required for a player to win
public: public:
GameModeType getMode (); GameModeType getMode ();
......
/* /**
* *
* servergame.cpp * @file servergame.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 18th July 2009: Created servergame.cpp from parts of game.cpp * 18th July 2009: Created servergame.cpp from parts of game.cpp
* 2nd August 2009: Created gamemode.cpp from parts of servergame.cpp * 2nd August 2009: Created gamemode.cpp from parts of servergame.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -36,6 +37,13 @@ ...@@ -36,6 +37,13 @@
#include <string.h> #include <string.h>
/**
* Create game server
*
* @param modeType Game mode
* @param firstLevel File name of the first level to play
* @param gameDifficulty Difficulty setting
*/
ServerGame::ServerGame (GameModeType modeType, char* firstLevel, int gameDifficulty) { ServerGame::ServerGame (GameModeType modeType, char* firstLevel, int gameDifficulty) {
int count; int count;
...@@ -84,6 +92,9 @@ ServerGame::ServerGame (GameModeType modeType, char* firstLevel, int gameDifficu ...@@ -84,6 +92,9 @@ ServerGame::ServerGame (GameModeType modeType, char* firstLevel, int gameDifficu
} }
/**
* Disconnect clients and destroy server
*/
ServerGame::~ServerGame () { ServerGame::~ServerGame () {
int count; int count;
...@@ -105,6 +116,13 @@ ServerGame::~ServerGame () { ...@@ -105,6 +116,13 @@ ServerGame::~ServerGame () {
} }
/**
* Set the next level and load it into memory
*
* @param fileName The file name of the next level
*
* @return Error code
*/
int ServerGame::setLevel (char* fileName) { int ServerGame::setLevel (char* fileName) {
File* file; File* file;
...@@ -162,6 +180,11 @@ int ServerGame::setLevel (char* fileName) { ...@@ -162,6 +180,11 @@ int ServerGame::setLevel (char* fileName) {
} }
/**
* Send data to clients
*
* @param buffer Data to send. First byte indicates length.
*/
void ServerGame::send (unsigned char* buffer) { void ServerGame::send (unsigned char* buffer) {
int count; int count;
...@@ -182,6 +205,13 @@ void ServerGame::send (unsigned char* buffer) { ...@@ -182,6 +205,13 @@ void ServerGame::send (unsigned char* buffer) {
} }
/**
* Game iteration
*
* @param ticks Current time
*
* @return Error code
*/
int ServerGame::step (unsigned int ticks) { int ServerGame::step (unsigned int ticks) {
unsigned char sendBuffer[BUFFER_LENGTH]; unsigned char sendBuffer[BUFFER_LENGTH];
...@@ -449,6 +479,11 @@ int ServerGame::step (unsigned int ticks) { ...@@ -449,6 +479,11 @@ int ServerGame::step (unsigned int ticks) {
} }
/**
* Assign point to team and inform clients
*
* @param team Team to receive point
*/
void ServerGame::score (unsigned char team) { void ServerGame::score (unsigned char team) {
unsigned char buffer[MTL_G_SCORE]; unsigned char buffer[MTL_G_SCORE];
...@@ -472,6 +507,12 @@ void ServerGame::score (unsigned char team) { ...@@ -472,6 +507,12 @@ void ServerGame::score (unsigned char team) {
} }
/**
* Set the checkpoint and inform clients
*
* @param gridX X-coordinate (in tiles) of the checkpoint
* @param gridY Y-coordinate (in tiles) of the checkpoint
*/
void ServerGame::setCheckpoint (unsigned char gridX, unsigned char gridY) { void ServerGame::setCheckpoint (unsigned char gridX, unsigned char gridY) {
unsigned char buffer[MTL_G_CHECK]; unsigned char buffer[MTL_G_CHECK];
......
/* /**
* *
* controls.cpp * @file controls.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 13th July 2009: Created controls.cpp from parts of main.cpp * 13th July 2009: Created controls.cpp from parts of main.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -17,9 +18,7 @@ ...@@ -17,9 +18,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Deals with input. * Deals with input.
* *
*/ */
......
/* /**
* *
* controls.h * @file controls.h
* *
* Part of the OpenJazz project
*
* @section History
* 13th July 2009: Created controls.h from parts of OpenJazz.h * 13th July 2009: Created controls.h from parts of OpenJazz.h
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -53,36 +54,36 @@ ...@@ -53,36 +54,36 @@
// Class // Class
/// Keeps track of all control input
class Controls { class Controls {
private: private:
struct { struct {
int key; // Keyboard key int key; ///< Keyboard key
bool state; bool state;
} keys[CONTROLS]; } keys[CONTROLS];
struct { struct {
int button; // Joystick button int button; ///< Joystick button
bool state; bool state;
} buttons[CONTROLS]; } buttons[CONTROLS];
struct { struct {
int axis; // Joystick axis int axis; ///< Joystick axis
bool direction; // Axis direction bool direction; ///< Axis direction
bool state; bool state;
} axes[CONTROLS]; } axes[CONTROLS];
struct { struct {
unsigned int time; /* The time from which the control will respond unsigned int time; ///< The time from which the control will respond to being pressed
to being pressed */
bool state; bool state;
} controls[CONTROLS]; } controls[CONTROLS];
......
/* /**
* *
* file.cpp * @file file.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 3rd February 2009: Created file.cpp from parts of util.cpp * 3rd February 2009: Created file.cpp from parts of util.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -17,6 +18,9 @@ ...@@ -17,6 +18,9 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @section Description
* Deals with files.
*
*/ */
...@@ -28,13 +32,17 @@ ...@@ -28,13 +32,17 @@
#include <string.h> #include <string.h>
#include <zlib.h> #include <zlib.h>
/**
* Try opening a file from the available paths
*
* @param name File name
* @param write Whether or not the file can be written to
*/
File::File (const char* name, bool write) { File::File (const char* name, bool write) {
Path* path; Path* path;
// Try opening the file from all the available directories
path = firstPath; path = firstPath;
while (path) { while (path) {
......
/* /**
* *
* file.h * @file file.h
* *
* Part of the OpenJazz project
*
* @section History
* 3rd February 2009: Created file.h from parts of OpenJazz.h * 3rd February 2009: Created file.h from parts of OpenJazz.h
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -31,7 +32,8 @@ ...@@ -31,7 +32,8 @@
// Classes // Classes
/// File i/o
class File { class File {
private: private:
...@@ -65,12 +67,13 @@ class File { ...@@ -65,12 +67,13 @@ class File {
void loadPalette (SDL_Color* palette, bool rle = true); void loadPalette (SDL_Color* palette, bool rle = true);
}; };
/// Directory path
class Path { class Path {
public: public:
Path* next; Path* next; ///< Next path to check
char* path; char* path; ///< Path
Path (Path* newNext, char* newPath); Path (Path* newNext, char* newPath);
~Path (); ~Path ();
......
/* /**
* *
* anim.cpp * @file anim.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 26th July 2009: Created anim.cpp from parts of sprite.cpp * 26th July 2009: Created anim.cpp from parts of sprite.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
......
/* /**
* *
* anim.h * @file anim.h
* *
* Part of the OpenJazz project
*
* @section History
* 26th July 2009: Created anim.h from parts of sprite.h * 26th July 2009: Created anim.h from parts of sprite.h
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -32,11 +33,12 @@ ...@@ -32,11 +33,12 @@
// Classes // Classes
class Sprite; class Sprite;
/// Animation
class Anim { class Anim {
private: private:
Sprite** sprites; Sprite** sprites; ///< Sprite images
signed char* xOffsets; signed char* xOffsets;
signed char* yOffsets; signed char* yOffsets;
bool ignoreDefaultYOffset; bool ignoreDefaultYOffset;
...@@ -45,10 +47,10 @@ class Anim { ...@@ -45,10 +47,10 @@ class Anim {
signed char accessoryX; signed char accessoryX;
signed char accessoryY; signed char accessoryY;
signed char yOffset; signed char yOffset;
unsigned char frames; // Number of frames unsigned char frames; ///< Number of frames
unsigned char frame; // Current frame unsigned char frame; ///< Current frame
unsigned char accessory; // Number of an animation that is an accessory to this animation unsigned char accessory; ///< Number of an animation that is an accessory to this animation
// Most of the time accessories are used with guardians. ///< Most of the time accessories are used with guardians.
public: public:
Anim (); Anim ();
......
/* /**
* *
* font.cpp * @file font.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 23rd August 2005: Created font.c * 23rd August 2005: Created font.c
* 3rd February 2009: Renamed font.c to font.cpp * 3rd February 2009: Renamed font.c to font.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -18,9 +19,7 @@ ...@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Deals with the loading, displaying and freeing of screen fonts. * Deals with the loading, displaying and freeing of screen fonts.
* *
*/ */
...@@ -493,14 +492,20 @@ void Font::showNumber (int n, int x, int y) { ...@@ -493,14 +492,20 @@ void Font::showNumber (int n, int x, int y) {
} }
/**
* Map a range of palette indices to another range
*
* @param start Start of original range
* @param length Span of original range
* @param newStart Start of new range
* @param newLength Span of new range
*/
void Font::mapPalette (int start, int length, int newStart, int newLength) { void Font::mapPalette (int start, int length, int newStart, int newLength) {
SDL_Color palette[256]; SDL_Color palette[256];
int count; int count;
// Map a range of palette indices to another range
for (count = 0; count < length; count++) for (count = 0; count < length; count++)
palette[count].r = palette[count].g = palette[count].b = palette[count].r = palette[count].g = palette[count].b =
(count * newLength / length) + newStart; (count * newLength / length) + newStart;
......
/* /**
* *
* font.h * @file font.h
* *
* Part of the OpenJazz project
*
* @section History
* 3rd February 2009: Created font.h from parts of OpenJazz.h * 3rd February 2009: Created font.h from parts of OpenJazz.h
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -32,14 +33,15 @@ ...@@ -32,14 +33,15 @@
// Classes // Classes
class File; class File;
/// Font
class Font { class Font {
private: private:
SDL_Surface *characters[128]; SDL_Surface *characters[128]; ///< Symbol images
int nCharacters; int nCharacters; ///< Number of symbols
unsigned char lineHeight; unsigned char lineHeight; ///< Vertical spacing of displayed characters
char map[128]; // Maps ASCII values to letter positions char map[128]; ///< Maps ASCII values to symbol indices
public: public:
Font (const char *fileName); Font (const char *fileName);
...@@ -61,13 +63,13 @@ class Font { ...@@ -61,13 +63,13 @@ class Font {
// Variables // Variables
EXTERN Font *font2; /* Taken from .0FN file name */ EXTERN Font *font2; /** Taken from .0FN file name */
EXTERN Font *fontbig; /* Taken from .0FN file name */ EXTERN Font *fontbig; /** Taken from .0FN file name */
EXTERN Font *fontiny; /* Taken from .0FN file name */ EXTERN Font *fontiny; /** Taken from .0FN file name */
EXTERN Font *fontmn1; /* Taken from .0FN file name */ EXTERN Font *fontmn1; /** Taken from .0FN file name */
EXTERN Font *fontmn2; /* Taken from .0FN file name */ EXTERN Font *fontmn2; /** Taken from .0FN file name */
EXTERN Font *panelBigFont; /* Found in PANEL.000 */ EXTERN Font *panelBigFont; /** Found in PANEL.000 */
EXTERN Font *panelSmallFont; /* Found in PANEL.000 */ EXTERN Font *panelSmallFont; /** Found in PANEL.000 */
#endif #endif
/* /**
* *
* paletteeffects.cpp * @file paletteeffects.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 4th February 2009: Created palette.cpp from parts of main.cpp and util.cpp * 4th February 2009: Created palette.cpp from parts of main.cpp and util.cpp
* 1st August 2009: Renamed palette.cpp to paletteeffects.cpp * 1st August 2009: Renamed palette.cpp to paletteeffects.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -61,7 +62,7 @@ void PaletteEffect::apply (SDL_Color* shownPalette, bool direct, int mspf) { ...@@ -61,7 +62,7 @@ void PaletteEffect::apply (SDL_Color* shownPalette, bool direct, int mspf) {
WhiteInPaletteEffect::WhiteInPaletteEffect WhiteInPaletteEffect::WhiteInPaletteEffect
(fixed newDuration, PaletteEffect* nextPE) : PaletteEffect (nextPE) { (int newDuration, PaletteEffect* nextPE) : PaletteEffect (nextPE) {
duration = newDuration; duration = newDuration;
whiteness = F1 + FH; whiteness = F1 + FH;
......
/* /**
* *
* paletteeffects.h * @file paletteeffects.h
* *
* Part of the OpenJazz project
*
* @section History
* 4th February 2009: Created palette.h from parts of OpenJazz.h * 4th February 2009: Created palette.h from parts of OpenJazz.h
* 1st August 2009: Renamed palette.h to paletteeffects.h * 1st August 2009: Renamed palette.h to paletteeffects.h
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -45,11 +46,12 @@ ...@@ -45,11 +46,12 @@
// Class // Class
/// Palette effect base class
class PaletteEffect { class PaletteEffect {
protected: protected:
PaletteEffect* next; // Next effect to use PaletteEffect* next; ///< Next effect to use
public: public:
PaletteEffect (PaletteEffect* nextPE); PaletteEffect (PaletteEffect* nextPE);
...@@ -59,11 +61,11 @@ class PaletteEffect { ...@@ -59,11 +61,11 @@ class PaletteEffect {
}; };
/// Dissolve from white palette effect
class WhiteInPaletteEffect : public PaletteEffect { class WhiteInPaletteEffect : public PaletteEffect {
private: private:
int duration; // Number of milliseconds the effect lasts int duration; ///< Number of milliseconds the effect lasts
fixed whiteness; fixed whiteness;
public: public:
...@@ -73,11 +75,11 @@ class WhiteInPaletteEffect : public PaletteEffect { ...@@ -73,11 +75,11 @@ class WhiteInPaletteEffect : public PaletteEffect {
}; };
/// Fade in palette effect
class FadeInPaletteEffect : public PaletteEffect { class FadeInPaletteEffect : public PaletteEffect {
private: private:
int duration; // Number of milliseconds the effect lasts int duration; ///< Number of milliseconds the effect lasts
fixed blackness; fixed blackness;
public: public:
...@@ -87,11 +89,11 @@ class FadeInPaletteEffect : public PaletteEffect { ...@@ -87,11 +89,11 @@ class FadeInPaletteEffect : public PaletteEffect {
}; };
/// Dissolve to white palette effect
class WhiteOutPaletteEffect : public PaletteEffect { class WhiteOutPaletteEffect : public PaletteEffect {
private: private:
int duration; // Number of milliseconds the effect lasts int duration; ///< Number of milliseconds the effect lasts
fixed whiteness; fixed whiteness;
public: public:
...@@ -101,11 +103,11 @@ class WhiteOutPaletteEffect : public PaletteEffect { ...@@ -101,11 +103,11 @@ class WhiteOutPaletteEffect : public PaletteEffect {
}; };
/// Fade out palette effect
class FadeOutPaletteEffect : public PaletteEffect { class FadeOutPaletteEffect : public PaletteEffect {
private: private:
int duration; // Number of milliseconds the effect lasts int duration; ///< Number of milliseconds the effect lasts
fixed blackness; fixed blackness;
public: public:
...@@ -115,13 +117,13 @@ class FadeOutPaletteEffect : public PaletteEffect { ...@@ -115,13 +117,13 @@ class FadeOutPaletteEffect : public PaletteEffect {
}; };
/// Flash colour (dissolve to it and back again) palette effect
class FlashPaletteEffect : public PaletteEffect { class FlashPaletteEffect : public PaletteEffect {
private: private:
int duration; // Number of milliseconds the effect lasts int duration; ///< Number of milliseconds the effect lasts
fixed progress; fixed progress;
unsigned char red, green, blue; // Flash colour unsigned char red, green, blue; ///< Flash colour
public: public:
FlashPaletteEffect (unsigned char newRed, unsigned char newGreen, unsigned char newBlue, int newDuration, PaletteEffect* nextPE); FlashPaletteEffect (unsigned char newRed, unsigned char newGreen, unsigned char newBlue, int newDuration, PaletteEffect* nextPE);
...@@ -130,13 +132,13 @@ class FlashPaletteEffect : public PaletteEffect { ...@@ -130,13 +132,13 @@ class FlashPaletteEffect : public PaletteEffect {
}; };
/// Entry rotation palette effect
class RotatePaletteEffect : public PaletteEffect { class RotatePaletteEffect : public PaletteEffect {
private: private:
unsigned char first; /* The first palette index affected */ unsigned char first; ///< The first palette index affected
int amount; /* The number of (consecutive) palette indices affected */ int amount; ///< The number of (consecutive) palette indices affected
fixed speed; // Rotations per second fixed speed; ///< Rotations per second
fixed position; fixed position;
public: public:
...@@ -146,14 +148,14 @@ class RotatePaletteEffect : public PaletteEffect { ...@@ -146,14 +148,14 @@ class RotatePaletteEffect : public PaletteEffect {
}; };
/// Sky palette palette effect
class SkyPaletteEffect : public PaletteEffect { class SkyPaletteEffect : public PaletteEffect {
private: private:
SDL_Color* skyPalette; SDL_Color* skyPalette;
unsigned char first; /* The first palette index affected */ unsigned char first; ///< The first palette index affected
int amount; /* The number of (consecutive) palette indices affected */ int amount; ///< The number of (consecutive) palette indices affected
fixed speed; // Relative Y speed - as in Jazz 2 fixed speed; ///< Relative Y speed - as in Jazz 2
public: public:
SkyPaletteEffect (unsigned char newFirst, int newAmount, fixed newSpeed, SDL_Color* newSkyPalette, PaletteEffect* nextPE); SkyPaletteEffect (unsigned char newFirst, int newAmount, fixed newSpeed, SDL_Color* newSkyPalette, PaletteEffect* nextPE);
...@@ -162,13 +164,13 @@ class SkyPaletteEffect : public PaletteEffect { ...@@ -162,13 +164,13 @@ class SkyPaletteEffect : public PaletteEffect {
}; };
/// 2D parallaxing background palette effect
class P2DPaletteEffect : public PaletteEffect { class P2DPaletteEffect : public PaletteEffect {
private: private:
unsigned char first; /* The first palette index affected */ unsigned char first; ///< The first palette index affected
int amount; /* The number of (consecutive) palette indices affected */ int amount; ///< The number of (consecutive) palette indices affected
fixed speed; // Relative X & Y speed - as in Jazz 2 fixed speed; ///< Relative X & Y speed - as in Jazz 2
public: public:
P2DPaletteEffect (unsigned char newFirst, int newAmount, fixed newSpeed, PaletteEffect* nextPE); P2DPaletteEffect (unsigned char newFirst, int newAmount, fixed newSpeed, PaletteEffect* nextPE);
...@@ -177,13 +179,13 @@ class P2DPaletteEffect : public PaletteEffect { ...@@ -177,13 +179,13 @@ class P2DPaletteEffect : public PaletteEffect {
}; };
/// 1D parallaxing background palette effect
class P1DPaletteEffect : public PaletteEffect { class P1DPaletteEffect : public PaletteEffect {
private: private:
unsigned char first; /* The first palette index affected */ unsigned char first; ///< The first palette index affected
int amount; /* The number of (consecutive) palette indices affected */ int amount; ///< The number of (consecutive) palette indices affected
fixed speed; // Relative X & Y speed - as in Jazz 2 fixed speed; ///< Relative X & Y speed - as in Jazz 2
public: public:
P1DPaletteEffect (unsigned char newFirst, int newAmount, fixed newSpeed, PaletteEffect* nextPE); P1DPaletteEffect (unsigned char newFirst, int newAmount, fixed newSpeed, PaletteEffect* nextPE);
...@@ -192,11 +194,11 @@ class P1DPaletteEffect : public PaletteEffect { ...@@ -192,11 +194,11 @@ class P1DPaletteEffect : public PaletteEffect {
}; };
/// Underwater darkening palette effect
class WaterPaletteEffect : public PaletteEffect { class WaterPaletteEffect : public PaletteEffect {
private: private:
fixed depth; /* Number of pixels between water surface and total darkness */ fixed depth; ///< Number of pixels between water surface and total darkness
public: public:
WaterPaletteEffect (fixed newDepth, PaletteEffect* nextPE); WaterPaletteEffect (fixed newDepth, PaletteEffect* nextPE);
......
/* /**
* *
* sprite.cpp * @file sprite.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 19th March 2009: Created sprite.cpp from parts of event.cpp and player.cpp * 19th March 2009: Created sprite.cpp from parts of event.cpp and player.cpp
* 26th July 2009: Created anim.cpp from parts of sprite.cpp * 26th July 2009: Created anim.cpp from parts of sprite.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
......
/* /**
* *
* sprite.h * @file sprite.h
* *
* Part of the OpenJazz project
*
* @section History
* 19th March 2009: Created sprite.h from parts of level.h * 19th March 2009: Created sprite.h from parts of level.h
* 26th July 2009: Created anim.h from parts of sprite.h * 26th July 2009: Created anim.h from parts of sprite.h
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -31,11 +32,12 @@ ...@@ -31,11 +32,12 @@
// Class // Class
/// Sprite
class Sprite { class Sprite {
private: private:
SDL_Surface* pixels; SDL_Surface* pixels; ///< Sprite image
public: public:
short int xOffset; short int xOffset;
......
/* /**
*
* video.cpp
* *
* @file video.cpp
*
* Part of the OpenJazz project
*
* @section History
* 13th July 2009: Created graphics.cpp from parts of util.cpp * 13th July 2009: Created graphics.cpp from parts of util.cpp
* 26th July 2009: Renamed graphics.cpp to video.cpp * 26th July 2009: Renamed graphics.cpp to video.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -18,9 +19,7 @@ ...@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Contains graphics utility functions. * Contains graphics utility functions.
* *
*/ */
...@@ -152,7 +151,7 @@ bool Video::create (int width, int height) { ...@@ -152,7 +151,7 @@ bool Video::create (int width, int height) {
gain. gain.
b) the palette is emulated, there will be a HUGE speed loss. b) the palette is emulated, there will be a HUGE speed loss.
Therefore, assume the palette is emulated. */ Therefore, assume the palette is emulated. */
// TODO: Find a better way /// @todo Find a better way to determine if palette is emulated
fakePalette = true; fakePalette = true;
return true; return true;
......
/* /**
* *
* video.h * @file video.h
* *
* Part of the OpenJazz project
*
* @section History
* 13th July 2009: Created graphics.h from parts of OpenJazz.h * 13th July 2009: Created graphics.h from parts of OpenJazz.h
* 26th July 2009: Renamed graphics.h to video.h * 26th July 2009: Renamed graphics.h to video.h
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -52,27 +53,29 @@ ...@@ -52,27 +53,29 @@
// Class // Class
/// Video output
class Video { class Video {
private: private:
SDL_Surface* screen; SDL_Surface* screen; ///< Output surface
// Palettes // Palettes
SDL_Color* currentPalette; SDL_Color* currentPalette; ///< Current palette
SDL_Color logicalPalette[256]; SDL_Color logicalPalette[256]; ///< Logical palette (greyscale)
bool fakePalette; bool fakePalette; ///< Whether or not the palette mode is being emulated
int screenW, screenH; int screenW; ///< Real width
int screenH; ///< Real height
#ifdef SCALE #ifdef SCALE
int scaleFactor; int scaleFactor; ///< Scaling factor
#endif #endif
#ifndef FULLSCREEN_ONLY #ifndef FULLSCREEN_ONLY
bool fullscreen; bool fullscreen; ///< Full-screen mode
#endif #endif
public: public:
Video (); Video ();
bool create (int width, int height); bool create (int width, int height);
...@@ -102,10 +105,11 @@ class Video { ...@@ -102,10 +105,11 @@ class Video {
// Variables // Variables
EXTERN SDL_Surface* canvas; EXTERN SDL_Surface* canvas; ///< Surface used for drawing
EXTERN int canvasW, canvasH; EXTERN int canvasW; ///< Drawing surface width
EXTERN int canvasH; ///< Drawing surface height
EXTERN Video video; EXTERN Video video; ///< Video output
// Functions // Functions
......
/* /**
* *
* network.cpp * @file network.cpp
*
* 3rd June 2009: Created network.cpp from parts of game.cpp
* *
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* @section History
* 3rd June 2009: Created network.cpp from parts of game.cpp
* *
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -17,9 +18,7 @@ ...@@ -17,9 +18,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Deals with a platform-specific networking API. * Deals with a platform-specific networking API.
* *
* On most platforms, USE_SOCKETS should be defined. * On most platforms, USE_SOCKETS should be defined.
...@@ -73,6 +72,7 @@ Network::Network () { ...@@ -73,6 +72,7 @@ Network::Network () {
} }
Network::~Network () { Network::~Network () {
#ifdef USE_SOCKETS #ifdef USE_SOCKETS
...@@ -88,6 +88,7 @@ Network::~Network () { ...@@ -88,6 +88,7 @@ Network::~Network () {
} }
int Network::host () { int Network::host () {
#ifdef USE_SOCKETS #ifdef USE_SOCKETS
...@@ -141,6 +142,7 @@ int Network::host () { ...@@ -141,6 +142,7 @@ int Network::host () {
} }
int Network::join (char *address) { int Network::join (char *address) {
#ifdef USE_SOCKETS #ifdef USE_SOCKETS
...@@ -250,6 +252,7 @@ int Network::join (char *address) { ...@@ -250,6 +252,7 @@ int Network::join (char *address) {
} }
int Network::accept (int sock) { int Network::accept (int sock) {
#ifdef USE_SOCKETS #ifdef USE_SOCKETS
...@@ -281,6 +284,7 @@ int Network::accept (int sock) { ...@@ -281,6 +284,7 @@ int Network::accept (int sock) {
} }
void Network::close (int sock) { void Network::close (int sock) {
#ifdef USE_SOCKETS #ifdef USE_SOCKETS
...@@ -297,6 +301,7 @@ void Network::close (int sock) { ...@@ -297,6 +301,7 @@ void Network::close (int sock) {
} }
int Network::send (int sock, unsigned char *buffer) { int Network::send (int sock, unsigned char *buffer) {
#ifdef USE_SOCKETS #ifdef USE_SOCKETS
...@@ -309,6 +314,7 @@ int Network::send (int sock, unsigned char *buffer) { ...@@ -309,6 +314,7 @@ int Network::send (int sock, unsigned char *buffer) {
} }
int Network::recv (int sock, unsigned char *buffer, int length) { int Network::recv (int sock, unsigned char *buffer, int length) {
#ifdef USE_SOCKETS #ifdef USE_SOCKETS
...@@ -321,6 +327,7 @@ int Network::recv (int sock, unsigned char *buffer, int length) { ...@@ -321,6 +327,7 @@ int Network::recv (int sock, unsigned char *buffer, int length) {
} }
bool Network::isConnected (int sock) { bool Network::isConnected (int sock) {
#ifdef USE_SOCKETS #ifdef USE_SOCKETS
......
/* /**
* *
* network.h * @file network.h
* *
* Part of the OpenJazz project
*
* @section History
* 3rd June 2009: Created network.h from parts of OpenJazz.h * 3rd June 2009: Created network.h from parts of OpenJazz.h
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -47,7 +48,8 @@ ...@@ -47,7 +48,8 @@
// Class // Class
/// Networking
class Network { class Network {
public: public:
...@@ -75,7 +77,7 @@ class Network { ...@@ -75,7 +77,7 @@ class Network {
// Variables // Variables
EXTERN char *netAddress; EXTERN char *netAddress; /// Server address
EXTERN Network *net; EXTERN Network *net;
#endif #endif
......
/* /**
* *
* sound.cpp * @file sound.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 23rd August 2005: Created sound.c * 23rd August 2005: Created sound.c
* 3rd February 2009: Renamed sound.c to sound.cpp * 3rd February 2009: Renamed sound.c to sound.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -18,9 +19,7 @@ ...@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Deals with the loading, playing and freeing of music and sound effects. * Deals with the loading, playing and freeing of music and sound effects.
* *
* For music, USE_MODPLUG must be defined. * For music, USE_MODPLUG must be defined.
...@@ -354,10 +353,11 @@ void freeSounds () { ...@@ -354,10 +353,11 @@ void freeSounds () {
} }
/**
* Set the sound to be played
*/
void playSound (int newSound) { void playSound (int newSound) {
// Set the sound to be played
if (sounds && (newSound >= 0)) sounds[newSound].position = 0; if (sounds && (newSound >= 0)) sounds[newSound].position = 0;
return; return;
......
/* /**
* *
* sound.h * @file sound.h
* *
* Part of the OpenJazz project
*
* @section History
* 2nd June 2009: Created sound.h from parts of OpenJazz.h * 2nd June 2009: Created sound.h from parts of OpenJazz.h
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -55,7 +56,8 @@ ...@@ -55,7 +56,8 @@
// Datatype // Datatype
/// Sound effect
typedef struct { typedef struct {
unsigned char *data; unsigned char *data;
......
/* /**
* *
* jj2event.cpp * @file jj2event.cpp
*
* 2nd July 2010: Created jj2event.cpp from parts of jj2level.cpp
* *
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* @section History
* 2nd July 2010: Created jj2event.cpp from parts of jj2level.cpp
* *
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -17,9 +18,7 @@ ...@@ -17,9 +18,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Deals with the creating and freeing of JJ2 events. * Deals with the creating and freeing of JJ2 events.
* *
*/ */
......
/* /**
* *
* jj2event.h * @file jj2event.h
*
* 2nd July 2010: Created jj2event.h from parts of jj2level.h
* *
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* @section History
* 2nd July 2010: Created jj2event.h from parts of jj2level.h
* *
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -31,6 +32,7 @@ ...@@ -31,6 +32,7 @@
class Anim; class Anim;
/// JJ2 level "movable" event
class JJ2Event : public Movable { class JJ2Event : public Movable {
private: private:
...@@ -39,8 +41,8 @@ class JJ2Event : public Movable { ...@@ -39,8 +41,8 @@ class JJ2Event : public Movable {
protected: protected:
unsigned char type; unsigned char type;
int properties; int properties;
unsigned int endTime; // Point at which the event will terminate unsigned int endTime; ///< Point at which the event will terminate
bool flipped; bool flipped; ///< Whether or not the sprite image should be flipped
JJ2Event (JJ2Event* newNext, unsigned char gridX, unsigned char gridY, unsigned char newType, int newProperties); JJ2Event (JJ2Event* newNext, unsigned char gridX, unsigned char gridY, unsigned char newType, int newProperties);
...@@ -59,6 +61,7 @@ class JJ2Event : public Movable { ...@@ -59,6 +61,7 @@ class JJ2Event : public Movable {
}; };
/// JJ2 level pickup event
class PickupJJ2Event : public JJ2Event { class PickupJJ2Event : public JJ2Event {
private: private:
...@@ -72,6 +75,7 @@ class PickupJJ2Event : public JJ2Event { ...@@ -72,6 +75,7 @@ class PickupJJ2Event : public JJ2Event {
}; };
/// JJ2 level ammo
class AmmoJJ2Event : public PickupJJ2Event { class AmmoJJ2Event : public PickupJJ2Event {
public: public:
...@@ -82,6 +86,7 @@ class AmmoJJ2Event : public PickupJJ2Event { ...@@ -82,6 +86,7 @@ class AmmoJJ2Event : public PickupJJ2Event {
}; };
/// JJ2 level gold/silver coin
class CoinGemJJ2Event : public PickupJJ2Event { class CoinGemJJ2Event : public PickupJJ2Event {
private: private:
...@@ -95,6 +100,7 @@ class CoinGemJJ2Event : public PickupJJ2Event { ...@@ -95,6 +100,7 @@ class CoinGemJJ2Event : public PickupJJ2Event {
}; };
/// JJ2 level food
class FoodJJ2Event : public PickupJJ2Event { class FoodJJ2Event : public PickupJJ2Event {
public: public:
...@@ -105,6 +111,7 @@ class FoodJJ2Event : public PickupJJ2Event { ...@@ -105,6 +111,7 @@ class FoodJJ2Event : public PickupJJ2Event {
}; };
/// Unimplemented JJ2 level event
class OtherJJ2Event : public JJ2Event { class OtherJJ2Event : public JJ2Event {
public: public:
......
/* /**
* *
* jj2eventframe.cpp * @file jj2eventframe.cpp
*
* 2nd July 2010: Created jj2eventframe.cpp from parts of jj2level.cpp
* *
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* @section History
* 2nd July 2010: Created jj2eventframe.cpp from parts of jj2level.cpp
* *
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -17,9 +18,7 @@ ...@@ -17,9 +18,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Deals with the playing of JJ2 levels. * Deals with the playing of JJ2 levels.
* *
*/ */
...@@ -34,7 +33,7 @@ ...@@ -34,7 +33,7 @@
#include "player/jj2levelplayer.h" #include "player/jj2levelplayer.h"
// Look-up table for ammo animations (in animSet 1) /// Look-up table for ammo animations (in animSet 1)
const unsigned char ammoAnims[] = { const unsigned char ammoAnims[] = {
28, // Ice 28, // Ice
24, // Bouncer 24, // Bouncer
...@@ -46,7 +45,7 @@ const unsigned char ammoAnims[] = { ...@@ -46,7 +45,7 @@ const unsigned char ammoAnims[] = {
67 // Sparks 67 // Sparks
}; };
// Look-up table for food etc. animations (in animSet 67) /// Look-up table for food etc. animations (in animSet 67)
const unsigned char pickupAnims[] = { const unsigned char pickupAnims[] = {
0, // 0 0, // 0
0, // 1 0, // 1
...@@ -347,7 +346,7 @@ JJ2Event* PickupJJ2Event::step (unsigned int ticks, int msps) { ...@@ -347,7 +346,7 @@ JJ2Event* PickupJJ2Event::step (unsigned int ticks, int msps) {
} else { } else {
// TODO: Check for bullet overlap /// @todo Check for bullet overlap
// floating = false; // floating = false;
} }
...@@ -367,7 +366,7 @@ void AmmoJJ2Event::draw (unsigned int ticks, int change) { ...@@ -367,7 +366,7 @@ void AmmoJJ2Event::draw (unsigned int ticks, int change) {
drawX = getDrawX(change); drawX = getDrawX(change);
drawY = getDrawY(change); drawY = getDrawY(change);
// TODO: Check if ammo is powered up /// @todo Check if ammo is powered up
if (!endTime)an = jj2Level->getAnim(0, ammoAnims[type - 33] + 1, flipped); if (!endTime)an = jj2Level->getAnim(0, ammoAnims[type - 33] + 1, flipped);
else an = jj2Level->getAnim(67, 86, flipped); else an = jj2Level->getAnim(67, 86, flipped);
......
/* /**
* *
* jj2layer.cpp * @file jj2layer.cpp
*
* 30th June 2010: Created jj2layer.cpp from parts of jj2levelframe.cpp
* *
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* @section History
* 30th June 2010: Created jj2layer.cpp from parts of jj2levelframe.cpp
* *
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -17,9 +18,7 @@ ...@@ -17,9 +18,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Handles JJ2 level layers. * Handles JJ2 level layers.
* *
*/ */
...@@ -30,10 +29,11 @@ ...@@ -30,10 +29,11 @@
#include "io/gfx/video.h" #include "io/gfx/video.h"
/**
* Create a blank layer
*/
JJ2Layer::JJ2Layer () { JJ2Layer::JJ2Layer () {
// Create a blank layer
width = height = 1; width = height = 1;
grid = new JJ2Tile *[1]; grid = new JJ2Tile *[1];
...@@ -78,10 +78,11 @@ JJ2Layer::~JJ2Layer () { ...@@ -78,10 +78,11 @@ JJ2Layer::~JJ2Layer () {
} }
/**
* Get flipped. We aim to offend!
*/
bool JJ2Layer::getFlipped (int x, int y) { bool JJ2Layer::getFlipped (int x, int y) {
// Get flipped. We aim to offend!
if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) return false; if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) return false;
return grid[y][x].flipped; return grid[y][x].flipped;
......
/* /**
* *
* jj2level.cpp * @file jj2level.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 29th June 2010: Created jj2level.cpp from parts of level.cpp * 29th June 2010: Created jj2level.cpp from parts of level.cpp
* 2nd July 2010: Created jj2event.cpp from parts of jj2level.cpp * 2nd July 2010: Created jj2event.cpp from parts of jj2level.cpp
* 2nd July 2010: Created jj2eventframe.cpp from parts of jj2level.cpp * 2nd July 2010: Created jj2eventframe.cpp from parts of jj2level.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -19,9 +20,7 @@ ...@@ -19,9 +20,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Deals with the creating, playing and freeing of JJ2 levels. * Deals with the creating, playing and freeing of JJ2 levels.
* *
*/ */
...@@ -269,10 +268,13 @@ void JJ2Level::warp (JJ2LevelPlayer *player, int id) { ...@@ -269,10 +268,13 @@ void JJ2Level::warp (JJ2LevelPlayer *player, int id) {
} }
/**
* Interpret data received from client/server
*
* @param buffer Received data
*/
void JJ2Level::receive (unsigned char* buffer) { void JJ2Level::receive (unsigned char* buffer) {
// Interpret data received from client/server
switch (buffer[1]) { switch (buffer[1]) {
case MT_L_PROP: case MT_L_PROP:
......
/* /**
* *
* jj2level.h * @file jj2level.h
* *
* Part of the OpenJazz project
*
* @section History
* 29th June 2010: Created jj2level.h from parts of level.h * 29th June 2010: Created jj2level.h from parts of level.h
* 2nd July 2010: Created jj2event.h from parts of jj2level.h * 2nd July 2010: Created jj2event.h from parts of jj2level.h
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -47,15 +48,17 @@ ...@@ -47,15 +48,17 @@
// Datatypes // Datatypes
/// JJ2 level tile
typedef struct { typedef struct {
unsigned short int tile; // Indexes the tile set unsigned short int tile; ///< Indexes the tile set
unsigned char frame; // Current frame being used (for animated tiles) unsigned char frame; ///< Current frame being used (for animated tiles)
bool flipped; bool flipped; ///< Whether or not the tile image and mask are flipped
} JJ2Tile; } JJ2Tile;
/// JJ2 level tile modifier event
typedef struct { typedef struct {
unsigned char type; unsigned char type;
...@@ -67,13 +70,18 @@ typedef struct { ...@@ -67,13 +70,18 @@ typedef struct {
// Classes // Classes
class Font; class Font;
///< JJ2 level parallaxing layer
class JJ2Layer { class JJ2Layer {
private: private:
JJ2Tile** grid; JJ2Tile** grid; ///< Layer tiles
int width, height; int width; ///< Width (in tiles)
bool tileX, tileY, limit, warp; int height; ///< Height (in tiles)
bool tileX; ///< Repeat horizontally
bool tileY; ///< Repeat vertically
bool limit; ///< Do not view beyond edges
bool warp; ///< Warp effect
public: public:
JJ2Layer (); JJ2Layer ();
...@@ -94,30 +102,31 @@ class JJ2Layer { ...@@ -94,30 +102,31 @@ class JJ2Layer {
class JJ2Event; class JJ2Event;
class JJ2LevelPlayer; class JJ2LevelPlayer;
/// JJ2 level
class JJ2Level : public BaseLevel { class JJ2Level : public BaseLevel {
private: private:
SDL_Surface* tileSet; SDL_Surface* tileSet; ///< Tile images
SDL_Surface* flippedTileSet; SDL_Surface* flippedTileSet; ///< Tile images (flipped)
JJ2Event* events; JJ2Event* events; ///< "Movable" events
Font* font; Font* font; ///< On-screen message font
char* mask; char* mask; ///< Tile masks
char* flippedMask; char* flippedMask; ///< Tile masks (flipped)
char* musicFile; char* musicFile; ///< Music file name
char* nextLevel; char* nextLevel; ///< Next level file name
Sprite* spriteSet; Sprite* spriteSet; ///< Sprite images
Sprite* flippedSpriteSet; Sprite* flippedSpriteSet; ///< Sprite images (flipped)
Anim** animSets; Anim** animSets; ///< Animation sets
Anim** flippedAnimSets; Anim** flippedAnimSets; ///< Animation sets (flipped)
JJ2Layer* layers[LAYERS]; JJ2Layer* layers[LAYERS]; ///< All layers
JJ2Layer* layer; JJ2Layer* layer; ///< Layer 4
JJ2Modifier** mods; JJ2Modifier** mods; ///< Modifier events for each tile in layer 4
int nAnimSets; int nAnimSets; ///< Number of animation sets
bool TSF; bool TSF; ///< 1.24 level
unsigned char difficulty; unsigned char difficulty; ///< Difficulty setting (0 = easy, 1 = medium, 2 or 3 = hard)
fixed waterLevel; fixed waterLevel; ///< Height of water
fixed waterLevelTarget; fixed waterLevelTarget; ///< Future height of water
fixed waterLevelSpeed; fixed waterLevelSpeed; ///< Rate of water level change
void createEvent (int x, int y, unsigned char* data); void createEvent (int x, int y, unsigned char* data);
int load (char* fileName, unsigned char diff, bool checkpoint); int load (char* fileName, unsigned char diff, bool checkpoint);
...@@ -152,7 +161,7 @@ class JJ2Level : public BaseLevel { ...@@ -152,7 +161,7 @@ class JJ2Level : public BaseLevel {
// Variable // Variable
EXTERN JJ2Level* jj2Level; EXTERN JJ2Level* jj2Level; //< JJ2 level
#endif #endif
/* /**
* *
* jj2levelframe.cpp * @file jj2levelframe.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 29th June 2010: Created jj2levelframe.cpp from parts of levelframe.cpp * 29th June 2010: Created jj2levelframe.cpp from parts of levelframe.cpp
* 30th June 2010: Created jj2layer.cpp from parts of jj2levelframe.cpp * 30th June 2010: Created jj2layer.cpp from parts of jj2levelframe.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -18,9 +19,7 @@ ...@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Provides the once-per-frame functions for levels. * Provides the once-per-frame functions for levels.
* *
*/ */
......
/* /**
* *
* levelloadjj2.cpp * @file jj2levelload.cpp
*
* 28th June 2010: Created levelloadjj2.cpp from parts of levelload.cpp
* 29th June 2010: Renamed levelloadjj2.cpp to jj2levelload.cpp
* *
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* @section History
* 28th June 2010: Created levelloadjj2.cpp from parts of levelload.cpp
* 29th June 2010: Renamed levelloadjj2.cpp to jj2levelload.cpp
* *
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -18,9 +19,7 @@ ...@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Deals with the loading of JJ2 level data. * Deals with the loading of JJ2 level data.
* *
*/ */
......
/* /**
* *
* bullet.cpp * @file bullet.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 11th February 2009: Created bullet.cpp from parts of events.cpp * 11th February 2009: Created bullet.cpp from parts of events.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
......
/* /**
* *
* bullet.h * @file bullet.h
* *
* Part of the OpenJazz project
*
* @section History
* 11th February 2009: Created bullet.h from parts of events.h * 11th February 2009: Created bullet.h from parts of events.h
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -53,16 +54,17 @@ class Bird; ...@@ -53,16 +54,17 @@ class Bird;
class Event; class Event;
class LevelPlayer; class LevelPlayer;
class Sprite; class Sprite;
/// Bullet
class Bullet : public Movable { class Bullet : public Movable {
private: private:
Bullet* next; Bullet* next;
LevelPlayer* source; // If NULL, was fired by an event LevelPlayer* source; ///< Source player. If NULL, was fired by an event
Sprite* sprite; Sprite* sprite; ///< Sprite
int type; // -1 is TNT, otherwise indexes the bullet set int type; ///< -1 is TNT, otherwise indexes the bullet set
int direction; // 0: Left, 1: Right, 2: L (lower), 3: R (lower) int direction; ///< 0: Left, 1: Right, 2: L (lower), 3: R (lower)
unsigned int time; // Time at which the bullet will self-destruct unsigned int time; ///< Time at which the bullet will self-destruct
Bullet* remove (); Bullet* remove ();
......
/* /**
* *
* demolevel.cpp * @file demolevel.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 18th July 2009: Created demolevel.cpp from parts of level.cpp and * 18th July 2009: Created demolevel.cpp from parts of level.cpp and
* levelload.cpp * levelload.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -18,9 +19,7 @@ ...@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Deals with the loading and playing of demo levels. * Deals with the loading and playing of demo levels.
* *
*/ */
......
/* /**
* *
* bridge.cpp * @file bridge.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 2nd March 2010: Created bridge.cpp from parts of event.cpp and eventframe.cpp * 2nd March 2010: Created bridge.cpp from parts of event.cpp and eventframe.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -17,9 +18,7 @@ ...@@ -17,9 +18,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Provides the functions of bridge events. * Provides the functions of bridge events.
* *
*/ */
......
/* /**
* *
* event.cpp * @file event.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 1st January 2006: Created events.c from parts of level.c * 1st January 2006: Created events.c from parts of level.c
* 3rd February 2009: Renamed events.c to events.cpp * 3rd February 2009: Renamed events.c to events.cpp
* 5th February 2009: Added parts of events.cpp and level.cpp to player.cpp * 5th February 2009: Added parts of events.cpp and level.cpp to player.cpp
...@@ -14,9 +17,7 @@ ...@@ -14,9 +17,7 @@
* 2nd March 2010: Created guardians.cpp from parts of event.cpp and eventframe.cpp * 2nd March 2010: Created guardians.cpp from parts of event.cpp and eventframe.cpp
* 2nd March 2010: Created bridge.cpp from parts of event.cpp and eventframe.cpp * 2nd March 2010: Created bridge.cpp from parts of event.cpp and eventframe.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -26,9 +27,7 @@ ...@@ -26,9 +27,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Deals with events in ordinary levels. * Deals with events in ordinary levels.
* *
*/ */
...@@ -157,13 +156,19 @@ void Event::destroy (unsigned int ticks) { ...@@ -157,13 +156,19 @@ void Event::destroy (unsigned int ticks) {
} }
/**
* Deal with bullet collisions
*
* @param source Source of the bullet
* @param ticks Current time
*
* @return Whether or not the hit was successful
*/
bool Event::hit (LevelPlayer *source, unsigned int ticks) { bool Event::hit (LevelPlayer *source, unsigned int ticks) {
int hitsRemaining; int hitsRemaining;
// Deal with bullet collisions
// Check if event has already been destroyed // Check if event has already been destroyed
if ((animType == E_LFINISHANIM) || (animType == E_RFINISHANIM) || if ((animType == E_LFINISHANIM) || (animType == E_RFINISHANIM) ||
(ticks < flashTime)) return false; (ticks < flashTime)) return false;
......
/* /**
* *
* event.h * @file event.h
* *
* Part of the OpenJazz project
*
* @section History
* 4th February 2009: Created events.h from parts of level.h * 4th February 2009: Created events.h from parts of level.h
* 11th February 2009: Created bullet.h from parts of events.h * 11th February 2009: Created bullet.h from parts of events.h
* 1st March 2009: Created bird.h from parts of events.h * 1st March 2009: Created bird.h from parts of events.h
* 19th July 2009: Renamed events.h to event.h * 19th July 2009: Renamed events.h to event.h
* 2nd March 2010: Created guardians.h from parts of event.h * 2nd March 2010: Created guardians.h from parts of event.h
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -78,15 +79,16 @@ ...@@ -78,15 +79,16 @@
// Classes // Classes
class LevelPlayer; class LevelPlayer;
/// JJ1 level event
class Event : public Movable { class Event : public Movable {
protected: protected:
Event* next; Event* next;
unsigned char gridX, gridY; // Grid position of the event unsigned char gridX, gridY; ///< Grid position of the event
unsigned char animType; // E_LEFTANIM, etc, or 0 unsigned char animType; ///< E_LEFTANIM, etc, or 0
unsigned char frame; unsigned char frame; ///< Current animation frame
unsigned int flashTime; unsigned int flashTime;///< Time flash will end
bool noAnimOffset; bool noAnimOffset;
bool onlyLAnimOffset; bool onlyLAnimOffset;
bool onlyRAnimOffset; bool onlyRAnimOffset;
...@@ -118,7 +120,8 @@ class Event : public Movable { ...@@ -118,7 +120,8 @@ class Event : public Movable {
void drawEnergy (unsigned int ticks); void drawEnergy (unsigned int ticks);
}; };
/// JJ1 level bridge
class Bridge : public Event { class Bridge : public Event {
private: private:
......
/* /**
* *
* eventframe.cpp * @file eventframe.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 19th July 2009: Created eventframe.cpp from parts of events.cpp * 19th July 2009: Created eventframe.cpp from parts of events.cpp
* 2nd March 2010: Created guardians.cpp from parts of event.cpp and eventframe.cpp * 2nd March 2010: Created guardians.cpp from parts of event.cpp and eventframe.cpp
* 2nd March 2010: Created bridge.cpp from parts of event.cpp and eventframe.cpp * 2nd March 2010: Created bridge.cpp from parts of event.cpp and eventframe.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -19,9 +20,7 @@ ...@@ -19,9 +20,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Provides the once-per-frame functions of ordinary events. * Provides the once-per-frame functions of ordinary events.
* *
*/ */
...@@ -155,7 +154,7 @@ Event* Event::step (unsigned int ticks, int msps) { ...@@ -155,7 +154,7 @@ Event* Event::step (unsigned int ticks, int msps) {
case 5: case 5:
// TODO: Find out what this is /// @todo Find out what behaviour 5 is
break; break;
...@@ -182,19 +181,19 @@ Event* Event::step (unsigned int ticks, int msps) { ...@@ -182,19 +181,19 @@ Event* Event::step (unsigned int ticks, int msps) {
case 8: case 8:
// TODO: Bird-esque following /// @todo Bird-esque following
break; break;
case 9: case 9:
// TODO: Find out what this is /// @todo Find out what behaviour 9 is
break; break;
case 10: case 10:
// TODO: Find out what this is /// @todo Find out what behaviour 10 is
break; break;
...@@ -226,13 +225,13 @@ Event* Event::step (unsigned int ticks, int msps) { ...@@ -226,13 +225,13 @@ Event* Event::step (unsigned int ticks, int msps) {
case 14: case 14:
// TODO: Move back and forth rapidly /// @todo Move back and forth rapidly
break; break;
case 15: case 15:
// TODO: Rise or lower to meet jazz /// @todo Rise or lower to meet jazz
break; break;
...@@ -246,25 +245,25 @@ Event* Event::step (unsigned int ticks, int msps) { ...@@ -246,25 +245,25 @@ Event* Event::step (unsigned int ticks, int msps) {
case 17: case 17:
// TODO: Find out what this is /// @todo Find out what behaviour 17 is
break; break;
case 18: case 18:
// TODO: Find out what this is /// @todo Find out what behaviour 18 is
break; break;
case 19: case 19:
// TODO: Find out what this is /// @todo Find out what behaviour 19 is
break; break;
case 20: case 20:
// TODO: Find out what this is /// @todo Find out what behaviour 20 is
break; break;
...@@ -278,31 +277,31 @@ Event* Event::step (unsigned int ticks, int msps) { ...@@ -278,31 +277,31 @@ Event* Event::step (unsigned int ticks, int msps) {
case 22: case 22:
// TODO: Fall down in random spot and repeat /// @todo Fall down in random spot and repeat
break; break;
case 23: case 23:
// TODO: Find out what this is /// @todo Find out what behaviour 23 is
break; break;
case 24: case 24:
// TODO: Crawl along ground and go downstairs /// @todo Crawl along ground and go downstairs
break; break;
case 26: case 26:
// TODO: Find out what this is /// @todo Find out what behaviour 26 is
break; break;
case 27: case 27:
// TODO: Face jazz /// @todo Face jazz
break; break;
...@@ -467,49 +466,49 @@ Event* Event::step (unsigned int ticks, int msps) { ...@@ -467,49 +466,49 @@ Event* Event::step (unsigned int ticks, int msps) {
case 39: case 39:
// TODO: Collapsing floor /// @todo Collapsing floor
break; break;
case 40: case 40:
// TODO: Find out what this is /// @todo Find out what behaviour 40 is
break; break;
case 41: case 41:
// TODO: Switch left & right anim periodically /// @todo Switch left & right anim periodically
break; break;
case 42: case 42:
// TODO: Find out what this is /// @todo Find out what behaviour 42 is
break; break;
case 43: case 43:
// TODO: Find out what this is /// @todo Find out what behaviour 43 is
break; break;
case 44: case 44:
// TODO: Leap to greet Jazz very quickly /// @todo Leap to greet Jazz very quickly
break; break;
case 45: case 45:
// TODO: Find out what this is /// @todo Find out what behaviour 45 is
break; break;
case 46: case 46:
// TODO: "Final" boss /// @todo "Final" boss
break; break;
...@@ -533,7 +532,7 @@ Event* Event::step (unsigned int ticks, int msps) { ...@@ -533,7 +532,7 @@ Event* Event::step (unsigned int ticks, int msps) {
// 0: Static // 0: Static
// 25: Float up / Belt // 25: Float up / Belt
// TODO: Remaining event behaviours /// @todo Remaining event behaviours
break; break;
......
/* /**
* *
* guardians.cpp * @file guardians.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 2nd March 2010: Created guardians.cpp from parts of event.cpp and eventframe.cpp * 2nd March 2010: Created guardians.cpp from parts of event.cpp and eventframe.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -17,9 +18,7 @@ ...@@ -17,9 +18,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Provides the functions of guardian events. * Provides the functions of guardian events.
* *
*/ */
......
/* /**
* *
* guardians.h * @file guardians.h
* *
* Part of the OpenJazz project
*
* @section History
* 2nd March 2010: Created guardians.h from parts of event.h * 2nd March 2010: Created guardians.h from parts of event.h
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -29,7 +30,7 @@ ...@@ -29,7 +30,7 @@
// Class // Class
/// Guardian event base class
class Guardian : public Event { class Guardian : public Event {
protected: protected:
...@@ -40,7 +41,7 @@ class Guardian : public Event { ...@@ -40,7 +41,7 @@ class Guardian : public Event {
}; };
/// Episode B guardian
class DeckGuardian : public Guardian { class DeckGuardian : public Guardian {
public: public:
...@@ -52,7 +53,7 @@ class DeckGuardian : public Guardian { ...@@ -52,7 +53,7 @@ class DeckGuardian : public Guardian {
}; };
/// Episode 1 guardian
class MedGuardian : public Guardian { class MedGuardian : public Guardian {
private: private:
......
/* /**
* *
* level.cpp * @file level.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 23rd August 2005: Created level.c * 23rd August 2005: Created level.c
* 1st January 2006: Created events.c from parts of level.c * 1st January 2006: Created events.c from parts of level.c
* 22nd July 2008: Created levelload.c from parts of level.c * 22nd July 2008: Created levelload.c from parts of level.c
...@@ -17,9 +20,7 @@ ...@@ -17,9 +20,7 @@
* levelframe.cpp * levelframe.cpp
* 29th June 2010: Created jj2level.cpp from parts of level.cpp * 29th June 2010: Created jj2level.cpp from parts of level.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -29,9 +30,7 @@ ...@@ -29,9 +30,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Deals with the creating, playing and freeing of levels. * Deals with the creating, playing and freeing of levels.
* *
*/ */
...@@ -468,10 +467,13 @@ int Level::playBonus () { ...@@ -468,10 +467,13 @@ int Level::playBonus () {
} }
/**
* Interpret data received from client/server
*
* @param buffer Received data
*/
void Level::receive (unsigned char* buffer) { void Level::receive (unsigned char* buffer) {
// Interpret data received from client/server
switch (buffer[1]) { switch (buffer[1]) {
case MT_L_PROP: case MT_L_PROP:
......
/* /**
* *
* level.h * @file level.h
* *
* Part of the OpenJazz project
*
* @section History
* 31st January 2006: Created level.h from parts of OpenJazz.h * 31st January 2006: Created level.h from parts of OpenJazz.h
* 4th February 2009: Created events.h from parts of level.h * 4th February 2009: Created events.h from parts of level.h
* 19th March 2009: Created sprite.h from parts of level.h * 19th March 2009: Created sprite.h from parts of level.h
* 30th March 2010: Created baselevel.h from parts of level.h * 30th March 2010: Created baselevel.h from parts of level.h
* 29th June 2010: Created jj2level.h from parts of level.h * 29th June 2010: Created jj2level.h from parts of level.h
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -62,23 +63,25 @@ ...@@ -62,23 +63,25 @@
// Datatypes // Datatypes
/// JJ1 level grid element
typedef struct { typedef struct {
unsigned char tile; // Indexes the tile set unsigned char tile; ///< Indexes the tile set
unsigned char bg; // 0 = Effect background, 1 = Black background unsigned char bg; ///< 0 = Effect background, 1 = Black background
unsigned char event; // Indexes the event set unsigned char event; ///< Indexes the event set
unsigned char hits; // Number of times the event has been shot unsigned char hits; ///< Number of times the event has been shot
int time; /* Point at which the event will do something, e.g. terminate */ int time; ///< Point at which the event will do something, e.g. terminate
} GridElement; } GridElement;
/// Pre-defined JJ1 event movement path
typedef struct { typedef struct {
short int* x; short int* x; ///< X-coordinates for each node
short int* y; short int* y; ///< Y-coordinates for each node
unsigned char length; unsigned char length; ///< Number of nodes
unsigned char node; unsigned char node; ///< Current node
} EventPath; } EventPath;
...@@ -90,34 +93,38 @@ class Event; ...@@ -90,34 +93,38 @@ class Event;
class Font; class Font;
class LevelPlayer; class LevelPlayer;
class Scene; class Scene;
/// JJ1 level
class Level : public BaseLevel { class Level : public BaseLevel {
private: private:
SDL_Surface* tileSet; SDL_Surface* tileSet; ///< Tile images
SDL_Surface* panel; SDL_Surface* panel; ///< HUD background image
SDL_Surface* panelAmmo[5]; SDL_Surface* panelAmmo[5]; ///< HUD ammo type images
Event* events; Event* events; ///< Events
char* musicFile; char* musicFile; ///< Music file name
char* sceneFile; char* sceneFile; ///< File name of cutscene to play when level has been completed
Sprite* spriteSet; Sprite* spriteSet; ///< Sprites
Anim animSet[ANIMS]; Anim animSet[ANIMS]; ///< Animations
char miscAnims[4]; char miscAnims[4]; ///< Further animations
signed char bulletSet[BULLETS][BLENGTH]; signed char bulletSet[BULLETS][BLENGTH]; ///< Bullet types
signed char eventSet[EVENTS][ELENGTH]; signed char eventSet[EVENTS][ELENGTH]; ///< Event types
char mask[240][64]; // At most 240 tiles, all with 8 * 8 masks char mask[240][64]; ///< Tile masks. At most 240 tiles, all with 8 * 8 masks
GridElement grid[LH][LW]; // All levels are the same size GridElement grid[LH][LW]; ///< Level grid. All levels are the same size
int soundMap[32]; int soundMap[32]; ///< Maps event sound effect numbers to actual sound effect indices
SDL_Color skyPalette[256]; SDL_Color skyPalette[256]; ///< Full palette for sky background
bool sky; bool sky; ///< Whether or not to use sky background
unsigned char skyOrb; unsigned char skyOrb; ///< The tile to use as the background sun/moon/etc.
int levelNum, worldNum, nextLevelNum, nextWorldNum; int levelNum; ///<
unsigned char difficulty; int worldNum; ///<
int enemies; int nextLevelNum; ///<
fixed waterLevel; int nextWorldNum; ///<
fixed waterLevelTarget; unsigned char difficulty; ///< Difficulty setting (0 = easy, 1 = medium, 2 = hard, 3 = turbo)
fixed waterLevelSpeed; int enemies; ///< Number of enemies to kill
fixed energyBar; fixed waterLevel; ///< Height of water
fixed waterLevelTarget; ///< Future height of water
fixed waterLevelSpeed; ///< Rate of water level change
fixed energyBar; ///< HUD energy bar fullness
void deletePanel (); void deletePanel ();
int loadPanel (); int loadPanel ();
...@@ -127,15 +134,15 @@ class Level : public BaseLevel { ...@@ -127,15 +134,15 @@ class Level : public BaseLevel {
int playBonus (); int playBonus ();
protected: protected:
Font* font; Font* font; ///< On-screen message font
int load (char* fileName, unsigned char diff, bool checkpoint); int load (char* fileName, unsigned char diff, bool checkpoint);
int step (); int step ();
void draw (); void draw ();
public: public:
Bullet* bullets; Bullet* bullets; ///< Active bullets
EventPath path[PATHS]; EventPath path[PATHS]; ///< Pre-defined event movement paths
Level (); Level ();
Level (char* fileName, unsigned char diff, bool checkpoint, bool multi); Level (char* fileName, unsigned char diff, bool checkpoint, bool multi);
...@@ -167,11 +174,11 @@ class Level : public BaseLevel { ...@@ -167,11 +174,11 @@ class Level : public BaseLevel {
}; };
/// JJ1 level played as a demo
class DemoLevel : public Level { class DemoLevel : public Level {
private: private:
unsigned char* macro; unsigned char* macro; ///< Sequence of player control codes
public: public:
DemoLevel (const char* fileName); DemoLevel (const char* fileName);
...@@ -184,9 +191,9 @@ class DemoLevel : public Level { ...@@ -184,9 +191,9 @@ class DemoLevel : public Level {
// Variables // Variables
EXTERN Level* level; EXTERN Level* level; ///< JJ1 level
EXTERN int viewH; EXTERN int viewH; ///< Canvas height, minus 33 if the panel obscures the whole of the bottom of the canvas
#define viewW canvasW #define viewW canvasW
#endif #endif
......
/* /**
* *
* levelframe.cpp * @file levelframe.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 19th July 2009: Created levelframe.cpp from parts of level.cpp * 19th July 2009: Created levelframe.cpp from parts of level.cpp
* 30th March 2010: Created baselevel.cpp from parts of level.cpp and * 30th March 2010: Created baselevel.cpp from parts of level.cpp and
* levelframe.cpp * levelframe.cpp
* 29th June 2010: Created jj2levelframe.cpp from parts of levelframe.cpp * 29th June 2010: Created jj2levelframe.cpp from parts of levelframe.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -20,9 +21,7 @@ ...@@ -20,9 +21,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Provides the once-per-frame functions for levels. * Provides the once-per-frame functions for levels.
* *
*/ */
......
/* /**
* *
* levelload.cpp * @file levelload.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 22nd July 2008: Created levelload.c from parts of level.c * 22nd July 2008: Created levelload.c from parts of level.c
* 3rd February 2009: Renamed levelload.c to levelload.cpp * 3rd February 2009: Renamed levelload.c to levelload.cpp
* 18th July 2009: Created demolevel.cpp from parts of level.cpp and * 18th July 2009: Created demolevel.cpp from parts of level.cpp and
...@@ -10,9 +13,7 @@ ...@@ -10,9 +13,7 @@
* 19th July 2009: Added parts of levelload.cpp to level.cpp * 19th July 2009: Added parts of levelload.cpp to level.cpp
* 28th June 2010: Created levelloadjj2.cpp from parts of levelload.cpp * 28th June 2010: Created levelloadjj2.cpp from parts of levelload.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -22,9 +23,7 @@ ...@@ -22,9 +23,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Deals with the loading of level data. * Deals with the loading of level data.
* *
*/ */
......
/* /**
* *
* movable.cpp * @file movable.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 15th January 2010: Created movable.cpp * 15th January 2010: Created movable.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -17,9 +18,7 @@ ...@@ -17,9 +18,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Contains the base class for all movable objects. * Contains the base class for all movable objects.
* *
*/ */
......
/* /**
* *
* movable.h * @file movable.h
* *
* Part of the OpenJazz project
*
* @section History
* 15th January 2010: Created movable.h * 15th January 2010: Created movable.h
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -28,7 +29,8 @@ ...@@ -28,7 +29,8 @@
// Class // Class
/// Base class for all movable objects (players, events, bullets, birds)
class Movable { class Movable {
protected: protected:
......
/* /**
* *
* loop.h * @file loop.h
*
* 30th April 2010: Created loop.h from parts of OpenJazz.h
* *
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* @section History
* 30th April 2010: Created loop.h from parts of OpenJazz.h
* *
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -29,6 +30,7 @@ ...@@ -29,6 +30,7 @@
// Enum // Enum
/// Ways the loop function should handle input.
enum LoopType { enum LoopType {
NORMAL_LOOP, TYPING_LOOP, SET_KEY_LOOP, SET_JOYSTICK_LOOP NORMAL_LOOP, TYPING_LOOP, SET_KEY_LOOP, SET_JOYSTICK_LOOP
......
/* /**
*
* main.cpp
* *
* @file main.cpp
*
* Part of the OpenJazz project
*
* @section History
* 23rd August 2005: Created main.c * 23rd August 2005: Created main.c
* 22nd July 2008: Created util.c from parts of main.c * 22nd July 2008: Created util.c from parts of main.c
* 3rd February 2009: Renamed main.c to main.cpp * 3rd February 2009: Renamed main.c to main.cpp
* 4th February 2009: Created palette.cpp from parts of main.cpp and util.cpp * 4th February 2009: Created palette.cpp from parts of main.cpp and util.cpp
* 13th July 2009: Created controls.cpp from parts of main.cpp * 13th July 2009: Created controls.cpp from parts of main.cpp
* *
* Part of the OpenJazz project * @section Licence
* * Copyright (c) 2005-2010 Alister Thomson
* *
* Copyright (c) 2005-2010 Alister Thomson
*
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0 * the GNU General Public License, version 2.0
* *
...@@ -21,9 +22,7 @@ ...@@ -21,9 +22,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Contains the main function. * Contains the main function.
* *
*/ */
...@@ -63,7 +62,18 @@ extern float sinf (float); ...@@ -63,7 +62,18 @@ extern float sinf (float);
#define PI 3.141592f #define PI 3.141592f
/**
* Initialises OpenJazz.
*
* Establishes the paths from which to read files, loads configuration, sets up
* the game window and loads required data.
*
* @param argc Number of arguments, as passed to main function
* @param argv Array of argument strings, as apsse to main function
*
* @return Error code
*/
int loadMain (int argc, char *argv[]) { int loadMain (int argc, char *argv[]) {
File* file; File* file;
...@@ -400,6 +410,11 @@ int loadMain (int argc, char *argv[]) { ...@@ -400,6 +410,11 @@ int loadMain (int argc, char *argv[]) {
} }
/**
* De-initialises OpenJazz.
*
* Frees data, writes configuration, and shuts down SDL.
*/
void freeMain () { void freeMain () {
File *file; File *file;
...@@ -503,6 +518,16 @@ void freeMain () { ...@@ -503,6 +518,16 @@ void freeMain () {
} }
/**
* Process iteration.
*
* Called once per game iteration. Updates timing, video, and input
*
* @param type Type of loop. Normal, typing, or input configuration
* @param paletteEffects Palette effects to apply to video output
*
* @return Error code
*/
int loop (LoopType type, PaletteEffect* paletteEffects) { int loop (LoopType type, PaletteEffect* paletteEffects) {
SDL_Event event; SDL_Event event;
...@@ -597,6 +622,11 @@ int loop (LoopType type, PaletteEffect* paletteEffects) { ...@@ -597,6 +622,11 @@ int loop (LoopType type, PaletteEffect* paletteEffects) {
} }
/**
* Main.
*
* Initialises SDL and launches game.
*/
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
MainMenu *mainMenu = NULL; MainMenu *mainMenu = NULL;
......
/* /**
* *
* gamemenu.cpp * @file gamemenu.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 18th July 2009: Created menugame.cpp from parts of menu.cpp * 18th July 2009: Created menugame.cpp from parts of menu.cpp
* 26th July 2009: Renamed menugame.cpp to gamemenu.cpp * 26th July 2009: Renamed menugame.cpp to gamemenu.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -18,9 +19,7 @@ ...@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Deals with the running of the menus used to create a new game. * Deals with the running of the menus used to create a new game.
* *
*/ */
...@@ -234,7 +233,7 @@ int GameMenu::newGameDifficulty (GameModeType mode, int levelNum, int worldNum) ...@@ -234,7 +233,7 @@ int GameMenu::newGameDifficulty (GameModeType mode, int levelNum, int worldNum)
int GameMenu::loadGame () { int GameMenu::loadGame () {
// TODO: Actual loading of saved games /// @todo Actual loading of saved games
int option, worldNum, levelNum; int option, worldNum, levelNum;
......
/* /**
* *
* mainmenu.cpp * @file mainmenu.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 19th July 2009: Created menumain.cpp from parts of menu.cpp * 19th July 2009: Created menumain.cpp from parts of menu.cpp
* 26th July 2009: Renamed menumain.cpp to mainmenu.cpp * 26th July 2009: Renamed menumain.cpp to mainmenu.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -18,9 +19,7 @@ ...@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Deals with the running of the main menu and its generic sub-menus. * Deals with the running of the main menu and its generic sub-menus.
* *
*/ */
......
/* /**
* *
* menu.cpp * @file menu.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 23rd of August 2005: Created menu.c * 23rd of August 2005: Created menu.c
* 3rd of February 2009: Renamed menu.c to menu.cpp * 3rd of February 2009: Renamed menu.c to menu.cpp
* 9th March 2009: Created game.cpp from parts of menu.cpp and level.cpp * 9th March 2009: Created game.cpp from parts of menu.cpp and level.cpp
...@@ -12,9 +15,7 @@ ...@@ -12,9 +15,7 @@
* 19th July 2009: Created menumain.cpp from parts of menu.cpp * 19th July 2009: Created menumain.cpp from parts of menu.cpp
* 23rd June 2010: Merged menuutil.cpp into menu.cpp * 23rd June 2010: Merged menuutil.cpp into menu.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -24,9 +25,7 @@ ...@@ -24,9 +25,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Provides various generic menus. * Provides various generic menus.
* *
*/ */
...@@ -44,10 +43,11 @@ ...@@ -44,10 +43,11 @@
#include <string.h> #include <string.h>
/**
* Display a message to the user
*/
int Menu::message (const char* text) { int Menu::message (const char* text) {
// Display a message to the user
video.setPalette(menuPalette); video.setPalette(menuPalette);
while (true) { while (true) {
...@@ -71,10 +71,11 @@ int Menu::message (const char* text) { ...@@ -71,10 +71,11 @@ int Menu::message (const char* text) {
} }
/**
* Let the user select from a menu of the given options
*/
int Menu::generic (const char** optionNames, int options, int& chosen) { int Menu::generic (const char** optionNames, int options, int& chosen) {
// Let the user select from a menu of the given options
int count; int count;
video.setPalette(menuPalette); video.setPalette(menuPalette);
...@@ -121,10 +122,11 @@ int Menu::generic (const char** optionNames, int options, int& chosen) { ...@@ -121,10 +122,11 @@ int Menu::generic (const char** optionNames, int options, int& chosen) {
} }
/**
* Let the user edit a text string
*/
int Menu::textInput (const char* request, char*& text) { int Menu::textInput (const char* request, char*& text) {
// Let the user to edit a text string
char *input; char *input;
int count, terminate, character, x; int count, terminate, character, x;
unsigned int cursor; unsigned int cursor;
......
/* /**
* *
* menu.h * @file menu.h
* *
* Part of the OpenJazz project
*
* @section History
* 3rd February 2009: Created menu.h from parts of OpenJazz.h * 3rd February 2009: Created menu.h from parts of OpenJazz.h
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -39,7 +40,8 @@ ...@@ -39,7 +40,8 @@
// Classes // Classes
/// Menu base class, providing generic menu screens
class Menu { class Menu {
protected: protected:
...@@ -49,16 +51,16 @@ class Menu { ...@@ -49,16 +51,16 @@ class Menu {
}; };
/// New game menus
class GameMenu : public Menu { class GameMenu : public Menu {
private: private:
SDL_Surface* episodeScreens[11]; SDL_Surface* episodeScreens[11]; ///< Episode images
SDL_Surface* difficultyScreen; SDL_Surface* difficultyScreen; ///< 4 difficulty images
SDL_Color palette[256]; SDL_Color palette[256]; ///< Episode selection palette
SDL_Color greyPalette[256]; SDL_Color greyPalette[256]; ///< Greyed-out episode selection palette
int episodes; int episodes; ///< Number of episodes
unsigned char difficulty; unsigned char difficulty; ///< Difficulty setting (0 = easy, 1 = medium, 2 = hard, 3 = turbo (hard in JJ2 levels))
int newGameDifficulty (GameModeType mode, char* firstLevel); int newGameDifficulty (GameModeType mode, char* firstLevel);
int newGameDifficulty (GameModeType mode, int levelNum, int worldNum); int newGameDifficulty (GameModeType mode, int levelNum, int worldNum);
...@@ -75,7 +77,7 @@ class GameMenu : public Menu { ...@@ -75,7 +77,7 @@ class GameMenu : public Menu {
}; };
/// Setup menus
class SetupMenu : public Menu { class SetupMenu : public Menu {
private: private:
...@@ -92,15 +94,15 @@ class SetupMenu : public Menu { ...@@ -92,15 +94,15 @@ class SetupMenu : public Menu {
}; };
/// Main menu
class MainMenu : public Menu { class MainMenu : public Menu {
private: private:
SDL_Surface* background; SDL_Surface* background; ///< Menu image
SDL_Surface* highlight; SDL_Surface* highlight; ///< Menu image with highlighted text
SDL_Surface* logo; SDL_Surface* logo; ///< OJ logo image
GameMenu* gameMenu; GameMenu* gameMenu; ///< New game menu
SDL_Color palette[256]; SDL_Color palette[256]; ///< Menu palette
public: public:
MainMenu (); MainMenu ();
...@@ -113,7 +115,7 @@ class MainMenu : public Menu { ...@@ -113,7 +115,7 @@ class MainMenu : public Menu {
// Variable // Variable
EXTERN SDL_Color menuPalette[256]; EXTERN SDL_Color menuPalette[256]; /// Palette used by most menu screens
#endif #endif
/* /**
* *
* plasma.cpp * @file plasma.cpp
*
* 23rd June 2010: Created plasma.c
*
* Part of the OpenJazz project
* *
* Part of the OpenJazz project
*
* @section History
* 23rd June 2010: Created plasma.cpp
* *
* @section Licence
* Copyright (c) 2010 Alireza Nejati * Copyright (c) 2010 Alireza Nejati
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -17,10 +18,9 @@ ...@@ -17,10 +18,9 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Cool plasma effects for the main menu. * Cool plasma effects for the main menu.
*
*/ */
...@@ -35,7 +35,9 @@ ...@@ -35,7 +35,9 @@
#include "io/gfx/scale2x/scalebit.h" #include "io/gfx/scale2x/scalebit.h"
#endif #endif
// Precalculate buffers /**
* Precalculate buffers
*/
Plasma::Plasma(){ Plasma::Plasma(){
p0=0; p0=0;
...@@ -47,9 +49,11 @@ Plasma::Plasma(){ ...@@ -47,9 +49,11 @@ Plasma::Plasma(){
// -1024 < out < 1024 // -1024 < out < 1024
} }
// TODO: this code is awful in so many ways /// @todo this code is awful in so many ways
// Draws plasma onto canvas /**
* Draws plasma onto canvas
*/
int Plasma::draw(){ int Plasma::draw(){
int x,y; int x,y;
...@@ -59,7 +63,7 @@ int Plasma::draw(){ ...@@ -59,7 +63,7 @@ int Plasma::draw(){
unsigned char colour; unsigned char colour;
unsigned int colb; unsigned int colb;
// draw plasma // draw plasma
SDL_LockSurface(canvas); SDL_LockSurface(canvas);
...@@ -68,7 +72,7 @@ int Plasma::draw(){ ...@@ -68,7 +72,7 @@ int Plasma::draw(){
pitch = canvas->pitch; pitch = canvas->pitch;
px = (unsigned char *)canvas->pixels; px = (unsigned char *)canvas->pixels;
t1 = p0; t1 = p0;
t2 = p1; t2 = p1;
for(y=0;y<h;y++){ for(y=0;y<h;y++){
...@@ -81,7 +85,7 @@ int Plasma::draw(){ ...@@ -81,7 +85,7 @@ int Plasma::draw(){
t3 += 3; t3 += 3;
t4 += 2; t4 += 2;
px[x] = colour; px[x] = colour;
} }
// go to next row // go to next row
...@@ -89,12 +93,12 @@ int Plasma::draw(){ ...@@ -89,12 +93,12 @@ int Plasma::draw(){
t1 += 2; t1 += 2;
t2 += 1; t2 += 1;
} }
p0 = p0 < 256 ? p0+1 : 1; p0 = p0 < 256 ? p0+1 : 1;
p1 = p1 < 256 ? p1+2 : 2; p1 = p1 < 256 ? p1+2 : 2;
p2 = p2 < 256 ? p2+3 : 3; p2 = p2 < 256 ? p2+3 : 3;
p3 = p3 < 256 ? p3+4 : 4; p3 = p3 < 256 ? p3+4 : 4;
SDL_UnlockSurface(canvas); SDL_UnlockSurface(canvas);
return E_NONE; return E_NONE;
......
/* /**
* *
* plasma.h * @file plasma.h
* *
* Part of the OpenJazz project
*
* @section History
* 23rd June 2010: Created plasma.h * 23rd June 2010: Created plasma.h
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2010 Alireza Nejati * Copyright (c) 2010 Alireza Nejati
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -24,6 +25,7 @@ ...@@ -24,6 +25,7 @@
#include <SDL/SDL.h> #include <SDL/SDL.h>
/// Main menu background plasma effect
class Plasma { class Plasma {
private: private:
......
/* /**
* *
* setupmenu.cpp * @file setupmenu.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 18th July 2009: Created menusetup.cpp from parts of menu.cpp * 18th July 2009: Created menusetup.cpp from parts of menu.cpp
* 26th July 2009: Renamed menusetup.cpp to setupmenu.cpp * 26th July 2009: Renamed menusetup.cpp to setupmenu.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -18,9 +19,7 @@ ...@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Deals with the running of setup menus. * Deals with the running of setup menus.
* *
*/ */
......
/* /**
* *
* planet.cpp * @file planet.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 23rd August 2005: Created planet.c * 23rd August 2005: Created planet.c
* 3rd February 2009: Renamed planet.c to planet.cpp * 3rd February 2009: Renamed planet.c to planet.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2009 Alister Thomson * Copyright (c) 2005-2009 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -18,9 +19,7 @@ ...@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Deals with the loading, displaying and freeing of the planet landing * Deals with the loading, displaying and freeing of the planet landing
* sequence. * sequence.
* *
......
/* /**
* *
* planet.h * @file planet.h
* *
* Part of the OpenJazz project
*
* @section History
* 3rd of February 2009: Created planet.h * 3rd of February 2009: Created planet.h
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2009 Alister Thomson * Copyright (c) 2009 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -30,14 +31,15 @@ ...@@ -30,14 +31,15 @@
// Class // Class
/// Planet approach sequence
class Planet { class Planet {
private: private:
SDL_Color palette[256]; SDL_Color palette[256]; /// Palette
Sprite sprite; Sprite sprite; /// Planet image
char* name; char* name; /// Planet name
int id; int id; /// World number
public: public:
Planet (char * fileName, int previous); Planet (char * fileName, int previous);
......
/**
*
* @file symbian.cpp
*
* Part of the OpenJazz project
*
* @section Licence
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include <eikenv.h> #include <eikenv.h>
#include <eikapp.h> #include <eikapp.h>
#include <eikappui.h> #include <eikappui.h>
...@@ -12,7 +30,8 @@ ...@@ -12,7 +30,8 @@
char KOpenJazzPath[256]; char KOpenJazzPath[256];
FILE* mystdout = NULL; FILE* mystdout = NULL;
FILE *mystderr = NULL; FILE *mystderr = NULL;
/// Symbian app
class COpenJazzApp: public CSDLApp { class COpenJazzApp: public CSDLApp {
public: public:
COpenJazzApp(); COpenJazzApp();
......
/**
*
* @file wiz.cpp
*
* Part of the OpenJazz project
*
* @section Licence
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "wiz.h" #include "wiz.h"
#if defined(WIZ) || defined(GP2X) #if defined(WIZ) || defined(GP2X)
......
/**
*
* @file wiz.h
*
* Part of the OpenJazz project
*
* @section Licence
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef _WIZ_H #ifndef _WIZ_H
#define _WIZ_H #define _WIZ_H
......
/* /**
* *
* bird.cpp * @file bird.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 1st March 2009: Created bird.cpp from parts of events.cpp * 1st March 2009: Created bird.cpp from parts of events.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
......
/* /**
* *
* bird.h * @file bird.h
* *
* Part of the OpenJazz project
*
* @section History
* 1st March 2009: Created bird.h from parts of events.h * 1st March 2009: Created bird.h from parts of events.h
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -41,13 +42,14 @@ ...@@ -41,13 +42,14 @@
// Classes // Classes
class LevelPlayer; class LevelPlayer;
/// JJ1 bird companion
class Bird : public Movable { class Bird : public Movable {
private: private:
LevelPlayer* player; LevelPlayer* player; ///< Player that rescued the bird
bool fleeing; bool fleeing; ///< Flying away, player having been shot
unsigned int fireTime; unsigned int fireTime; ///< Next time the bird will fire
public: public:
Bird (LevelPlayer* player, unsigned char gX, unsigned char gY); Bird (LevelPlayer* player, unsigned char gX, unsigned char gY);
......
/* /**
* *
* bonusplayer.cpp * @file bonusplayer.cpp
*
* 24th June 2010: Created bonusplayer.cpp from parts of player.cpp and
* playerframe.cpp
* *
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* @section History
* 24th June 2010: Created bonusplayer.cpp from parts of player.cpp and
* playerframe.cpp
* *
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -18,9 +19,7 @@ ...@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Deals with players in bonus levels. * Deals with players in bonus levels.
* *
*/ */
...@@ -59,7 +58,7 @@ BonusPlayer::BonusPlayer (Player* parent, Anim **newAnims, unsigned char startX, ...@@ -59,7 +58,7 @@ BonusPlayer::BonusPlayer (Player* parent, Anim **newAnims, unsigned char startX,
for (count = 0; count < 256; count++) for (count = 0; count < 256; count++)
palette[count].r = palette[count].g = palette[count].b = count; palette[count].r = palette[count].g = palette[count].b = count;
// TODO: Custom colours /// @todo Custom colours
return; return;
......
/* /**
* *
* bonusplayer.h * @file bonusplayer.h
*
* 24th June 2010: Created bonusplayer.h from parts of player.h
* *
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* @section History
* 24th June 2010: Created bonusplayer.h from parts of player.h
* *
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -59,17 +60,21 @@ ...@@ -59,17 +60,21 @@
class Anim; class Anim;
class Bonus; class Bonus;
/// JJ1 bonus level player
class BonusPlayer { class BonusPlayer {
private: private:
SDL_Color palette[256]; SDL_Color palette[256]; ///< Palette (for custom colours)
Anim* anims[BPANIMS]; Anim* anims[BPANIMS]; ///< Animations
fixed x, y, direction, dr; fixed x; ///< X-coordinate
unsigned char animType; fixed y; ///< Y-coordinate
int gems; fixed direction; ///< Direction
fixed dr; ///< Forward speed
unsigned char animType; ///< Current animation
int gems; ///< Number of gems collected
public: public:
Player* player; Player* player; ///< Corresponding game player
BonusPlayer (Player* parent, Anim** newAnims, unsigned char startX, unsigned char startY); BonusPlayer (Player* parent, Anim** newAnims, unsigned char startX, unsigned char startY);
~BonusPlayer (); ~BonusPlayer ();
......
/* /**
* *
* jj2levelplayer.cpp * @file jj2levelplayer.cpp
*
* 29th June 2010: Created jj2levelplayer.cpp from parts of levelplayer.cpp
* *
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* @section History
* 29th June 2010: Created jj2levelplayer.cpp from parts of levelplayer.cpp
* *
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -17,9 +18,7 @@ ...@@ -17,9 +18,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Deals with the creation and destruction of players in levels, and their * Deals with the creation and destruction of players in levels, and their
* interactions with other level objects. * interactions with other level objects.
* *
...@@ -555,10 +554,11 @@ bool JJ2LevelPlayer::touchEvent (JJ2Event* touched, unsigned int ticks, int msps ...@@ -555,10 +554,11 @@ bool JJ2LevelPlayer::touchEvent (JJ2Event* touched, unsigned int ticks, int msps
} }
/**
* Copy data to be sent to clients/server
*/
void JJ2LevelPlayer::send (unsigned char *buffer) { void JJ2LevelPlayer::send (unsigned char *buffer) {
// Copy data to be sent to clients/server
buffer[9] = bird? 1: 0; buffer[9] = bird? 1: 0;
buffer[23] = energy; buffer[23] = energy;
buffer[25] = shield; buffer[25] = shield;
...@@ -586,10 +586,11 @@ void JJ2LevelPlayer::send (unsigned char *buffer) { ...@@ -586,10 +586,11 @@ void JJ2LevelPlayer::send (unsigned char *buffer) {
} }
/**
* Interpret data received from client/server
*/
void JJ2LevelPlayer::receive (unsigned char *buffer) { void JJ2LevelPlayer::receive (unsigned char *buffer) {
// Interpret data received from client/server
switch (buffer[1]) { switch (buffer[1]) {
case MT_P_ANIMS: case MT_P_ANIMS:
......
/* /**
* *
* jj2levelplayer.h * @file jj2levelplayer.h
*
* 29th June 2010: Created jj2levelplayer.h from parts of levelplayer.h
* *
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* @section History
* 29th June 2010: Created jj2levelplayer.h from parts of levelplayer.h
* *
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -226,12 +227,14 @@ ...@@ -226,12 +227,14 @@
// Enum // Enum
/// JJ2 player reaction type
enum JJ2PlayerReaction { enum JJ2PlayerReaction {
JJ2PR_NONE, JJ2PR_HURT, JJ2PR_KILLED, JJ2PR_INVINCIBLE JJ2PR_NONE, JJ2PR_HURT, JJ2PR_KILLED, JJ2PR_INVINCIBLE
}; };
/// JJ2 shield type
enum JJ2Shield { enum JJ2Shield {
JJ2S_NONE = 0, JJ2S_FLAME = 1, JJ2S_BUBBLE = 2, JJ2S_PLASMA = 3, JJ2S_LASER = 4 JJ2S_NONE = 0, JJ2S_FLAME = 1, JJ2S_BUBBLE = 2, JJ2S_PLASMA = 3, JJ2S_LASER = 4
...@@ -244,37 +247,39 @@ enum JJ2Shield { ...@@ -244,37 +247,39 @@ enum JJ2Shield {
class Anim; class Anim;
class JJ2Event; class JJ2Event;
/// JJ2 level player
class JJ2LevelPlayer : public Movable { class JJ2LevelPlayer : public Movable {
private: private:
bool bird; // Placeholder for eventual JJ2Bird object bool bird; ///< Placeholder for eventual JJ2Bird object
Anim* anims; Anim* anims; ///< Animations
Anim* flippedAnims; Anim* flippedAnims; ///< Animations (flipped)
JJ2Modifier* mod; JJ2Modifier* mod; ///< Modifier currently affecting player
SDL_Color palette[256]; SDL_Color palette[256]; ///< Palette (for custom colours)
int energy; int energy; ///< 0 = dead, 3 or 5 = maximum
JJ2Shield shield; JJ2Shield shield; ///< Current shield
int floating; /* 0 = normal, 1 = helicopter ears, 2 = boarding */ int floating; ///< 0 = normal, 1 = helicopter ears, 2 = boarding
bool facing; bool facing; ///< false = left, true = right
unsigned char animType; unsigned char animType; ///< Current animation
PlayerEvent event; PlayerEvent event; ///< Event type
int lookTime; /* Negative if looking up, positive if looking down, 0 if neither */ int lookTime; ///< Negative if looking up, positive if looking down, 0 if neither
JJ2PlayerReaction reaction; JJ2PlayerReaction reaction; ///< Reaction type
unsigned int reactionTime; unsigned int reactionTime; ///< Time reaction will end
unsigned int fireTime; unsigned int fireTime; ///< The next time the player can fire
fixed jumpHeight; fixed jumpHeight; ///< The height the player can reach when jumping
fixed throwX, throwY; fixed throwX; ///< Having been thrown, the x-coordinate the player can reach
fixed throwY; ///< Having been thrown, the y-coordinate the player can reach
unsigned int fastFeetTime; unsigned int fastFeetTime;
unsigned int stopTime; unsigned int stopTime;
int gems[4]; int gems[4]; ///< Gems collected
int coins; int coins; ///< Value of coins collected
void centreX (); void centreX ();
void centreY (); void centreY ();
void modify (JJ2Modifier* nextMod, unsigned int ticks); void modify (JJ2Modifier* nextMod, unsigned int ticks);
public: public:
Player* player; Player* player; ///< Corresponding game player
JJ2LevelPlayer (Player* parent, Anim** newAnims, unsigned char startX, unsigned char startY, bool hasBird); JJ2LevelPlayer (Player* parent, Anim** newAnims, unsigned char startX, unsigned char startY, bool hasBird);
~JJ2LevelPlayer (); ~JJ2LevelPlayer ();
......
/* /**
* *
* jj2levelplayerframe.cpp * @file jj2levelplayerframe.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 29th June 2010: Created jj2levelplayerframe.cpp from parts of * 29th June 2010: Created jj2levelplayerframe.cpp from parts of
* levelplayerframe.cpp * levelplayerframe.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -18,9 +19,7 @@ ...@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Provides the once-per-frame functions of players in levels. * Provides the once-per-frame functions of players in levels.
* *
*/ */
...@@ -178,14 +177,15 @@ void JJ2LevelPlayer::modify (JJ2Modifier* nextMod, unsigned int ticks) { ...@@ -178,14 +177,15 @@ void JJ2LevelPlayer::modify (JJ2Modifier* nextMod, unsigned int ticks) {
} }
/**
* Respond to controls, unless the player has been killed
*/
void JJ2LevelPlayer::control (unsigned int ticks, int msps) { void JJ2LevelPlayer::control (unsigned int ticks, int msps) {
JJ2Modifier* nextMod; JJ2Modifier* nextMod;
bool drop, platform; bool drop, platform;
// Respond to controls, unless the player has been killed
// If the player has been killed, do not move // If the player has been killed, do not move
if (!energy) { if (!energy) {
...@@ -449,7 +449,7 @@ void JJ2LevelPlayer::control (unsigned int ticks, int msps) { ...@@ -449,7 +449,7 @@ void JJ2LevelPlayer::control (unsigned int ticks, int msps) {
// Make sure bullet position is taken from correct animation // Make sure bullet position is taken from correct animation
if (platform) animType = PA_STANDSHOOT; if (platform) animType = PA_STANDSHOOT;
// TODO: Create new bullet /// @todo Create new bullet when firing
// Set when the next bullet can be fired // Set when the next bullet can be fired
if (player->fireSpeed) fireTime = ticks + (1000 / player->fireSpeed); if (player->fireSpeed) fireTime = ticks + (1000 / player->fireSpeed);
...@@ -748,12 +748,13 @@ void JJ2LevelPlayer::move (unsigned int ticks, int msps) { ...@@ -748,12 +748,13 @@ void JJ2LevelPlayer::move (unsigned int ticks, int msps) {
} }
/**
* Calculate viewport
*/
void JJ2LevelPlayer::view (unsigned int ticks, int mspf) { void JJ2LevelPlayer::view (unsigned int ticks, int mspf) {
int oldViewX, oldViewY, speed; int oldViewX, oldViewY, speed;
// Calculate viewport
// Record old viewport position for applying lag // Record old viewport position for applying lag
oldViewX = viewX; oldViewX = viewX;
oldViewY = viewY; oldViewY = viewY;
...@@ -847,7 +848,7 @@ void JJ2LevelPlayer::draw (unsigned int ticks, int change) { ...@@ -847,7 +848,7 @@ void JJ2LevelPlayer::draw (unsigned int ticks, int change) {
if (reaction == JJ2PR_INVINCIBLE) { if (reaction == JJ2PR_INVINCIBLE) {
// TODO: Show invincibility effect /// @todo Show invincibility effect
} }
...@@ -861,25 +862,25 @@ void JJ2LevelPlayer::draw (unsigned int ticks, int change) { ...@@ -861,25 +862,25 @@ void JJ2LevelPlayer::draw (unsigned int ticks, int change) {
case JJ2S_FLAME: case JJ2S_FLAME:
// TODO: Show shield effect /// @todo Show shield effect
break; break;
case JJ2S_BUBBLE: case JJ2S_BUBBLE:
// TODO: Show shield effect /// @todo Show shield effect
break; break;
case JJ2S_PLASMA: case JJ2S_PLASMA:
// TODO: Show shield effect /// @todo Show shield effect
break; break;
case JJ2S_LASER: case JJ2S_LASER:
// TODO: Show shield effect /// @todo Show shield effect
break; break;
......
/* /**
* *
* levelplayer.cpp * @file levelplayer.cpp
*
* 24th June 2010: Created levelplayer.cpp from parts of player.cpp
* 29th June 2010: Created jj2levelplayer.cpp from parts of levelplayer.cpp
* *
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* @section History
* 24th June 2010: Created levelplayer.cpp from parts of player.cpp
* 29th June 2010: Created jj2levelplayer.cpp from parts of levelplayer.cpp
* *
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -18,9 +19,7 @@ ...@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Deals with the creation and destruction of players in levels, and their * Deals with the creation and destruction of players in levels, and their
* interactions with other level objects. * interactions with other level objects.
* *
......
/* /**
* *
* levelplayer.h * @file levelplayer.h
*
* 24th June 2010: Created levelplayer.h from parts of player.h
* 29th June 2010: Created jj2levelplayer.h from parts of levelplayer.h
* *
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* @section History
* 24th June 2010: Created levelplayer.h from parts of player.h
* 29th June 2010: Created jj2levelplayer.h from parts of levelplayer.h
* *
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -135,6 +136,7 @@ ...@@ -135,6 +136,7 @@
// Enum // Enum
/// JJ1 player reaction type
enum PlayerReaction { enum PlayerReaction {
PR_NONE, PR_HURT, PR_KILLED, PR_INVINCIBLE PR_NONE, PR_HURT, PR_KILLED, PR_INVINCIBLE
...@@ -147,34 +149,37 @@ enum PlayerReaction { ...@@ -147,34 +149,37 @@ enum PlayerReaction {
class Anim; class Anim;
class Bird; class Bird;
/// JJ1 level player
class LevelPlayer : public Movable { class LevelPlayer : public Movable {
private: private:
Bird* bird; Bird* bird; ///< Bird companion
SDL_Color palette[256]; SDL_Color palette[256]; ///< Palette (for custom colours)
Anim* anims[PANIMS]; Anim* anims[PANIMS]; ///< Animations
int energy; int energy; ///< 0 = dead, 4 = maximum
int shield; /* 0 = none, 1 = 1 yellow, 2 = 2 yellow, 3 = 1 orange, 4 = 2 orange, 5 = 3 orange, 6 = 4 orange */ int shield; ///< 0 = none, 1 = 1 yellow, 2 = 2 yellow, 3 = 1 orange, 4 = 2 orange, 5 = 3 orange, 6 = 4 orange
bool floating; /* false = normal, true = boarding/bird/etc. */ bool floating; ///< false = normal, true = boarding/bird/etc.
bool facing; bool facing; ///< false = left, true = right
unsigned char animType; unsigned char animType; ///< Current animation
unsigned char eventX; unsigned char eventX; ///< X-coordinate (in tiles) of an event (spring, platform, bridge)
unsigned char eventY; /* Position of an event (spring, platform, bridge) */ unsigned char eventY; ///< Y-coordinate (in tiles) of an event (spring, platform, bridge)
PlayerEvent event; PlayerEvent event; ///< Event type
int lookTime; /* Negative if looking up, positive if looking down, 0 if neither */ int lookTime; ///< Negative if looking up, positive if looking down, 0 if neither
PlayerReaction reaction; PlayerReaction reaction; ///< Reaction type
unsigned int reactionTime; unsigned int reactionTime; ///< Time reaction will end
unsigned int fireTime; unsigned int fireTime; ///< The next time the player can fire
fixed jumpHeight; fixed jumpHeight; ///< The height the player can reach when jumping
fixed jumpY; fixed jumpY; ///< Having started jumping, the y-coordinate the player can reach
unsigned int fastFeetTime; unsigned int fastFeetTime; ///< Time fast feet will expire
unsigned char warpX, warpY; unsigned char warpX; ///< X-coordinate (in tiles) player will warp to
unsigned int warpTime; unsigned char warpY; ///< Y-coordinate (in tiles) player will warp to
int enemies, items; unsigned int warpTime; ///< Time the warp will happen
bool gem; int enemies; ///< Number of enemies killed
int items; ///< Number of items collected
bool gem; ///< Bonus level gem collected
public: public:
Player* player; Player* player; ///< Corresponding game player
LevelPlayer (Player* parent, Anim** newAnims, unsigned char startX, unsigned char startY, bool hasBird); LevelPlayer (Player* parent, Anim** newAnims, unsigned char startX, unsigned char startY, bool hasBird);
~LevelPlayer (); ~LevelPlayer ();
......
/* /**
* *
* levelplayerframe.cpp * @file levelplayerframe.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 18th July 2009: Created playerframe.cpp from parts of player.cpp * 18th July 2009: Created playerframe.cpp from parts of player.cpp
* 24th June 2010: Renamed playerframe.cpp to levelplayerframe.cpp * 24th June 2010: Renamed playerframe.cpp to levelplayerframe.cpp
* 29th June 2010: Created jj2levelplayerframe.cpp from parts of * 29th June 2010: Created jj2levelplayerframe.cpp from parts of
* levelplayerframe.cpp * levelplayerframe.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -20,9 +21,7 @@ ...@@ -20,9 +21,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Provides the once-per-frame functions of players in levels. * Provides the once-per-frame functions of players in levels.
* *
*/ */
...@@ -43,12 +42,14 @@ ...@@ -43,12 +42,14 @@
#include "util.h" #include "util.h"
/**
* Respond to controls, unless the player has been killed
*/
void LevelPlayer::control (unsigned int ticks, int msps) { void LevelPlayer::control (unsigned int ticks, int msps) {
int speed; int speed;
bool platform; bool platform;
// Respond to controls, unless the player has been killed
// If the player has been killed, drop but otherwise do not move // If the player has been killed, drop but otherwise do not move
if (!energy) { if (!energy) {
...@@ -619,12 +620,13 @@ void LevelPlayer::move (unsigned int ticks, int msps) { ...@@ -619,12 +620,13 @@ void LevelPlayer::move (unsigned int ticks, int msps) {
} }
/**
* Calculate viewport
*/
void LevelPlayer::view (unsigned int ticks, int mspf) { void LevelPlayer::view (unsigned int ticks, int mspf) {
int oldViewX, oldViewY, speed; int oldViewX, oldViewY, speed;
// Calculate viewport
// Record old viewport position for applying lag // Record old viewport position for applying lag
oldViewX = viewX; oldViewX = viewX;
oldViewY = viewY; oldViewY = viewY;
......
/* /**
* *
* player.cpp * @file player.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 3rd February 2009: Created player.cpp * 3rd February 2009: Created player.cpp
* 5th February 2009: Added parts of events.cpp and level.cpp to player.cpp * 5th February 2009: Added parts of events.cpp and level.cpp to player.cpp
* 19th March 2009: Created sprite.cpp from parts of event.cpp and player.cpp * 19th March 2009: Created sprite.cpp from parts of event.cpp and player.cpp
* 18th July 2009: Created playerframe.cpp from parts of player.cpp * 18th July 2009: Created playerframe.cpp from parts of player.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -20,9 +21,7 @@ ...@@ -20,9 +21,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Deals with the creation and destruction of players, and their interactions * Deals with the creation and destruction of players, and their interactions
* with other objects. * with other objects.
* *
...@@ -295,10 +294,11 @@ unsigned char Player::getTeam () { ...@@ -295,10 +294,11 @@ unsigned char Player::getTeam () {
} }
/**
* Copy data to be sent to clients/server
*/
void Player::send (unsigned char *buffer) { void Player::send (unsigned char *buffer) {
// Copy data to be sent to clients/server
buffer[3] = pcontrols[C_UP]; buffer[3] = pcontrols[C_UP];
buffer[4] = pcontrols[C_DOWN]; buffer[4] = pcontrols[C_DOWN];
buffer[5] = pcontrols[C_LEFT]; buffer[5] = pcontrols[C_LEFT];
...@@ -331,10 +331,11 @@ void Player::send (unsigned char *buffer) { ...@@ -331,10 +331,11 @@ void Player::send (unsigned char *buffer) {
} }
/**
* Interpret data received from client/server
*/
void Player::receive (unsigned char *buffer) { void Player::receive (unsigned char *buffer) {
// Interpret data received from client/server
if (buffer[1] == MT_P_TEMP) { if (buffer[1] == MT_P_TEMP) {
pcontrols[C_UP] = buffer[3]; pcontrols[C_UP] = buffer[3];
......
/* /**
* *
* player.h * @file player.h
* *
* Part of the OpenJazz project
*
* @section History
* 31st January 2006: Created player.h from parts of OpenJazz.h * 31st January 2006: Created player.h from parts of OpenJazz.h
* 24th June 2010: Created levelplayer.h from parts of player.h * 24th June 2010: Created levelplayer.h from parts of player.h
* 24th June 2010: Created bonusplayer.h from parts of player.h * 24th June 2010: Created bonusplayer.h from parts of player.h
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -50,6 +51,7 @@ ...@@ -50,6 +51,7 @@
// Enums // Enums
/// Player colours
enum PlayerColour { enum PlayerColour {
PC_GREY = 0, PC_GREY = 0,
...@@ -69,6 +71,7 @@ enum PlayerColour { ...@@ -69,6 +71,7 @@ enum PlayerColour {
}; };
/// Player event types
enum PlayerEvent { enum PlayerEvent {
LPE_NONE, LPE_SPRING, LPE_FLOAT, LPE_PLATFORM LPE_NONE, LPE_SPRING, LPE_FLOAT, LPE_PLATFORM
...@@ -82,28 +85,29 @@ class Anim; ...@@ -82,28 +85,29 @@ class Anim;
class LevelPlayer; class LevelPlayer;
class BonusPlayer; class BonusPlayer;
class JJ2LevelPlayer; class JJ2LevelPlayer;
/// Game player
class Player { class Player {
private: private:
LevelPlayer* levelPlayer; LevelPlayer* levelPlayer; ///< JJ1 level player
BonusPlayer* bonusPlayer; BonusPlayer* bonusPlayer; ///< JJ1 bonus level player
JJ2LevelPlayer* jj2LevelPlayer; JJ2LevelPlayer* jj2LevelPlayer; ///< JJ2 level player
char* name; char* name; ///< Name
bool pcontrols[PCONTROLS]; bool pcontrols[PCONTROLS]; ///< Control status
unsigned char cols[PCOLOURS]; unsigned char cols[PCOLOURS]; ///< Character colours
int ammo[4]; int ammo[4]; ///< Amount of ammo
int ammoType; /* -1 = blaster, 0 = toaster, 1 = missiles, 2 = bouncer 3 = TNT */ int ammoType; ///< Ammo type. -1 = blaster, 0 = toaster, 1 = missiles, 2 = bouncer 3 = TNT
int score; int score; ///< Total score
int lives; int lives; ///< Remaining lives
int fireSpeed; int fireSpeed; ///< Rapid-fire rate
bool bird; bool bird; ///< Accompanied by a bird
unsigned char team; unsigned char team; ///< Team ID
void addAmmo (int type, int amount); void addAmmo (int type, int amount);
public: public:
int teamScore; int teamScore; ///< Team's total score
Player (); Player ();
~Player (); ~Player ();
......
/* /**
* *
* scene.cpp * @file scene.cpp
* *
* Part of the OpenJazz project
*
* @section History
* 23rd August 2005: Created scene.c * 23rd August 2005: Created scene.c
* 3rd February 2009: Created scene.h from parts of scene.c * 3rd February 2009: Created scene.h from parts of scene.c
* 3rd February 2009: Renamed scene.c to scene.cpp * 3rd February 2009: Renamed scene.c to scene.cpp
* 27th March 2010: Created sceneload.cpp from parts of scene.cpp * 27th March 2010: Created sceneload.cpp from parts of scene.cpp
* *
* Part of the OpenJazz project * @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -20,9 +21,7 @@ ...@@ -20,9 +21,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ * @section Description
/*
* Deals with the displaying and freeing of the cutscenes. * Deals with the displaying and freeing of the cutscenes.
* *
*/ */
...@@ -198,7 +197,7 @@ Scene::Scene (const char * fileName) { ...@@ -198,7 +197,7 @@ Scene::Scene (const char * fileName) {
palettes = NULL; palettes = NULL;
animations = NULL; animations = NULL;
file->seek(ESignatureLength, true); // Skip Digital Dimensions header file->seek(0x13, true); // Skip Digital Dimensions header
signed long int dataOffset = file->loadInt(); //get offset pointer to first data block signed long int dataOffset = file->loadInt(); //get offset pointer to first data block
scriptItems = file->loadShort(); // Get number of script items scriptItems = file->loadShort(); // Get number of script items
......
/* /**
*
* scene.h
* *
* 3rd February 2009: Created scene.h from parts of scene.c * @file scene.h
* *
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* @section History
* 3rd February 2009: Created scene.h from parts of scene.c
* *
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -32,11 +33,12 @@ ...@@ -32,11 +33,12 @@
// Enums // Enums
/** /**
* Cutscene file animation headers
11 11
1L 1L
/0/0 /0/0
PB PB
FF FF
RN RN
RB RB
RC RC
...@@ -48,36 +50,28 @@ AN ...@@ -48,36 +50,28 @@ AN
_E _E
MX MX
ST ST
SL SL
*/ */
enum ANIHeaders enum ANIHeaders
{ {
E11AniHeader = 0x3131, // Background/start image E11AniHeader = 0x3131, ///< Background/start image
E1LAniHeader = 0x4c31, E1LAniHeader = 0x4c31,
EPBAniHeader = 0x4250, EPBAniHeader = 0x4250,
EFFAniHeader = 0x4646, // Floodfill? or full frame? EFFAniHeader = 0x4646, ///< Floodfill? or full frame?
ERNAniHeader = 0x4e52, ERNAniHeader = 0x4e52,
ERBAniHeader = 0x4252, ERBAniHeader = 0x4252,
ERCAniHeader = 0x4352, ERCAniHeader = 0x4352,
ERLAniHeader = 0x4c52, ERLAniHeader = 0x4c52,
ERRAniHeader = 0x5252, ERRAniHeader = 0x5252,
E_EHeader = 0x455F, // ANI End E_EHeader = 0x455F, ///< ANI End
ESquareAniHeader = 0x5b5d, ESquareAniHeader = 0x5b5d,
EMXAniHeader = 0x584d, EMXAniHeader = 0x584d,
ESTAniHeader = 0x5453, // Sound tag ESTAniHeader = 0x5453, ///< Sound tag
ESoundListAniHeader = 0x4C53, ESoundListAniHeader = 0x4C53,
EPlayListAniHeader = 0x4C50 EPlayListAniHeader = 0x4C50
}; };
enum /// Cutscene script types - these are the known types
{
ESignatureLength = 0x13,
EScriptStartTag = 0x50,
EAnimationData = 0x4e41
};
// These are the known script types
enum { enum {
ESceneYesNo = 0x23, ESceneYesNo = 0x23,
ESceneMusic = 0x2A, ESceneMusic = 0x2A,
...@@ -111,6 +105,7 @@ enum { ...@@ -111,6 +105,7 @@ enum {
class Font; class Font;
/// Cutscene page text
class SceneText { class SceneText {
public: public:
...@@ -127,6 +122,7 @@ class SceneText { ...@@ -127,6 +122,7 @@ class SceneText {
}; };
/// Cutscene page
class ScenePage { class ScenePage {
public: public:
...@@ -134,13 +130,13 @@ class ScenePage { ...@@ -134,13 +130,13 @@ class ScenePage {
int bgIndex[30]; int bgIndex[30];
unsigned short int bgX[30]; unsigned short int bgX[30];
unsigned short int bgY[30]; unsigned short int bgY[30];
int animLoops; int animLoops;
int animSpeed; int animSpeed;
int animIndex; int animIndex;
int nextPageAfterAnim; int nextPageAfterAnim;
// Length of the scene in seconds, or if zero = anim complete, or 256 = user interaction /// Length of the scene in seconds, or if zero = anim complete, or 256 = user interaction
int pageTime; int pageTime;
SceneText texts[100]; SceneText texts[100];
int nTexts; int nTexts;
...@@ -153,6 +149,7 @@ class ScenePage { ...@@ -153,6 +149,7 @@ class ScenePage {
}; };
/// Cutscene background image
class SceneImage { class SceneImage {
public: public:
...@@ -165,6 +162,7 @@ class SceneImage { ...@@ -165,6 +162,7 @@ class SceneImage {
}; };
/// Cutscene palette
class ScenePalette { class ScenePalette {
public: public:
...@@ -177,6 +175,7 @@ class ScenePalette { ...@@ -177,6 +175,7 @@ class ScenePalette {
}; };
/// Cutscene font
class SceneFont { class SceneFont {
public: public:
...@@ -185,6 +184,7 @@ class SceneFont { ...@@ -185,6 +184,7 @@ class SceneFont {
}; };
/// Cutscene animation frame
class SceneFrame class SceneFrame
{ {
public: public:
...@@ -198,6 +198,7 @@ public: ...@@ -198,6 +198,7 @@ public:
SceneFrame* prev; SceneFrame* prev;
}; };
/// Cutscene animation
class SceneAnimation class SceneAnimation
{ {
public: public:
...@@ -205,7 +206,7 @@ public: ...@@ -205,7 +206,7 @@ public:
~SceneAnimation (); ~SceneAnimation ();
void addFrame(int frameType, unsigned char* frameData, int frameSize); void addFrame(int frameType, unsigned char* frameData, int frameSize);
SDL_Surface* background; SDL_Surface* background;
SceneAnimation* next; SceneAnimation* next;
int id; int id;
int noSounds; int noSounds;
char soundNames[16][10]; char soundNames[16][10];
...@@ -215,9 +216,10 @@ public: ...@@ -215,9 +216,10 @@ public:
int reverseAnimation; int reverseAnimation;
}; };
/// Cutscene
class Scene { class Scene {
private: private:
SceneAnimation* animations; SceneAnimation* animations;
SceneImage* images; SceneImage* images;
ScenePalette* palettes; ScenePalette* palettes;
...@@ -228,7 +230,7 @@ class Scene { ...@@ -228,7 +230,7 @@ class Scene {
signed long int* scriptStarts; signed long int* scriptStarts;
signed long int* dataOffsets; signed long int* dataOffsets;
// Scripts all information needed to render script pages, text etc /// Scripts all information needed to render script pages, text etc
ScenePage* pages; ScenePage* pages;
void loadScripts (File* f); void loadScripts (File* f);
......
This diff is collapsed.
This diff is collapsed.
/* /**
* *
* util.h * @file util.h
*
* 30th April 2010: Created util.h from parts of OpenJazz.h
* *
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* @section History
* 30th April 2010: Created util.h from parts of OpenJazz.h
* *
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
...@@ -29,7 +30,7 @@ ...@@ -29,7 +30,7 @@
// Variable // Variable
// Trigonometric function look-up table /// Trigonometric function look-up table
EXTERN fixed sinLut[1024]; EXTERN fixed sinLut[1024];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment