[Change] Simply changed naming convention of private members to _member; rather than m_member;

This commit is contained in:
Rtch90 2011-12-17 23:41:22 +00:00
parent 2f05f06f10
commit 854c820140
36 changed files with 385 additions and 406 deletions

View File

@ -1,6 +1,6 @@
############################################################################# #############################################################################
# Makefile for building: Unuk-QT # Makefile for building: Unuk-QT
# Generated by qmake (2.01a) (Qt 4.7.3) on: Sat Dec 17 22:49:43 2011 # Generated by qmake (2.01a) (Qt 4.7.3) on: Sat Dec 17 23:40:48 2011
# Project: Unuk-QT.pro # Project: Unuk-QT.pro
# Template: app # Template: app
# Command: /usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug -o Makefile Unuk-QT.pro # Command: /usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug -o Makefile Unuk-QT.pro
@ -196,7 +196,7 @@ qmake: FORCE
dist: dist:
@$(CHK_DIR_EXISTS) .tmp/Unuk-QT1.0.0 || $(MKDIR) .tmp/Unuk-QT1.0.0 @$(CHK_DIR_EXISTS) .tmp/Unuk-QT1.0.0 || $(MKDIR) .tmp/Unuk-QT1.0.0
$(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/Unuk-QT1.0.0/ && $(COPY_FILE) --parents ../src/libUnuk/Debug.h ../src/Libs/wglext.h ../src/Libs/glxext.h ../src/libUnuk/Input.h ../src/libUnuk/Rect.h ../src/libUnuk/Timer.h ../src/libUnuk/Font.h ../Constants.h ../src/Unuk/Constants.h ../src/libUnuk/ApplySurface.h ../src/Unuk/Globals.h ../src/libUnuk/ImageLoader.h ../src/libUnuk/TextureManager.h ../src/libUnuk/Texture.h ../src/libUnuk/Text.h ../src/libUnuk/MapTile.h ../src/libUnuk/Map.h ../src/libUnuk/Button.h ../src/libUnuk/ButtonToggle.h ../src/libUnuk/Menu.h ../src/libUnuk/MainMenu.h ../src/libUnuk/ParticleEmitter.h ../src/libUnuk/IngameMenu.h ../src/libUnuk/Collision.h ../src/libUnuk/Character.h ../src/libUnuk/NPC.h ../src/Unuk/Player.h ../src/Unuk/Game.h ../src/libUnuk/MapElement.h ../src/libUnuk/MapEntities.h ../src/libUnuk/FPS.h ../src/libUnuk/DialogueBox.h .tmp/Unuk-QT1.0.0/ && $(COPY_FILE) --parents ../src/libUnuk/Debug.cpp ../src/Unuk/main.cpp ../src/libUnuk/Input.cpp ../src/libUnuk/Timer.cpp ../src/libUnuk/Font.cpp ../src/libUnuk/ApplySurface.cpp ../src/Unuk/Globals.cpp ../src/libUnuk/Rect.cpp ../src/libUnuk/ImageLoader.cpp ../src/libUnuk/TextureManager.cpp ../src/libUnuk/Texture.cpp ../src/libUnuk/Text.cpp ../src/libUnuk/Map.cpp ../src/libUnuk/Button.cpp ../src/libUnuk/ButtonToggle.cpp ../src/libUnuk/ParticleEmitter.cpp ../src/libUnuk/MainMenu.cpp ../src/libUnuk/IngameMenu.cpp ../src/libUnuk/Collision.cpp ../src/libUnuk/Character.cpp ../src/libUnuk/NPC.cpp ../src/Unuk/Player.cpp ../src/Unuk/Game.cpp ../src/libUnuk/MapElement.cpp ../src/libUnuk/MapEntities.cpp ../src/libUnuk/FPS.cpp ../src/libUnuk/DialogueBox.cpp .tmp/Unuk-QT1.0.0/ && (cd `dirname .tmp/Unuk-QT1.0.0` && $(TAR) Unuk-QT1.0.0.tar Unuk-QT1.0.0 && $(COMPRESS) Unuk-QT1.0.0.tar) && $(MOVE) `dirname .tmp/Unuk-QT1.0.0`/Unuk-QT1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/Unuk-QT1.0.0 $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/Unuk-QT1.0.0/ && $(COPY_FILE) --parents ../src/libUnuk/Debug.h ../src/Libs/wglext.h ../src/Libs/glxext.h ../src/libUnuk/Input.h ../src/libUnuk/Rect.h ../src/libUnuk/Timer.h ../src/libUnuk/Font.h ../Constants.h ../src/Unuk/Constants.h ../src/libUnuk/ApplySurface.h ../src/Unuk/Globals.h ../src/libUnuk/ImageLoader.h ../src/libUnuk/TextureManager.h ../src/libUnuk/Texture.h ../src/libUnuk/Text.h ../src/libUnuk/MapTile.h ../src/libUnuk/Map.h ../src/libUnuk/Button.h ../src/libUnuk/ButtonToggle.h ../src/libUnuk/MainMenu.h ../src/libUnuk/ParticleEmitter.h ../src/libUnuk/IngameMenu.h ../src/libUnuk/Collision.h ../src/libUnuk/Character.h ../src/libUnuk/NPC.h ../src/Unuk/Player.h ../src/Unuk/Game.h ../src/libUnuk/MapElement.h ../src/libUnuk/MapEntities.h ../src/libUnuk/FPS.h ../src/libUnuk/DialogueBox.h .tmp/Unuk-QT1.0.0/ && $(COPY_FILE) --parents ../src/libUnuk/Debug.cpp ../src/Unuk/main.cpp ../src/libUnuk/Input.cpp ../src/libUnuk/Timer.cpp ../src/libUnuk/Font.cpp ../src/libUnuk/ApplySurface.cpp ../src/Unuk/Globals.cpp ../src/libUnuk/Rect.cpp ../src/libUnuk/ImageLoader.cpp ../src/libUnuk/TextureManager.cpp ../src/libUnuk/Texture.cpp ../src/libUnuk/Text.cpp ../src/libUnuk/Map.cpp ../src/libUnuk/Button.cpp ../src/libUnuk/ButtonToggle.cpp ../src/libUnuk/ParticleEmitter.cpp ../src/libUnuk/MainMenu.cpp ../src/libUnuk/IngameMenu.cpp ../src/libUnuk/Collision.cpp ../src/libUnuk/Character.cpp ../src/libUnuk/NPC.cpp ../src/Unuk/Player.cpp ../src/Unuk/Game.cpp ../src/libUnuk/MapElement.cpp ../src/libUnuk/MapEntities.cpp ../src/libUnuk/FPS.cpp ../src/libUnuk/DialogueBox.cpp .tmp/Unuk-QT1.0.0/ && (cd `dirname .tmp/Unuk-QT1.0.0` && $(TAR) Unuk-QT1.0.0.tar Unuk-QT1.0.0 && $(COMPRESS) Unuk-QT1.0.0.tar) && $(MOVE) `dirname .tmp/Unuk-QT1.0.0`/Unuk-QT1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/Unuk-QT1.0.0
clean:compiler_clean clean:compiler_clean

View File

@ -26,7 +26,6 @@ HEADERS += ../src/libUnuk/Debug.h \
../src/libUnuk/Map.h \ ../src/libUnuk/Map.h \
../src/libUnuk/Button.h \ ../src/libUnuk/Button.h \
../src/libUnuk/ButtonToggle.h \ ../src/libUnuk/ButtonToggle.h \
../src/libUnuk/Menu.h \
../src/libUnuk/MainMenu.h \ ../src/libUnuk/MainMenu.h \
../src/libUnuk/ParticleEmitter.h \ ../src/libUnuk/ParticleEmitter.h \
../src/libUnuk/IngameMenu.h \ ../src/libUnuk/IngameMenu.h \

View File

@ -1,23 +1,23 @@
#include "Game.h" #include "Game.h"
Game::Game(void) { Game::Game(void) {
m_player = new Player(&m_map); _player = new Player(&_map);
m_npc = new NPC(&m_map); _npc = new NPC(&_map);
m_runGameReturnValue = gameMainMenu; _runGameReturnValue = gameMainMenu;
} }
Game::~Game(void) { Game::~Game(void) {
delete m_player; delete _player;
delete m_npc; delete _npc;
} }
gameNavVal_t Game::Run(const string savegameIDArg) { gameNavVal_t Game::Run(const string savegameIDArg) {
m_player->SetXY(50, 50); _player->SetXY(50, 50);
m_player->LoadSprites("../Data/Media/Images/Characters/template.png", 40, 45); _player->LoadSprites("../Data/Media/Images/Characters/template.png", 40, 45);
m_npc->SetXY(300, 300); _npc->SetXY(300, 300);
m_npc->LoadSprites("../Data/Media/Images/Characters/template.png", 40,45); _npc->LoadSprites("../Data/Media/Images/Characters/template.png", 40,45);
LoadSavegame(savegameIDArg); LoadSavegame(savegameIDArg);
@ -34,18 +34,18 @@ gameNavVal_t Game::Run(const string savegameIDArg) {
Timer renderTimer; Timer renderTimer;
Timer updateTimer; Timer updateTimer;
m_gameRenderTime.SetXY(10, 10); _gameRenderTime.SetXY(10, 10);
m_gameRenderTime.SetTextBlended("Render - XX", vsmall, COLOUR_BLACK); _gameRenderTime.SetTextBlended("Render - XX", vsmall, COLOUR_BLACK);
m_gameUpdateTime.SetXY(10, 30); _gameUpdateTime.SetXY(10, 30);
m_gameUpdateTime.SetTextBlended("Update - XX", vsmall, COLOUR_BLACK); _gameUpdateTime.SetTextBlended("Update - XX", vsmall, COLOUR_BLACK);
stringstream playerXYString; stringstream playerXYString;
m_playerXY.SetXY(10, 50); _playerXY.SetXY(10, 50);
m_playerXY.SetTextBlended("Player coords - XX XX", vsmall, COLOUR_BLACK); _playerXY.SetTextBlended("Player coords - XX XX", vsmall, COLOUR_BLACK);
m_gameRunning = true; _gameRunning = true;
while(m_gameRunning) { while(_gameRunning) {
updateTimer.Start(); updateTimer.Start();
while((int)SDL_GetTicks() > nextGameTick) { while((int)SDL_GetTicks() > nextGameTick) {
HandleInput(); HandleInput();
@ -73,12 +73,12 @@ gameNavVal_t Game::Run(const string savegameIDArg) {
// Check to see if we are allowed to display debug info. // Check to see if we are allowed to display debug info.
if(debugEnabled) { if(debugEnabled) {
m_gameUpdateTime.SetTextBlended("Update - " + updateTimer.GetTicksStr(), vsmall, COLOUR_BLACK); _gameUpdateTime.SetTextBlended("Update - " + updateTimer.GetTicksStr(), vsmall, COLOUR_BLACK);
m_gameRenderTime.SetTextBlended("Render - " + renderTimer.GetTicksStr(), vsmall, COLOUR_BLACK); _gameRenderTime.SetTextBlended("Render - " + renderTimer.GetTicksStr(), vsmall, COLOUR_BLACK);
playerXYString.str(""); playerXYString.str("");
playerXYString << "Player coords: x" << m_player->GetX() << ", y" << m_player->GetY(); playerXYString << "Player coords: x" << _player->GetX() << ", y" << _player->GetY();
m_playerXY.SetTextBlended(playerXYString.str(), vsmall, COLOUR_BLACK); _playerXY.SetTextBlended(playerXYString.str(), vsmall, COLOUR_BLACK);
} }
} }
// Restrict the fps. // Restrict the fps.
@ -91,32 +91,32 @@ gameNavVal_t Game::Run(const string savegameIDArg) {
frameTimer.Start(); frameTimer.Start();
frame++; frame++;
} }
return m_runGameReturnValue; return _runGameReturnValue;
} }
void Game::HandleInput(void) { void Game::HandleInput(void) {
if(m_ingameMenu.GetStatus() == false) { if(_ingameMenu.GetStatus() == false) {
while(SDL_PollEvent(&event)) { while(SDL_PollEvent(&event)) {
m_player->HandleInput(); _player->HandleInput();
if(event.key.type == SDL_KEYDOWN) { if(event.key.type == SDL_KEYDOWN) {
if(event.key.keysym.sym == SDLK_ESCAPE) if(event.key.keysym.sym == SDLK_ESCAPE)
m_ingameMenu.SetStatus(true); _ingameMenu.SetStatus(true);
if(event.key.keysym.sym == SDLK_p) if(event.key.keysym.sym == SDLK_p)
debugEnabled = !debugEnabled; debugEnabled = !debugEnabled;
} }
else if(event.type == SDL_QUIT) { else if(event.type == SDL_QUIT) {
m_gameRunning = false; _gameRunning = false;
m_runGameReturnValue = gameQuitGame; _runGameReturnValue = gameQuitGame;
break; break;
} }
} }
} else { } else {
switch(m_ingameMenu.HandleInput()) { switch(_ingameMenu.HandleInput()) {
case ingameMenuNothing: case ingameMenuNothing:
break; break;
case ingameMenuResume: case ingameMenuResume:
m_ingameMenu.SetStatus(false); _ingameMenu.SetStatus(false);
break; break;
case ingameMenuSaveGame: case ingameMenuSaveGame:
break; break;
@ -125,49 +125,49 @@ void Game::HandleInput(void) {
case ingameMenuOptions: case ingameMenuOptions:
break; break;
case ingameMenuMainMenu: case ingameMenuMainMenu:
m_gameRunning = false; _gameRunning = false;
break; break;
} }
if(event.type == SDL_QUIT) { if(event.type == SDL_QUIT) {
m_gameRunning = false; _gameRunning = false;
m_ingameMenu.SetStatus(false); _ingameMenu.SetStatus(false);
m_runGameReturnValue = gameQuitGame; _runGameReturnValue = gameQuitGame;
} }
} }
} }
void Game::UpdateGame(void) { void Game::UpdateGame(void) {
if(m_ingameMenu.GetStatus() == false) { if(_ingameMenu.GetStatus() == false) {
m_player->Update(); _player->Update();
m_npc->Update(); _npc->Update();
} else { } else {
// :D // :D
} }
} }
void Game::Render(void) { void Game::Render(void) {
if(m_ingameMenu.GetStatus() == false) { if(_ingameMenu.GetStatus() == false) {
m_map.Render(); _map.Render();
m_player->Render(); _player->Render();
m_npc->Render(); _npc->Render();
if(debugEnabled) { if(debugEnabled) {
m_gameRenderTime.RenderLiteral(); _gameRenderTime.RenderLiteral();
m_gameUpdateTime.RenderLiteral(); _gameUpdateTime.RenderLiteral();
m_playerXY.RenderLiteral(); _playerXY.RenderLiteral();
} }
} else { } else {
m_ingameMenu.Render(); _ingameMenu.Render();
} }
SDL_Flip(screen); SDL_Flip(screen);
} }
void Game::LoadSavegame(const string savegameIDArg) { void Game::LoadSavegame(const string savegameIDArg) {
m_saveGameID = savegameIDArg; _saveGameID = savegameIDArg;
string saveFilename = "../Save/" + m_saveGameID; string saveFilename = "../Save/" + _saveGameID;
// Converting to XML ftw! // Converting to XML ftw!
TiXmlDocument mapFile(saveFilename.c_str()); TiXmlDocument mapFile(saveFilename.c_str());
@ -183,7 +183,7 @@ void Game::LoadSavegame(const string savegameIDArg) {
// <name> - Parse the player name. // <name> - Parse the player name.
dataElem = rootElem->FirstChildElement("name"); dataElem = rootElem->FirstChildElement("name");
assert(dataElem != NULL); assert(dataElem != NULL);
m_player->SetName(dataElem->GetText()); _player->SetName(dataElem->GetText());
// </name> // </name>
// <x> - Parse the player x coord. // <x> - Parse the player x coord.
@ -198,12 +198,12 @@ void Game::LoadSavegame(const string savegameIDArg) {
int playerY = atoi(dataElem->GetText()); int playerY = atoi(dataElem->GetText());
// </y> // </y>
m_player->SetXY(playerX, playerY); _player->SetXY(playerX, playerY);
// <map> - Parse the map file. // <map> - Parse the map file.
dataElem = dataElem->NextSiblingElement("map"); dataElem = dataElem->NextSiblingElement("map");
assert(dataElem != NULL); assert(dataElem != NULL);
m_map.Load(dataElem->GetText()); _map.Load(dataElem->GetText());
// </map> // </map>
} }
// <save> // <save>
@ -212,7 +212,7 @@ void Game::LoadSavegame(const string savegameIDArg) {
} }
void Game::SaveSavegame(void) { void Game::SaveSavegame(void) {
string saveFilename = "../Save/" + m_saveGameID; string saveFilename = "../Save/" + _saveGameID;
ofstream saveFile(saveFilename.c_str()); ofstream saveFile(saveFilename.c_str());
assert(saveFile.is_open()); assert(saveFile.is_open());

View File

@ -40,22 +40,22 @@ private:
static const int GAME_UPDATES_PER_SECOND = 60; static const int GAME_UPDATES_PER_SECOND = 60;
static const int SKIP_TICKS = 1000 / GAME_UPDATES_PER_SECOND; static const int SKIP_TICKS = 1000 / GAME_UPDATES_PER_SECOND;
bool m_gameRunning; bool _gameRunning;
gameNavVal_t m_runGameReturnValue; gameNavVal_t _runGameReturnValue;
string m_saveGameID; string _saveGameID;
string m_mapID; string _mapID;
Text m_gameUpdateTime; Text _gameUpdateTime;
Text m_gameRenderTime; Text _gameRenderTime;
Text m_playerXY; Text _playerXY;
IngameMenu m_ingameMenu; IngameMenu _ingameMenu;
Map m_map; Map _map;
Player* m_player; Player* _player;
NPC* m_npc; NPC* _npc;
}; };
#endif #endif

View File

@ -17,22 +17,22 @@ void Player::HandleInput(void) {
case SDLK_w: case SDLK_w:
yVel -= PLAYER_SPEED; yVel -= PLAYER_SPEED;
xVel = 0; xVel = 0;
m_directionFacing = FACING_UP; directionFacing = FACING_UP;
break; break;
case SDLK_s: case SDLK_s:
yVel += PLAYER_SPEED; yVel += PLAYER_SPEED;
xVel = 0; xVel = 0;
m_directionFacing = FACING_DOWN; directionFacing = FACING_DOWN;
break; break;
case SDLK_a: case SDLK_a:
xVel -= PLAYER_SPEED; xVel -= PLAYER_SPEED;
yVel = 0; yVel = 0;
m_directionFacing = FACING_LEFT; directionFacing = FACING_LEFT;
break; break;
case SDLK_d: case SDLK_d:
xVel += PLAYER_SPEED; xVel += PLAYER_SPEED;
yVel = 0; yVel = 0;
m_directionFacing = FACING_RIGHT; directionFacing = FACING_RIGHT;
break; break;
default: default:
break; break;
@ -49,8 +49,8 @@ void Player::HandleInput(void) {
} }
else if(event.type == SDL_MOUSEBUTTONDOWN) { else if(event.type == SDL_MOUSEBUTTONDOWN) {
if(event.button.button == SDL_BUTTON_LEFT) { if(event.button.button == SDL_BUTTON_LEFT) {
m_attacking = true; attacking = true;
m_attackTimer.Start(); attackTimer.Start();
} }
} }
} }
@ -61,7 +61,7 @@ void Player::Update(void) {
} }
void Player::SetName(string nameArg) { void Player::SetName(string nameArg) {
m_name = nameArg; _name = nameArg;
} }
void Player::SetCamera(void) { void Player::SetCamera(void) {

View File

@ -15,7 +15,7 @@ public:
void Update(void); void Update(void);
void SetName(string nameArg); void SetName(string nameArg);
string GetName(void) { return m_name; } string GetName(void) { return _name; }
protected: protected:
void Move(void); void Move(void);
@ -25,7 +25,7 @@ private:
void SetCamera(void); void SetCamera(void);
static const float PLAYER_SPEED; static const float PLAYER_SPEED;
string m_name; string _name;
}; };
#endif #endif

View File

@ -10,24 +10,24 @@ Button::~Button(void) {
void Button::SetOutRGB(Uint8 r, Uint8 g, Uint8 b) { void Button::SetOutRGB(Uint8 r, Uint8 g, Uint8 b) {
button.SetRGB(r, g, b); button.SetRGB(r, g, b);
m_mouseOutColour.r = r; _mouseOutColour.r = r;
m_mouseOutColour.g = g; _mouseOutColour.g = g;
m_mouseOutColour.b = b; _mouseOutColour.b = b;
} }
void Button::SetOutRGB(SDL_Color colour) { void Button::SetOutRGB(SDL_Color colour) {
button.SetRGB(colour); button.SetRGB(colour);
m_mouseOutColour = colour; _mouseOutColour = colour;
} }
void Button::SetOverRGB(Uint8 r, Uint8 g, Uint8 b) { void Button::SetOverRGB(Uint8 r, Uint8 g, Uint8 b) {
m_mouseOverColour.r = r; _mouseOverColour.r = r;
m_mouseOverColour.g = g; _mouseOverColour.g = g;
m_mouseOverColour.b = b; _mouseOverColour.b = b;
} }
void Button::SetOverRGB(SDL_Color colour) { void Button::SetOverRGB(SDL_Color colour) {
m_mouseOverColour = colour; _mouseOverColour = colour;
} }
void Button::SetXY(int xArg, int yArg) { void Button::SetXY(int xArg, int yArg) {
@ -35,47 +35,47 @@ void Button::SetXY(int xArg, int yArg) {
y = yArg; y = yArg;
button.SetXY(x, y); button.SetXY(x, y);
m_text.SetXY(x + 10, y + 10); _text.SetXY(x + 10, y + 10);
} }
void Button::SetTextRGB(Uint8 r, Uint8 g, Uint8 b) { void Button::SetTextRGB(Uint8 r, Uint8 g, Uint8 b) {
m_textColour.r = r; _textColour.r = r;
m_textColour.g = g; _textColour.g = g;
m_textColour.b = b; _textColour.b = b;
m_text.SetTextBlended(m_text.GetText(), small, m_textColour); _text.SetTextBlended(_text.GetText(), small, _textColour);
} }
void Button::SetTextRGB(SDL_Color colour) { void Button::SetTextRGB(SDL_Color colour) {
m_textColour = colour; _textColour = colour;
m_text.SetTextBlended(m_text.GetText(), small, colour); _text.SetTextBlended(_text.GetText(), small, colour);
} }
void Button::SetText(string textArg) { void Button::SetText(string textArg) {
m_text.SetTextBlended(textArg, small, m_textColour); _text.SetTextBlended(textArg, small, _textColour);
w = m_text.GetWidth(); w = _text.GetWidth();
h = m_text.GetHeight(); h = _text.GetHeight();
button.SetWidthHeight(w + 20, h + 15); button.SetWidthHeight(w + 20, h + 15);
} }
bool Button::CheckMouseOver(void) { bool Button::CheckMouseOver(void) {
if(event.motion.x > button.GetX() && event.motion.x < button.GetX() + button.GetWidth()) { if(event.motion.x > button.GetX() && event.motion.x < button.GetX() + button.GetWidth()) {
if(event.motion.y > button.GetY() && event.motion.y < button.GetY() + button.GetHeight()) { if(event.motion.y > button.GetY() && event.motion.y < button.GetY() + button.GetHeight()) {
button.SetRGB(m_mouseOverColour.r, m_mouseOverColour.g, m_mouseOverColour.b); button.SetRGB(_mouseOverColour.r, _mouseOverColour.g, _mouseOverColour.b);
return true; return true;
} }
} }
button.SetRGB(m_mouseOutColour); button.SetRGB(_mouseOutColour);
return false; return false;
} }
void Button::Render(void) { void Button::Render(void) {
button.DrawLiteral(); button.DrawLiteral();
m_text.RenderLiteral(); _text.RenderLiteral();
} }
void Button::Render(int xArg, int yArg) { void Button::Render(int xArg, int yArg) {
button.DrawLiteral(xArg, yArg); button.DrawLiteral(xArg, yArg);
m_text.RenderLiteral(xArg, yArg); _text.RenderLiteral(xArg, yArg);
} }

View File

@ -35,9 +35,9 @@ public:
void Render(int xArg, int yArg); void Render(int xArg, int yArg);
private: private:
SDL_Color m_mouseOutColour; SDL_Color _mouseOutColour;
SDL_Color m_mouseOverColour; SDL_Color _mouseOverColour;
SDL_Color m_textColour; SDL_Color _textColour;
int x; int x;
int y; int y;
@ -45,7 +45,7 @@ private:
int h; int h;
Rect button; Rect button;
Text m_text; Text _text;
}; };
#endif #endif

View File

@ -25,11 +25,11 @@ void ButtonToggle::SetOffRGB(SDL_Color colour) {
} }
void ButtonToggle::SetOnRGB(Uint8 r, Uint8 g, Uint8 b) { void ButtonToggle::SetOnRGB(Uint8 r, Uint8 g, Uint8 b) {
m_onColour.r = r; _onColour.r = r;
m_onColour.g = g; _onColour.g = g;
m_onColour.b = b; _onColour.b = b;
} }
void ButtonToggle::SetOnRGB(SDL_Color colour) { void ButtonToggle::SetOnRGB(SDL_Color colour) {
m_onColour = colour; _onColour = colour;
} }

View File

@ -22,18 +22,18 @@ public:
void SetOffText(string); void SetOffText(string);
void SetState(bool); void SetState(bool);
bool GetState(void) { return m_state; } bool GetState(void) { return _state; }
bool CheckMouseOver(void); bool CheckMouseOver(void);
void Render(void); void Render(void);
private: private:
bool m_state; bool _state;
SDL_Colour m_onColour; SDL_Colour _onColour;
Text m_onText; Text _onText;
}; };

