diff --git a/Data/Media/Images/Characters/Reniesta.png b/Data/Media/Images/Characters/Reniesta.png
new file mode 100644
index 0000000..1f31089
Binary files /dev/null and b/Data/Media/Images/Characters/Reniesta.png differ
diff --git a/Unuk-QT/Unuk-QT.pro b/Unuk-QT/Unuk-QT.pro
index 8f97244..2dc0a50 100644
--- a/Unuk-QT/Unuk-QT.pro
+++ b/Unuk-QT/Unuk-QT.pro
@@ -79,4 +79,5 @@ SOURCES += ../src/libUnuk/Engine/WorldManager.cpp \
../src/libUnuk/UI/EventHistory.cpp \
../src/libUnuk/UI/Bar.cpp \
../src/libUnuk/System/Vec2.cpp \
- ../src/libUnuk/UI/SavegameMenu.cpp
+ ../src/libUnuk/UI/SavegameMenu.cpp \
+ ../src/libUnuk/Engine/Spells.cpp
diff --git a/src/Unuk/Game.cpp b/src/Unuk/Game.cpp
index a2129d5..48be3d4 100644
--- a/src/Unuk/Game.cpp
+++ b/src/Unuk/Game.cpp
@@ -7,7 +7,7 @@
Game::Game(void) {
Debug::logger->message("Creating characters..");
_player = new Player(&_map);
- _map.SetPlayer(_player);
+ _map.SetPlayer(_player);
_runGameReturnValue = gameMainMenu;
}
@@ -19,29 +19,29 @@ Game::~Game(void) {
}
void Game::New(const string& savegameIDArg) {
- _saveGameID = savegameIDArg;
- NewSavegame(savegameIDArg);
-
- int spawnX;
- int spawnY;
- _map.FindSpawnPoint(spawnX, spawnY, 40, 45);
-
- _player->SetXY((float)spawnX, (float)spawnY);
+ _saveGameID = savegameIDArg;
+ NewSavegame(savegameIDArg);
+
+ int spawnX;
+ int spawnY;
+ _map.FindSpawnPoint(spawnX, spawnY, 40, 45);
+
+ _player->SetXY((float)spawnX, (float)spawnY);
}
void Game::Load(const string& savegameIDArg) {
- _saveGameID = savegameIDArg;
- LoadSavegame(savegameIDArg);
-
- int spawnX;
- int spawnY;
- _map.FindSpawnPoint(spawnX, spawnY, 40, 45);
-
- _player->SetXY((float)spawnX, (float)spawnY);
+ _saveGameID = savegameIDArg;
+ LoadSavegame(savegameIDArg);
+
+ int spawnX;
+ int spawnY;
+ _map.FindSpawnPoint(spawnX, spawnY, 40, 45);
+
+ _player->SetXY((float)spawnX, (float)spawnY);
}
gameNavVal_t Game::Run(void) {
- _player->LoadSprites("../Data/Media/Images/Characters/Player.png", 40, 45);
+ _player->LoadSprites("../Data/Media/Images/Characters/Reniesta.png", 40, 45);
int fps = 0;
int frame = 0;
@@ -252,10 +252,10 @@ void Game::Render(void) {
}
void Game::NewSavegame(const string savegameIDArg) {
- string saveFilename = "../Save/" + savegameIDArg;
+ string saveFilename = "../Save/" + savegameIDArg;
- _map.New();
- _map.Save(_saveGameID);
+ _map.New();
+ _map.Save(_saveGameID);
TiXmlDocument doc;
@@ -266,13 +266,13 @@ void Game::NewSavegame(const string savegameIDArg) {
TiXmlElement* nameElement = new TiXmlElement("name");
TiXmlText* nameText = new TiXmlText("Allanis"); //TODO: replace with _player->GetName() when it works. --konom
nameElement->LinkEndChild(nameText);
-
- int spawnX;
- int spawnY;
- _map.FindSpawnPoint(spawnX, spawnY, 40, 45);
-
- _player->SetXY(spawnX, spawnY);
-
+
+ int spawnX;
+ int spawnY;
+ _map.FindSpawnPoint(spawnX, spawnY, 40, 45);
+
+ _player->SetXY(spawnX, spawnY);
+
std::stringstream xString;
xString << spawnX;
@@ -286,22 +286,22 @@ void Game::NewSavegame(const string savegameIDArg) {
TiXmlElement* yElement = new TiXmlElement("y");
TiXmlText* yText = new TiXmlText(yString.str().c_str());
yElement->LinkEndChild(yText);
-
- _player->SetLevelLiteral(1);
-
- TiXmlElement* levelElement = new TiXmlElement("level");
- TiXmlText* levelText = new TiXmlText("1");
- levelElement->LinkEndChild(levelText);
-
- _player->SetExpLiteral(0);
-
- TiXmlElement* expElement = new TiXmlElement("exp");
- TiXmlText* expText = new TiXmlText("0");
- expElement->LinkEndChild(expText);
-
- TiXmlElement* healthElement = new TiXmlElement("health");
- TiXmlText* healthText = new TiXmlText("100");
- healthElement->LinkEndChild(healthText);
+
+ _player->SetLevelLiteral(1);
+
+ TiXmlElement* levelElement = new TiXmlElement("level");
+ TiXmlText* levelText = new TiXmlText("1");
+ levelElement->LinkEndChild(levelText);
+
+ _player->SetExpLiteral(0);
+
+ TiXmlElement* expElement = new TiXmlElement("exp");
+ TiXmlText* expText = new TiXmlText("0");
+ expElement->LinkEndChild(expText);
+
+ TiXmlElement* healthElement = new TiXmlElement("health");
+ TiXmlText* healthText = new TiXmlText("100");
+ healthElement->LinkEndChild(healthText);
TiXmlElement* mapElement = new TiXmlElement("map");
TiXmlText* mapText = new TiXmlText("map"); //TODO: replace with actual map name.
@@ -310,9 +310,9 @@ void Game::NewSavegame(const string savegameIDArg) {
saveElement->LinkEndChild(nameElement);
saveElement->LinkEndChild(xElement);
saveElement->LinkEndChild(yElement);
- saveElement->LinkEndChild(levelElement);
- saveElement->LinkEndChild(expElement);
- saveElement->LinkEndChild(healthElement);
+ saveElement->LinkEndChild(levelElement);
+ saveElement->LinkEndChild(expElement);
+ saveElement->LinkEndChild(healthElement);
saveElement->LinkEndChild(mapElement);
doc.LinkEndChild(decl);
@@ -327,12 +327,12 @@ void Game::LoadSavegame(const string savegameIDArg) {
// Converting to XML ftw!
TiXmlDocument mapFile(saveFilename.c_str());
-
- // Create new save if can't load file.
- if(!mapFile.LoadFile()) {
- New(savegameIDArg);
- return;
- }
+
+ // Create new save if can't load file.
+ if(!mapFile.LoadFile()) {
+ New(savegameIDArg);
+ return;
+ }
TiXmlElement* rootElem = NULL;
TiXmlElement* dataElem = NULL;
@@ -364,41 +364,41 @@ void Game::LoadSavegame(const string savegameIDArg) {
//
_player->SetXY((float)playerX, (float)playerY);
*/
-
- // - Parse the player level.
- dataElem = dataElem->NextSiblingElement("level");
- assert(dataElem != NULL);
- int playerLevel = atoi(dataElem->GetText());
- //
-
- _player->SetLevelLiteral(playerLevel);
-
- // - Parse the player exp.
- dataElem = dataElem->NextSiblingElement("exp");
- assert(dataElem != NULL);
- int playerExp = atoi(dataElem->GetText());
- //
-
- _player->SetExpLiteral(playerExp);
-
- // - Parse the player health.
- dataElem = dataElem->NextSiblingElement("health");
- assert(dataElem != NULL);
- int playerHealth = atoi(dataElem->GetText());
- //
-
- _player->SetHealthLiteral(playerHealth);
+
+ // - Parse the player level.
+ dataElem = dataElem->NextSiblingElement("level");
+ assert(dataElem != NULL);
+ int playerLevel = atoi(dataElem->GetText());
+ //
+
+ _player->SetLevelLiteral(playerLevel);
+
+ // - Parse the player exp.
+ dataElem = dataElem->NextSiblingElement("exp");
+ assert(dataElem != NULL);
+ int playerExp = atoi(dataElem->GetText());
+ //
+
+ _player->SetExpLiteral(playerExp);
+
+ // - Parse the player health.
+ dataElem = dataElem->NextSiblingElement("health");
+ assert(dataElem != NULL);
+ int playerHealth = atoi(dataElem->GetText());
+ //
+
+ _player->SetHealthLiteral(playerHealth);
}
//
//
-
- _map.Load(_saveGameID);
+
+ _map.Load(_saveGameID);
}
void Game::SaveSavegame(void) {
string saveFilename = "../Save/" + _saveGameID;
-
+
TiXmlDocument doc;
TiXmlDeclaration* decl = new TiXmlDeclaration("1.0", "", "");
@@ -425,38 +425,38 @@ void Game::SaveSavegame(void) {
yElement->LinkEndChild(yText);
*/
- std::stringstream levelString;
- levelString << _player->GetLevel();
-
- TiXmlElement* levelElement = new TiXmlElement("level");
- TiXmlText* levelText = new TiXmlText(levelString.str().c_str());
- levelElement->LinkEndChild(levelText);
-
- std::stringstream expString;
- expString << _player->GetExp();
-
- TiXmlElement* expElement = new TiXmlElement("exp");
- TiXmlText* expText = new TiXmlText(expString.str().c_str());
- expElement->LinkEndChild(expText);
-
- std::stringstream healthString;
- healthString << _player->GetHealth();
-
- TiXmlElement* healthElement = new TiXmlElement("health");
- TiXmlText* healthText = new TiXmlText(healthString.str().c_str());
- healthElement->LinkEndChild(healthText);
+ std::stringstream levelString;
+ levelString << _player->GetLevel();
+
+ TiXmlElement* levelElement = new TiXmlElement("level");
+ TiXmlText* levelText = new TiXmlText(levelString.str().c_str());
+ levelElement->LinkEndChild(levelText);
+
+ std::stringstream expString;
+ expString << _player->GetExp();
+
+ TiXmlElement* expElement = new TiXmlElement("exp");
+ TiXmlText* expText = new TiXmlText(expString.str().c_str());
+ expElement->LinkEndChild(expText);
+
+ std::stringstream healthString;
+ healthString << _player->GetHealth();
+
+ TiXmlElement* healthElement = new TiXmlElement("health");
+ TiXmlText* healthText = new TiXmlText(healthString.str().c_str());
+ healthElement->LinkEndChild(healthText);
saveElement->LinkEndChild(nameElement);
//saveElement->LinkEndChild(xElement);
//saveElement->LinkEndChild(yElement);
- saveElement->LinkEndChild(levelElement);
- saveElement->LinkEndChild(expElement);
- saveElement->LinkEndChild(healthElement);
+ saveElement->LinkEndChild(levelElement);
+ saveElement->LinkEndChild(expElement);
+ saveElement->LinkEndChild(healthElement);
doc.LinkEndChild(decl);
doc.LinkEndChild(saveElement);
doc.SaveFile(saveFilename.c_str());
-
- _map.Save(_saveGameID);
+
+ _map.Save(_saveGameID);
}
diff --git a/src/Unuk/Player.cpp b/src/Unuk/Player.cpp
index 900ee97..36e5baa 100644
--- a/src/Unuk/Player.cpp
+++ b/src/Unuk/Player.cpp
@@ -17,23 +17,23 @@ const int Player::EXP_TABLE[MAX_LEVEL] = {
2000,
3500,
5000,
- 6500,
- 8500,
- 10250,
- 12000,
- 15000,
- 25000,
- 50000,
- 65000,
- 80000,
- 100000
+ 6500,
+ 8500,
+ 10250,
+ 12000,
+ 15000,
+ 25000,
+ 50000,
+ 65000,
+ 80000,
+ 100000
};
Player::Player(LevelGen *mapArg) : Character(mapArg) {
_level = 1;
_exp = 0;
- _lastTileX = 0;
- _lastTileY = 0;
+ _lastTileX = 0;
+ _lastTileY = 0;
}
Player::~Player(void) {
@@ -101,14 +101,14 @@ void Player::Update(void) {
// For now The camera will be static.
//SetCamera();
- int tileX = x / TILE_WIDTH;
- int tileY = y / TILE_HEIGHT;
- if(tileX != _lastTileX || tileY != _lastTileY) {
- _lastTileX = tileX;
- _lastTileY = tileY;
-
- map->GetWorld().OnPlayerMove(this);
- }
+ int tileX = x / TILE_WIDTH;
+ int tileY = y / TILE_HEIGHT;
+ if(tileX != _lastTileX || tileY != _lastTileY) {
+ _lastTileX = tileX;
+ _lastTileY = tileY;
+
+ map->GetWorld().OnPlayerMove(this);
+ }
_healthBar.SetProgress((float)GetHealth() / 100.0f);
}
@@ -133,8 +133,8 @@ void Player::SetCamera(void) {
}
void Player::Move() {
- map->MoveIfPossible(this, xVel, yVel, true);
- Character::HealthBarScroll();
+ map->MoveIfPossible(this, xVel, yVel, true);
+ Character::HealthBarScroll();
}
void Player::SetLevel(int level) {
@@ -143,10 +143,10 @@ void Player::SetLevel(int level) {
if(_exp < 0) {
_exp = 0;
}
- if(_level == MAX_LEVEL) {
- eventHistory->LogEvent("YOU BEAT IT! I'M SO PROUD!");
- eventHistory->LogEvent("*Sheds Tear*");
- }
+ if(_level == MAX_LEVEL) {
+ eventHistory->LogEvent("YOU BEAT IT! I'M SO PROUD!");
+ eventHistory->LogEvent("*Sheds Tear*");
+ }
}
void Player::SetExp(int exp) {
diff --git a/src/Unuk/Player.h b/src/Unuk/Player.h
index a5bf7f4..253ee06 100644
--- a/src/Unuk/Player.h
+++ b/src/Unuk/Player.h
@@ -4,46 +4,46 @@
#include "Globals.h"
#include "Constants.h"
#include "../libUnuk/Engine/Character.h"
-#include "../libUnuk//System/Debug.h"
+#include "../libUnuk/System/Debug.h"
class Player : public Character {
public:
- Player(LevelGen* mapArg);
- ~Player(void);
+ Player(LevelGen* mapArg);
+ ~Player(void);
- void HandleInput(void);
- void Update(void);
+ void HandleInput(void);
+ void Update(void);
- void SetName(string nameArg);
- string GetName(void) { return _name; }
-
- void SetLevel(int level);
- int GetLevel(void) { return _level; }
+ void SetName(string nameArg);
+ string GetName(void) { return _name; }
- void SetExp(int exp);
- int GetExp(void) { return _exp; }
-
- void SetLevelLiteral(int level) { _level = level; }
- void SetExpLiteral(int exp) { _exp = exp; }
- void SetHealthLiteral(int health) { _health = health; }
+ void SetLevel(int level);
+ int GetLevel(void) { return _level; }
+
+ void SetExp(int exp);
+ int GetExp(void) { return _exp; }
+
+ void SetLevelLiteral(int level) { _level = level; }
+ void SetExpLiteral(int exp) { _exp = exp; }
+ void SetHealthLiteral(int health) { _health = health; }
+
+ void SetXY(float xArg, float yArg) { x = xArg, y = yArg; _lastTileX = xArg / TILE_WIDTH; _lastTileY = yArg / TILE_HEIGHT; }
+
+ static const int MAX_LEVEL = 20;
+ static const int EXP_TABLE[MAX_LEVEL];
- void SetXY(float xArg, float yArg) { x = xArg, y = yArg; _lastTileX = xArg / TILE_WIDTH; _lastTileY = yArg / TILE_HEIGHT; }
-
- static const int MAX_LEVEL = 20;
- static const int EXP_TABLE[MAX_LEVEL];
-
protected:
- void Move(void);
- void CheckTileCollisions(void);
+ void Move(void);
+ void CheckTileCollisions(void);
private:
- void SetCamera(void);
- static const float PLAYER_SPEED;
+ void SetCamera(void);
+ static const float PLAYER_SPEED;
- string _name;
- int _level;
- int _exp;
+ string _name;
+ int _level;
+ int _exp;
- int _lastTileX;
- int _lastTileY;
+ int _lastTileX;
+ int _lastTileY;
};
diff --git a/src/libUnuk/Engine/ParticleEmitter.cpp b/src/libUnuk/Engine/ParticleEmitter.cpp
index b029fab..7b492c2 100644
--- a/src/libUnuk/Engine/ParticleEmitter.cpp
+++ b/src/libUnuk/Engine/ParticleEmitter.cpp
@@ -9,72 +9,72 @@ ParticleEmitter::~ParticleEmitter(void) {
}
void ParticleEmitter::SetXY(int xArg, int yArg) {
- x = xArg;
- y = yArg;
+ x = xArg;
+ y = yArg;
}
void ParticleEmitter::ForceXY(int xArg, int yArg) {
- for(int i = 0; i < _particleCount; i++) {
- m_particle[i].x = (float)xArg;
- m_particle[i].y = (float)yArg;
- }
+ for(int i = 0; i < _particleCount; i++) {
+ m_particle[i].x = (float)xArg;
+ m_particle[i].y = (float)yArg;
+ }
}
void ParticleEmitter::SetParticleCount(int countArg) {
- _particleCount = countArg;
- m_particle.resize(_particleCount);
+ _particleCount = countArg;
+ m_particle.resize(_particleCount);
- for(int i = 0; i < _particleCount; i++) {
- m_particle[i].startTime = SDL_GetTicks();
- }
+ for(int i = 0; i < _particleCount; i++) {
+ m_particle[i].startTime = SDL_GetTicks();
+ }
}
void ParticleEmitter::SetParticleSpeed(float speedArg) {
- _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());
+ string textureFilename = "../../Data/Media/Images/Particles/" + typeArg + ".png";
+ _particleTexture = LoadImageAlpha(textureFilename.c_str());
}
void ParticleEmitter::SetParticleLifetime(int lifetimeArg) {
- _particleLifetime = lifetimeArg;
+ _particleLifetime = lifetimeArg;
- for(int i = 0; i < _particleCount; i++) {
- m_particle[i].lifetime = rand() % _particleLifetime + _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 < _particleCount; i++) {
- ApplySurface((int)m_particle[i].x, (int)m_particle[i].y, _particleTexture, screen);
- }
+ for(int i = 0; i < _particleCount; i++) {
+ ApplySurface((int)m_particle[i].x, (int)m_particle[i].y, _particleTexture, screen);
+ }
}
void ParticleEmitter::Update(void) {
- 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 = (float)x;
- m_particle[i].y = (float)y;
+ 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 = (float)x;
+ m_particle[i].y = (float)y;
- m_particle[i].xVel = (float)(rand() % 360);
- m_particle[i].yVel = (float)(rand() % 360);
+ m_particle[i].xVel = (float)(rand() % 360);
+ m_particle[i].yVel = (float)(rand() % 360);
- if(rand() % 2)
- m_particle[i].xVel = m_particle[i].xVel * -1.0f;
- if(rand() % 2)
- m_particle[i].yVel = m_particle[i].yVel * -1.0f;
+ if(rand() % 2)
+ m_particle[i].xVel = m_particle[i].xVel * -1.0f;
+ if(rand() % 2)
+ m_particle[i].yVel = m_particle[i].yVel * -1.0f;
- m_particle[i].startTime = SDL_GetTicks();
- } else {
- m_particle[i].x += m_particle[i].xVel * _particleSpeed;
- m_particle[i].y += m_particle[i].yVel * _particleSpeed;
- }
- }
+ m_particle[i].startTime = SDL_GetTicks();
+ } else {
+ m_particle[i].x += m_particle[i].xVel * _particleSpeed;
+ m_particle[i].y += m_particle[i].yVel * _particleSpeed;
+ }
+ }
}
diff --git a/src/libUnuk/Engine/Spells.cpp b/src/libUnuk/Engine/Spells.cpp
new file mode 100644
index 0000000..9de8469
--- /dev/null
+++ b/src/libUnuk/Engine/Spells.cpp
@@ -0,0 +1,17 @@
+#include "Spells.h"
+
+Spells::Spells(void) {
+
+}
+
+Spells::~Spells(void) {
+
+}
+
+void Spells::CastSpell() {
+
+}
+
+void Spells::Render(void) {
+ //_particle->Render();
+}
diff --git a/src/libUnuk/Engine/Spells.h b/src/libUnuk/Engine/Spells.h
index 03eabc2..b7fc547 100644
--- a/src/libUnuk/Engine/Spells.h
+++ b/src/libUnuk/Engine/Spells.h
@@ -1,4 +1,4 @@
-#pragma once;
+#pragma once
#include "../../Unuk/Player.h"
#include "../System/Timer.h"
#include "ParticleEmitter.h"
@@ -13,9 +13,10 @@ public:
ICE
};
- void CastSpell(Player* player);
+ void CastSpell(/*Player* player*/);
+ void Render(void);
private:
Timer* _timeBetweenCast;
-
+ ParticleEmitter* _particle;
};
diff --git a/src/libUnuk/Engine/WorldManager.cpp b/src/libUnuk/Engine/WorldManager.cpp
index b9f164b..3a0399f 100644
--- a/src/libUnuk/Engine/WorldManager.cpp
+++ b/src/libUnuk/Engine/WorldManager.cpp
@@ -187,7 +187,7 @@ void WorldManager::OnPlayerAttack(Player* player) {
}
void WorldManager::OnPlayerMove(Player* player) {
- for(std::list::iterator i = _npcs.begin(); i != _npcs.end(); ++i) {
- (*i)->OnPlayerMove(player);
- }
+ for(std::list::iterator i = _npcs.begin(); i != _npcs.end(); ++i) {
+ (*i)->OnPlayerMove(player);
+ }
}
diff --git a/src/libUnuk/Engine/WorldManager.h b/src/libUnuk/Engine/WorldManager.h
index bcb0cfa..9ef2132 100644
--- a/src/libUnuk/Engine/WorldManager.h
+++ b/src/libUnuk/Engine/WorldManager.h
@@ -1,7 +1,6 @@
#pragma once
#include
#include "MemClass.h"
-
class Character;
class NPC;
class Player;