[Change] Simply changed naming convention of private members to _member; rather than m_member;
This commit is contained in:
parent
2f05f06f10
commit
854c820140
@ -1,6 +1,6 @@
|
||||
#############################################################################
|
||||
# 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
|
||||
# Template: app
|
||||
# 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:
|
||||
@$(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
|
||||
|
@ -26,7 +26,6 @@ HEADERS += ../src/libUnuk/Debug.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 \
|
||||
|
@ -1,23 +1,23 @@
|
||||
#include "Game.h"
|
||||
|
||||
Game::Game(void) {
|
||||
m_player = new Player(&m_map);
|
||||
m_npc = new NPC(&m_map);
|
||||
_player = new Player(&_map);
|
||||
_npc = new NPC(&_map);
|
||||
|
||||
m_runGameReturnValue = gameMainMenu;
|
||||
_runGameReturnValue = gameMainMenu;
|
||||
}
|
||||
|
||||
Game::~Game(void) {
|
||||
delete m_player;
|
||||
delete m_npc;
|
||||
delete _player;
|
||||
delete _npc;
|
||||
}
|
||||
|
||||
gameNavVal_t Game::Run(const string savegameIDArg) {
|
||||
m_player->SetXY(50, 50);
|
||||
m_player->LoadSprites("../Data/Media/Images/Characters/template.png", 40, 45);
|
||||
_player->SetXY(50, 50);
|
||||
_player->LoadSprites("../Data/Media/Images/Characters/template.png", 40, 45);
|
||||
|
||||
m_npc->SetXY(300, 300);
|
||||
m_npc->LoadSprites("../Data/Media/Images/Characters/template.png", 40,45);
|
||||
_npc->SetXY(300, 300);
|
||||
_npc->LoadSprites("../Data/Media/Images/Characters/template.png", 40,45);
|
||||
|
||||
LoadSavegame(savegameIDArg);
|
||||
|
||||
@ -34,18 +34,18 @@ gameNavVal_t Game::Run(const string savegameIDArg) {
|
||||
Timer renderTimer;
|
||||
Timer updateTimer;
|
||||
|
||||
m_gameRenderTime.SetXY(10, 10);
|
||||
m_gameRenderTime.SetTextBlended("Render - XX", vsmall, COLOUR_BLACK);
|
||||
_gameRenderTime.SetXY(10, 10);
|
||||
_gameRenderTime.SetTextBlended("Render - XX", vsmall, COLOUR_BLACK);
|
||||
|
||||
m_gameUpdateTime.SetXY(10, 30);
|
||||
m_gameUpdateTime.SetTextBlended("Update - XX", vsmall, COLOUR_BLACK);
|
||||
_gameUpdateTime.SetXY(10, 30);
|
||||
_gameUpdateTime.SetTextBlended("Update - XX", vsmall, COLOUR_BLACK);
|
||||
|
||||
stringstream playerXYString;
|
||||
m_playerXY.SetXY(10, 50);
|
||||
m_playerXY.SetTextBlended("Player coords - XX XX", vsmall, COLOUR_BLACK);
|
||||
_playerXY.SetXY(10, 50);
|
||||
_playerXY.SetTextBlended("Player coords - XX XX", vsmall, COLOUR_BLACK);
|
||||
|
||||
m_gameRunning = true;
|
||||
while(m_gameRunning) {
|
||||
_gameRunning = true;
|
||||
while(_gameRunning) {
|
||||
updateTimer.Start();
|
||||
while((int)SDL_GetTicks() > nextGameTick) {
|
||||
HandleInput();
|
||||
@ -73,12 +73,12 @@ gameNavVal_t Game::Run(const string savegameIDArg) {
|
||||
|
||||
// Check to see if we are allowed to display debug info.
|
||||
if(debugEnabled) {
|
||||
m_gameUpdateTime.SetTextBlended("Update - " + updateTimer.GetTicksStr(), vsmall, COLOUR_BLACK);
|
||||
m_gameRenderTime.SetTextBlended("Render - " + renderTimer.GetTicksStr(), vsmall, COLOUR_BLACK);
|
||||
_gameUpdateTime.SetTextBlended("Update - " + updateTimer.GetTicksStr(), vsmall, COLOUR_BLACK);
|
||||
_gameRenderTime.SetTextBlended("Render - " + renderTimer.GetTicksStr(), vsmall, COLOUR_BLACK);
|
||||
|
||||
playerXYString.str("");
|
||||
playerXYString << "Player coords: x" << m_player->GetX() << ", y" << m_player->GetY();
|
||||
m_playerXY.SetTextBlended(playerXYString.str(), vsmall, COLOUR_BLACK);
|
||||
playerXYString << "Player coords: x" << _player->GetX() << ", y" << _player->GetY();
|
||||
_playerXY.SetTextBlended(playerXYString.str(), vsmall, COLOUR_BLACK);
|
||||
}
|
||||
}
|
||||
// Restrict the fps.
|
||||
@ -91,32 +91,32 @@ gameNavVal_t Game::Run(const string savegameIDArg) {
|
||||
frameTimer.Start();
|
||||
frame++;
|
||||
}
|
||||
return m_runGameReturnValue;
|
||||
return _runGameReturnValue;
|
||||
}
|
||||
|
||||
void Game::HandleInput(void) {
|
||||
if(m_ingameMenu.GetStatus() == false) {
|
||||
if(_ingameMenu.GetStatus() == false) {
|
||||
while(SDL_PollEvent(&event)) {
|
||||
m_player->HandleInput();
|
||||
_player->HandleInput();
|
||||
|
||||
if(event.key.type == SDL_KEYDOWN) {
|
||||
if(event.key.keysym.sym == SDLK_ESCAPE)
|
||||
m_ingameMenu.SetStatus(true);
|
||||
_ingameMenu.SetStatus(true);
|
||||
if(event.key.keysym.sym == SDLK_p)
|
||||
debugEnabled = !debugEnabled;
|
||||
}
|
||||
else if(event.type == SDL_QUIT) {
|
||||
m_gameRunning = false;
|
||||
m_runGameReturnValue = gameQuitGame;
|
||||
_gameRunning = false;
|
||||
_runGameReturnValue = gameQuitGame;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch(m_ingameMenu.HandleInput()) {
|
||||
switch(_ingameMenu.HandleInput()) {
|
||||
case ingameMenuNothing:
|
||||
break;
|
||||
case ingameMenuResume:
|
||||
m_ingameMenu.SetStatus(false);
|
||||
_ingameMenu.SetStatus(false);
|
||||
break;
|
||||
case ingameMenuSaveGame:
|
||||
break;
|
||||
@ -125,49 +125,49 @@ void Game::HandleInput(void) {
|
||||
case ingameMenuOptions:
|
||||
break;
|
||||
case ingameMenuMainMenu:
|
||||
m_gameRunning = false;
|
||||
_gameRunning = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if(event.type == SDL_QUIT) {
|
||||
m_gameRunning = false;
|
||||
m_ingameMenu.SetStatus(false);
|
||||
m_runGameReturnValue = gameQuitGame;
|
||||
_gameRunning = false;
|
||||
_ingameMenu.SetStatus(false);
|
||||
_runGameReturnValue = gameQuitGame;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Game::UpdateGame(void) {
|
||||
if(m_ingameMenu.GetStatus() == false) {
|
||||
m_player->Update();
|
||||
m_npc->Update();
|
||||
if(_ingameMenu.GetStatus() == false) {
|
||||
_player->Update();
|
||||
_npc->Update();
|
||||
} else {
|
||||
// :D
|
||||
}
|
||||
}
|
||||
|
||||
void Game::Render(void) {
|
||||
if(m_ingameMenu.GetStatus() == false) {
|
||||
m_map.Render();
|
||||
if(_ingameMenu.GetStatus() == false) {
|
||||
_map.Render();
|
||||
|
||||
m_player->Render();
|
||||
m_npc->Render();
|
||||
_player->Render();
|
||||
_npc->Render();
|
||||
|
||||
if(debugEnabled) {
|
||||
m_gameRenderTime.RenderLiteral();
|
||||
m_gameUpdateTime.RenderLiteral();
|
||||
m_playerXY.RenderLiteral();
|
||||
_gameRenderTime.RenderLiteral();
|
||||
_gameUpdateTime.RenderLiteral();
|
||||
_playerXY.RenderLiteral();
|
||||
}
|
||||
} else {
|
||||
m_ingameMenu.Render();
|
||||
_ingameMenu.Render();
|
||||
}
|
||||
|
||||
SDL_Flip(screen);
|
||||
}
|
||||
|
||||
void Game::LoadSavegame(const string savegameIDArg) {
|
||||
m_saveGameID = savegameIDArg;
|
||||
string saveFilename = "../Save/" + m_saveGameID;
|
||||
_saveGameID = savegameIDArg;
|
||||
string saveFilename = "../Save/" + _saveGameID;
|
||||
|
||||
// Converting to XML ftw!
|
||||
TiXmlDocument mapFile(saveFilename.c_str());
|
||||
@ -183,7 +183,7 @@ void Game::LoadSavegame(const string savegameIDArg) {
|
||||
// <name> - Parse the player name.
|
||||
dataElem = rootElem->FirstChildElement("name");
|
||||
assert(dataElem != NULL);
|
||||
m_player->SetName(dataElem->GetText());
|
||||
_player->SetName(dataElem->GetText());
|
||||
// </name>
|
||||
|
||||
// <x> - Parse the player x coord.
|
||||
@ -198,12 +198,12 @@ void Game::LoadSavegame(const string savegameIDArg) {
|
||||
int playerY = atoi(dataElem->GetText());
|
||||
// </y>
|
||||
|
||||
m_player->SetXY(playerX, playerY);
|
||||
_player->SetXY(playerX, playerY);
|
||||
|
||||
// <map> - Parse the map file.
|
||||
dataElem = dataElem->NextSiblingElement("map");
|
||||
assert(dataElem != NULL);
|
||||
m_map.Load(dataElem->GetText());
|
||||
_map.Load(dataElem->GetText());
|
||||
// </map>
|
||||
}
|
||||
// <save>
|
||||
@ -212,7 +212,7 @@ void Game::LoadSavegame(const string savegameIDArg) {
|
||||
}
|
||||
|
||||
void Game::SaveSavegame(void) {
|
||||
string saveFilename = "../Save/" + m_saveGameID;
|
||||
string saveFilename = "../Save/" + _saveGameID;
|
||||
|
||||
ofstream saveFile(saveFilename.c_str());
|
||||
assert(saveFile.is_open());
|
||||
|
@ -40,22 +40,22 @@ private:
|
||||
static const int GAME_UPDATES_PER_SECOND = 60;
|
||||
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 m_mapID;
|
||||
string _saveGameID;
|
||||
string _mapID;
|
||||
|
||||
Text m_gameUpdateTime;
|
||||
Text m_gameRenderTime;
|
||||
Text m_playerXY;
|
||||
Text _gameUpdateTime;
|
||||
Text _gameRenderTime;
|
||||
Text _playerXY;
|
||||
|
||||
IngameMenu m_ingameMenu;
|
||||
Map m_map;
|
||||
IngameMenu _ingameMenu;
|
||||
Map _map;
|
||||
|
||||
Player* m_player;
|
||||
NPC* m_npc;
|
||||
Player* _player;
|
||||
NPC* _npc;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -17,22 +17,22 @@ void Player::HandleInput(void) {
|
||||
case SDLK_w:
|
||||
yVel -= PLAYER_SPEED;
|
||||
xVel = 0;
|
||||
m_directionFacing = FACING_UP;
|
||||
directionFacing = FACING_UP;
|
||||
break;
|
||||
case SDLK_s:
|
||||
yVel += PLAYER_SPEED;
|
||||
xVel = 0;
|
||||
m_directionFacing = FACING_DOWN;
|
||||
directionFacing = FACING_DOWN;
|
||||
break;
|
||||
case SDLK_a:
|
||||
xVel -= PLAYER_SPEED;
|
||||
yVel = 0;
|
||||
m_directionFacing = FACING_LEFT;
|
||||
directionFacing = FACING_LEFT;
|
||||
break;
|
||||
case SDLK_d:
|
||||
xVel += PLAYER_SPEED;
|
||||
yVel = 0;
|
||||
m_directionFacing = FACING_RIGHT;
|
||||
directionFacing = FACING_RIGHT;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -49,8 +49,8 @@ void Player::HandleInput(void) {
|
||||
}
|
||||
else if(event.type == SDL_MOUSEBUTTONDOWN) {
|
||||
if(event.button.button == SDL_BUTTON_LEFT) {
|
||||
m_attacking = true;
|
||||
m_attackTimer.Start();
|
||||
attacking = true;
|
||||
attackTimer.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -61,7 +61,7 @@ void Player::Update(void) {
|
||||
}
|
||||
|
||||
void Player::SetName(string nameArg) {
|
||||
m_name = nameArg;
|
||||
_name = nameArg;
|
||||
}
|
||||
|
||||
void Player::SetCamera(void) {
|
||||
|
@ -15,7 +15,7 @@ public:
|
||||
void Update(void);
|
||||
|
||||
void SetName(string nameArg);
|
||||
string GetName(void) { return m_name; }
|
||||
string GetName(void) { return _name; }
|
||||
|
||||
protected:
|
||||
void Move(void);
|
||||
@ -25,7 +25,7 @@ private:
|
||||
void SetCamera(void);
|
||||
static const float PLAYER_SPEED;
|
||||
|
||||
string m_name;
|
||||
string _name;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -10,24 +10,24 @@ Button::~Button(void) {
|
||||
|
||||
void Button::SetOutRGB(Uint8 r, Uint8 g, Uint8 b) {
|
||||
button.SetRGB(r, g, b);
|
||||
m_mouseOutColour.r = r;
|
||||
m_mouseOutColour.g = g;
|
||||
m_mouseOutColour.b = b;
|
||||
_mouseOutColour.r = r;
|
||||
_mouseOutColour.g = g;
|
||||
_mouseOutColour.b = b;
|
||||
}
|
||||
|
||||
void Button::SetOutRGB(SDL_Color colour) {
|
||||
button.SetRGB(colour);
|
||||
m_mouseOutColour = colour;
|
||||
_mouseOutColour = colour;
|
||||
}
|
||||
|
||||
void Button::SetOverRGB(Uint8 r, Uint8 g, Uint8 b) {
|
||||
m_mouseOverColour.r = r;
|
||||
m_mouseOverColour.g = g;
|
||||
m_mouseOverColour.b = b;
|
||||
_mouseOverColour.r = r;
|
||||
_mouseOverColour.g = g;
|
||||
_mouseOverColour.b = b;
|
||||
}
|
||||
|
||||
void Button::SetOverRGB(SDL_Color colour) {
|
||||
m_mouseOverColour = colour;
|
||||
_mouseOverColour = colour;
|
||||
}
|
||||
|
||||
void Button::SetXY(int xArg, int yArg) {
|
||||
@ -35,47 +35,47 @@ void Button::SetXY(int xArg, int yArg) {
|
||||
y = yArg;
|
||||
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) {
|
||||
m_textColour.r = r;
|
||||
m_textColour.g = g;
|
||||
m_textColour.b = b;
|
||||
_textColour.r = r;
|
||||
_textColour.g = g;
|
||||
_textColour.b = b;
|
||||
|
||||
m_text.SetTextBlended(m_text.GetText(), small, m_textColour);
|
||||
_text.SetTextBlended(_text.GetText(), small, _textColour);
|
||||
}
|
||||
|
||||
void Button::SetTextRGB(SDL_Color colour) {
|
||||
m_textColour = colour;
|
||||
m_text.SetTextBlended(m_text.GetText(), small, colour);
|
||||
_textColour = colour;
|
||||
_text.SetTextBlended(_text.GetText(), small, colour);
|
||||
}
|
||||
|
||||
void Button::SetText(string textArg) {
|
||||
m_text.SetTextBlended(textArg, small, m_textColour);
|
||||
_text.SetTextBlended(textArg, small, _textColour);
|
||||
|
||||
w = m_text.GetWidth();
|
||||
h = m_text.GetHeight();
|
||||
w = _text.GetWidth();
|
||||
h = _text.GetHeight();
|
||||
button.SetWidthHeight(w + 20, h + 15);
|
||||
}
|
||||
|
||||
bool Button::CheckMouseOver(void) {
|
||||
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()) {
|
||||
button.SetRGB(m_mouseOverColour.r, m_mouseOverColour.g, m_mouseOverColour.b);
|
||||
button.SetRGB(_mouseOverColour.r, _mouseOverColour.g, _mouseOverColour.b);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
button.SetRGB(m_mouseOutColour);
|
||||
button.SetRGB(_mouseOutColour);
|
||||
return false;
|
||||
}
|
||||
|
||||
void Button::Render(void) {
|
||||
button.DrawLiteral();
|
||||
m_text.RenderLiteral();
|
||||
_text.RenderLiteral();
|
||||
}
|
||||
|
||||
void Button::Render(int xArg, int yArg) {
|
||||
button.DrawLiteral(xArg, yArg);
|
||||
m_text.RenderLiteral(xArg, yArg);
|
||||
_text.RenderLiteral(xArg, yArg);
|
||||
}
|
||||
|
@ -35,9 +35,9 @@ public:
|
||||
void Render(int xArg, int yArg);
|
||||
|
||||
private:
|
||||
SDL_Color m_mouseOutColour;
|
||||
SDL_Color m_mouseOverColour;
|
||||
SDL_Color m_textColour;
|
||||
SDL_Color _mouseOutColour;
|
||||
SDL_Color _mouseOverColour;
|
||||
SDL_Color _textColour;
|
||||
|
||||
int x;
|
||||
int y;
|
||||
@ -45,7 +45,7 @@ private:
|
||||
int h;
|
||||
|
||||
Rect button;
|
||||
Text m_text;
|
||||
Text _text;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -25,11 +25,11 @@ void ButtonToggle::SetOffRGB(SDL_Color colour) {
|
||||
}
|
||||
|
||||
void ButtonToggle::SetOnRGB(Uint8 r, Uint8 g, Uint8 b) {
|
||||
m_onColour.r = r;
|
||||
m_onColour.g = g;
|
||||
m_onColour.b = b;
|
||||
_onColour.r = r;
|
||||
_onColour.g = g;
|
||||
_onColour.b = b;
|
||||
}
|
||||
|
||||
void ButtonToggle::SetOnRGB(SDL_Color colour) {
|
||||
m_onColour = colour;
|
||||
_onColour = colour;
|
||||
}
|
||||
|
@ -22,18 +22,18 @@ public:
|
||||
void SetOffText(string);
|
||||
|
||||
void SetState(bool);
|
||||
bool GetState(void) { return m_state; }
|
||||
bool GetState(void) { return _state; }
|
||||
|
||||
bool CheckMouseOver(void);
|
||||
|
||||
void Render(void);
|
||||
|
||||
private:
|
||||
bool m_state;
|
||||
bool _state;
|
||||
|
||||
SDL_Colour m_onColour;
|
||||
SDL_Colour _onColour;
|
||||
|
||||
Text m_onText;
|
||||
Text _onText;
|
||||
};
|
||||
|
||||
|
||||
|
@ -8,22 +8,22 @@ static list<Character*>::iterator collisionIter;
|
||||
|
||||
Character::Character(Map* mapArg) {
|
||||
map = mapArg;
|
||||
m_attacking = false;
|
||||
m_directionFacing = FACING_DOWN;
|
||||
m_animationStage = ANIM_NO_FOOT;
|
||||
m_animationTimer.Start();
|
||||
m_leftFoot = false;
|
||||
attacking = false;
|
||||
directionFacing = FACING_DOWN;
|
||||
_animationStage = ANIM_NO_FOOT;
|
||||
_animationTimer.Start();
|
||||
_leftFoot = false;
|
||||
|
||||
xVel = 0.0f;
|
||||
yVel = 0.0f;
|
||||
|
||||
m_texture = NULL;
|
||||
_texture = NULL;
|
||||
|
||||
collisionList.push_front(this);
|
||||
}
|
||||
|
||||
Character::~Character(void) {
|
||||
SDL_FreeSurface(m_texture);
|
||||
SDL_FreeSurface(_texture);
|
||||
for(collisionIter = collisionList.begin(); collisionIter != collisionList.end(); collisionIter++) {
|
||||
if((*collisionIter) == this) {
|
||||
collisionList.erase(collisionIter);
|
||||
@ -33,37 +33,37 @@ Character::~Character(void) {
|
||||
}
|
||||
|
||||
void Character::LoadSprites(string filename, int wArg, int hArg) {
|
||||
if(m_texture != NULL)
|
||||
SDL_FreeSurface(m_texture);
|
||||
if(_texture != NULL)
|
||||
SDL_FreeSurface(_texture);
|
||||
|
||||
m_texture = LoadImageAlpha(filename.c_str());
|
||||
_texture = LoadImageAlpha(filename.c_str());
|
||||
|
||||
w = wArg;
|
||||
h = hArg;
|
||||
|
||||
for(int m_direction = 0; m_direction < 4; m_direction++) {
|
||||
for(int m_action = 0; m_action < 4; 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].w = w;
|
||||
sprites[m_direction][m_action].h = h;
|
||||
_sprites[m_direction][m_action].x = w * m_action;
|
||||
_sprites[m_direction][m_action].y = h * m_direction;
|
||||
_sprites[m_direction][m_action].w = w;
|
||||
_sprites[m_direction][m_action].h = h;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Character::AddSpeachBubble(string text) {
|
||||
m_speachBubble.push_back(text);
|
||||
_speachBubble.push_back(text);
|
||||
|
||||
//m_speachBubbleText.SetTextBlended(text, "small", 0, 0, 0);
|
||||
|
||||
if(m_speachBubbleTimer.IsStarted() == false)
|
||||
m_speachBubbleTimer.Start();
|
||||
if(_speachBubbleTimer.IsStarted() == false)
|
||||
_speachBubbleTimer.Start();
|
||||
}
|
||||
|
||||
void Character::Render(void) {
|
||||
// Draw some fancy speach bubbles. It is a bit of a mess, I am playing.
|
||||
if(m_speachBubble.size() != 0) {
|
||||
if(m_speachBubbleTimer.GetTicks() < SPEACH_BUBBLE_DISPLAY_LENGTH) {
|
||||
if(_speachBubble.size() != 0) {
|
||||
if(_speachBubbleTimer.GetTicks() < SPEACH_BUBBLE_DISPLAY_LENGTH) {
|
||||
roundedBoxRGBA(screen, (x + w / 2) - 100,
|
||||
y - 100,
|
||||
(x + w / 2) + 100,
|
||||
@ -78,53 +78,53 @@ void Character::Render(void) {
|
||||
y - 40,
|
||||
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) {
|
||||
ApplySurface(x, y, m_texture, screen, &sprites[m_directionFacing][ANIM_ATTACK]);
|
||||
if(attacking && attackTimer.GetTicks() < ATTACKING_DISPLAY_LEN) {
|
||||
ApplySurface(x, y, _texture, screen, &_sprites[directionFacing][ANIM_ATTACK]);
|
||||
return;
|
||||
}
|
||||
else if(m_attacking)
|
||||
m_attacking = false;
|
||||
else if(attacking)
|
||||
attacking = false;
|
||||
|
||||
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 {
|
||||
if(m_animationTimer.GetTicks() > ANIMATION_SPEED) {
|
||||
if(m_animationStage == ANIM_NO_FOOT) {
|
||||
if(m_leftFoot == true)
|
||||
m_animationStage = ANIM_RIGHT_FOOT;
|
||||
if(_animationTimer.GetTicks() > ANIMATION_SPEED) {
|
||||
if(_animationStage == ANIM_NO_FOOT) {
|
||||
if(_leftFoot == true)
|
||||
_animationStage = ANIM_RIGHT_FOOT;
|
||||
else
|
||||
m_animationStage = ANIM_LEFT_FOOT;
|
||||
_animationStage = ANIM_LEFT_FOOT;
|
||||
}
|
||||
else if(m_animationStage == ANIM_LEFT_FOOT) {
|
||||
m_animationStage = ANIM_NO_FOOT;
|
||||
m_leftFoot = true;
|
||||
else if(_animationStage == ANIM_LEFT_FOOT) {
|
||||
_animationStage = ANIM_NO_FOOT;
|
||||
_leftFoot = true;
|
||||
}
|
||||
else if(m_animationStage == ANIM_RIGHT_FOOT) {
|
||||
m_animationStage = ANIM_NO_FOOT;
|
||||
m_leftFoot = false;
|
||||
else if(_animationStage == ANIM_RIGHT_FOOT) {
|
||||
_animationStage = ANIM_NO_FOOT;
|
||||
_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) {
|
||||
Move();
|
||||
|
||||
if(m_speachBubble.size() != 0) {
|
||||
if(m_speachBubbleTimer.GetTicks() > SPEACH_BUBBLE_DISPLAY_LENGTH) {
|
||||
m_speachBubble.pop_front();
|
||||
if(_speachBubble.size() != 0) {
|
||||
if(_speachBubbleTimer.GetTicks() > SPEACH_BUBBLE_DISPLAY_LENGTH) {
|
||||
_speachBubble.pop_front();
|
||||
|
||||
if(m_speachBubble.size() != 0) {
|
||||
m_speachBubbleTimer.Start();
|
||||
if(_speachBubble.size() != 0) {
|
||||
_speachBubbleTimer.Start();
|
||||
}
|
||||
} else {
|
||||
if(m_speachBubble.front() != m_speachBubbleText.GetText()) {
|
||||
if(_speachBubble.front() != _speachBubbleText.GetText()) {
|
||||
//m_speachBubbleText.SetTextBlended(m_speachBubble.front(), "small", 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
@ -56,14 +56,14 @@ protected:
|
||||
int tileX;
|
||||
int tileY;
|
||||
|
||||
Timer m_attackTimer;
|
||||
bool m_attacking;
|
||||
Timer attackTimer;
|
||||
bool attacking;
|
||||
|
||||
Map* map;
|
||||
|
||||
static const float CHARACTER_SPEED;
|
||||
|
||||
int m_directionFacing;
|
||||
int directionFacing;
|
||||
static const int FACING_UP = 0;
|
||||
static const int FACING_RIGHT = 1;
|
||||
static const int FACING_DOWN = 2;
|
||||
@ -80,19 +80,19 @@ private:
|
||||
|
||||
static const int SPEACH_BUBBLE_DISPLAY_LENGTH = 6000;
|
||||
|
||||
SDL_Surface* m_texture;
|
||||
SDL_Surface* _texture;
|
||||
|
||||
// [direction][action]
|
||||
SDL_Rect sprites[4][4];
|
||||
SDL_Rect _sprites[4][4];
|
||||
|
||||
Timer m_animationTimer;
|
||||
int m_animationStage;
|
||||
bool m_leftFoot;
|
||||
Timer _animationTimer;
|
||||
int _animationStage;
|
||||
bool _leftFoot;
|
||||
|
||||
list<string> m_speachBubble;
|
||||
list<string>::iterator m_speachBubbleIter;
|
||||
Timer m_speachBubbleTimer;
|
||||
Text m_speachBubbleText;
|
||||
list<string> _speachBubble;
|
||||
list<string>::iterator _speachBubbleIter;
|
||||
Timer _speachBubbleTimer;
|
||||
Text _speachBubbleText;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -20,14 +20,14 @@ Debug *Debug::logger = NULL;
|
||||
Debug::Debug(bool logToFile) {
|
||||
time_t timestamp;
|
||||
if(logToFile) {
|
||||
logFile.open("../Bin/Debug.log", ios::out);
|
||||
_logFile.open("../Bin/Debug.log", ios::out);
|
||||
if(!logToFile) {
|
||||
// We can not open our log.
|
||||
cerr << "Warning: Can not open Debug.log to write, continueing without logging\n";
|
||||
} else {
|
||||
// Log File is open, let us give it a nice time stamp.
|
||||
timestamp = time(NULL);
|
||||
logFile << "Log Started: " << ctime(×tamp) << endl;
|
||||
_logFile << "Log Started: " << ctime(×tamp) << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -36,19 +36,19 @@ Debug::~Debug(void) {
|
||||
time_t timestamp;
|
||||
|
||||
// We only need to close the log if it is open.
|
||||
if(logFile) {
|
||||
if(_logFile) {
|
||||
// Give it a closing timestamp.
|
||||
timestamp = time(NULL);
|
||||
logFile << endl << "Log Closed: " << ctime(×tamp) << endl;
|
||||
_logFile << endl << "Log Closed: " << ctime(×tamp) << endl;
|
||||
|
||||
// Close the log file.
|
||||
logFile.close();
|
||||
_logFile.close();
|
||||
}
|
||||
}
|
||||
|
||||
void Debug::message(std::string msg) {
|
||||
if(logFile) {
|
||||
logFile << msg << endl;
|
||||
if(_logFile) {
|
||||
_logFile << msg << endl;
|
||||
}
|
||||
cerr << msg << endl << endl;
|
||||
}
|
||||
@ -74,8 +74,8 @@ void Debug::message(const char *msg, ...) {
|
||||
outLen = sizeof(outBuf);
|
||||
}
|
||||
|
||||
if(logFile) {
|
||||
logFile << outBuf << endl;
|
||||
if(_logFile) {
|
||||
_logFile << outBuf << endl;
|
||||
}
|
||||
|
||||
cerr << outBuf << endl;
|
||||
|
@ -17,7 +17,7 @@ public:
|
||||
static Debug *logger;
|
||||
|
||||
private:
|
||||
std::ofstream logFile;
|
||||
std::ofstream _logFile;
|
||||
};
|
||||
|
||||
#endif // _DEBUG_H_
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "IngameMenu.h"
|
||||
|
||||
IngameMenu::IngameMenu(void) {
|
||||
m_active = false;
|
||||
_active = false;
|
||||
|
||||
btnResume.SetOutRGB(200, 200, 200);
|
||||
btnResume.SetOverRGB(255, 255, 255);
|
||||
|
@ -23,11 +23,11 @@ public:
|
||||
ingameMenuNavVal_t HandleInput(void);
|
||||
void Render(void);
|
||||
|
||||
void SetStatus(bool arg) { m_active = arg; }
|
||||
bool GetStatus(void) { return m_active; }
|
||||
void SetStatus(bool arg) { _active = arg; }
|
||||
bool GetStatus(void) { return _active; }
|
||||
|
||||
private:
|
||||
bool m_active;
|
||||
bool _active;
|
||||
|
||||
Button btnResume;
|
||||
Button btnSaveGame;
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
void Render(void);
|
||||
|
||||
private:
|
||||
Map m_background;
|
||||
Map _background;
|
||||
|
||||
Text lblMenu;
|
||||
|
||||
|
@ -10,7 +10,7 @@ Map::~Map(void) {
|
||||
|
||||
void Map::Load(const string filename) {
|
||||
Unload();
|
||||
m_currentMap = filename;
|
||||
_currentMap = filename;
|
||||
string fullMapPath = "../Data/Media/Maps/" + filename;
|
||||
TiXmlDocument mapFile(fullMapPath);
|
||||
|
||||
@ -43,14 +43,14 @@ void Map::Load(const string filename) {
|
||||
assert(tileElem != NULL);
|
||||
while(tileElem) {
|
||||
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.
|
||||
dataElem = tileElem->FirstChildElement("tileTexture");
|
||||
assert(dataElem != NULL);
|
||||
stringstream tilePath;
|
||||
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.
|
||||
|
||||
// <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();
|
||||
assert(tileSolidity == "false" || tileSolidity == "true");
|
||||
if(tileSolidity == "false")
|
||||
m_tile[x][y].SetTileSolidity(false);
|
||||
_tile[x][y].SetTileSolidity(false);
|
||||
else
|
||||
m_tile[x][y].SetTileSolidity(true);
|
||||
_tile[x][y].SetTileSolidity(true);
|
||||
// </solidTile>
|
||||
|
||||
// <entityTexture>
|
||||
@ -71,10 +71,10 @@ void Map::Load(const string filename) {
|
||||
if(entityName != "null") {
|
||||
stringstream entityPath;
|
||||
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,
|
||||
m_tile[x][y].GetTileY() + TILE_HEIGHT / 2 - m_tile[x][y].GetEntityHeight() / 2);
|
||||
_tile[x][y].SetEntityXY(_tile[x][y].GetTileX() + TILE_WIDTH / 2 - _tile[x][y].GetEntityWidth() / 2,
|
||||
_tile[x][y].GetTileY() + TILE_HEIGHT / 2 - _tile[x][y].GetEntityHeight() / 2);
|
||||
}
|
||||
// </entityTexture>
|
||||
|
||||
@ -84,21 +84,21 @@ void Map::Load(const string filename) {
|
||||
string entitySolidity = dataElem->GetText();
|
||||
assert(entitySolidity == "false" || entitySolidity == "true");
|
||||
if(entitySolidity == "false")
|
||||
m_tile[x][y].SetEntitySolidity(false);
|
||||
_tile[x][y].SetEntitySolidity(false);
|
||||
else
|
||||
m_tile[x][y].SetEntitySolidity(true);
|
||||
_tile[x][y].SetEntitySolidity(true);
|
||||
// </solidEntity>
|
||||
|
||||
// <zlevel>
|
||||
dataElem = dataElem->NextSiblingElement("zLevel");
|
||||
assert(dataElem != NULL);
|
||||
m_tile[x][y].SetZLevel(atoi(dataElem->GetText()));
|
||||
_tile[x][y].SetZLevel(atoi(dataElem->GetText()));
|
||||
// </zlevel>
|
||||
|
||||
// <mapTransition>
|
||||
dataElem = dataElem->NextSiblingElement("mapTransition");
|
||||
assert(dataElem != NULL);
|
||||
m_tile[x][y].SetMapTransitionName(dataElem->GetText());
|
||||
_tile[x][y].SetMapTransitionName(dataElem->GetText());
|
||||
// </mapTransition>
|
||||
|
||||
// <mapTransX>
|
||||
@ -147,30 +147,30 @@ void Map::Render(void) {
|
||||
|
||||
for(int i = xOrig; i < xEnd; i++) {
|
||||
for(int j = yOrig; j < yEnd; j++) {
|
||||
m_tile[i][j].Render();
|
||||
_tile[i][j].Render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Map::Unload(void) {
|
||||
m_tileTextures.Unload();
|
||||
m_entityTextures.Unload();
|
||||
_tileTextures.Unload();
|
||||
_entityTextures.Unload();
|
||||
}
|
||||
|
||||
string Map::GetCurrentMap(void) {
|
||||
return m_currentMap;
|
||||
return _currentMap;
|
||||
}
|
||||
|
||||
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) {
|
||||
return m_tile[xArg + 1][yArg + 1].GetTileX();
|
||||
return _tile[xArg + 1][yArg + 1].GetTileX();
|
||||
}
|
||||
|
||||
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) {
|
||||
@ -178,37 +178,37 @@ bool Map::GetEntitySolidity(int xArg, int yArg) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return m_tile[xArg + 1][yArg + 1].GetEntitySolitity();
|
||||
return _tile[xArg + 1][yArg + 1].GetEntitySolitity();
|
||||
}
|
||||
|
||||
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) {
|
||||
return m_tile[xArg + 1][yArg + 1].GetEntityY();
|
||||
return _tile[xArg + 1][yArg + 1].GetEntityY();
|
||||
}
|
||||
|
||||
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) {
|
||||
return m_tile[xArg + 1][yArg + 1].GetEntityHeight();
|
||||
return _tile[xArg + 1][yArg + 1].GetEntityHeight();
|
||||
}
|
||||
|
||||
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) {
|
||||
return m_tile[xArg + 1][yArg + 1].GetMapTransitionName();
|
||||
return _tile[xArg + 1][yArg + 1].GetMapTransitionName();
|
||||
}
|
||||
|
||||
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) {
|
||||
return m_tile[xArg + 1][yArg + 1].GetMapTransitionY();
|
||||
return _tile[xArg + 1][yArg + 1].GetMapTransitionY();
|
||||
}
|
||||
|
@ -47,15 +47,15 @@ public:
|
||||
private:
|
||||
void Unload(void);
|
||||
|
||||
string m_currentMap;
|
||||
string _currentMap;
|
||||
int x;
|
||||
int y;
|
||||
|
||||
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 m_entityTextures;
|
||||
TextureManager _tileTextures;
|
||||
TextureManager _entityTextures;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -9,11 +9,11 @@ MapElement::~MapElement(void) {
|
||||
}
|
||||
|
||||
void MapElement::SetTexture(SDL_Surface* arg) {
|
||||
m_texture = arg;
|
||||
_texture = arg;
|
||||
}
|
||||
|
||||
void MapElement::Render(void) {
|
||||
ApplySurface(x, y, m_texture, screen);
|
||||
ApplySurface(x, y, _texture, screen);
|
||||
}
|
||||
|
||||
void MapElement::Update(void) {
|
||||
@ -21,11 +21,11 @@ void MapElement::Update(void) {
|
||||
}
|
||||
|
||||
void MapElement::SetSolidity(bool arg) {
|
||||
m_solid = arg;
|
||||
_solid = arg;
|
||||
}
|
||||
|
||||
bool MapElement::GetSolidity(void) {
|
||||
return m_solid;
|
||||
return _solid;
|
||||
}
|
||||
|
||||
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::GetY(void) { return y; }
|
||||
int MapElement::GetWidth(void) { return m_texture->w; }
|
||||
int MapElement::GetHeight(void) { return m_texture->h; }
|
||||
int MapElement::GetWidth(void) { return _texture->w; }
|
||||
int MapElement::GetHeight(void) { return _texture->h; }
|
||||
|
@ -28,9 +28,9 @@ public:
|
||||
int GetHeight(void);
|
||||
|
||||
protected:
|
||||
SDL_Surface* m_texture;
|
||||
SDL_Surface* _texture;
|
||||
|
||||
bool m_solid;
|
||||
bool _solid;
|
||||
|
||||
int x;
|
||||
int y;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "MapEntities.h"
|
||||
|
||||
MapEntityGeneric::MapEntityGeneric(void) {
|
||||
m_texture = NULL;
|
||||
_texture = NULL;
|
||||
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@ MapEntityGeneric::~MapEntityGeneric(void) {
|
||||
}
|
||||
|
||||
void MapEntityGeneric::Render(void) {
|
||||
if(m_texture != NULL) {
|
||||
if(_texture != NULL) {
|
||||
MapElement::Render();
|
||||
}
|
||||
}
|
||||
|
@ -15,52 +15,52 @@ public:
|
||||
MapTile(void) { }
|
||||
~MapTile(void) { }
|
||||
|
||||
void Render(void) { m_tile.Render(), m_entity.Render(); }
|
||||
void Render(void) { _tile.Render(), _entity.Render(); }
|
||||
|
||||
// Tile Mutators.
|
||||
SDL_Surface SetTileTexture(SDL_Surface* arg) { m_tile.SetTexture(arg); }
|
||||
void SetTileSolidity(bool arg) { m_tile.SetSolidity(arg); }
|
||||
bool GetTileSolidity(void) { return m_tile.GetSolidity(); }
|
||||
void SetTileXY(int xArg, int yArg) { m_tile.GetX(), m_tile.GetY(); }
|
||||
int GetTileX(void) { return m_tile.GetX(); }
|
||||
int GetTileY(void) { return m_tile.GetY(); }
|
||||
SDL_Surface SetTileTexture(SDL_Surface* arg) { _tile.SetTexture(arg); }
|
||||
void SetTileSolidity(bool arg) { _tile.SetSolidity(arg); }
|
||||
bool GetTileSolidity(void) { return _tile.GetSolidity(); }
|
||||
void SetTileXY(int xArg, int yArg) { _tile.GetX(), _tile.GetY(); }
|
||||
int GetTileX(void) { return _tile.GetX(); }
|
||||
int GetTileY(void) { return _tile.GetY(); }
|
||||
|
||||
// Entity Mutators.
|
||||
void SetEntityTexture(SDL_Surface* arg) { m_entity.SetTexture(arg); }
|
||||
void SetEntityXY(int xArg, int yArg) { m_entity.SetXY(xArg, yArg); }
|
||||
void SetEntitySolidity(bool arg) { m_entity.SetSolidity(arg); }
|
||||
bool GetEntitySolitity(void) { return m_entity.GetSolidity(); }
|
||||
void SetEntityTexture(SDL_Surface* arg) { _entity.SetTexture(arg); }
|
||||
void SetEntityXY(int xArg, int yArg) { _entity.SetXY(xArg, yArg); }
|
||||
void SetEntitySolidity(bool arg) { _entity.SetSolidity(arg); }
|
||||
bool GetEntitySolitity(void) { return _entity.GetSolidity(); }
|
||||
|
||||
// Entity Mutators.
|
||||
int GetEntityX(void) { return m_entity.GetX(); }
|
||||
int GetEntityY(void) { return m_entity.GetY(); }
|
||||
int GetEntityWidth(void) { return m_entity.GetWidth(); }
|
||||
int GetEntityHeight(void) { return m_entity.GetHeight(); }
|
||||
int GetEntityX(void) { return _entity.GetX(); }
|
||||
int GetEntityY(void) { return _entity.GetY(); }
|
||||
int GetEntityWidth(void) { return _entity.GetWidth(); }
|
||||
int GetEntityHeight(void) { return _entity.GetHeight(); }
|
||||
|
||||
// ZLevel Mutators.
|
||||
void SetZLevel(int arg) { m_zLevel = arg; }
|
||||
int GetZLevel(void) { return m_zLevel; }
|
||||
void SetZLevel(int arg) { _zLevel = arg; }
|
||||
int GetZLevel(void) { return _zLevel; }
|
||||
|
||||
// Map Transition Mutators.
|
||||
void SetMapTransitionName(string arg) { m_mapTransitionName = arg; }
|
||||
string GetMapTransitionName(void) { return m_mapTransitionName; }
|
||||
void SetMapTransitionName(string arg) { _mapTransitionName = arg; }
|
||||
string GetMapTransitionName(void) { return _mapTransitionName; }
|
||||
|
||||
void SetMapTransitionXY(int xArg, int yArg) { m_mapTransitionX = xArg, m_mapTransitionY = yArg; }
|
||||
int GetMapTransitionX(void) { return m_mapTransitionX; }
|
||||
int GetMapTransitionY(void) { return m_mapTransitionY; }
|
||||
void SetMapTransitionXY(int xArg, int yArg) { _mapTransitionX = xArg, _mapTransitionY = yArg; }
|
||||
int GetMapTransitionX(void) { return _mapTransitionX; }
|
||||
int GetMapTransitionY(void) { return _mapTransitionY; }
|
||||
|
||||
private:
|
||||
MapElement m_tile;
|
||||
MapEntityGeneric m_entity;
|
||||
MapElement _tile;
|
||||
MapEntityGeneric _entity;
|
||||
|
||||
// -1 is a 'special' tile, the next tile that the player walks
|
||||
// on is the players new zlevel.
|
||||
int m_zLevel;
|
||||
int _zLevel;
|
||||
|
||||
// If not 'null', switch map when the player walks on this tile.
|
||||
string m_mapTransitionName;
|
||||
int m_mapTransitionX;
|
||||
int m_mapTransitionY;
|
||||
string _mapTransitionName;
|
||||
int _mapTransitionX;
|
||||
int _mapTransitionY;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -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
|
@ -1,11 +1,11 @@
|
||||
#include "NPC.h"
|
||||
|
||||
NPC::NPC(Map* mapArg) : Character(mapArg) {
|
||||
m_moveTimer.Start();
|
||||
_moveTimer.Start();
|
||||
|
||||
m_moveChangeFrequency = 14000;
|
||||
m_moveDurationMax = 3000;
|
||||
m_moveDurationMin = 1000;
|
||||
_moveChangeFrequency = 14000;
|
||||
_moveDurationMax = 3000;
|
||||
_moveDurationMin = 1000;
|
||||
}
|
||||
|
||||
NPC::~NPC(void) {
|
||||
@ -15,28 +15,28 @@ NPC::~NPC(void) {
|
||||
void NPC::Update(void) {
|
||||
Move();
|
||||
|
||||
if(xVel > 0) m_directionFacing = FACING_RIGHT;
|
||||
else if(xVel < 0) m_directionFacing = FACING_LEFT;
|
||||
else if(yVel > 0) m_directionFacing = FACING_DOWN;
|
||||
else if(yVel < 0) m_directionFacing = FACING_UP;
|
||||
if(xVel > 0) directionFacing = FACING_RIGHT;
|
||||
else if(xVel < 0) directionFacing = FACING_LEFT;
|
||||
else if(yVel > 0) directionFacing = FACING_DOWN;
|
||||
else if(yVel < 0) directionFacing = FACING_UP;
|
||||
}
|
||||
|
||||
void NPC::Move(void) {
|
||||
if(m_moving && m_moveTimer.GetTicks() > m_moveDurationMax) {
|
||||
if(_moving && _moveTimer.GetTicks() > _moveDurationMax) {
|
||||
xVel = 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;
|
||||
yVel = 0.0f;
|
||||
m_moving = false;
|
||||
_moving = false;
|
||||
}
|
||||
|
||||
if(m_moveTimer.GetTicks() > m_moveChangeFrequency) {
|
||||
m_moveTimer.Start();
|
||||
m_moveDurationCurrent = m_moveDurationMin + (rand() % (m_moveDurationMax - m_moveDurationMin));
|
||||
if(_moveTimer.GetTicks() > _moveChangeFrequency) {
|
||||
_moveTimer.Start();
|
||||
_moveDurationCurrent = _moveDurationMin + (rand() % (_moveDurationMax - _moveDurationMin));
|
||||
if(rand() % 2) {
|
||||
yVel = 0.0f;
|
||||
if(rand() % 2)
|
||||
@ -50,7 +50,7 @@ void NPC::Move(void) {
|
||||
else
|
||||
yVel = -CHARACTER_SPEED;
|
||||
}
|
||||
m_moving = true;
|
||||
_moving = true;
|
||||
}
|
||||
Character::Move();
|
||||
}
|
||||
|
@ -14,15 +14,15 @@ protected:
|
||||
void Move(void);
|
||||
|
||||
private:
|
||||
int m_moveChangeFrequency;
|
||||
int _moveChangeFrequency;
|
||||
|
||||
int m_moveDurationCurrent;
|
||||
int m_moveDurationMin;
|
||||
int m_moveDurationMax;
|
||||
int _moveDurationCurrent;
|
||||
int _moveDurationMin;
|
||||
int _moveDurationMax;
|
||||
|
||||
bool m_moving;
|
||||
bool _moving;
|
||||
|
||||
Timer m_moveTimer;
|
||||
Timer _moveTimer;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -14,50 +14,50 @@ void ParticleEmitter::SetXY(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].y = yArg;
|
||||
}
|
||||
}
|
||||
|
||||
void ParticleEmitter::SetParticleCount(int countArg) {
|
||||
m_particleCount = countArg;
|
||||
m_particle.resize(m_particleCount);
|
||||
_particleCount = countArg;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
void ParticleEmitter::SetParticleSpeed(float speedArg) {
|
||||
m_particleSpeed = speedArg;
|
||||
_particleSpeed = speedArg;
|
||||
}
|
||||
|
||||
void ParticleEmitter::SetParticleType(string typeArg) {
|
||||
if(!particleTexture) {
|
||||
SDL_FreeSurface(particleTexture);
|
||||
if(!_particleTexture) {
|
||||
SDL_FreeSurface(_particleTexture);
|
||||
}
|
||||
|
||||
string textureFilename = "../Data/Media/Images/Particles/" + typeArg + ".png";
|
||||
particleTexture = LoadImageAlpha(textureFilename.c_str());
|
||||
_particleTexture = LoadImageAlpha(textureFilename.c_str());
|
||||
}
|
||||
|
||||
void ParticleEmitter::SetParticleLifetime(int lifetimeArg) {
|
||||
m_particleLifetime = lifetimeArg;
|
||||
_particleLifetime = lifetimeArg;
|
||||
|
||||
for(int i = 0; i < m_particleCount; i++) {
|
||||
m_particle[i].lifetime = rand() % m_particleLifetime + m_particleLifetime / 4;
|
||||
for(int i = 0; i < _particleCount; i++) {
|
||||
m_particle[i].lifetime = rand() % _particleLifetime + _particleLifetime / 4;
|
||||
}
|
||||
}
|
||||
|
||||
void ParticleEmitter::Render(void) {
|
||||
for(int i = 0; i < m_particleCount; i++) {
|
||||
ApplySurface(m_particle[i].x, m_particle[i].y, particleTexture, screen);
|
||||
for(int i = 0; i < _particleCount; i++) {
|
||||
ApplySurface(m_particle[i].x, m_particle[i].y, _particleTexture, screen);
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
// Reset the x and y coords.
|
||||
m_particle[i].x = x;
|
||||
@ -73,8 +73,8 @@ void ParticleEmitter::Update(void) {
|
||||
|
||||
m_particle[i].startTime = SDL_GetTicks();
|
||||
} else {
|
||||
m_particle[i].x += m_particle[i].xVel * m_particleSpeed;
|
||||
m_particle[i].y += m_particle[i].yVel * m_particleSpeed;
|
||||
m_particle[i].x += m_particle[i].xVel * _particleSpeed;
|
||||
m_particle[i].y += m_particle[i].yVel * _particleSpeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,11 +45,11 @@ private:
|
||||
int x;
|
||||
int y;
|
||||
|
||||
int m_particleCount;
|
||||
int m_particleLifetime;
|
||||
float m_particleSpeed;
|
||||
int _particleCount;
|
||||
int _particleLifetime;
|
||||
float _particleSpeed;
|
||||
|
||||
SDL_Surface* particleTexture;
|
||||
SDL_Surface* _particleTexture;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -7,12 +7,12 @@ TTF_Font* Text::largeFont = NULL;
|
||||
TTF_Font* Text::vLargeFont = NULL;
|
||||
|
||||
Text::Text(void) {
|
||||
m_text = NULL;
|
||||
_text = NULL;
|
||||
}
|
||||
|
||||
Text::~Text(void) {
|
||||
assert(m_text != NULL);
|
||||
SDL_FreeSurface(m_text);
|
||||
assert(_text != NULL);
|
||||
SDL_FreeSurface(_text);
|
||||
}
|
||||
|
||||
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) {
|
||||
m_textContents = textArg;
|
||||
_textContents = textArg;
|
||||
|
||||
if(m_text != NULL) {
|
||||
SDL_FreeSurface(m_text);
|
||||
if(_text != NULL) {
|
||||
SDL_FreeSurface(_text);
|
||||
}
|
||||
|
||||
if(size == vsmall) {
|
||||
m_text = TTF_RenderText_Blended(vSmallFont, textArg.c_str(), colour);
|
||||
_text = TTF_RenderText_Blended(vSmallFont, textArg.c_str(), colour);
|
||||
return 1;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
} else {
|
||||
m_text = TTF_RenderText_Blended(vLargeFont, textArg.c_str(), colour);
|
||||
_text = TTF_RenderText_Blended(vLargeFont, textArg.c_str(), colour);
|
||||
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) {
|
||||
m_textContents = textArg;
|
||||
_textContents = textArg;
|
||||
|
||||
if(m_text != NULL) {
|
||||
SDL_FreeSurface(m_text);
|
||||
if(_text != NULL) {
|
||||
SDL_FreeSurface(_text);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
} else {
|
||||
m_text = TTF_RenderText_Shaded(vLargeFont, textArg.c_str(), colour, bgColour);
|
||||
_text = TTF_RenderText_Shaded(vLargeFont, textArg.c_str(), colour, bgColour);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -118,17 +118,17 @@ int Text::SetTextShaded(string textArg, textSizes_t size, Uint8 rF, Uint8 gF, Ui
|
||||
}
|
||||
|
||||
void Text::Render(void) {
|
||||
ApplySurface(x, y, m_text, screen);
|
||||
ApplySurface(x, y, _text, screen);
|
||||
}
|
||||
|
||||
void Text::Render(int xArg, int yArg) {
|
||||
ApplySurface(xArg, yArg, m_text, screen);
|
||||
ApplySurface(xArg, yArg, _text, screen);
|
||||
}
|
||||
|
||||
void Text::RenderLiteral(void) {
|
||||
ApplySurfaceLiteral(x, y, m_text, screen);
|
||||
ApplySurfaceLiteral(x, y, _text, screen);
|
||||
}
|
||||
|
||||
void Text::RenderLiteral(int xArg, int yArg) {
|
||||
ApplySurfaceLiteral(xArg, yArg, m_text, screen);
|
||||
ApplySurfaceLiteral(xArg, yArg, _text, screen);
|
||||
}
|
||||
|
@ -20,13 +20,13 @@ public:
|
||||
static void LoadFonts(void);
|
||||
static void FreeFonts(void);
|
||||
|
||||
int GetWidth(void) { return m_text->w; }
|
||||
int GetHeight(void) { return m_text->h; }
|
||||
int GetWidth(void) { return _text->w; }
|
||||
int GetHeight(void) { return _text->h; }
|
||||
int GetX(void) { return x; }
|
||||
int GetY(void) { return y; }
|
||||
|
||||
string GetText(void) { return m_textContents; }
|
||||
SDL_Color GetColour(void) { return m_textColour; }
|
||||
string GetText(void) { return _textContents; }
|
||||
SDL_Color GetColour(void) { return _textColour; }
|
||||
|
||||
void SetXY(int xArg, int yArg);
|
||||
|
||||
@ -43,9 +43,9 @@ public:
|
||||
private:
|
||||
int x, y, w, h;
|
||||
|
||||
string m_textContents;
|
||||
SDL_Color m_textColour;
|
||||
SDL_Surface* m_text;
|
||||
string _textContents;
|
||||
SDL_Color _textColour;
|
||||
SDL_Surface* _text;
|
||||
|
||||
static TTF_Font* vSmallFont;
|
||||
static TTF_Font* smallFont;
|
||||
|
@ -1,12 +1,12 @@
|
||||
#include "Texture.h"
|
||||
|
||||
Texture::Texture(void) {
|
||||
texture = NULL;
|
||||
_texture = NULL;
|
||||
}
|
||||
|
||||
Texture::~Texture(void) {
|
||||
assert(texture != NULL);
|
||||
SDL_FreeSurface(texture);
|
||||
assert(_texture != NULL);
|
||||
SDL_FreeSurface(_texture);
|
||||
}
|
||||
|
||||
void Texture::SetXY(int xArg, int yArg) {
|
||||
@ -15,39 +15,39 @@ void Texture::SetXY(int xArg, int yArg) {
|
||||
}
|
||||
|
||||
void Texture::Render(void) {
|
||||
ApplySurface(x, y, texture, screen);
|
||||
ApplySurface(x, y, _texture, screen);
|
||||
}
|
||||
|
||||
void Texture::Render(int xArg, int yArg) {
|
||||
ApplySurface(xArg, yArg, texture, screen);
|
||||
ApplySurface(xArg, yArg, _texture, screen);
|
||||
}
|
||||
|
||||
void Texture::RenderLiteral(void) {
|
||||
ApplySurfaceLiteral(x, y, texture, screen);
|
||||
ApplySurfaceLiteral(x, y, _texture, screen);
|
||||
}
|
||||
|
||||
void Texture::RenderLiteral(int xArg, int yArg) {
|
||||
ApplySurfaceLiteral(xArg, yArg,texture, screen);
|
||||
ApplySurfaceLiteral(xArg, yArg,_texture, screen);
|
||||
}
|
||||
|
||||
void Texture::Load(const char* filename) {
|
||||
if(texture != NULL) {
|
||||
if(_texture != NULL) {
|
||||
// Free the texture.
|
||||
SDL_FreeSurface(texture);
|
||||
SDL_FreeSurface(_texture);
|
||||
}
|
||||
// Load the texture.
|
||||
texture = LoadImage(filename);
|
||||
_texture = LoadImage(filename);
|
||||
}
|
||||
|
||||
void Texture::LoadAlpha(const char* filename) {
|
||||
if(texture != NULL) {
|
||||
if(_texture != NULL) {
|
||||
// Free the texture.
|
||||
SDL_FreeSurface(texture);
|
||||
SDL_FreeSurface(_texture);
|
||||
}
|
||||
// Load the texture with an alpha channel.
|
||||
texture = LoadImageAlpha(filename);
|
||||
_texture = LoadImageAlpha(filename);
|
||||
}
|
||||
|
||||
void Texture::SetAlpha(int alphaArg) {
|
||||
SDL_SetAlpha(texture, SDL_SRCALPHA, alphaArg);
|
||||
SDL_SetAlpha(_texture, SDL_SRCALPHA, alphaArg);
|
||||
}
|
||||
|
@ -9,8 +9,8 @@ public:
|
||||
Texture(void);
|
||||
~Texture(void);
|
||||
|
||||
int GetWidth(void) { return texture->w; }
|
||||
int GetHeight(void) { return texture->h; }
|
||||
int GetWidth(void) { return _texture->w; }
|
||||
int GetHeight(void) { return _texture->h; }
|
||||
int GetX(void) { return x; }
|
||||
int GetY(void) { return y; }
|
||||
|
||||
@ -30,7 +30,7 @@ protected:
|
||||
int x, y;
|
||||
|
||||
private:
|
||||
SDL_Surface* texture;
|
||||
SDL_Surface* _texture;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "TextureManager.h"
|
||||
|
||||
TextureManager::TextureManager(void) {
|
||||
m_allocated = 0;
|
||||
_allocated = 0;
|
||||
}
|
||||
|
||||
TextureManager::~TextureManager(void) {
|
||||
@ -9,47 +9,47 @@ TextureManager::~TextureManager(void) {
|
||||
}
|
||||
|
||||
void TextureManager::Unload(void) {
|
||||
for(int i = 0; i < m_allocated; i++) {
|
||||
SDL_FreeSurface(textures[i].texture);
|
||||
textures[i].name.clear();
|
||||
for(int i = 0; i < _allocated; i++) {
|
||||
SDL_FreeSurface(_textures[i].texture);
|
||||
_textures[i].name.clear();
|
||||
}
|
||||
m_allocated = 0;
|
||||
_allocated = 0;
|
||||
}
|
||||
|
||||
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?
|
||||
for(int i = 0; i < m_allocated; i++) {
|
||||
if(textures[i].name == filename) {
|
||||
return textures[i].texture;
|
||||
for(int i = 0; i < _allocated; i++) {
|
||||
if(_textures[i].name == filename) {
|
||||
return _textures[i].texture;
|
||||
}
|
||||
}
|
||||
// If not, then load it.
|
||||
textures[m_allocated].name = filename;
|
||||
textures[m_allocated].texture = LoadImage(filename.c_str());
|
||||
_textures[_allocated].name = filename;
|
||||
_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) {
|
||||
assert(m_allocated < TEXTURE_ARR_SIZE - 1);
|
||||
assert(_allocated < TEXTURE_ARR_SIZE - 1);
|
||||
|
||||
// Has the texture been loaded already?
|
||||
for(int i = 0; i < m_allocated; i++) {
|
||||
if(textures[i].name == filename) {
|
||||
return textures[i].texture;
|
||||
for(int i = 0; i < _allocated; i++) {
|
||||
if(_textures[i].name == filename) {
|
||||
return _textures[i].texture;
|
||||
}
|
||||
}
|
||||
|
||||
// If not, then load it.
|
||||
|
||||
textures[m_allocated].name = filename;
|
||||
textures[m_allocated].texture = LoadImageAlpha(filename.c_str());
|
||||
_textures[_allocated].name = filename;
|
||||
_textures[_allocated].texture = LoadImageAlpha(filename.c_str());
|
||||
|
||||
m_allocated++;
|
||||
_allocated++;
|
||||
|
||||
return textures[m_allocated -1].texture;
|
||||
return _textures[_allocated -1].texture;
|
||||
}
|
||||
|
@ -32,9 +32,9 @@ private:
|
||||
|
||||
// We should not need more than a hundred..
|
||||
static const int TEXTURE_ARR_SIZE = 100;
|
||||
textureNode textures[TEXTURE_ARR_SIZE];
|
||||
textureNode _textures[TEXTURE_ARR_SIZE];
|
||||
|
||||
int m_allocated;
|
||||
int _allocated;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,47 +1,47 @@
|
||||
#include "Timer.h"
|
||||
|
||||
Timer::Timer(void) {
|
||||
m_startTicks = 0;
|
||||
m_pausedTicks = 0;
|
||||
m_paused = false;
|
||||
m_started = false;
|
||||
_startTicks = 0;
|
||||
_pausedTicks = 0;
|
||||
_paused = false;
|
||||
_started = false;
|
||||
}
|
||||
|
||||
Timer::~Timer(void) {
|
||||
}
|
||||
|
||||
void Timer::Start(void) {
|
||||
m_paused = false;
|
||||
m_started = true;
|
||||
m_startTicks = SDL_GetTicks();
|
||||
_paused = false;
|
||||
_started = true;
|
||||
_startTicks = SDL_GetTicks();
|
||||
}
|
||||
|
||||
void Timer::Stop(void) {
|
||||
m_paused = false;
|
||||
m_started = true;
|
||||
_paused = false;
|
||||
_started = true;
|
||||
}
|
||||
|
||||
void Timer::Pause(void) {
|
||||
assert(m_paused == false);
|
||||
m_paused = true;
|
||||
assert(_paused == false);
|
||||
_paused = true;
|
||||
|
||||
m_pausedTicks = SDL_GetTicks() - m_startTicks;
|
||||
_pausedTicks = SDL_GetTicks() - _startTicks;
|
||||
}
|
||||
|
||||
void Timer::Unpause(void) {
|
||||
assert(m_paused == true);
|
||||
m_paused = false;
|
||||
assert(_paused == true);
|
||||
_paused = false;
|
||||
|
||||
m_startTicks = SDL_GetTicks() - m_pausedTicks;
|
||||
_startTicks = SDL_GetTicks() - _pausedTicks;
|
||||
|
||||
m_pausedTicks = 0;
|
||||
_pausedTicks = 0;
|
||||
}
|
||||
|
||||
int Timer::GetTicks(void) {
|
||||
if(m_paused == true)
|
||||
return m_pausedTicks;
|
||||
else if(m_started == true)
|
||||
return SDL_GetTicks() - m_startTicks;
|
||||
if(_paused == true)
|
||||
return _pausedTicks;
|
||||
else if(_started == true)
|
||||
return SDL_GetTicks() - _startTicks;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
@ -16,19 +16,19 @@ public:
|
||||
void Start(void);
|
||||
void Stop(void);
|
||||
|
||||
bool IsPaused(void) { return m_paused; }
|
||||
bool IsStarted(void) { return m_started; }
|
||||
bool IsPaused(void) { return _paused; }
|
||||
bool IsStarted(void) { return _started; }
|
||||
|
||||
int GetTicks(void);
|
||||
|
||||
string GetTicksStr(void);
|
||||
|
||||
private:
|
||||
bool m_paused;
|
||||
bool m_started;
|
||||
bool _paused;
|
||||
bool _started;
|
||||
|
||||
int m_startTicks;
|
||||
int m_pausedTicks;
|
||||
int _startTicks;
|
||||
int _pausedTicks;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user