Changed Character subclasses to not have config as parameter.
This commit is contained in:
parent
d9a5821e1a
commit
4067d351e5
8 changed files with 32 additions and 16 deletions
|
@ -28,7 +28,7 @@ Game::Game(sf::RenderWindow& window) :
|
|||
|
||||
mGenerator.generateTiles(sf::IntRect(-32, -32, 64, 64));
|
||||
mPlayer = std::shared_ptr<Player>(new Player(mWorld, mPathfinder,
|
||||
mGenerator.getPlayerSpawn(), Yaml("player.yaml")));
|
||||
mGenerator.getPlayerSpawn()));
|
||||
mWorld.insertCharacter(mPlayer);
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ Character::onThink(int elapsed) {
|
|||
*/
|
||||
void
|
||||
Character::onDeath() {
|
||||
mWorld.insert(std::shared_ptr<Sprite>(new Corpse(getPosition(), Yaml("body.yaml"))));
|
||||
mWorld.insert(std::shared_ptr<Sprite>(new Corpse(getPosition())));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,7 +7,11 @@
|
|||
|
||||
#include "Corpse.h"
|
||||
|
||||
Corpse::Corpse(const sf::Vector2f& position, const Yaml& config) :
|
||||
Sprite(Data(position, CATEGORY_NONSOLID, MASK_NONE), config) {
|
||||
#include "../util/Yaml.h"
|
||||
|
||||
const std::string Corpse::CONFIG = "corpse.yaml";
|
||||
|
||||
Corpse::Corpse(const sf::Vector2f& position) :
|
||||
Sprite(Data(position, CATEGORY_NONSOLID, MASK_NONE), Yaml(CONFIG)) {
|
||||
}
|
||||
|
||||
|
|
|
@ -10,11 +10,12 @@
|
|||
|
||||
#include "../abstract/Sprite.h"
|
||||
|
||||
class Yaml;
|
||||
|
||||
class Corpse : public Sprite {
|
||||
public:
|
||||
explicit Corpse(const sf::Vector2f& position, const Yaml& config);
|
||||
explicit Corpse(const sf::Vector2f& position);
|
||||
|
||||
private:
|
||||
static const std::string CONFIG;
|
||||
};
|
||||
|
||||
#endif /* DG_CORPSE_H_ */
|
||||
|
|
|
@ -9,10 +9,14 @@
|
|||
|
||||
#include <Thor/Vectors.hpp>
|
||||
|
||||
#include "../util/Yaml.h"
|
||||
|
||||
const std::string Enemy::CONFIG = "enemy.yaml";
|
||||
|
||||
Enemy::Enemy(World& world, Pathfinder& pathfinder,
|
||||
const sf::Vector2f& position, const Yaml& config) :
|
||||
const sf::Vector2f& position) :
|
||||
Character(world, pathfinder, Data(position, CATEGORY_ACTOR, MASK_ALL),
|
||||
config) {
|
||||
Yaml(CONFIG)) {
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -11,15 +11,17 @@
|
|||
#include "../abstract/Character.h"
|
||||
|
||||
class World;
|
||||
class Yaml;
|
||||
|
||||
class Enemy : public Character {
|
||||
public:
|
||||
explicit Enemy(World& world, Pathfinder& pathfinder,
|
||||
const sf::Vector2f& position, const Yaml& config);
|
||||
const sf::Vector2f& position);
|
||||
|
||||
protected:
|
||||
private:
|
||||
virtual void onThink(int elapsed);
|
||||
|
||||
private:
|
||||
static const std::string CONFIG;
|
||||
};
|
||||
|
||||
#endif /* DG_ENEMY_H_ */
|
||||
|
|
|
@ -9,13 +9,17 @@
|
|||
|
||||
#include <Thor/Vectors.hpp>
|
||||
|
||||
#include "../util/Yaml.h"
|
||||
|
||||
const std::string Player::CONFIG = "player.yaml";
|
||||
|
||||
/**
|
||||
* Initializes Sprite.
|
||||
*/
|
||||
Player::Player(World& world, Pathfinder& pathfinder,
|
||||
const sf::Vector2f& position, const Yaml& config) :
|
||||
const sf::Vector2f& position) :
|
||||
Character(world, pathfinder,
|
||||
Data(position, CATEGORY_ACTOR, MASK_ALL), config),
|
||||
Data(position, CATEGORY_ACTOR, MASK_ALL), Yaml(CONFIG)),
|
||||
mDirection(0) {
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
#include "../abstract/Character.h"
|
||||
|
||||
class Yaml;
|
||||
class World;
|
||||
|
||||
/**
|
||||
|
@ -30,7 +29,7 @@ public:
|
|||
|
||||
public:
|
||||
explicit Player(World& world, Pathfinder& pathfinder,
|
||||
const sf::Vector2f& position, const Yaml& config);
|
||||
const sf::Vector2f& position);
|
||||
|
||||
void setCrosshairPosition(const sf::Vector2f& position);
|
||||
void pullTrigger();
|
||||
|
@ -42,6 +41,8 @@ private:
|
|||
void onThink(int elapsed);
|
||||
|
||||
private:
|
||||
static const std::string CONFIG;
|
||||
|
||||
sf::Vector2f mCrosshairPosition; //< Relative position of the point to fire at (mouse cursor).
|
||||
unsigned char mDirection; //< Current movement direction for direct control.
|
||||
};
|
||||
|
|
Reference in a new issue