Works
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user