diff --git a/Data/Media/Maps/TestLevel b/Data/Media/Maps/Backup/TestLevel
similarity index 100%
rename from Data/Media/Maps/TestLevel
rename to Data/Media/Maps/Backup/TestLevel
diff --git a/Data/Media/Maps/format b/Data/Media/Maps/Backup/format
similarity index 100%
rename from Data/Media/Maps/format
rename to Data/Media/Maps/Backup/format
diff --git a/Save/1 b/Save/1
deleted file mode 100644
index c3f407c..0000000
--- a/Save/1
+++ /dev/null
@@ -1 +0,0 @@
-55
diff --git a/Save/2 b/Save/2
deleted file mode 100644
index e69de29..0000000
diff --git a/Save/save b/Save/save
new file mode 100644
index 0000000..23f1fec
--- /dev/null
+++ b/Save/save
@@ -0,0 +1,6 @@
+
+ Allanis
+ 150
+ 150
+
+
diff --git a/Unuk-QT/Makefile b/Unuk-QT/Makefile
index 6bf4200..fb71f52 100644
--- a/Unuk-QT/Makefile
+++ b/Unuk-QT/Makefile
@@ -1,6 +1,6 @@
#############################################################################
# Makefile for building: Unuk-QT
-# Generated by qmake (2.01a) (Qt 4.7.3) on: Tue Dec 13 22:04:29 2011
+# Generated by qmake (2.01a) (Qt 4.7.3) on: Wed Dec 14 00:58:57 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
@@ -16,7 +16,7 @@ CXXFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES)
INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I.
LINK = g++
LFLAGS =
-LIBS = $(SUBLIBS) -L/usr/lib -lGL -lSDL -lSDL_ttf -lSDL_image -lGLU -lQtGui -lQtCore -lpthread
+LIBS = $(SUBLIBS) -L/usr/lib -lGL -lSDL -lSDL_ttf -lSDL_image -lSDL_gfx -ltinyxml -lGLU -lQtGui -lQtCore -lpthread
AR = ar cqs
RANLIB =
QMAKE = /usr/bin/qmake-qt4
@@ -396,7 +396,9 @@ Character.o: ../src/libUnuk/Character.cpp ../src/libUnuk/Character.h \
../src/libUnuk/TextureManager.h \
../src/libUnuk/MapTile.h \
../src/libUnuk/Entity.h \
- ../src/libUnuk/Timer.h
+ ../src/libUnuk/Timer.h \
+ ../src/libUnuk/Text.h \
+ ../src/libUnuk/Font.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o Character.o ../src/libUnuk/Character.cpp
NPC.o: ../src/libUnuk/NPC.cpp ../src/libUnuk/NPC.h \
@@ -411,7 +413,9 @@ NPC.o: ../src/libUnuk/NPC.cpp ../src/libUnuk/NPC.h \
../src/libUnuk/TextureManager.h \
../src/libUnuk/MapTile.h \
../src/libUnuk/Entity.h \
- ../src/libUnuk/Timer.h
+ ../src/libUnuk/Timer.h \
+ ../src/libUnuk/Text.h \
+ ../src/libUnuk/Font.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o NPC.o ../src/libUnuk/NPC.cpp
Player.o: ../src/Unuk/Player.cpp ../src/Unuk/Player.h \
@@ -426,7 +430,9 @@ Player.o: ../src/Unuk/Player.cpp ../src/Unuk/Player.h \
../src/libUnuk/TextureManager.h \
../src/libUnuk/MapTile.h \
../src/libUnuk/Entity.h \
- ../src/libUnuk/Timer.h
+ ../src/libUnuk/Timer.h \
+ ../src/libUnuk/Text.h \
+ ../src/libUnuk/Font.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o Player.o ../src/Unuk/Player.cpp
Game.o: ../src/Unuk/Game.cpp ../src/Unuk/Game.h \
@@ -443,12 +449,12 @@ Game.o: ../src/Unuk/Game.cpp ../src/Unuk/Game.h \
../src/libUnuk/MapTile.h \
../src/libUnuk/Entity.h \
../src/libUnuk/Timer.h \
+ ../src/libUnuk/Text.h \
+ ../src/libUnuk/Font.h \
../src/libUnuk/IngameMenu.h \
../src/libUnuk/Menu.h \
../src/libUnuk/Button.h \
../src/libUnuk/Input.h \
- ../src/libUnuk/Text.h \
- ../src/libUnuk/Font.h \
../src/libUnuk/Rect.h \
../src/libUnuk/ButtonToggle.h \
../src/libUnuk/NPC.h
diff --git a/Unuk-QT/Unuk-QT b/Unuk-QT/Unuk-QT
new file mode 100755
index 0000000..26cbd82
Binary files /dev/null and b/Unuk-QT/Unuk-QT differ
diff --git a/Unuk-QT/Unuk-QT.pro b/Unuk-QT/Unuk-QT.pro
index e1cd2ff..5dbd7ae 100644
--- a/Unuk-QT/Unuk-QT.pro
+++ b/Unuk-QT/Unuk-QT.pro
@@ -2,6 +2,8 @@ LIBS += -lGL \
-lSDL \
-lSDL_ttf \
-lSDL_image \
+ -lSDL_gfx \
+ -ltinyxml \
-lGLU
RESOURCES +=
OTHER_FILES += ../src/libUnuk/Debug.o
diff --git a/src/Unuk/Game.cpp b/src/Unuk/Game.cpp
index b75cf2b..80184ad 100644
--- a/src/Unuk/Game.cpp
+++ b/src/Unuk/Game.cpp
@@ -162,19 +162,54 @@ void Game::Render(void) {
m_ingameMenu.Render();
}
SDL_Flip(screen);
- SDL_Flip(screen);
+ //SDL_Flip(screen);
}
void Game::LoadSavegame(const string savegameIDArg) {
m_saveGameID = savegameIDArg;
-
string saveFilename = "../Save/" + m_saveGameID;
- ifstream saveFile(saveFilename.c_str());
- assert(saveFile.is_open());
-
- // Read stuff.
- m_map.Load("TestLevel");
+ // Converting to XML ftw!
+ TiXmlDocument mapFile(saveFilename.c_str());
+ assert(mapFile.LoadFile() == true);
+
+ TiXmlElement* rootElem = NULL;
+ TiXmlElement* dataElem = NULL;
+
+ // - Grab a save file.
+ rootElem = mapFile.FirstChildElement("save");
+ assert(rootElem != NULL);
+ if(rootElem) {
+ // - Parse the player name.
+ dataElem = rootElem->FirstChildElement("name");
+ assert(dataElem != NULL);
+ m_player->SetName(dataElem->GetText());
+ //
+
+ // - Parse the player x coord.
+ dataElem = dataElem->NextSiblingElement("x");
+ assert(dataElem != NULL);
+ int playerX = atoi(dataElem->GetText());
+ //
+
+ // - Parse the player y coord.
+ dataElem = dataElem->NextSiblingElement("y");
+ assert(dataElem != NULL);
+ int playerY = atoi(dataElem->GetText());
+ //
+
+ m_player->SetXY(playerX, playerY);
+
+ //
+ }
+ //
+
+ //
}
void Game::SaveSavegame(void) {
diff --git a/src/Unuk/Game.h b/src/Unuk/Game.h
index 15656e5..6927cc1 100644
--- a/src/Unuk/Game.h
+++ b/src/Unuk/Game.h
@@ -6,6 +6,7 @@
#include
#include
#include
+#include
#include "Constants.h"
#include "Globals.h"
diff --git a/src/Unuk/Globals.cpp b/src/Unuk/Globals.cpp
index 8bc0852..fbe29f4 100644
--- a/src/Unuk/Globals.cpp
+++ b/src/Unuk/Globals.cpp
@@ -2,12 +2,17 @@
SDL_Surface* screen = NULL;
SDL_Surface* errorTexture = NULL;
-
SDL_Rect camera;
-
SDL_Event event;
int levelWidth;
int levelHeight;
bool debugEnabled = true;
+
+int plrKeyUp;
+int plrKeyDown;
+int plrKeyeft;
+int plrKeyRight;
+
+int plrBtnSpell;
diff --git a/src/Unuk/Globals.h b/src/Unuk/Globals.h
index a9e0790..762e31c 100644
--- a/src/Unuk/Globals.h
+++ b/src/Unuk/Globals.h
@@ -1,13 +1,10 @@
#ifndef _GLOBALS_H_
#define _GLOBALS_H_
#include
-#include
extern SDL_Surface* screen;
extern SDL_Surface* errorTexture;
-
extern SDL_Rect camera;
-
extern SDL_Event event;
extern int levelWidth;
diff --git a/src/Unuk/Player.cpp b/src/Unuk/Player.cpp
index 950db58..74d6280 100644
--- a/src/Unuk/Player.cpp
+++ b/src/Unuk/Player.cpp
@@ -60,6 +60,10 @@ void Player::Update(void) {
SetCamera();
}
+void Player::SetName(string nameArg) {
+ m_name = nameArg;
+}
+
void Player::SetCamera(void) {
camera.x = (x + w / 2) - SCREEN_WIDTH / 2;
camera.y = (y + h / 2) - SCREEN_HEIGHT / 2;
diff --git a/src/Unuk/Player.h b/src/Unuk/Player.h
index 01252fe..49317ec 100644
--- a/src/Unuk/Player.h
+++ b/src/Unuk/Player.h
@@ -14,6 +14,9 @@ public:
void HandleInput(void);
void Update(void);
+ void SetName(string nameArg);
+ string GetName(void) { return m_name; }
+
protected:
void Move(void);
void CheckTileCollisions(void);
@@ -21,6 +24,8 @@ protected:
private:
void SetCamera(void);
static const float PLAYER_SPEED;
+
+ string m_name;
};
#endif
diff --git a/src/Unuk/main.cpp b/src/Unuk/main.cpp
index e58520c..3a42e51 100644
--- a/src/Unuk/main.cpp
+++ b/src/Unuk/main.cpp
@@ -63,7 +63,7 @@ int main() {
delete menu;
game = new Game;
- gameReturnVal = game->Run("1");
+ gameReturnVal = game->Run("save.xml");
if(gameReturnVal == GAME_RETURN_TO_MMENU)
menu = new MainMenu;
diff --git a/src/libUnuk/Character.cpp b/src/libUnuk/Character.cpp
index a864cd9..dd5226e 100644
--- a/src/libUnuk/Character.cpp
+++ b/src/libUnuk/Character.cpp
@@ -4,7 +4,7 @@
const float Character::CHARACTER_SPEED = 3.5f;
static listcollisionList;
-static list::iterator collisionIterator;
+static list::iterator collisionIter;
Character::Character(Map* mapArg) {
map = mapArg;
@@ -24,15 +24,64 @@ Character::Character(Map* mapArg) {
Character::~Character(void) {
SDL_FreeSurface(m_texture);
- for(collisionIterator = collisionList.begin(); collisionIterator != collisionList.end(); collisionIterator++) {
- if((*collisionIterator) == this) {
- collisionList.erase(collisionIterator);
+ for(collisionIter = collisionList.begin(); collisionIter != collisionList.end(); collisionIter++) {
+ if((*collisionIter) == this) {
+ collisionList.erase(collisionIter);
break;
}
}
}
+void Character::LoadSprites(string filename, int wArg, int hArg) {
+ if(m_texture != NULL)
+ SDL_FreeSurface(m_texture);
+
+ m_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;
+ }
+ }
+}
+
+void Character::AddSpeachBubble(string text) {
+ m_speachBubble.push_back(text);
+
+ m_speachBubbleText.SetTextBlended(text, "small", 0, 0, 0);
+
+ if(m_speachBubbleTimer.IsStarted() == false)
+ m_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) {
+ roundedBoxRGBA(screen, (x + w / 2) - 100,
+ y - 100,
+ (x + w / 2) + 100,
+ y - 35,
+ 5, 255, 255, 255, 255);
+
+ filledTrigonRGBA(screen, (x + w / 2) - 100,
+ y - 100,
+ (x + w / 2) - 10,
+ y - 40,
+ (x + w / 2) + 10,
+ y - 40,
+ 255, 255, 255, 255);
+
+ m_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]);
return;
@@ -64,27 +113,22 @@ void Character::Render(void) {
}
}
-void Character::LoadSprites(string filename, int wArg, int hArg) {
- if(m_texture != NULL)
- SDL_FreeSurface(m_texture);
-
- m_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;
- }
- }
-}
-
void Character::Update(void) {
Move();
+
+ if(m_speachBubble.size() != 0) {
+ if(m_speachBubbleTimer.GetTicks() > SPEACH_BUBBLE_DISPLAY_LENGTH) {
+ m_speachBubble.pop_front();
+
+ if(m_speachBubble.size() != 0) {
+ m_speachBubbleTimer.Start();
+ }
+ } else {
+ if(m_speachBubble.front() != m_speachBubbleText.GetText()) {
+ m_speachBubbleText.SetTextBlended(m_speachBubble.front(), "small", 0, 0, 0);
+ }
+ }
+ }
}
void Character::Move(void) {
@@ -143,15 +187,15 @@ bool Character::CheckEntityCollisions(void) {
}
bool Character::CheckCharacterCollisions(void) {
- for(collisionIterator = collisionList.begin();
- collisionIterator != collisionList.end();
- collisionIterator++) {
- if((*collisionIterator) != this) {
+ for(collisionIter = collisionList.begin();
+ collisionIter != collisionList.end();
+ collisionIter++) {
+ if((*collisionIter) != this) {
if(CheckCollisionXY(x, y, w, h,
- (*collisionIterator)->GetX(),
- (*collisionIterator)->GetY(),
- (*collisionIterator)->GetWidth(),
- (*collisionIterator)->GetHeight())) {
+ (*collisionIter)->GetX(),
+ (*collisionIter)->GetY(),
+ (*collisionIter)->GetWidth(),
+ (*collisionIter)->GetHeight())) {
return true;
}
}
diff --git a/src/libUnuk/Character.h b/src/libUnuk/Character.h
index 6b7c24d..0b4f63f 100644
--- a/src/libUnuk/Character.h
+++ b/src/libUnuk/Character.h
@@ -1,6 +1,7 @@
#ifndef _CHARACTER_H_
#define _CHARACTER_H_
#include
+#include
#include
#include "../Unuk/Globals.h"
@@ -10,6 +11,7 @@
#include "Collision.h"
#include "Map.h"
#include "Timer.h"
+#include "Text.h"
#include "Debug.h"
using namespace std;
@@ -19,6 +21,8 @@ class Character {
public:
Character(Map* mapArg);
~Character(void);
+
+ void LoadSprites(string filename, int wArg, int hArg);
float GetX(void) { return x; }
float GetY(void) { return y; }
@@ -29,9 +33,9 @@ public:
void SetXVelocity(float arg) { xVel = arg; }
void SetYVelocity(float arg) { yVel = arg; }
+ void AddSpeachBubble(string text);
+
void Render(void);
- void LoadSprites(string filename, int wArg, int hArg);
-
void Update(void);
protected:
@@ -73,6 +77,8 @@ protected:
private:
static const int ANIMATION_SPEED = 200;
static const int ATTACKING_DISPLAY_LEN = 150;
+
+ static const int SPEACH_BUBBLE_DISPLAY_LENGTH = 6000;
SDL_Surface* m_texture;
@@ -82,6 +88,11 @@ private:
Timer m_animationTimer;
int m_animationStage;
bool m_leftFoot;
+
+ list m_speachBubble;
+ list::iterator m_speachBubbleIter;
+ Timer m_speachBubbleTimer;
+ Text m_speachBubbleText;
};
#endif
diff --git a/src/libUnuk/Timer.cpp b/src/libUnuk/Timer.cpp
index e06aba0..9764c8b 100644
--- a/src/libUnuk/Timer.cpp
+++ b/src/libUnuk/Timer.cpp
@@ -3,38 +3,47 @@
Timer::Timer(void) {
m_startTicks = 0;
m_pausedTicks = 0;
- m_paused = false;
+ m_paused = false;
+ m_started = false;
}
Timer::~Timer(void) {
}
void Timer::Start(void) {
- m_paused = false;
+ m_paused = false;
+ m_started = true;
m_startTicks = SDL_GetTicks();
}
+void Timer::Stop(void) {
+ m_paused = false;
+ m_started = true;
+}
+
void Timer::Pause(void) {
- if(m_paused == false) {
- m_paused = true;
- m_pausedTicks = SDL_GetTicks() - m_startTicks;
- }
+ assert(m_paused == false);
+ m_paused = true;
+
+ m_pausedTicks = SDL_GetTicks() - m_startTicks;
}
void Timer::Unpause(void) {
- if(m_paused == true) {
- m_paused = false;
- m_startTicks = SDL_GetTicks() - m_pausedTicks;
- m_pausedTicks = 0;
- }
+ assert(m_paused == true);
+ m_paused = false;
+
+ m_startTicks = SDL_GetTicks() - m_pausedTicks;
+
+ m_pausedTicks = 0;
}
int Timer::GetTicks(void) {
- if(m_paused == true) {
+ if(m_paused == true)
return m_pausedTicks;
- } else {
+ else if(m_started == true)
return SDL_GetTicks() - m_startTicks;
- }
+ else
+ return 0;
}
string Timer::GetTicksStr(void) {
diff --git a/src/libUnuk/Timer.h b/src/libUnuk/Timer.h
index 593a2e1..2eb8c87 100644
--- a/src/libUnuk/Timer.h
+++ b/src/libUnuk/Timer.h
@@ -2,6 +2,7 @@
#define _TIMER_H_
#include
#include
+#include
#include
using namespace std;
@@ -13,8 +14,10 @@ public:
void Pause(void);
void Unpause(void);
void Start(void);
+ void Stop(void);
- bool IsPaused(void) { return m_paused; }
+ bool IsPaused(void) { return m_paused; }
+ bool IsStarted(void) { return m_started; }
int GetTicks(void);
@@ -22,6 +25,8 @@ public:
private:
bool m_paused;
+ bool m_started;
+
int m_startTicks;
int m_pausedTicks;
};