[Add] A little spell stuff.
[Add] Woot, Rachel did the character sprite.
This commit is contained in:
parent
4b86f12f3a
commit
45d5720e4b
BIN
Data/Media/Images/Characters/Reniesta.png
Normal file
BIN
Data/Media/Images/Characters/Reniesta.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.8 KiB |
@ -79,4 +79,5 @@ SOURCES += ../src/libUnuk/Engine/WorldManager.cpp \
|
|||||||
../src/libUnuk/UI/EventHistory.cpp \
|
../src/libUnuk/UI/EventHistory.cpp \
|
||||||
../src/libUnuk/UI/Bar.cpp \
|
../src/libUnuk/UI/Bar.cpp \
|
||||||
../src/libUnuk/System/Vec2.cpp \
|
../src/libUnuk/System/Vec2.cpp \
|
||||||
../src/libUnuk/UI/SavegameMenu.cpp
|
../src/libUnuk/UI/SavegameMenu.cpp \
|
||||||
|
../src/libUnuk/Engine/Spells.cpp
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
Game::Game(void) {
|
Game::Game(void) {
|
||||||
Debug::logger->message("Creating characters..");
|
Debug::logger->message("Creating characters..");
|
||||||
_player = new Player(&_map);
|
_player = new Player(&_map);
|
||||||
_map.SetPlayer(_player);
|
_map.SetPlayer(_player);
|
||||||
|
|
||||||
_runGameReturnValue = gameMainMenu;
|
_runGameReturnValue = gameMainMenu;
|
||||||
}
|
}
|
||||||
@ -19,29 +19,29 @@ Game::~Game(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Game::New(const string& savegameIDArg) {
|
void Game::New(const string& savegameIDArg) {
|
||||||
_saveGameID = savegameIDArg;
|
_saveGameID = savegameIDArg;
|
||||||
NewSavegame(savegameIDArg);
|
NewSavegame(savegameIDArg);
|
||||||
|
|
||||||
int spawnX;
|
int spawnX;
|
||||||
int spawnY;
|
int spawnY;
|
||||||
_map.FindSpawnPoint(spawnX, spawnY, 40, 45);
|
_map.FindSpawnPoint(spawnX, spawnY, 40, 45);
|
||||||
|
|
||||||
_player->SetXY((float)spawnX, (float)spawnY);
|
_player->SetXY((float)spawnX, (float)spawnY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::Load(const string& savegameIDArg) {
|
void Game::Load(const string& savegameIDArg) {
|
||||||
_saveGameID = savegameIDArg;
|
_saveGameID = savegameIDArg;
|
||||||
LoadSavegame(savegameIDArg);
|
LoadSavegame(savegameIDArg);
|
||||||
|
|
||||||
int spawnX;
|
int spawnX;
|
||||||
int spawnY;
|
int spawnY;
|
||||||
_map.FindSpawnPoint(spawnX, spawnY, 40, 45);
|
_map.FindSpawnPoint(spawnX, spawnY, 40, 45);
|
||||||
|
|
||||||
_player->SetXY((float)spawnX, (float)spawnY);
|
_player->SetXY((float)spawnX, (float)spawnY);
|
||||||
}
|
}
|
||||||
|
|
||||||
gameNavVal_t Game::Run(void) {
|
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 fps = 0;
|
||||||
int frame = 0;
|
int frame = 0;
|
||||||
@ -252,10 +252,10 @@ void Game::Render(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Game::NewSavegame(const string savegameIDArg) {
|
void Game::NewSavegame(const string savegameIDArg) {
|
||||||
string saveFilename = "../Save/" + savegameIDArg;
|
string saveFilename = "../Save/" + savegameIDArg;
|
||||||
|
|
||||||
_map.New();
|
_map.New();
|
||||||
_map.Save(_saveGameID);
|
_map.Save(_saveGameID);
|
||||||
|
|
||||||
TiXmlDocument doc;
|
TiXmlDocument doc;
|
||||||
|
|
||||||
@ -267,11 +267,11 @@ void Game::NewSavegame(const string savegameIDArg) {
|
|||||||
TiXmlText* nameText = new TiXmlText("Allanis"); //TODO: replace with _player->GetName() when it works. --konom
|
TiXmlText* nameText = new TiXmlText("Allanis"); //TODO: replace with _player->GetName() when it works. --konom
|
||||||
nameElement->LinkEndChild(nameText);
|
nameElement->LinkEndChild(nameText);
|
||||||
|
|
||||||
int spawnX;
|
int spawnX;
|
||||||
int spawnY;
|
int spawnY;
|
||||||
_map.FindSpawnPoint(spawnX, spawnY, 40, 45);
|
_map.FindSpawnPoint(spawnX, spawnY, 40, 45);
|
||||||
|
|
||||||
_player->SetXY(spawnX, spawnY);
|
_player->SetXY(spawnX, spawnY);
|
||||||
|
|
||||||
std::stringstream xString;
|
std::stringstream xString;
|
||||||
xString << spawnX;
|
xString << spawnX;
|
||||||
@ -287,21 +287,21 @@ void Game::NewSavegame(const string savegameIDArg) {
|
|||||||
TiXmlText* yText = new TiXmlText(yString.str().c_str());
|
TiXmlText* yText = new TiXmlText(yString.str().c_str());
|
||||||
yElement->LinkEndChild(yText);
|
yElement->LinkEndChild(yText);
|
||||||
|
|
||||||
_player->SetLevelLiteral(1);
|
_player->SetLevelLiteral(1);
|
||||||
|
|
||||||
TiXmlElement* levelElement = new TiXmlElement("level");
|
TiXmlElement* levelElement = new TiXmlElement("level");
|
||||||
TiXmlText* levelText = new TiXmlText("1");
|
TiXmlText* levelText = new TiXmlText("1");
|
||||||
levelElement->LinkEndChild(levelText);
|
levelElement->LinkEndChild(levelText);
|
||||||
|
|
||||||
_player->SetExpLiteral(0);
|
_player->SetExpLiteral(0);
|
||||||
|
|
||||||
TiXmlElement* expElement = new TiXmlElement("exp");
|
TiXmlElement* expElement = new TiXmlElement("exp");
|
||||||
TiXmlText* expText = new TiXmlText("0");
|
TiXmlText* expText = new TiXmlText("0");
|
||||||
expElement->LinkEndChild(expText);
|
expElement->LinkEndChild(expText);
|
||||||
|
|
||||||
TiXmlElement* healthElement = new TiXmlElement("health");
|
TiXmlElement* healthElement = new TiXmlElement("health");
|
||||||
TiXmlText* healthText = new TiXmlText("100");
|
TiXmlText* healthText = new TiXmlText("100");
|
||||||
healthElement->LinkEndChild(healthText);
|
healthElement->LinkEndChild(healthText);
|
||||||
|
|
||||||
TiXmlElement* mapElement = new TiXmlElement("map");
|
TiXmlElement* mapElement = new TiXmlElement("map");
|
||||||
TiXmlText* mapText = new TiXmlText("map"); //TODO: replace with actual map name.
|
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(nameElement);
|
||||||
saveElement->LinkEndChild(xElement);
|
saveElement->LinkEndChild(xElement);
|
||||||
saveElement->LinkEndChild(yElement);
|
saveElement->LinkEndChild(yElement);
|
||||||
saveElement->LinkEndChild(levelElement);
|
saveElement->LinkEndChild(levelElement);
|
||||||
saveElement->LinkEndChild(expElement);
|
saveElement->LinkEndChild(expElement);
|
||||||
saveElement->LinkEndChild(healthElement);
|
saveElement->LinkEndChild(healthElement);
|
||||||
saveElement->LinkEndChild(mapElement);
|
saveElement->LinkEndChild(mapElement);
|
||||||
|
|
||||||
doc.LinkEndChild(decl);
|
doc.LinkEndChild(decl);
|
||||||
@ -328,11 +328,11 @@ void Game::LoadSavegame(const string savegameIDArg) {
|
|||||||
// Converting to XML ftw!
|
// Converting to XML ftw!
|
||||||
TiXmlDocument mapFile(saveFilename.c_str());
|
TiXmlDocument mapFile(saveFilename.c_str());
|
||||||
|
|
||||||
// Create new save if can't load file.
|
// Create new save if can't load file.
|
||||||
if(!mapFile.LoadFile()) {
|
if(!mapFile.LoadFile()) {
|
||||||
New(savegameIDArg);
|
New(savegameIDArg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TiXmlElement* rootElem = NULL;
|
TiXmlElement* rootElem = NULL;
|
||||||
TiXmlElement* dataElem = NULL;
|
TiXmlElement* dataElem = NULL;
|
||||||
@ -365,35 +365,35 @@ void Game::LoadSavegame(const string savegameIDArg) {
|
|||||||
_player->SetXY((float)playerX, (float)playerY);
|
_player->SetXY((float)playerX, (float)playerY);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// <level> - Parse the player level.
|
// <level> - Parse the player level.
|
||||||
dataElem = dataElem->NextSiblingElement("level");
|
dataElem = dataElem->NextSiblingElement("level");
|
||||||
assert(dataElem != NULL);
|
assert(dataElem != NULL);
|
||||||
int playerLevel = atoi(dataElem->GetText());
|
int playerLevel = atoi(dataElem->GetText());
|
||||||
// </level>
|
// </level>
|
||||||
|
|
||||||
_player->SetLevelLiteral(playerLevel);
|
_player->SetLevelLiteral(playerLevel);
|
||||||
|
|
||||||
// <exp> - Parse the player exp.
|
// <exp> - Parse the player exp.
|
||||||
dataElem = dataElem->NextSiblingElement("exp");
|
dataElem = dataElem->NextSiblingElement("exp");
|
||||||
assert(dataElem != NULL);
|
assert(dataElem != NULL);
|
||||||
int playerExp = atoi(dataElem->GetText());
|
int playerExp = atoi(dataElem->GetText());
|
||||||
// </exp>
|
// </exp>
|
||||||
|
|
||||||
_player->SetExpLiteral(playerExp);
|
_player->SetExpLiteral(playerExp);
|
||||||
|
|
||||||
// <health> - Parse the player health.
|
// <health> - Parse the player health.
|
||||||
dataElem = dataElem->NextSiblingElement("health");
|
dataElem = dataElem->NextSiblingElement("health");
|
||||||
assert(dataElem != NULL);
|
assert(dataElem != NULL);
|
||||||
int playerHealth = atoi(dataElem->GetText());
|
int playerHealth = atoi(dataElem->GetText());
|
||||||
// </health>
|
// </health>
|
||||||
|
|
||||||
_player->SetHealthLiteral(playerHealth);
|
_player->SetHealthLiteral(playerHealth);
|
||||||
}
|
}
|
||||||
// <save>
|
// <save>
|
||||||
|
|
||||||
// </save>
|
// </save>
|
||||||
|
|
||||||
_map.Load(_saveGameID);
|
_map.Load(_saveGameID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::SaveSavegame(void) {
|
void Game::SaveSavegame(void) {
|
||||||
@ -425,38 +425,38 @@ void Game::SaveSavegame(void) {
|
|||||||
yElement->LinkEndChild(yText);
|
yElement->LinkEndChild(yText);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
std::stringstream levelString;
|
std::stringstream levelString;
|
||||||
levelString << _player->GetLevel();
|
levelString << _player->GetLevel();
|
||||||
|
|
||||||
TiXmlElement* levelElement = new TiXmlElement("level");
|
TiXmlElement* levelElement = new TiXmlElement("level");
|
||||||
TiXmlText* levelText = new TiXmlText(levelString.str().c_str());
|
TiXmlText* levelText = new TiXmlText(levelString.str().c_str());
|
||||||
levelElement->LinkEndChild(levelText);
|
levelElement->LinkEndChild(levelText);
|
||||||
|
|
||||||
std::stringstream expString;
|
std::stringstream expString;
|
||||||
expString << _player->GetExp();
|
expString << _player->GetExp();
|
||||||
|
|
||||||
TiXmlElement* expElement = new TiXmlElement("exp");
|
TiXmlElement* expElement = new TiXmlElement("exp");
|
||||||
TiXmlText* expText = new TiXmlText(expString.str().c_str());
|
TiXmlText* expText = new TiXmlText(expString.str().c_str());
|
||||||
expElement->LinkEndChild(expText);
|
expElement->LinkEndChild(expText);
|
||||||
|
|
||||||
std::stringstream healthString;
|
std::stringstream healthString;
|
||||||
healthString << _player->GetHealth();
|
healthString << _player->GetHealth();
|
||||||
|
|
||||||
TiXmlElement* healthElement = new TiXmlElement("health");
|
TiXmlElement* healthElement = new TiXmlElement("health");
|
||||||
TiXmlText* healthText = new TiXmlText(healthString.str().c_str());
|
TiXmlText* healthText = new TiXmlText(healthString.str().c_str());
|
||||||
healthElement->LinkEndChild(healthText);
|
healthElement->LinkEndChild(healthText);
|
||||||
|
|
||||||
saveElement->LinkEndChild(nameElement);
|
saveElement->LinkEndChild(nameElement);
|
||||||
//saveElement->LinkEndChild(xElement);
|
//saveElement->LinkEndChild(xElement);
|
||||||
//saveElement->LinkEndChild(yElement);
|
//saveElement->LinkEndChild(yElement);
|
||||||
saveElement->LinkEndChild(levelElement);
|
saveElement->LinkEndChild(levelElement);
|
||||||
saveElement->LinkEndChild(expElement);
|
saveElement->LinkEndChild(expElement);
|
||||||
saveElement->LinkEndChild(healthElement);
|
saveElement->LinkEndChild(healthElement);
|
||||||
|
|
||||||
doc.LinkEndChild(decl);
|
doc.LinkEndChild(decl);
|
||||||
doc.LinkEndChild(saveElement);
|
doc.LinkEndChild(saveElement);
|
||||||
|
|
||||||
doc.SaveFile(saveFilename.c_str());
|
doc.SaveFile(saveFilename.c_str());
|
||||||
|
|
||||||
_map.Save(_saveGameID);
|
_map.Save(_saveGameID);
|
||||||
}
|
}
|
||||||
|
@ -17,23 +17,23 @@ const int Player::EXP_TABLE[MAX_LEVEL] = {
|
|||||||
2000,
|
2000,
|
||||||
3500,
|
3500,
|
||||||
5000,
|
5000,
|
||||||
6500,
|
6500,
|
||||||
8500,
|
8500,
|
||||||
10250,
|
10250,
|
||||||
12000,
|
12000,
|
||||||
15000,
|
15000,
|
||||||
25000,
|
25000,
|
||||||
50000,
|
50000,
|
||||||
65000,
|
65000,
|
||||||
80000,
|
80000,
|
||||||
100000
|
100000
|
||||||
};
|
};
|
||||||
|
|
||||||
Player::Player(LevelGen *mapArg) : Character(mapArg) {
|
Player::Player(LevelGen *mapArg) : Character(mapArg) {
|
||||||
_level = 1;
|
_level = 1;
|
||||||
_exp = 0;
|
_exp = 0;
|
||||||
_lastTileX = 0;
|
_lastTileX = 0;
|
||||||
_lastTileY = 0;
|
_lastTileY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player::~Player(void) {
|
Player::~Player(void) {
|
||||||
@ -101,14 +101,14 @@ void Player::Update(void) {
|
|||||||
// For now The camera will be static.
|
// For now The camera will be static.
|
||||||
//SetCamera();
|
//SetCamera();
|
||||||
|
|
||||||
int tileX = x / TILE_WIDTH;
|
int tileX = x / TILE_WIDTH;
|
||||||
int tileY = y / TILE_HEIGHT;
|
int tileY = y / TILE_HEIGHT;
|
||||||
if(tileX != _lastTileX || tileY != _lastTileY) {
|
if(tileX != _lastTileX || tileY != _lastTileY) {
|
||||||
_lastTileX = tileX;
|
_lastTileX = tileX;
|
||||||
_lastTileY = tileY;
|
_lastTileY = tileY;
|
||||||
|
|
||||||
map->GetWorld().OnPlayerMove(this);
|
map->GetWorld().OnPlayerMove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
_healthBar.SetProgress((float)GetHealth() / 100.0f);
|
_healthBar.SetProgress((float)GetHealth() / 100.0f);
|
||||||
}
|
}
|
||||||
@ -133,8 +133,8 @@ void Player::SetCamera(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Player::Move() {
|
void Player::Move() {
|
||||||
map->MoveIfPossible(this, xVel, yVel, true);
|
map->MoveIfPossible(this, xVel, yVel, true);
|
||||||
Character::HealthBarScroll();
|
Character::HealthBarScroll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::SetLevel(int level) {
|
void Player::SetLevel(int level) {
|
||||||
@ -143,10 +143,10 @@ void Player::SetLevel(int level) {
|
|||||||
if(_exp < 0) {
|
if(_exp < 0) {
|
||||||
_exp = 0;
|
_exp = 0;
|
||||||
}
|
}
|
||||||
if(_level == MAX_LEVEL) {
|
if(_level == MAX_LEVEL) {
|
||||||
eventHistory->LogEvent("YOU BEAT IT! I'M SO PROUD!");
|
eventHistory->LogEvent("YOU BEAT IT! I'M SO PROUD!");
|
||||||
eventHistory->LogEvent("*Sheds Tear*");
|
eventHistory->LogEvent("*Sheds Tear*");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::SetExp(int exp) {
|
void Player::SetExp(int exp) {
|
||||||
|
@ -4,46 +4,46 @@
|
|||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
#include "../libUnuk/Engine/Character.h"
|
#include "../libUnuk/Engine/Character.h"
|
||||||
#include "../libUnuk//System/Debug.h"
|
#include "../libUnuk/System/Debug.h"
|
||||||
|
|
||||||
class Player : public Character {
|
class Player : public Character {
|
||||||
public:
|
public:
|
||||||
Player(LevelGen* mapArg);
|
Player(LevelGen* mapArg);
|
||||||
~Player(void);
|
~Player(void);
|
||||||
|
|
||||||
void HandleInput(void);
|
void HandleInput(void);
|
||||||
void Update(void);
|
void Update(void);
|
||||||
|
|
||||||
void SetName(string nameArg);
|
void SetName(string nameArg);
|
||||||
string GetName(void) { return _name; }
|
string GetName(void) { return _name; }
|
||||||
|
|
||||||
void SetLevel(int level);
|
void SetLevel(int level);
|
||||||
int GetLevel(void) { return _level; }
|
int GetLevel(void) { return _level; }
|
||||||
|
|
||||||
void SetExp(int exp);
|
void SetExp(int exp);
|
||||||
int GetExp(void) { return _exp; }
|
int GetExp(void) { return _exp; }
|
||||||
|
|
||||||
void SetLevelLiteral(int level) { _level = level; }
|
void SetLevelLiteral(int level) { _level = level; }
|
||||||
void SetExpLiteral(int exp) { _exp = exp; }
|
void SetExpLiteral(int exp) { _exp = exp; }
|
||||||
void SetHealthLiteral(int health) { _health = health; }
|
void SetHealthLiteral(int health) { _health = health; }
|
||||||
|
|
||||||
void SetXY(float xArg, float yArg) { x = xArg, y = yArg; _lastTileX = xArg / TILE_WIDTH; _lastTileY = yArg / TILE_HEIGHT; }
|
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 MAX_LEVEL = 20;
|
||||||
static const int EXP_TABLE[MAX_LEVEL];
|
static const int EXP_TABLE[MAX_LEVEL];
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Move(void);
|
void Move(void);
|
||||||
void CheckTileCollisions(void);
|
void CheckTileCollisions(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetCamera(void);
|
void SetCamera(void);
|
||||||
static const float PLAYER_SPEED;
|
static const float PLAYER_SPEED;
|
||||||
|
|
||||||
string _name;
|
string _name;
|
||||||
int _level;
|
int _level;
|
||||||
int _exp;
|
int _exp;
|
||||||
|
|
||||||
int _lastTileX;
|
int _lastTileX;
|
||||||
int _lastTileY;
|
int _lastTileY;
|
||||||
};
|
};
|
||||||
|
@ -9,72 +9,72 @@ ParticleEmitter::~ParticleEmitter(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ParticleEmitter::SetXY(int xArg, int yArg) {
|
void ParticleEmitter::SetXY(int xArg, int yArg) {
|
||||||
x = xArg;
|
x = xArg;
|
||||||
y = yArg;
|
y = yArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleEmitter::ForceXY(int xArg, int yArg) {
|
void ParticleEmitter::ForceXY(int xArg, int yArg) {
|
||||||
for(int i = 0; i < _particleCount; i++) {
|
for(int i = 0; i < _particleCount; i++) {
|
||||||
m_particle[i].x = (float)xArg;
|
m_particle[i].x = (float)xArg;
|
||||||
m_particle[i].y = (float)yArg;
|
m_particle[i].y = (float)yArg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleEmitter::SetParticleCount(int countArg) {
|
void ParticleEmitter::SetParticleCount(int countArg) {
|
||||||
_particleCount = countArg;
|
_particleCount = countArg;
|
||||||
m_particle.resize(_particleCount);
|
m_particle.resize(_particleCount);
|
||||||
|
|
||||||
for(int i = 0; i < _particleCount; i++) {
|
for(int i = 0; i < _particleCount; i++) {
|
||||||
m_particle[i].startTime = SDL_GetTicks();
|
m_particle[i].startTime = SDL_GetTicks();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleEmitter::SetParticleSpeed(float speedArg) {
|
void ParticleEmitter::SetParticleSpeed(float speedArg) {
|
||||||
_particleSpeed = speedArg;
|
_particleSpeed = speedArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleEmitter::SetParticleType(string typeArg) {
|
void ParticleEmitter::SetParticleType(string typeArg) {
|
||||||
if(!_particleTexture) {
|
if(!_particleTexture) {
|
||||||
SDL_FreeSurface(_particleTexture);
|
SDL_FreeSurface(_particleTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
string textureFilename = "../Data/Media/Images/Particles/" + typeArg + ".png";
|
string textureFilename = "../../Data/Media/Images/Particles/" + typeArg + ".png";
|
||||||
_particleTexture = LoadImageAlpha(textureFilename.c_str());
|
_particleTexture = LoadImageAlpha(textureFilename.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleEmitter::SetParticleLifetime(int lifetimeArg) {
|
void ParticleEmitter::SetParticleLifetime(int lifetimeArg) {
|
||||||
_particleLifetime = lifetimeArg;
|
_particleLifetime = lifetimeArg;
|
||||||
|
|
||||||
for(int i = 0; i < _particleCount; i++) {
|
for(int i = 0; i < _particleCount; i++) {
|
||||||
m_particle[i].lifetime = rand() % _particleLifetime + _particleLifetime / 4;
|
m_particle[i].lifetime = rand() % _particleLifetime + _particleLifetime / 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleEmitter::Render(void) {
|
void ParticleEmitter::Render(void) {
|
||||||
for(int i = 0; i < _particleCount; i++) {
|
for(int i = 0; i < _particleCount; i++) {
|
||||||
ApplySurface((int)m_particle[i].x, (int)m_particle[i].y, _particleTexture, screen);
|
ApplySurface((int)m_particle[i].x, (int)m_particle[i].y, _particleTexture, screen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleEmitter::Update(void) {
|
void ParticleEmitter::Update(void) {
|
||||||
for(int i = 0; i < _particleCount; i++) {
|
for(int i = 0; i < _particleCount; i++) {
|
||||||
if((int)SDL_GetTicks() - m_particle[i].startTime > m_particle[i].lifetime) {
|
if((int)SDL_GetTicks() - m_particle[i].startTime > m_particle[i].lifetime) {
|
||||||
// Reset the x and y coords.
|
// Reset the x and y coords.
|
||||||
m_particle[i].x = (float)x;
|
m_particle[i].x = (float)x;
|
||||||
m_particle[i].y = (float)y;
|
m_particle[i].y = (float)y;
|
||||||
|
|
||||||
m_particle[i].xVel = (float)(rand() % 360);
|
m_particle[i].xVel = (float)(rand() % 360);
|
||||||
m_particle[i].yVel = (float)(rand() % 360);
|
m_particle[i].yVel = (float)(rand() % 360);
|
||||||
|
|
||||||
if(rand() % 2)
|
if(rand() % 2)
|
||||||
m_particle[i].xVel = m_particle[i].xVel * -1.0f;
|
m_particle[i].xVel = m_particle[i].xVel * -1.0f;
|
||||||
if(rand() % 2)
|
if(rand() % 2)
|
||||||
m_particle[i].yVel = m_particle[i].yVel * -1.0f;
|
m_particle[i].yVel = m_particle[i].yVel * -1.0f;
|
||||||
|
|
||||||
m_particle[i].startTime = SDL_GetTicks();
|
m_particle[i].startTime = SDL_GetTicks();
|
||||||
} else {
|
} else {
|
||||||
m_particle[i].x += m_particle[i].xVel * _particleSpeed;
|
m_particle[i].x += m_particle[i].xVel * _particleSpeed;
|
||||||
m_particle[i].y += m_particle[i].yVel * _particleSpeed;
|
m_particle[i].y += m_particle[i].yVel * _particleSpeed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
17
src/libUnuk/Engine/Spells.cpp
Normal file
17
src/libUnuk/Engine/Spells.cpp
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#include "Spells.h"
|
||||||
|
|
||||||
|
Spells::Spells(void) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Spells::~Spells(void) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Spells::CastSpell() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Spells::Render(void) {
|
||||||
|
//_particle->Render();
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
#pragma once;
|
#pragma once
|
||||||
#include "../../Unuk/Player.h"
|
#include "../../Unuk/Player.h"
|
||||||
#include "../System/Timer.h"
|
#include "../System/Timer.h"
|
||||||
#include "ParticleEmitter.h"
|
#include "ParticleEmitter.h"
|
||||||
@ -13,9 +13,10 @@ public:
|
|||||||
ICE
|
ICE
|
||||||
};
|
};
|
||||||
|
|
||||||
void CastSpell(Player* player);
|
void CastSpell(/*Player* player*/);
|
||||||
|
void Render(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Timer* _timeBetweenCast;
|
Timer* _timeBetweenCast;
|
||||||
|
ParticleEmitter* _particle;
|
||||||
};
|
};
|
||||||
|
@ -187,7 +187,7 @@ void WorldManager::OnPlayerAttack(Player* player) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WorldManager::OnPlayerMove(Player* player) {
|
void WorldManager::OnPlayerMove(Player* player) {
|
||||||
for(std::list<NPC*>::iterator i = _npcs.begin(); i != _npcs.end(); ++i) {
|
for(std::list<NPC*>::iterator i = _npcs.begin(); i != _npcs.end(); ++i) {
|
||||||
(*i)->OnPlayerMove(player);
|
(*i)->OnPlayerMove(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <list>
|
#include <list>
|
||||||
#include "MemClass.h"
|
#include "MemClass.h"
|
||||||
|
|
||||||
class Character;
|
class Character;
|
||||||
class NPC;
|
class NPC;
|
||||||
class Player;
|
class Player;
|
||||||
|
Loading…
Reference in New Issue
Block a user