View File

@ -8,22 +8,22 @@ static list<Character*>::iterator collisionIter;
Character::Character(Map* mapArg) { Character::Character(Map* mapArg) {
map = mapArg; map = mapArg;
m_attacking = false; attacking = false;
m_directionFacing = FACING_DOWN; directionFacing = FACING_DOWN;
m_animationStage = ANIM_NO_FOOT; _animationStage = ANIM_NO_FOOT;
m_animationTimer.Start(); _animationTimer.Start();
m_leftFoot = false; _leftFoot = false;
xVel = 0.0f; xVel = 0.0f;
yVel = 0.0f; yVel = 0.0f;
m_texture = NULL; _texture = NULL;
collisionList.push_front(this); collisionList.push_front(this);
} }
Character::~Character(void) { Character::~Character(void) {
SDL_FreeSurface(m_texture); SDL_FreeSurface(_texture);
for(collisionIter = collisionList.begin(); collisionIter != collisionList.end(); collisionIter++) { for(collisionIter = collisionList.begin(); collisionIter != collisionList.end(); collisionIter++) {
if((*collisionIter) == this) { if((*collisionIter) == this) {
collisionList.erase(collisionIter); collisionList.erase(collisionIter);
@ -33,37 +33,37 @@ Character::~Character(void) {
} }
void Character::LoadSprites(string filename, int wArg, int hArg) { void Character::LoadSprites(string filename, int wArg, int hArg) {
if(m_texture != NULL) if(_texture != NULL)
SDL_FreeSurface(m_texture); SDL_FreeSurface(_texture);
m_texture = LoadImageAlpha(filename.c_str()); _texture = LoadImageAlpha(filename.c_str());
w = wArg; w = wArg;
h = hArg; h = hArg;
for(int m_direction = 0; m_direction < 4; m_direction++) { for(int m_direction = 0; m_direction < 4; m_direction++) {
for(int m_action = 0; m_action < 4; m_action++) { for(int m_action = 0; m_action < 4; m_action++) {
sprites[m_direction][m_action].x = w * m_action; _sprites[m_direction][m_action].x = w * m_action;
sprites[m_direction][m_action].y = h * m_direction; _sprites[m_direction][m_action].y = h * m_direction;
sprites[m_direction][m_action].w = w; _sprites[m_direction][m_action].w = w;
sprites[m_direction][m_action].h = h; _sprites[m_direction][m_action].h = h;
} }
} }
} }
void Character::AddSpeachBubble(string text) { void Character::AddSpeachBubble(string text) {
m_speachBubble.push_back(text); _speachBubble.push_back(text);
//m_speachBubbleText.SetTextBlended(text, "small", 0, 0, 0); //m_speachBubbleText.SetTextBlended(text, "small", 0, 0, 0);
if(m_speachBubbleTimer.IsStarted() == false) if(_speachBubbleTimer.IsStarted() == false)
m_speachBubbleTimer.Start(); _speachBubbleTimer.Start();
} }
void Character::Render(void) { void Character::Render(void) {
// Draw some fancy speach bubbles. It is a bit of a mess, I am playing. // Draw some fancy speach bubbles. It is a bit of a mess, I am playing.
if(m_speachBubble.size() != 0) { if(_speachBubble.size() != 0) {
if(m_speachBubbleTimer.GetTicks() < SPEACH_BUBBLE_DISPLAY_LENGTH) { if(_speachBubbleTimer.GetTicks() < SPEACH_BUBBLE_DISPLAY_LENGTH) {
roundedBoxRGBA(screen, (x + w / 2) - 100, roundedBoxRGBA(screen, (x + w / 2) - 100,
y - 100, y - 100,
(x + w / 2) + 100, (x + w / 2) + 100,
@ -78,53 +78,53 @@ void Character::Render(void) {
y - 40, y - 40,
255, 255, 255, 255); 255, 255, 255, 255);
m_speachBubbleText.Render((x + w / 2) - 90, y - 90); _speachBubbleText.Render((x + w / 2) - 90, y - 90);
} }
} }
if(m_attacking && m_attackTimer.GetTicks() < ATTACKING_DISPLAY_LEN) { if(attacking && attackTimer.GetTicks() < ATTACKING_DISPLAY_LEN) {
ApplySurface(x, y, m_texture, screen, &sprites[m_directionFacing][ANIM_ATTACK]); ApplySurface(x, y, _texture, screen, &_sprites[directionFacing][ANIM_ATTACK]);
return; return;
} }
else if(m_attacking) else if(attacking)
m_attacking = false; attacking = false;
if(xVel == 0.0f && yVel == 0.0f) if(xVel == 0.0f && yVel == 0.0f)
ApplySurface(x, y, m_texture, screen, &sprites[m_directionFacing][ANIM_NO_FOOT]); ApplySurface(x, y, _texture, screen, &_sprites[directionFacing][ANIM_NO_FOOT]);
else { else {
if(m_animationTimer.GetTicks() > ANIMATION_SPEED) { if(_animationTimer.GetTicks() > ANIMATION_SPEED) {
if(m_animationStage == ANIM_NO_FOOT) { if(_animationStage == ANIM_NO_FOOT) {
if(m_leftFoot == true) if(_leftFoot == true)
m_animationStage = ANIM_RIGHT_FOOT; _animationStage = ANIM_RIGHT_FOOT;
else else
m_animationStage = ANIM_LEFT_FOOT; _animationStage = ANIM_LEFT_FOOT;
} }
else if(m_animationStage == ANIM_LEFT_FOOT) { else if(_animationStage == ANIM_LEFT_FOOT) {
m_animationStage = ANIM_NO_FOOT; _animationStage = ANIM_NO_FOOT;
m_leftFoot = true; _leftFoot = true;
} }
else if(m_animationStage == ANIM_RIGHT_FOOT) { else if(_animationStage == ANIM_RIGHT_FOOT) {
m_animationStage = ANIM_NO_FOOT; _animationStage = ANIM_NO_FOOT;
m_leftFoot = false; _leftFoot = false;
} }
m_animationTimer.Start(); _animationTimer.Start();
} }
ApplySurface(x, y, m_texture, screen, &sprites[m_directionFacing][m_animationStage]); ApplySurface(x, y, _texture, screen, &_sprites[directionFacing][_animationStage]);
} }
} }
void Character::Update(void) { void Character::Update(void) {
Move(); Move();
if(m_speachBubble.size() != 0) { if(_speachBubble.size() != 0) {
if(m_speachBubbleTimer.GetTicks() > SPEACH_BUBBLE_DISPLAY_LENGTH) { if(_speachBubbleTimer.GetTicks() > SPEACH_BUBBLE_DISPLAY_LENGTH) {
m_speachBubble.pop_front(); _speachBubble.pop_front();
if(m_speachBubble.size() != 0) { if(_speachBubble.size() != 0) {
m_speachBubbleTimer.Start(); _speachBubbleTimer.Start();
} }
} else { } else {
if(m_speachBubble.front() != m_speachBubbleText.GetText()) { if(_speachBubble.front() != _speachBubbleText.GetText()) {
//m_speachBubbleText.SetTextBlended(m_speachBubble.front(), "small", 0, 0, 0); //m_speachBubbleText.SetTextBlended(m_speachBubble.front(), "small", 0, 0, 0);
} }
} }

View File

@ -56,14 +56,14 @@ protected:
int tileX; int tileX;
int tileY; int tileY;
Timer m_attackTimer; Timer attackTimer;
bool m_attacking; bool attacking;
Map* map; Map* map;
static const float CHARACTER_SPEED; static const float CHARACTER_SPEED;
int m_directionFacing; int directionFacing;
static const int FACING_UP = 0; static const int FACING_UP = 0;
static const int FACING_RIGHT = 1; static const int FACING_RIGHT = 1;
static const int FACING_DOWN = 2; static const int FACING_DOWN = 2;
@ -80,19 +80,19 @@ private:
static const int SPEACH_BUBBLE_DISPLAY_LENGTH = 6000; static const int SPEACH_BUBBLE_DISPLAY_LENGTH = 6000;
SDL_Surface* m_texture; SDL_Surface* _texture;
// [direction][action] // [direction][action]
SDL_Rect sprites[4][4]; SDL_Rect _sprites[4][4];
Timer m_animationTimer; Timer _animationTimer;
int m_animationStage; int _animationStage;
bool m_leftFoot; bool _leftFoot;
list<string> m_speachBubble; list<string> _speachBubble;
list<string>::iterator m_speachBubbleIter; list<string>::iterator _speachBubbleIter;
Timer m_speachBubbleTimer; Timer _speachBubbleTimer;
Text m_speachBubbleText; Text _speachBubbleText;
}; };
#endif #endif

View File

@ -20,14 +20,14 @@ Debug *Debug::logger = NULL;
Debug::Debug(bool logToFile) { Debug::Debug(bool logToFile) {
time_t timestamp; time_t timestamp;
if(logToFile) { if(logToFile) {
logFile.open("../Bin/Debug.log", ios::out); _logFile.open("../Bin/Debug.log", ios::out);
if(!logToFile) { if(!logToFile) {
// We can not open our log. // We can not open our log.
cerr << "Warning: Can not open Debug.log to write, continueing without logging\n"; cerr << "Warning: Can not open Debug.log to write, continueing without logging\n";
} else { } else {
// Log File is open, let us give it a nice time stamp. // Log File is open, let us give it a nice time stamp.
timestamp = time(NULL); timestamp = time(NULL);
logFile << "Log Started: " << ctime(&timestamp) << endl; _logFile << "Log Started: " << ctime(&timestamp) << endl;
} }
} }
} }
@ -36,19 +36,19 @@ Debug::~Debug(void) {
time_t timestamp; time_t timestamp;
// We only need to close the log if it is open. // We only need to close the log if it is open.
if(logFile) { if(_logFile) {
// Give it a closing timestamp. // Give it a closing timestamp.
timestamp = time(NULL); timestamp = time(NULL);
logFile << endl << "Log Closed: " << ctime(&timestamp) << endl; _logFile << endl << "Log Closed: " << ctime(&timestamp) << endl;
// Close the log file. // Close the log file.
logFile.close(); _logFile.close();
} }
} }
void Debug::message(std::string msg) { void Debug::message(std::string msg) {
if(logFile) { if(_logFile) {
logFile << msg << endl; _logFile << msg << endl;
} }
cerr << msg << endl << endl; cerr << msg << endl << endl;
} }
@ -74,8 +74,8 @@ void Debug::message(const char *msg, ...) {
outLen = sizeof(outBuf); outLen = sizeof(outBuf);
} }
if(logFile) { if(_logFile) {
logFile << outBuf << endl; _logFile << outBuf << endl;
} }
cerr << outBuf << endl; cerr << outBuf << endl;

View File

@ -17,7 +17,7 @@ public:
static Debug *logger; static Debug *logger;
private: private:
std::ofstream logFile; std::ofstream _logFile;
}; };
#endif // _DEBUG_H_ #endif // _DEBUG_H_

View File

@ -1,7 +1,7 @@
#include "IngameMenu.h" #include "IngameMenu.h"
IngameMenu::IngameMenu(void) { IngameMenu::IngameMenu(void) {
m_active = false; _active = false;
btnResume.SetOutRGB(200, 200, 200); btnResume.SetOutRGB(200, 200, 200);
btnResume.SetOverRGB(255, 255, 255); btnResume.SetOverRGB(255, 255, 255);

View File

@ -23,11 +23,11 @@ public:
ingameMenuNavVal_t HandleInput(void); ingameMenuNavVal_t HandleInput(void);
void Render(void); void Render(void);
void SetStatus(bool arg) { m_active = arg; } void SetStatus(bool arg) { _active = arg; }
bool GetStatus(void) { return m_active; } bool GetStatus(void) { return _active; }
private: private:
bool m_active; bool _active;
Button btnResume; Button btnResume;
Button btnSaveGame; Button btnSaveGame;

View File

@ -24,7 +24,7 @@ public:
void Render(void); void Render(void);
private: private:
Map m_background; Map _background;
Text lblMenu; Text lblMenu;

View File

@ -10,7 +10,7 @@ Map::~Map(void) {
void Map::Load(const string filename) { void Map::Load(const string filename) {
Unload(); Unload();
m_currentMap = filename; _currentMap = filename;
string fullMapPath = "../Data/Media/Maps/" + filename; string fullMapPath = "../Data/Media/Maps/" + filename;
TiXmlDocument mapFile(fullMapPath); TiXmlDocument mapFile(fullMapPath);
@ -43,14 +43,14 @@ void Map::Load(const string filename) {
assert(tileElem != NULL); assert(tileElem != NULL);
while(tileElem) { while(tileElem) {
x++; x++;
m_tile[x][y].SetTileXY(x * TILE_WIDTH, y * TILE_HEIGHT); _tile[x][y].SetTileXY(x * TILE_WIDTH, y * TILE_HEIGHT);
// <tileTexture> - Apply a teture to the tile. // <tileTexture> - Apply a teture to the tile.
dataElem = tileElem->FirstChildElement("tileTexture"); dataElem = tileElem->FirstChildElement("tileTexture");
assert(dataElem != NULL); assert(dataElem != NULL);
stringstream tilePath; stringstream tilePath;
tilePath << "../Data/Media/Images/Tiles/" << dataElem->GetText() << ".png"; tilePath << "../Data/Media/Images/Tiles/" << dataElem->GetText() << ".png";
m_tile[x][y].SetTileTexture(m_tileTextures.Add(tilePath.str())); _tile[x][y].SetTileTexture(_tileTextures.Add(tilePath.str()));
// <tileTexture> - Finished applying the texture, move to the next sibling. // <tileTexture> - Finished applying the texture, move to the next sibling.
// <solidTile> - Check to see if the tile is solid or not. // <solidTile> - Check to see if the tile is solid or not.
@ -59,9 +59,9 @@ void Map::Load(const string filename) {
string tileSolidity = dataElem->GetText(); string tileSolidity = dataElem->GetText();
assert(tileSolidity == "false" || tileSolidity == "true"); assert(tileSolidity == "false" || tileSolidity == "true");
if(tileSolidity == "false") if(tileSolidity == "false")
m_tile[x][y].SetTileSolidity(false); _tile[x][y].SetTileSolidity(false);
else else
m_tile[x][y].SetTileSolidity(true); _tile[x][y].SetTileSolidity(true);
// </solidTile> // </solidTile>
// <entityTexture> // <entityTexture>
@ -71,10 +71,10 @@ void Map::Load(const string filename) {
if(entityName != "null") { if(entityName != "null") {
stringstream entityPath; stringstream entityPath;
entityPath << "../Data/Media/Images/Entities/" << entityName << ".png"; entityPath << "../Data/Media/Images/Entities/" << entityName << ".png";
m_tile[x][y].SetEntityTexture(m_entityTextures.AddAlpha(entityPath.str())); _tile[x][y].SetEntityTexture(_entityTextures.AddAlpha(entityPath.str()));
m_tile[x][y].SetEntityXY(m_tile[x][y].GetTileX() + TILE_WIDTH / 2 - m_tile[x][y].GetEntityWidth() / 2, _tile[x][y].SetEntityXY(_tile[x][y].GetTileX() + TILE_WIDTH / 2 - _tile[x][y].GetEntityWidth() / 2,
m_tile[x][y].GetTileY() + TILE_HEIGHT / 2 - m_tile[x][y].GetEntityHeight() / 2); _tile[x][y].GetTileY() + TILE_HEIGHT / 2 - _tile[x][y].GetEntityHeight() / 2);
} }
// </entityTexture> // </entityTexture>
@ -84,21 +84,21 @@ void Map::Load(const string filename) {
string entitySolidity = dataElem->GetText(); string entitySolidity = dataElem->GetText();
assert(entitySolidity == "false" || entitySolidity == "true"); assert(entitySolidity == "false" || entitySolidity == "true");
if(entitySolidity == "false") if(entitySolidity == "false")
m_tile[x][y].SetEntitySolidity(false); _tile[x][y].SetEntitySolidity(false);
else else
m_tile[x][y].SetEntitySolidity(true); _tile[x][y].SetEntitySolidity(true);
// </solidEntity> // </solidEntity>
// <zlevel> // <zlevel>
dataElem = dataElem->NextSiblingElement("zLevel"); dataElem = dataElem->NextSiblingElement("zLevel");
assert(dataElem != NULL); assert(dataElem != NULL);
m_tile[x][y].SetZLevel(atoi(dataElem->GetText())); _tile[x][y].SetZLevel(atoi(dataElem->GetText()));
// </zlevel> // </zlevel>
// <mapTransition> // <mapTransition>
dataElem = dataElem->NextSiblingElement("mapTransition"); dataElem = dataElem->NextSiblingElement("mapTransition");
assert(dataElem != NULL); assert(dataElem != NULL);
m_tile[x][y].SetMapTransitionName(dataElem->GetText()); _tile[x][y].SetMapTransitionName(dataElem->GetText());
// </mapTransition> // </mapTransition>
// <mapTransX> // <mapTransX>
@ -147,30 +147,30 @@ void Map::Render(void) {
for(int i = xOrig; i < xEnd; i++) { for(int i = xOrig; i < xEnd; i++) {
for(int j = yOrig; j < yEnd; j++) { for(int j = yOrig; j < yEnd; j++) {
m_tile[i][j].Render(); _tile[i][j].Render();
} }
} }
} }
void Map::Unload(void) { void Map::Unload(void) {
m_tileTextures.Unload(); _tileTextures.Unload();
m_entityTextures.Unload(); _entityTextures.Unload();
} }
string Map::GetCurrentMap(void) { string Map::GetCurrentMap(void) {
return m_currentMap; return _currentMap;
} }
bool Map::GetTileSolidity(int xArg, int yArg) { bool Map::GetTileSolidity(int xArg, int yArg) {
return m_tile[xArg + 1][yArg + 1].GetTileSolidity(); return _tile[xArg + 1][yArg + 1].GetTileSolidity();
} }
int Map::GetTileX(int xArg, int yArg) { int Map::GetTileX(int xArg, int yArg) {
return m_tile[xArg + 1][yArg + 1].GetTileX(); return _tile[xArg + 1][yArg + 1].GetTileX();
} }
int Map::GetTileY(int xArg, int yArg) { int Map::GetTileY(int xArg, int yArg) {
return m_tile[xArg + 1][yArg + 1].GetTileY(); return _tile[xArg + 1][yArg + 1].GetTileY();
} }
bool Map::GetEntitySolidity(int xArg, int yArg) { bool Map::GetEntitySolidity(int xArg, int yArg) {
@ -178,37 +178,37 @@ bool Map::GetEntitySolidity(int xArg, int yArg) {
return false; return false;
} }
return m_tile[xArg + 1][yArg + 1].GetEntitySolitity(); return _tile[xArg + 1][yArg + 1].GetEntitySolitity();
} }
int Map::GetEntityX(int xArg, int yArg) { int Map::GetEntityX(int xArg, int yArg) {
return m_tile[xArg + 1][yArg + 1].GetEntityX(); return _tile[xArg + 1][yArg + 1].GetEntityX();
} }
int Map::GetEntityY(int xArg, int yArg) { int Map::GetEntityY(int xArg, int yArg) {
return m_tile[xArg + 1][yArg + 1].GetEntityY(); return _tile[xArg + 1][yArg + 1].GetEntityY();
} }
int Map::GetEntityWidth(int xArg, int yArg) { int Map::GetEntityWidth(int xArg, int yArg) {
return m_tile[xArg + 1][yArg + 1].GetEntityWidth(); return _tile[xArg + 1][yArg + 1].GetEntityWidth();
} }
int Map::GetEntityHeight(int xArg, int yArg) { int Map::GetEntityHeight(int xArg, int yArg) {
return m_tile[xArg + 1][yArg + 1].GetEntityHeight(); return _tile[xArg + 1][yArg + 1].GetEntityHeight();
} }
int Map::GetTileZLevel(int xArg, int yArg) { int Map::GetTileZLevel(int xArg, int yArg) {
return m_tile[xArg + 1][yArg + 1].GetZLevel(); return _tile[xArg + 1][yArg + 1].GetZLevel();
} }
string Map::GetMapTransitionName(int xArg, int yArg) { string Map::GetMapTransitionName(int xArg, int yArg) {
return m_tile[xArg + 1][yArg + 1].GetMapTransitionName(); return _tile[xArg + 1][yArg + 1].GetMapTransitionName();
} }
int Map::GetMapTransitionX(int xArg, int yArg) { int Map::GetMapTransitionX(int xArg, int yArg) {
return m_tile[xArg + 1][yArg + 1].GetMapTransitionX(); return _tile[xArg + 1][yArg + 1].GetMapTransitionX();
} }
int Map::GetMapTransitionY(int xArg, int yArg) { int Map::GetMapTransitionY(int xArg, int yArg) {
return m_tile[xArg + 1][yArg + 1].GetMapTransitionY(); return _tile[xArg + 1][yArg + 1].GetMapTransitionY();
} }

View File

@ -47,15 +47,15 @@ public:
private: private:
void Unload(void); void Unload(void);
string m_currentMap; string _currentMap;
int x; int x;
int y; int y;
static const int TILE_ARRAY_SIZE = 150; static const int TILE_ARRAY_SIZE = 150;
MapTile m_tile[TILE_ARRAY_SIZE][TILE_ARRAY_SIZE]; MapTile _tile[TILE_ARRAY_SIZE][TILE_ARRAY_SIZE];
TextureManager m_tileTextures; TextureManager _tileTextures;
TextureManager m_entityTextures; TextureManager _entityTextures;
}; };
#endif #endif

View File

@ -9,11 +9,11 @@ MapElement::~MapElement(void) {
} }
void MapElement::SetTexture(SDL_Surface* arg) { void MapElement::SetTexture(SDL_Surface* arg) {
m_texture = arg; _texture = arg;
} }
void MapElement::Render(void) { void MapElement::Render(void) {
ApplySurface(x, y, m_texture, screen); ApplySurface(x, y, _texture, screen);
} }
void MapElement::Update(void) { void MapElement::Update(void) {
@ -21,11 +21,11 @@ void MapElement::Update(void) {
} }
void MapElement::SetSolidity(bool arg) { void MapElement::SetSolidity(bool arg) {
m_solid = arg; _solid = arg;
} }
bool MapElement::GetSolidity(void) { bool MapElement::GetSolidity(void) {
return m_solid; return _solid;
} }
void MapElement::SetXY(int xArg, int yArg) { void MapElement::SetXY(int xArg, int yArg) {
@ -35,5 +35,5 @@ void MapElement::SetXY(int xArg, int yArg) {
int MapElement::GetX(void) { return x; } int MapElement::GetX(void) { return x; }
int MapElement::GetY(void) { return y; } int MapElement::GetY(void) { return y; }
int MapElement::GetWidth(void) { return m_texture->w; } int MapElement::GetWidth(void) { return _texture->w; }
int MapElement::GetHeight(void) { return m_texture->h; } int MapElement::GetHeight(void) { return _texture->h; }

View File

@ -28,9 +28,9 @@ public:
int GetHeight(void); int GetHeight(void);
protected: protected:
SDL_Surface* m_texture; SDL_Surface* _texture;
bool m_solid; bool _solid;
int x; int x;
int y; int y;

View File

@ -1,7 +1,7 @@
#include "MapEntities.h" #include "MapEntities.h"
MapEntityGeneric::MapEntityGeneric(void) { MapEntityGeneric::MapEntityGeneric(void) {
m_texture = NULL; _texture = NULL;
} }
@ -10,7 +10,7 @@ MapEntityGeneric::~MapEntityGeneric(void) {
} }
void MapEntityGeneric::Render(void) { void MapEntityGeneric::Render(void) {
if(m_texture != NULL) { if(_texture != NULL) {
MapElement::Render(); MapElement::Render();
} }
} }

View File

@ -15,52 +15,52 @@ public:
MapTile(void) { } MapTile(void) { }
~MapTile(void) { } ~MapTile(void) { }
void Render(void) { m_tile.Render(), m_entity.Render(); } void Render(void) { _tile.Render(), _entity.Render(); }
// Tile Mutators. // Tile Mutators.
SDL_Surface SetTileTexture(SDL_Surface* arg) { m_tile.SetTexture(arg); } SDL_Surface SetTileTexture(SDL_Surface* arg) { _tile.SetTexture(arg); }
void SetTileSolidity(bool arg) { m_tile.SetSolidity(arg); } void SetTileSolidity(bool arg) { _tile.SetSolidity(arg); }
bool GetTileSolidity(void) { return m_tile.GetSolidity(); } bool GetTileSolidity(void) { return _tile.GetSolidity(); }
void SetTileXY(int xArg, int yArg) { m_tile.GetX(), m_tile.GetY(); } void SetTileXY(int xArg, int yArg) { _tile.GetX(), _tile.GetY(); }
int GetTileX(void) { return m_tile.GetX(); } int GetTileX(void) { return _tile.GetX(); }
int GetTileY(void) { return m_tile.GetY(); } int GetTileY(void) { return _tile.GetY(); }
// Entity Mutators. // Entity Mutators.
void SetEntityTexture(SDL_Surface* arg) { m_entity.SetTexture(arg); } void SetEntityTexture(SDL_Surface* arg) { _entity.SetTexture(arg); }
void SetEntityXY(int xArg, int yArg) { m_entity.SetXY(xArg, yArg); } void SetEntityXY(int xArg, int yArg) { _entity.SetXY(xArg, yArg); }
void SetEntitySolidity(bool arg) { m_entity.SetSolidity(arg); } void SetEntitySolidity(bool arg) { _entity.SetSolidity(arg); }
bool GetEntitySolitity(void) { return m_entity.GetSolidity(); } bool GetEntitySolitity(void) { return _entity.GetSolidity(); }
// Entity Mutators. // Entity Mutators.
int GetEntityX(void) { return m_entity.GetX(); } int GetEntityX(void) { return _entity.GetX(); }
int GetEntityY(void) { return m_entity.GetY(); } int GetEntityY(void) { return _entity.GetY(); }
int GetEntityWidth(void) { return m_entity.GetWidth(); } int GetEntityWidth(void) { return _entity.GetWidth(); }
int GetEntityHeight(void) { return m_entity.GetHeight(); } int GetEntityHeight(void) { return _entity.GetHeight(); }
// ZLevel Mutators. // ZLevel Mutators.
void SetZLevel(int arg) { m_zLevel = arg; } void SetZLevel(int arg) { _zLevel = arg; }
int GetZLevel(void) { return m_zLevel; } int GetZLevel(void) { return _zLevel; }
// Map Transition Mutators. // Map Transition Mutators.
void SetMapTransitionName(string arg) { m_mapTransitionName = arg; } void SetMapTransitionName(string arg) { _mapTransitionName = arg; }
string GetMapTransitionName(void) { return m_mapTransitionName; } string GetMapTransitionName(void) { return _mapTransitionName; }
void SetMapTransitionXY(int xArg, int yArg) { m_mapTransitionX = xArg, m_mapTransitionY = yArg; } void SetMapTransitionXY(int xArg, int yArg) { _mapTransitionX = xArg, _mapTransitionY = yArg; }
int GetMapTransitionX(void) { return m_mapTransitionX; } int GetMapTransitionX(void) { return _mapTransitionX; }
int GetMapTransitionY(void) { return m_mapTransitionY; } int GetMapTransitionY(void) { return _mapTransitionY; }
private: private:
MapElement m_tile; MapElement _tile;
MapEntityGeneric m_entity; MapEntityGeneric _entity;
// -1 is a 'special' tile, the next tile that the player walks // -1 is a 'special' tile, the next tile that the player walks
// on is the players new zlevel. // on is the players new zlevel.
int m_zLevel; int _zLevel;
// If not 'null', switch map when the player walks on this tile. // If not 'null', switch map when the player walks on this tile.
string m_mapTransitionName; string _mapTransitionName;
int m_mapTransitionX; int _mapTransitionX;
int m_mapTransitionY; int _mapTransitionY;
}; };
#endif #endif

View File

@ -1,20 +0,0 @@
#ifndef _MENU_H_
#define _MENU_H_
#include "../Unuk/Globals.h"
#include "../Unuk/Constants.h"
#include "Button.h"
#include "ButtonToggle.h"
class Menu {
public:
Menu(void) {};
~Menu(void) {};
virtual int HandleInput(void) = 0;
virtual void Render(void) = 0;
protected:
};
#endif

View File

@ -1,11 +1,11 @@
#include "NPC.h" #include "NPC.h"
NPC::NPC(Map* mapArg) : Character(mapArg) { NPC::NPC(Map* mapArg) : Character(mapArg) {
m_moveTimer.Start(); _moveTimer.Start();
m_moveChangeFrequency = 14000; _moveChangeFrequency = 14000;
m_moveDurationMax = 3000; _moveDurationMax = 3000;
m_moveDurationMin = 1000; _moveDurationMin = 1000;
} }
NPC::~NPC(void) { NPC::~NPC(void) {
@ -15,28 +15,28 @@ NPC::~NPC(void) {
void NPC::Update(void) { void NPC::Update(void) {
Move(); Move();
if(xVel > 0) m_directionFacing = FACING_RIGHT; if(xVel > 0) directionFacing = FACING_RIGHT;
else if(xVel < 0) m_directionFacing = FACING_LEFT; else if(xVel < 0) directionFacing = FACING_LEFT;
else if(yVel > 0) m_directionFacing = FACING_DOWN; else if(yVel > 0) directionFacing = FACING_DOWN;
else if(yVel < 0) m_directionFacing = FACING_UP; else if(yVel < 0) directionFacing = FACING_UP;
} }
void NPC::Move(void) { void NPC::Move(void) {
if(m_moving && m_moveTimer.GetTicks() > m_moveDurationMax) { if(_moving && _moveTimer.GetTicks() > _moveDurationMax) {
xVel = 0.0f; xVel = 0.0f;
yVel = 0.0f; yVel = 0.0f;
m_moving = false; _moving = false;
} }
if(m_moving && m_moveTimer.GetTicks() >= m_moveDurationCurrent) { if(_moving && _moveTimer.GetTicks() >= _moveDurationCurrent) {
xVel = 0.0f; xVel = 0.0f;
yVel = 0.0f; yVel = 0.0f;
m_moving = false; _moving = false;
} }
if(m_moveTimer.GetTicks() > m_moveChangeFrequency) { if(_moveTimer.GetTicks() > _moveChangeFrequency) {
m_moveTimer.Start(); _moveTimer.Start();
m_moveDurationCurrent = m_moveDurationMin + (rand() % (m_moveDurationMax - m_moveDurationMin)); _moveDurationCurrent = _moveDurationMin + (rand() % (_moveDurationMax - _moveDurationMin));
if(rand() % 2) { if(rand() % 2) {
yVel = 0.0f; yVel = 0.0f;
if(rand() % 2) if(rand() % 2)
@ -50,7 +50,7 @@ void NPC::Move(void) {
else else
yVel = -CHARACTER_SPEED; yVel = -CHARACTER_SPEED;
} }
m_moving = true; _moving = true;
} }
Character::Move(); Character::Move();
} }

View File

@ -14,15 +14,15 @@ protected:
void Move(void); void Move(void);
private: private:
int m_moveChangeFrequency; int _moveChangeFrequency;
int m_moveDurationCurrent; int _moveDurationCurrent;
int m_moveDurationMin; int _moveDurationMin;
int m_moveDurationMax; int _moveDurationMax;
bool m_moving; bool _moving;
Timer m_moveTimer; Timer _moveTimer;
}; };
#endif #endif

View File

@ -14,50 +14,50 @@ void ParticleEmitter::SetXY(int xArg, int yArg) {
} }
void ParticleEmitter::ForceXY(int xArg, int yArg) { void ParticleEmitter::ForceXY(int xArg, int yArg) {
for(int i = 0; i < m_particleCount; i++) { for(int i = 0; i < _particleCount; i++) {
m_particle[i].x = xArg; m_particle[i].x = xArg;
m_particle[i].y = yArg; m_particle[i].y = yArg;
} }
} }
void ParticleEmitter::SetParticleCount(int countArg) { void ParticleEmitter::SetParticleCount(int countArg) {
m_particleCount = countArg; _particleCount = countArg;
m_particle.resize(m_particleCount); m_particle.resize(_particleCount);
for(int i = 0; i < m_particleCount; i++) { for(int i = 0; i < _particleCount; i++) {
m_particle[i].startTime = SDL_GetTicks(); m_particle[i].startTime = SDL_GetTicks();
} }
} }
void ParticleEmitter::SetParticleSpeed(float speedArg) { void ParticleEmitter::SetParticleSpeed(float speedArg) {
m_particleSpeed = speedArg; _particleSpeed = speedArg;
} }
void ParticleEmitter::SetParticleType(string typeArg) { void ParticleEmitter::SetParticleType(string typeArg) {
if(!particleTexture) { if(!_particleTexture) {
SDL_FreeSurface(particleTexture); SDL_FreeSurface(_particleTexture);
} }
string textureFilename = "../Data/Media/Images/Particles/" + typeArg + ".png"; string textureFilename = "../Data/Media/Images/Particles/" + typeArg + ".png";
particleTexture = LoadImageAlpha(textureFilename.c_str()); _particleTexture = LoadImageAlpha(textureFilename.c_str());
} }
void ParticleEmitter::SetParticleLifetime(int lifetimeArg) { void ParticleEmitter::SetParticleLifetime(int lifetimeArg) {
m_particleLifetime = lifetimeArg; _particleLifetime = lifetimeArg;
for(int i = 0; i < m_particleCount; i++) { for(int i = 0; i < _particleCount; i++) {
m_particle[i].lifetime = rand() % m_particleLifetime + m_particleLifetime / 4; m_particle[i].lifetime = rand() % _particleLifetime + _particleLifetime / 4;
} }
} }
void ParticleEmitter::Render(void) { void ParticleEmitter::Render(void) {
for(int i = 0; i < m_particleCount; i++) { for(int i = 0; i < _particleCount; i++) {
ApplySurface(m_particle[i].x, m_particle[i].y, particleTexture, screen); ApplySurface(m_particle[i].x, m_particle[i].y, _particleTexture, screen);
} }
} }
void ParticleEmitter::Update(void) { void ParticleEmitter::Update(void) {
for(int i = 0; i < m_particleCount; i++) { for(int i = 0; i < _particleCount; i++) {
if((int)SDL_GetTicks() - m_particle[i].startTime > m_particle[i].lifetime) { if((int)SDL_GetTicks() - m_particle[i].startTime > m_particle[i].lifetime) {
// Reset the x and y coords. // Reset the x and y coords.
m_particle[i].x = x; m_particle[i].x = x;
@ -73,8 +73,8 @@ void ParticleEmitter::Update(void) {
m_particle[i].startTime = SDL_GetTicks(); m_particle[i].startTime = SDL_GetTicks();
} else { } else {
m_particle[i].x += m_particle[i].xVel * m_particleSpeed; m_particle[i].x += m_particle[i].xVel * _particleSpeed;
m_particle[i].y += m_particle[i].yVel * m_particleSpeed; m_particle[i].y += m_particle[i].yVel * _particleSpeed;
} }
} }
} }

View File

@ -45,11 +45,11 @@ private:
int x; int x;
int y; int y;
int m_particleCount; int _particleCount;
int m_particleLifetime; int _particleLifetime;
float m_particleSpeed; float _particleSpeed;
SDL_Surface* particleTexture; SDL_Surface* _particleTexture;
}; };
#endif #endif

View File

@ -7,12 +7,12 @@ TTF_Font* Text::largeFont = NULL;
TTF_Font* Text::vLargeFont = NULL; TTF_Font* Text::vLargeFont = NULL;
Text::Text(void) { Text::Text(void) {
m_text = NULL; _text = NULL;
} }
Text::~Text(void) { Text::~Text(void) {
assert(m_text != NULL); assert(_text != NULL);
SDL_FreeSurface(m_text); SDL_FreeSurface(_text);
} }
void Text::LoadFonts(void) { void Text::LoadFonts(void) {
@ -51,29 +51,29 @@ void Text::SetXY(int xArg, int yArg) {
} }
int Text::SetTextBlended(string textArg, textSizes_t size, SDL_Color colour) { int Text::SetTextBlended(string textArg, textSizes_t size, SDL_Color colour) {
m_textContents = textArg; _textContents = textArg;
if(m_text != NULL) { if(_text != NULL) {
SDL_FreeSurface(m_text); SDL_FreeSurface(_text);
} }
if(size == vsmall) { if(size == vsmall) {
m_text = TTF_RenderText_Blended(vSmallFont, textArg.c_str(), colour); _text = TTF_RenderText_Blended(vSmallFont, textArg.c_str(), colour);
return 1; return 1;
} }
else if(size == small) { else if(size == small) {
m_text = TTF_RenderText_Blended(smallFont, textArg.c_str(), colour); _text = TTF_RenderText_Blended(smallFont, textArg.c_str(), colour);
return 1; return 1;
} }
else if(size == medium) { else if(size == medium) {
m_text = TTF_RenderText_Blended(mediumFont, textArg.c_str(), colour); _text = TTF_RenderText_Blended(mediumFont, textArg.c_str(), colour);
return 1; return 1;
} }
else if(size == large) { else if(size == large) {
m_text = TTF_RenderText_Blended(largeFont, textArg.c_str(), colour); _text = TTF_RenderText_Blended(largeFont, textArg.c_str(), colour);
return 1; return 1;
} else { } else {
m_text = TTF_RenderText_Blended(vLargeFont, textArg.c_str(), colour); _text = TTF_RenderText_Blended(vLargeFont, textArg.c_str(), colour);
return 1; return 1;
} }
} }
@ -84,29 +84,29 @@ int Text::SetTextBlended(string textArg, textSizes_t size, Uint8 r, Uint8 g, Uin
} }
int Text::SetTextShaded(string textArg, textSizes_t size, SDL_Color colour, SDL_Color bgColour) { int Text::SetTextShaded(string textArg, textSizes_t size, SDL_Color colour, SDL_Color bgColour) {
m_textContents = textArg; _textContents = textArg;
if(m_text != NULL) { if(_text != NULL) {
SDL_FreeSurface(m_text); SDL_FreeSurface(_text);
} }
if(size == vsmall) { if(size == vsmall) {
m_text = TTF_RenderText_Shaded(vSmallFont, textArg.c_str(), colour, bgColour); _text = TTF_RenderText_Shaded(vSmallFont, textArg.c_str(), colour, bgColour);
return 1; return 1;
} }
else if(size == small) { else if(size == small) {
m_text = TTF_RenderText_Shaded(smallFont, textArg.c_str(), colour, bgColour); _text = TTF_RenderText_Shaded(smallFont, textArg.c_str(), colour, bgColour);
return 1; return 1;
} }
else if(size == medium) { else if(size == medium) {
m_text = TTF_RenderText_Shaded(mediumFont, textArg.c_str(), colour, bgColour); _text = TTF_RenderText_Shaded(mediumFont, textArg.c_str(), colour, bgColour);
return 1; return 1;
} }
else if(size == large) { else if(size == large) {
m_text = TTF_RenderText_Shaded(largeFont, textArg.c_str(), colour, bgColour); _text = TTF_RenderText_Shaded(largeFont, textArg.c_str(), colour, bgColour);
return 1; return 1;
} else { } else {
m_text = TTF_RenderText_Shaded(vLargeFont, textArg.c_str(), colour, bgColour); _text = TTF_RenderText_Shaded(vLargeFont, textArg.c_str(), colour, bgColour);
return 1; return 1;
} }
} }
@ -118,17 +118,17 @@ int Text::SetTextShaded(string textArg, textSizes_t size, Uint8 rF, Uint8 gF, Ui
} }
void Text::Render(void) { void Text::Render(void) {
ApplySurface(x, y, m_text, screen); ApplySurface(x, y, _text, screen);
} }
void Text::Render(int xArg, int yArg) { void Text::Render(int xArg, int yArg) {
ApplySurface(xArg, yArg, m_text, screen); ApplySurface(xArg, yArg, _text, screen);
} }
void Text::RenderLiteral(void) { void Text::RenderLiteral(void) {
ApplySurfaceLiteral(x, y, m_text, screen); ApplySurfaceLiteral(x, y, _text, screen);
} }
void Text::RenderLiteral(int xArg, int yArg) { void Text::RenderLiteral(int xArg, int yArg) {
ApplySurfaceLiteral(xArg, yArg, m_text, screen); ApplySurfaceLiteral(xArg, yArg, _text, screen);
} }

View File

@ -20,13 +20,13 @@ public:
static void LoadFonts(void); static void LoadFonts(void);
static void FreeFonts(void); static void FreeFonts(void);
int GetWidth(void) { return m_text->w; } int GetWidth(void) { return _text->w; }
int GetHeight(void) { return m_text->h; } int GetHeight(void) { return _text->h; }
int GetX(void) { return x; } int GetX(void) { return x; }
int GetY(void) { return y; } int GetY(void) { return y; }
string GetText(void) { return m_textContents; } string GetText(void) { return _textContents; }
SDL_Color GetColour(void) { return m_textColour; } SDL_Color GetColour(void) { return _textColour; }
void SetXY(int xArg, int yArg); void SetXY(int xArg, int yArg);
@ -43,9 +43,9 @@ public:
private: private:
int x, y, w, h; int x, y, w, h;
string m_textContents; string _textContents;
SDL_Color m_textColour; SDL_Color _textColour;
SDL_Surface* m_text; SDL_Surface* _text;
static TTF_Font* vSmallFont; static TTF_Font* vSmallFont;
static TTF_Font* smallFont; static TTF_Font* smallFont;

View File

@ -1,12 +1,12 @@
#include "Texture.h" #include "Texture.h"
Texture::Texture(void) { Texture::Texture(void) {
texture = NULL; _texture = NULL;
} }
Texture::~Texture(void) { Texture::~Texture(void) {
assert(texture != NULL); assert(_texture != NULL);
SDL_FreeSurface(texture); SDL_FreeSurface(_texture);
} }
void Texture::SetXY(int xArg, int yArg) { void Texture::SetXY(int xArg, int yArg) {
@ -15,39 +15,39 @@ void Texture::SetXY(int xArg, int yArg) {
} }
void Texture::Render(void) { void Texture::Render(void) {
ApplySurface(x, y, texture, screen); ApplySurface(x, y, _texture, screen);
} }
void Texture::Render(int xArg, int yArg) { void Texture::Render(int xArg, int yArg) {
ApplySurface(xArg, yArg, texture, screen); ApplySurface(xArg, yArg, _texture, screen);
} }
void Texture::RenderLiteral(void) { void Texture::RenderLiteral(void) {
ApplySurfaceLiteral(x, y, texture, screen); ApplySurfaceLiteral(x, y, _texture, screen);
} }
void Texture::RenderLiteral(int xArg, int yArg) { void Texture::RenderLiteral(int xArg, int yArg) {
ApplySurfaceLiteral(xArg, yArg,texture, screen); ApplySurfaceLiteral(xArg, yArg,_texture, screen);
} }
void Texture::Load(const char* filename) { void Texture::Load(const char* filename) {
if(texture != NULL) { if(_texture != NULL) {
// Free the texture. // Free the texture.
SDL_FreeSurface(texture); SDL_FreeSurface(_texture);
} }
// Load the texture. // Load the texture.
texture = LoadImage(filename); _texture = LoadImage(filename);
} }
void Texture::LoadAlpha(const char* filename) { void Texture::LoadAlpha(const char* filename) {
if(texture != NULL) { if(_texture != NULL) {
// Free the texture. // Free the texture.
SDL_FreeSurface(texture); SDL_FreeSurface(_texture);
} }
// Load the texture with an alpha channel. // Load the texture with an alpha channel.
texture = LoadImageAlpha(filename); _texture = LoadImageAlpha(filename);
} }
void Texture::SetAlpha(int alphaArg) { void Texture::SetAlpha(int alphaArg) {
SDL_SetAlpha(texture, SDL_SRCALPHA, alphaArg); SDL_SetAlpha(_texture, SDL_SRCALPHA, alphaArg);
} }

View File

@ -9,8 +9,8 @@ public:
Texture(void); Texture(void);
~Texture(void); ~Texture(void);
int GetWidth(void) { return texture->w; } int GetWidth(void) { return _texture->w; }
int GetHeight(void) { return texture->h; } int GetHeight(void) { return _texture->h; }
int GetX(void) { return x; } int GetX(void) { return x; }
int GetY(void) { return y; } int GetY(void) { return y; }
@ -30,7 +30,7 @@ protected:
int x, y; int x, y;
private: private:
SDL_Surface* texture; SDL_Surface* _texture;
}; };
#endif #endif

View File

@ -1,7 +1,7 @@
#include "TextureManager.h" #include "TextureManager.h"
TextureManager::TextureManager(void) { TextureManager::TextureManager(void) {
m_allocated = 0; _allocated = 0;
} }
TextureManager::~TextureManager(void) { TextureManager::~TextureManager(void) {
@ -9,47 +9,47 @@ TextureManager::~TextureManager(void) {
} }
void TextureManager::Unload(void) { void TextureManager::Unload(void) {
for(int i = 0; i < m_allocated; i++) { for(int i = 0; i < _allocated; i++) {
SDL_FreeSurface(textures[i].texture); SDL_FreeSurface(_textures[i].texture);
textures[i].name.clear(); _textures[i].name.clear();
} }
m_allocated = 0; _allocated = 0;
} }
SDL_Surface* TextureManager::Add(string filename) { SDL_Surface* TextureManager::Add(string filename) {
assert(m_allocated < TEXTURE_ARR_SIZE - 1); assert(_allocated < TEXTURE_ARR_SIZE - 1);
// Has the texture been loaded already? // Has the texture been loaded already?
for(int i = 0; i < m_allocated; i++) { for(int i = 0; i < _allocated; i++) {
if(textures[i].name == filename) { if(_textures[i].name == filename) {
return textures[i].texture; return _textures[i].texture;
} }
} }
// If not, then load it. // If not, then load it.
textures[m_allocated].name = filename; _textures[_allocated].name = filename;
textures[m_allocated].texture = LoadImage(filename.c_str()); _textures[_allocated].texture = LoadImage(filename.c_str());
m_allocated++; _allocated++;
return textures[m_allocated - 1].texture; return _textures[_allocated - 1].texture;
} }
SDL_Surface* TextureManager::AddAlpha(string filename) { SDL_Surface* TextureManager::AddAlpha(string filename) {
assert(m_allocated < TEXTURE_ARR_SIZE - 1); assert(_allocated < TEXTURE_ARR_SIZE - 1);
// Has the texture been loaded already? // Has the texture been loaded already?
for(int i = 0; i < m_allocated; i++) { for(int i = 0; i < _allocated; i++) {
if(textures[i].name == filename) { if(_textures[i].name == filename) {
return textures[i].texture; return _textures[i].texture;
} }
} }
// If not, then load it. // If not, then load it.
textures[m_allocated].name = filename; _textures[_allocated].name = filename;
textures[m_allocated].texture = LoadImageAlpha(filename.c_str()); _textures[_allocated].texture = LoadImageAlpha(filename.c_str());
m_allocated++; _allocated++;
return textures[m_allocated -1].texture; return _textures[_allocated -1].texture;
} }

View File

@ -32,9 +32,9 @@ private:
// We should not need more than a hundred.. // We should not need more than a hundred..
static const int TEXTURE_ARR_SIZE = 100; static const int TEXTURE_ARR_SIZE = 100;
textureNode textures[TEXTURE_ARR_SIZE]; textureNode _textures[TEXTURE_ARR_SIZE];
int m_allocated; int _allocated;
}; };
#endif #endif

View File

@ -1,47 +1,47 @@
#include "Timer.h" #include "Timer.h"
Timer::Timer(void) { Timer::Timer(void) {
m_startTicks = 0; _startTicks = 0;
m_pausedTicks = 0; _pausedTicks = 0;
m_paused = false; _paused = false;
m_started = false; _started = false;
} }
Timer::~Timer(void) { Timer::~Timer(void) {
} }
void Timer::Start(void) { void Timer::Start(void) {
m_paused = false; _paused = false;
m_started = true; _started = true;
m_startTicks = SDL_GetTicks(); _startTicks = SDL_GetTicks();
} }
void Timer::Stop(void) { void Timer::Stop(void) {
m_paused = false; _paused = false;
m_started = true; _started = true;
} }
void Timer::Pause(void) { void Timer::Pause(void) {
assert(m_paused == false); assert(_paused == false);
m_paused = true; _paused = true;
m_pausedTicks = SDL_GetTicks() - m_startTicks; _pausedTicks = SDL_GetTicks() - _startTicks;
} }
void Timer::Unpause(void) { void Timer::Unpause(void) {
assert(m_paused == true); assert(_paused == true);
m_paused = false; _paused = false;
m_startTicks = SDL_GetTicks() - m_pausedTicks; _startTicks = SDL_GetTicks() - _pausedTicks;
m_pausedTicks = 0; _pausedTicks = 0;
} }
int Timer::GetTicks(void) { int Timer::GetTicks(void) {
if(m_paused == true) if(_paused == true)
return m_pausedTicks; return _pausedTicks;
else if(m_started == true) else if(_started == true)
return SDL_GetTicks() - m_startTicks; return SDL_GetTicks() - _startTicks;
else else
return 0; return 0;
} }

View File

@ -16,19 +16,19 @@ public:
void Start(void); void Start(void);
void Stop(void); void Stop(void);
bool IsPaused(void) { return m_paused; } bool IsPaused(void) { return _paused; }
bool IsStarted(void) { return m_started; } bool IsStarted(void) { return _started; }
int GetTicks(void); int GetTicks(void);
string GetTicksStr(void); string GetTicksStr(void);
private: private:
bool m_paused; bool _paused;
bool m_started; bool _started;
int m_startTicks; int _startTicks;
int m_pausedTicks; int _pausedTicks;
}; };
#endif #endif