diff --git a/Data/Media/Maps/map b/Data/Media/Maps/map
new file mode 100644
index 0000000..9e8b282
--- /dev/null
+++ b/Data/Media/Maps/map
@@ -0,0 +1,13611 @@
+
diff --git a/Unuk-QT/Unuk-QT b/Unuk-QT/Unuk-QT
deleted file mode 100755
index 26cbd82..0000000
Binary files a/Unuk-QT/Unuk-QT and /dev/null differ
diff --git a/src/Unuk/Game.cpp b/src/Unuk/Game.cpp
index 80184ad..005663f 100644
--- a/src/Unuk/Game.cpp
+++ b/src/Unuk/Game.cpp
@@ -4,7 +4,7 @@ Game::Game(void) {
m_player = new Player(&m_map);
m_npc = new NPC(&m_map);
- m_runGameReturnValue = GAME_RETURN_TO_MMENU;
+ m_runGameReturnValue = gameMainMenu;
}
Game::~Game(void) {
@@ -12,8 +12,8 @@ Game::~Game(void) {
delete m_npc;
}
-int Game::Run(const string savegameIDArg) {
- m_player->SetXY(100, 50);
+gameNavVal_t Game::Run(const string savegameIDArg) {
+ m_player->SetXY(50, 50);
m_player->LoadSprites("../Data/Media/Images/Characters/template.png", 40, 45);
m_npc->SetXY(300, 300);
@@ -35,14 +35,14 @@ int Game::Run(const string savegameIDArg) {
Timer updateTimer;
m_gameRenderTime.SetXY(10, 10);
- m_gameRenderTime.SetTextBlended("Render - XX", "vsmall", COLOUR_BLACK);
+ m_gameRenderTime.SetTextBlended("Render - XX", vsmall, COLOUR_BLACK);
m_gameUpdateTime.SetXY(10, 30);
- m_gameUpdateTime.SetTextBlended("Update - XX", "vsmall", COLOUR_BLACK);
+ m_gameUpdateTime.SetTextBlended("Update - XX", vsmall, COLOUR_BLACK);
stringstream playerXYString;
m_playerXY.SetXY(10, 50);
- m_playerXY.SetTextBlended("Player coords - XX XX", "vsmall", COLOUR_BLACK);
+ m_playerXY.SetTextBlended("Player coords - XX XX", vsmall, COLOUR_BLACK);
m_gameRunning = true;
while(m_gameRunning) {
@@ -73,12 +73,12 @@ int 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);
+ m_gameUpdateTime.SetTextBlended("Update - " + updateTimer.GetTicksStr(), vsmall, COLOUR_BLACK);
+ m_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);
+ m_playerXY.SetTextBlended(playerXYString.str(), vsmall, COLOUR_BLACK);
}
}
// Restrict the fps.
@@ -107,24 +107,24 @@ void Game::HandleInput(void) {
}
else if(event.type == SDL_QUIT) {
m_gameRunning = false;
- m_runGameReturnValue = GAME_QUIT_GAME;
+ m_runGameReturnValue = gameQuitGame;
break;
}
}
} else {
switch(m_ingameMenu.HandleInput()) {
- case INGAME_MENU_NOTHING:
+ case ingameMenuNothing:
break;
- case INGAME_MENU_RESUME:
+ case ingameMenuResume:
m_ingameMenu.SetStatus(false);
break;
- case INGAME_MENU_SAVE_GAME:
+ case ingameMenuSaveGame:
break;
- case INGAME_MENU_LOAD_GAME:
+ case ingameMenuLoadGame:
break;
- case INGAME_MENU_OPTIONS:
+ case ingameMenuOptions:
break;
- case INGAME_MENU_EXIT_TO_MMENU:
+ case ingameMenuMainMenu:
m_gameRunning = false;
break;
}
@@ -132,7 +132,7 @@ void Game::HandleInput(void) {
if(event.type == SDL_QUIT) {
m_gameRunning = false;
m_ingameMenu.SetStatus(false);
- m_runGameReturnValue = GAME_QUIT_GAME;
+ m_runGameReturnValue = gameQuitGame;
}
}
}
@@ -203,7 +203,6 @@ void Game::LoadSavegame(const string savegameIDArg) {
//
}
diff --git a/src/Unuk/Game.h b/src/Unuk/Game.h
index 6927cc1..3d84c28 100644
--- a/src/Unuk/Game.h
+++ b/src/Unuk/Game.h
@@ -19,15 +19,14 @@
#include "../libUnuk/Text.h"
using namespace std;
-const int GAME_RETURN_TO_MMENU = 0;
-const int GAME_QUIT_GAME = 1;
+enum gameNavVal_t { gameMainMenu, gameQuitGame };
class Game {
public:
Game(void);
~Game(void);
- int Run(const string savegameIDArg);
+ gameNavVal_t Run(const string savegameIDArg);
private:
void HandleInput(void);
@@ -37,9 +36,13 @@ private:
void LoadSavegame(const string savegameIDArg);
void SaveSavegame(void);
+ static const int MAX_FPS = 6000;
+ static const int GAME_UPDATES_PER_SECOND = 60;
+ static const int SKIP_TICKS = 1000 / GAME_UPDATES_PER_SECOND;
+
bool m_gameRunning;
- int m_runGameReturnValue;
+ gameNavVal_t m_runGameReturnValue;
string m_saveGameID;
string m_mapID;
@@ -48,10 +51,6 @@ private:
Text m_gameRenderTime;
Text m_playerXY;
- static const int MAX_FPS = 6000;
- static const int GAME_UPDATES_PER_SECOND = 60;
- static const int SKIP_TICKS = 1000 / GAME_UPDATES_PER_SECOND;
-
IngameMenu m_ingameMenu;
Map m_map;
diff --git a/src/Unuk/Player.cpp b/src/Unuk/Player.cpp
index 74d6280..bc5d34f 100644
--- a/src/Unuk/Player.cpp
+++ b/src/Unuk/Player.cpp
@@ -57,7 +57,7 @@ void Player::HandleInput(void) {
void Player::Update(void) {
Move();
- SetCamera();
+ //SetCamera();
}
void Player::SetName(string nameArg) {
diff --git a/src/Unuk/main.cpp b/src/Unuk/main.cpp
index 3a42e51..6be7473 100644
--- a/src/Unuk/main.cpp
+++ b/src/Unuk/main.cpp
@@ -50,33 +50,34 @@ int main() {
Timer fpsCalc;
fpsCalc.Start();
- int gameReturnVal;
bool menuRunning = true;
while(menuRunning) {
menu->Render();
SDL_Flip(screen);
switch(menu->HandleInput()) {
- case MAIN_MENU_NOTHING:
+ case mainMenuNothing:
break;
- case MAIN_MENU_NEW_GAME:
+ case mainMenuNewGame:
delete menu;
game = new Game;
- gameReturnVal = game->Run("save.xml");
-
- if(gameReturnVal == GAME_RETURN_TO_MMENU)
+ switch(game->Run("save")) {
+ case gameMainMenu:
menu = new MainMenu;
- else if(gameReturnVal == GAME_QUIT_GAME)
+ break;
+ case gameQuitGame:
menuRunning = false;
+ break;
+ }
delete game;
break;
- case MAIN_MENU_LOAD_GAME:
+ case mainMenuLoadGame:
break;
- case MAIN_MENU_OPTIONS:
+ case mainMenuOptions:
break;
- case MAIN_MENU_EXIT:
+ case mainMenuExitGame:
menuRunning = false;
delete menu;
break;
diff --git a/src/libUnuk/Button.cpp b/src/libUnuk/Button.cpp
index a4a8970..8fed72f 100644
--- a/src/libUnuk/Button.cpp
+++ b/src/libUnuk/Button.cpp
@@ -43,16 +43,16 @@ void Button::SetTextRGB(Uint8 r, Uint8 g, Uint8 b) {
m_textColour.g = g;
m_textColour.b = b;
- m_text.SetTextBlended(m_text.GetText(), "small", m_textColour);
+ m_text.SetTextBlended(m_text.GetText(), small, m_textColour);
}
void Button::SetTextRGB(SDL_Color colour) {
m_textColour = colour;
- m_text.SetTextBlended(m_text.GetText(), "small", colour);
+ m_text.SetTextBlended(m_text.GetText(), small, colour);
}
void Button::SetText(string textArg) {
- m_text.SetTextBlended(textArg, "small", m_textColour);
+ m_text.SetTextBlended(textArg, small, m_textColour);
w = m_text.GetWidth();
h = m_text.GetHeight();
diff --git a/src/libUnuk/Character.cpp b/src/libUnuk/Character.cpp
index dd5226e..3de7c58 100644
--- a/src/libUnuk/Character.cpp
+++ b/src/libUnuk/Character.cpp
@@ -54,7 +54,7 @@ void Character::LoadSprites(string filename, int wArg, int hArg) {
void Character::AddSpeachBubble(string text) {
m_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)
m_speachBubbleTimer.Start();
@@ -125,7 +125,7 @@ void Character::Update(void) {
}
} else {
if(m_speachBubble.front() != m_speachBubbleText.GetText()) {
- m_speachBubbleText.SetTextBlended(m_speachBubble.front(), "small", 0, 0, 0);
+ //m_speachBubbleText.SetTextBlended(m_speachBubble.front(), "small", 0, 0, 0);
}
}
}
@@ -136,27 +136,19 @@ void Character::Move(void) {
tileX = ((x + (w / 2)) / TILE_WIDTH);
tileY = ((y + (h / 2)) / TILE_HEIGHT);
- if((x < 0) || (x + w) > levelWidth)
- x -= xVel;
- if(CheckTileCollisions())
- x -= xVel;
- if(CheckEntityCollisions())
- x -= xVel;
- if(CheckCharacterCollisions())
- x -= xVel;
+ if((x < 0) || (x + w) > levelWidth) x -= xVel;
+ if(CheckTileCollisions()) x -= xVel;
+ if(CheckEntityCollisions()) x -= xVel;
+ if(CheckCharacterCollisions()) x -= xVel;
y += yVel;
tileX = ((x + (w / 2)) / TILE_WIDTH);
tileY = ((y + (h / 2)) / TILE_HEIGHT);
- if((y < 0) || (y + h) > levelHeight)
- y -= yVel;
- if(CheckTileCollisions())
- y -= yVel;
- if(CheckEntityCollisions())
- y -= yVel;
- if(CheckCharacterCollisions())
- y -= yVel;
+ if((y < 0) || (y + h) > levelHeight) y -= yVel;
+ if(CheckTileCollisions()) y -= yVel;
+ if(CheckEntityCollisions()) y -= yVel;
+ if(CheckCharacterCollisions()) y -= yVel;
}
bool Character::CheckTileCollisions(void) {
diff --git a/src/libUnuk/IngameMenu.cpp b/src/libUnuk/IngameMenu.cpp
index 144f3a4..9a6b0ac 100644
--- a/src/libUnuk/IngameMenu.cpp
+++ b/src/libUnuk/IngameMenu.cpp
@@ -1,7 +1,7 @@
#include "IngameMenu.h"
IngameMenu::IngameMenu(void) {
- m_isActive = false;
+ m_active = false;
btnResume.SetOutRGB(200, 200, 200);
btnResume.SetOverRGB(255, 255, 255);
@@ -38,7 +38,7 @@ IngameMenu::~IngameMenu(void) {
}
-int IngameMenu::HandleInput(void) {
+ingameMenuNavVal_t IngameMenu::HandleInput(void) {
while(SDL_PollEvent(&event)) {
btnResume.CheckMouseOver();
btnSaveGame.CheckMouseOver();
@@ -48,24 +48,24 @@ int IngameMenu::HandleInput(void) {
if(event.key.type == SDL_KEYDOWN) {
if(event.key.keysym.sym == SDLK_ESCAPE)
- return INGAME_MENU_RESUME;
+ return ingameMenuResume;
}
else if(event.type == SDL_MOUSEBUTTONUP) {
if(event.button.button == SDL_BUTTON_LEFT) {
if(btnResume.CheckMouseOver())
- return INGAME_MENU_RESUME;
+ return ingameMenuResume;
else if(btnSaveGame.CheckMouseOver())
- return INGAME_MENU_SAVE_GAME;
+ return ingameMenuSaveGame;
else if(btnLoadGame.CheckMouseOver())
- return INGAME_MENU_LOAD_GAME;
+ return ingameMenuLoadGame;
else if(btnOptions.CheckMouseOver())
- return INGAME_MENU_OPTIONS;
+ return ingameMenuOptions;
else if(btnExitToMenu.CheckMouseOver())
- return INGAME_MENU_EXIT_TO_MMENU;
+ return ingameMenuMainMenu;
}
}
}
- return INGAME_MENU_NOTHING;
+ return ingameMenuNothing;
}
void IngameMenu::Render(void) {
diff --git a/src/libUnuk/IngameMenu.h b/src/libUnuk/IngameMenu.h
index f0fec28..01a7a7e 100644
--- a/src/libUnuk/IngameMenu.h
+++ b/src/libUnuk/IngameMenu.h
@@ -1,27 +1,33 @@
#ifndef _INGAMEMENU_H_
#define _INGAMEMENU_H_
-#include "Menu.h"
-const int INGAME_MENU_NOTHING = 0;
-const int INGAME_MENU_RESUME = 1;
-const int INGAME_MENU_SAVE_GAME = 2;
-const int INGAME_MENU_LOAD_GAME = 3;
-const int INGAME_MENU_OPTIONS = 4;
-const int INGAME_MENU_EXIT_TO_MMENU = 5;
+#include "../Unuk/Globals.h"
+#include "../Unuk/Constants.h"
+#include "Button.h"
+#include "ButtonToggle.h"
-class IngameMenu : public Menu {
+enum ingameMenuNavVal_t {
+ ingameMenuNothing,
+ ingameMenuResume,
+ ingameMenuSaveGame,
+ ingameMenuLoadGame,
+ ingameMenuOptions,
+ ingameMenuMainMenu
+};
+
+class IngameMenu {
public:
IngameMenu(void);
~IngameMenu(void);
- int HandleInput(void);
+ ingameMenuNavVal_t HandleInput(void);
void Render(void);
- void SetStatus(bool arg) { m_isActive = arg; }
- bool GetStatus(void) { return m_isActive; }
+ void SetStatus(bool arg) { m_active = arg; }
+ bool GetStatus(void) { return m_active; }
private:
- bool m_isActive;
+ bool m_active;
Button btnResume;
Button btnSaveGame;
diff --git a/src/libUnuk/MainMenu.cpp b/src/libUnuk/MainMenu.cpp
index fbbbdb6..09cfefa 100644
--- a/src/libUnuk/MainMenu.cpp
+++ b/src/libUnuk/MainMenu.cpp
@@ -10,7 +10,7 @@ MainMenu::MainMenu(void) {
btnNewGameActive = false;
lblNewGame.SetXY(275, 160);
- lblNewGame.SetTextBlended("This will delete your current game, are you sure?", "vsmall", 0, 0, 0);
+ lblNewGame.SetTextBlended("This will delete your current game, are you sure?", vsmall, 0, 0, 0);
rectNewGame.SetRGB(200, 200, 200);
rectNewGame.SetXY(250, 150);
@@ -47,9 +47,9 @@ MainMenu::MainMenu(void) {
btnExit.SetXY(100, 300);
lblMenu.SetXY(100, 75);
- lblMenu.SetTextBlended("Unuk", "vlarge", 0, 0, 0);
+ lblMenu.SetTextBlended("Unuk", vlarge, 0, 0, 0);
- m_background.Load("MainMenu");
+ //m_background.Load("MainMenu");
camera.x = 0;
camera.y = 0;
@@ -59,7 +59,7 @@ MainMenu::~MainMenu(void) {
}
-int MainMenu::HandleInput(void) {
+mainMenuNavVal_t MainMenu::HandleInput(void) {
while(SDL_PollEvent(&event)) {
btnNewGame.CheckMouseOver();
if(btnNewGameActive) {
@@ -76,29 +76,29 @@ int MainMenu::HandleInput(void) {
if(btnNewGame.CheckMouseOver())
btnNewGameActive = !btnNewGameActive;
else if(btnLoadGame.CheckMouseOver())
- return MAIN_MENU_LOAD_GAME;
+ return mainMenuLoadGame;
else if(btnOptions.CheckMouseOver())
- return MAIN_MENU_OPTIONS;
+ return mainMenuOptions;
else if(btnExit.CheckMouseOver())
- return MAIN_MENU_EXIT;
+ return mainMenuOptions;
if(btnNewGameActive) {
if(btnNewGameYes.CheckMouseOver())
- return MAIN_MENU_NEW_GAME;
+ return mainMenuNewGame;
else if(btnNewGameNo.CheckMouseOver())
btnNewGameActive = false;
}
}
}
else if(event.type == SDL_QUIT) {
- return MAIN_MENU_EXIT;
+ return mainMenuExitGame;
}
}
- return MAIN_MENU_NOTHING;
+ return mainMenuNothing;
}
void MainMenu::Render(void) {
- m_background.Render();
+ //m_background.Render();
lblMenu.Render();
diff --git a/src/libUnuk/MainMenu.h b/src/libUnuk/MainMenu.h
index db6ea94..2ffc19b 100644
--- a/src/libUnuk/MainMenu.h
+++ b/src/libUnuk/MainMenu.h
@@ -1,23 +1,25 @@
#ifndef _MAINMENU_H_
#define _MAINMENU_H_
#include "../Unuk/Constants.h"
-#include "Menu.h"
+#include "Button.h"
#include "Map.h"
#include "Rect.h"
#include "Text.h"
-const int MAIN_MENU_NOTHING = 0;
-const int MAIN_MENU_NEW_GAME = 1;
-const int MAIN_MENU_LOAD_GAME = 2;
-const int MAIN_MENU_OPTIONS = 3;
-const int MAIN_MENU_EXIT = 4;
+enum mainMenuNavVal_t {
+ mainMenuNothing,
+ mainMenuNewGame,
+ mainMenuLoadGame,
+ mainMenuOptions,
+ mainMenuExitGame
+};
-class MainMenu : public Menu {
+class MainMenu {
public:
MainMenu(void);
~MainMenu(void);
- int HandleInput(void);
+ mainMenuNavVal_t HandleInput(void);
void Render(void);
private:
diff --git a/src/libUnuk/Map.cpp b/src/libUnuk/Map.cpp
index 63565e3..6a86896 100644
--- a/src/libUnuk/Map.cpp
+++ b/src/libUnuk/Map.cpp
@@ -1,107 +1,164 @@
#include "Map.h"
Map::Map(void) {
- //m_characters = CharacterManager;
+
}
Map::~Map(void) {
- //delete m_characters;
+
}
void Map::Load(const string filename) {
+ Unload();
m_currentMap = filename;
string fullMapPath = "../Data/Media/Maps/" + filename;
- ifstream mapFile(fullMapPath.c_str());
- assert(mapFile.is_open());
+ TiXmlDocument mapFile(fullMapPath);
- Unload();
+ assert(mapFile.LoadFile() == true);
- // Read in from the map file, one line at a time.
- string line;
- while(getline(mapFile, line)) {
- m_mapRows = 1;
+ // Getting dirty with some XML. This seems like a nicer
+ // approach to loading maps, rather than parsing tet files.
+ TiXmlElement* rootElem = NULL;
+ TiXmlElement* lineElem = NULL;
+ TiXmlElement* tileElem = NULL;
+ TiXmlElement* dataElem = NULL;
- istringstream iss(line);
+ // We will set x and y positions to zero for now, as we
+ // are going to set them withing the XML file.
+ x = 0;
+ y = 0;
- string tileName;
- while(iss >> tileName) {
- string fullTilePath = "../Data/Media/Images/Tiles/" + tileName + ".png";
- m_tile[m_mapRows][m_mapColumns].SetTileTexture(m_tileTextures.Add(fullTilePath));
+ //
+ levelWidth = (x - 1) * TILE_WIDTH;
+ levelHeight = (y - 1) * TILE_HEIGHT;
//character->Load(filename);
}
void Map::Render(void) {
+ for(int j = 1; j < x; j++)
+ for(int i = 1; i < y; i++) {
+ ApplySurface(m_tile[j][i].GetTileX(), m_tile[j][i].GetTileY(), m_tile[j][i].GetTileTexture(), screen);
+
+ if(m_tile[j][i].GetEntityTexture() != NULL)
+ ApplySurface(m_tile[j][i].GetEntityX(), m_tile[j][i].GetEntityY(), m_tile[j][i].GetEntityTexture(), screen);
+ }
+ return;
+
int xOrig = (camera.x / TILE_WIDTH) + 1;
int yOrig = (camera.y / TILE_HEIGHT) + 1;
int xEnd = xOrig + (SCREEN_WIDTH / TILE_WIDTH);
int yEnd = yOrig + (SCREEN_HEIGHT / TILE_HEIGHT);
- if(xEnd < m_mapRows)
+ if(xEnd < x)
xEnd++;
- if(yEnd < m_mapColumns)
+ if(yEnd < y)
yEnd++;
- for(int j = xOrig; j < xEnd; j++)
- for(int i = yOrig; i < yEnd; i++) {
+ for(int j = 1; j < xEnd; j++)
+ for(int i = 1; i < yEnd; i++) {
ApplySurface(m_tile[j][i].GetTileX(), m_tile[j][i].GetTileY(),
m_tile[j][i].GetTileTexture(), screen);
if(m_tile[j][i].GetEntityTexture() != NULL) {
+ Debug::logger->message("Entity");
ApplySurface(m_tile[j][i].GetEntityX(), m_tile[j][i].GetEntityY(),
m_tile[j][i].GetEntityTexture(), screen);
}
@@ -112,18 +169,13 @@ void Map::Unload(void) {
m_tileTextures.Unload();
m_entityTextures.Unload();
- // Start at 1,1 so we do not have to be concerned about messy
- // bounds checking when accessing the tile array within the game loop.
- m_mapRows = 1;
- m_mapColumns = 1;
-
- // As we are not doing bounds checking inside the game loop
- // we don't want there to be a solid entity with w,h of ($RAND)
- // creating an invisible wall anywhere.
for(int i = 0; i < TILE_ARRAY_SIZE; i++) {
for(int j = 0; j < TILE_ARRAY_SIZE; j++) {
m_tile[i][j].SetTileTexture(NULL);
+ m_tile[i][j].SetTileSolidity(false);
m_tile[i][j].SetEntityTexture(NULL);
+ m_tile[i][j].SetEntitySolidity(false);
+ m_tile[i][j].SetMapTransitionName("null");
}
}
}
diff --git a/src/libUnuk/Map.h b/src/libUnuk/Map.h
index 3c49796..b2ecc17 100644
--- a/src/libUnuk/Map.h
+++ b/src/libUnuk/Map.h
@@ -6,6 +6,7 @@
#include
#include
#include
+#include
#include "../Unuk/Globals.h"
#include "../Unuk/Constants.h"
@@ -13,6 +14,7 @@
#include "ApplySurface.h"
#include "TextureManager.h"
#include "MapTile.h"
+#include "Debug.h"
using namespace std;
//class CharacterManager;
@@ -47,12 +49,11 @@ private:
void Unload(void);
string m_currentMap;
- int m_mapColumns;
- int m_mapRows;
+ int x;
+ int y;
TextureManager m_tileTextures;
TextureManager m_entityTextures;
- //CharacterManager* m_characters;
static const int TILE_ARRAY_SIZE = 150;
MapTile m_tile[TILE_ARRAY_SIZE][TILE_ARRAY_SIZE];
diff --git a/src/libUnuk/MapTile.h b/src/libUnuk/MapTile.h
index 388a849..08ca8cc 100644
--- a/src/libUnuk/MapTile.h
+++ b/src/libUnuk/MapTile.h
@@ -62,10 +62,10 @@ private:
int m_entityH;
// -1 is a 'special' tile, the next tile that the player walks
- // on is the new player z-level.
+ // on is the players new zlevel.
int m_zLevel;
- //If not 'n', switch map when the player walks on this tile.
+ // If not 'null', switch map when the player walks on this tile.
string m_mapTransitionName;
int m_mapTransitionX;
int m_mapTransitionY;
diff --git a/src/libUnuk/Text.cpp b/src/libUnuk/Text.cpp
index e64d9d4..7bbcb27 100644
--- a/src/libUnuk/Text.cpp
+++ b/src/libUnuk/Text.cpp
@@ -50,78 +50,68 @@ void Text::SetXY(int xArg, int yArg) {
y = yArg;
}
-int Text::SetTextBlended(string textArg, string size, SDL_Color colour) {
+int Text::SetTextBlended(string textArg, textSizes_t size, SDL_Color colour) {
m_textContents = textArg;
if(m_text != NULL) {
SDL_FreeSurface(m_text);
}
- if(size == "vsmall") {
+ if(size == vsmall) {
m_text = TTF_RenderText_Blended(vSmallFont, textArg.c_str(), colour);
return 1;
}
- else if(size == "small") {
+ else if(size == small) {
m_text = TTF_RenderText_Blended(smallFont, textArg.c_str(), colour);
return 1;
}
- else if(size == "medium") {
+ else if(size == medium) {
m_text = TTF_RenderText_Blended(mediumFont, textArg.c_str(), colour);
return 1;
}
- else if(size == "large") {
+ else if(size == large) {
m_text = TTF_RenderText_Blended(largeFont, textArg.c_str(), colour);
return 1;
- }
- else if(size == "vlarge") {
+ } else {
m_text = TTF_RenderText_Blended(vLargeFont, textArg.c_str(), colour);
return 1;
- } else {
- Debug::logger->message("Text::SetTextBlended(): Invalid size argument %s. Defaulted to small.", size.c_str());
- m_text = TTF_RenderText_Blended(smallFont, textArg.c_str(), colour);
- return 0;
}
}
-int Text::SetTextBlended(string textArg, string size, Uint8 r, Uint8 g, Uint8 b) {
+int Text::SetTextBlended(string textArg, textSizes_t size, Uint8 r, Uint8 g, Uint8 b) {
SDL_Color f = { r, g, b };
return SetTextBlended(textArg, size, f);
}
-int Text::SetTextShaded(string textArg, string size, SDL_Color colour, SDL_Color bgColour) {
+int Text::SetTextShaded(string textArg, textSizes_t size, SDL_Color colour, SDL_Color bgColour) {
m_textContents = textArg;
if(m_text != NULL) {
SDL_FreeSurface(m_text);
}
- if(size == "vsmall") {
+ if(size == vsmall) {
m_text = TTF_RenderText_Shaded(vSmallFont, textArg.c_str(), colour, bgColour);
return 1;
}
- else if(size == "small") {
+ else if(size == small) {
m_text = TTF_RenderText_Shaded(smallFont, textArg.c_str(), colour, bgColour);
return 1;
}
- else if(size == "medium") {
+ else if(size == medium) {
m_text = TTF_RenderText_Shaded(mediumFont, textArg.c_str(), colour, bgColour);
return 1;
}
- else if(size == "large") {
+ else if(size == large) {
m_text = TTF_RenderText_Shaded(largeFont, textArg.c_str(), colour, bgColour);
return 1;
- }
- else if(size == "vlarge") {
+ } else {
m_text = TTF_RenderText_Shaded(vLargeFont, textArg.c_str(), colour, bgColour);
return 1;
- } else {
- Debug::logger->message("Text::SetTextBlended(): Invalid size argument %s. Defaulted to small.", size.c_str());
- m_text = TTF_RenderText_Shaded(smallFont, textArg.c_str(), colour, bgColour);
- return 0;
}
}
-int Text::SetTextShaded(string textArg, string size, Uint8 rF, Uint8 gF, Uint8 bF, Uint8 rB, Uint8 gB, Uint8 bB) {
+int Text::SetTextShaded(string textArg, textSizes_t size, Uint8 rF, Uint8 gF, Uint8 bF, Uint8 rB, Uint8 gB, Uint8 bB) {
SDL_Color f = { rF, gF, bF };
SDL_Color b = { rB, gB, bB };
return SetTextShaded(textArg, size, f, b);
diff --git a/src/libUnuk/Text.h b/src/libUnuk/Text.h
index 529e275..1681ead 100644
--- a/src/libUnuk/Text.h
+++ b/src/libUnuk/Text.h
@@ -10,6 +10,8 @@
#include "Debug.h"
using namespace std;
+enum textSizes_t { vsmall, small, medium, large, vlarge };
+
class Text {
public:
Text(void);
@@ -28,10 +30,10 @@ public:
void SetXY(int xArg, int yArg);
- int SetTextBlended(string textArg, string size, SDL_Color);
- int SetTextBlended(string textArg, string size, Uint8 r, Uint8 g, Uint8 b);
- int SetTextShaded(string textArg, string size, SDL_Color, SDL_Color);
- int SetTextShaded(string textArg, string size, Uint8 rF, Uint8 gF, Uint8 bF, Uint8 rB, Uint8 gB, Uint8 bB);
+ int SetTextBlended(string textArg, textSizes_t size, SDL_Color);
+ int SetTextBlended(string textArg, textSizes_t size, Uint8 r, Uint8 g, Uint8 b);
+ int SetTextShaded(string textArg, textSizes_t size, SDL_Color, SDL_Color);
+ int SetTextShaded(string textArg, textSizes_t size, Uint8 rF, Uint8 gF, Uint8 bF, Uint8 rB, Uint8 gB, Uint8 bB);
void Render(void);
void Render(int xArg, int yArg);
diff --git a/src/libUnuk/TextureManager.cpp b/src/libUnuk/TextureManager.cpp
index 0298859..8d9f862 100644
--- a/src/libUnuk/TextureManager.cpp
+++ b/src/libUnuk/TextureManager.cpp
@@ -17,7 +17,7 @@ void TextureManager::Unload(void) {
}
SDL_Surface* TextureManager::Add(string filename) {
- assert(m_allocated < TEXTURE_NODE_SIZE);
+ assert(m_allocated < TEXTURE_ARR_SIZE - 1);
// Has the texture been loaded already?
for(int i = 0; i < m_allocated; i++) {
@@ -35,7 +35,7 @@ SDL_Surface* TextureManager::Add(string filename) {
}
SDL_Surface* TextureManager::AddAlpha(string filename) {
- assert(m_allocated < TEXTURE_NODE_SIZE);
+ assert(m_allocated < TEXTURE_ARR_SIZE - 1);
// Has the texture been loaded already?
for(int i = 0; i < m_allocated; i++) {
diff --git a/src/libUnuk/TextureManager.h b/src/libUnuk/TextureManager.h
index 8399693..5c29c0d 100644
--- a/src/libUnuk/TextureManager.h
+++ b/src/libUnuk/TextureManager.h
@@ -10,8 +10,8 @@ using namespace std;
* The Texture Manager will keep a small "Database"
* of the name of the texture that is loaded and the
* actual texture so we can query it with the filename
- * and it will return an index that we can use to retrieve
- * the texture.
+ * and it will return the teture if it is already in memory
+ * or load the tture if it is not.
*/
class TextureManager {
public:
@@ -31,8 +31,8 @@ private:
};
// We should not need more than a hundred..
- static const int TEXTURE_NODE_SIZE = 100;
- textureNode textures[TEXTURE_NODE_SIZE];
+ static const int TEXTURE_ARR_SIZE = 100;
+ textureNode textures[TEXTURE_ARR_SIZE];
int m_allocated;
};