This commit is contained in:
2015-08-22 16:09:20 -07:00
parent 17207d8294
commit 98b3e75503
3 changed files with 11 additions and 12 deletions

View File

@@ -27,34 +27,32 @@ void Explorer::setDestination(sf::Vector2i destination_) {
bool Explorer::move() {
// While there are moves for us to take
if (!movement_stack.empty()) {
bool valid = false; // If the next move is valid, collision
int x = movement_stack.back();
switch (x) {
case 0:
break;
case 1: // North
case 0: // North
if (!map->getTile(position.x, position.y - 1)->isSolid()) {
valid = true;
position = sf::Vector2i(position.x, position.y - 1);
}
break;
case 2: // East
case 1: // East
if (!map->getTile(position.x + 1, position.y)->isSolid()) {
valid = true;
position = sf::Vector2i(position.x + 1, position.y);
}
break;
case 3: // South
case 2: // South
if (!map->getTile(position.x, position.y + 1)->isSolid()) {
valid = true;
position = sf::Vector2i(position.x, position.y + 1);
}
break;
case 4: // West
case 3: // West
if (!map->getTile(position.x - 1, position.y)->isSolid()) {
valid = true;
position = sf::Vector2i(position.x - 1, position.y);
@@ -74,6 +72,7 @@ bool Explorer::move() {
// If everything went well, pop and return true
movement_stack.pop_back();
return true;
}
else