Fixed player path finding, made Character::move() private.

This commit is contained in:
Felix Ableitner 2013-04-25 21:57:37 +02:00
parent 0b792295f7
commit d585a82ada
3 changed files with 9 additions and 8 deletions

View file

@ -60,7 +60,7 @@ Character::onDamage(int damage) {
}
/**
* Implement this function for any (regular) AI computations.
* Implement this function for any (periodical) AI computations.
* If overwritten, this function should always be called from the overwriting function.
*
* @param elapsed Amount of time to simulate.
@ -68,6 +68,7 @@ Character::onDamage(int damage) {
void
Character::onThink(int elapsed) {
mWeapon->onThink(elapsed);
move();
}
/**
@ -127,7 +128,7 @@ Character::setDestination(const sf::Vector2f& destination) {
/**
* Move towards a destination. Call setDestination() for setting the destination.
* This should be called from think() if path finding is to be used.
* This is automatically called from onThink().
*/
void
Character::move() {

View file

@ -33,11 +33,13 @@ protected:
void pullTrigger();
void releaseTrigger();
bool setDestination(const sf::Vector2f& destination);
void move();
bool isMoving() const;
bool isVisible(const sf::Vector2f& target) const;
std::vector<std::shared_ptr<Character> > getCharacters() const;
private:
void move();
private:
static const std::string KEY_HEALTH;
static const int DEFAULT_HEALTH;

View file

@ -34,9 +34,7 @@ Enemy::onThink(int elapsed) {
setDirection(target->getPosition() - getPosition());
pullTrigger();
}
else if (isMoving())
move();
else
else if (!isMoving())
setDestination(target->getPosition());
}
else