Fixed target initialization still using sf::Vector2i
Forgot to move manhattanDistance to .cpp
This commit is contained in:
parent
f7481f2bc9
commit
250a680cad
3 changed files with 9 additions and 7 deletions
|
@ -21,7 +21,7 @@ Entity::Entity(int x, int y, EntityType type, sf::Texture* texture, int width, i
|
||||||
|
|
||||||
currentState = State::Idle;
|
currentState = State::Idle;
|
||||||
nextState = State::Idle;
|
nextState = State::Idle;
|
||||||
target = sf::Vector2i(shape.getPosition());
|
target = pro_maat::GridPos(x,y);
|
||||||
nextTarget = target;
|
nextTarget = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,4 +36,11 @@ namespace pro_maat
|
||||||
window.display();
|
window.display();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float manhattanDistance(pro_maat::GridPos leftHandSide, pro_maat::GridPos rightHandSide)
|
||||||
|
{
|
||||||
|
// The *0.01 helps with breaking ties and minimizing exploration
|
||||||
|
// As per http://theory.stanford.edu/~amitp/GameProgramming/Heuristics.html#breaking-ties
|
||||||
|
return (std::abs(rightHandSide.first-leftHandSide.first)+std::abs(rightHandSide.second-leftHandSide.second))*1.01;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -23,12 +23,7 @@ static constexpr char fontFolder[] = "resources/";
|
||||||
void errorWindow(const std::string& error);
|
void errorWindow(const std::string& error);
|
||||||
|
|
||||||
// Good heuristic on 4-way grids
|
// Good heuristic on 4-way grids
|
||||||
double manhattanDistance(pro_maat::GridPos leftHandSide, pro_maat::GridPos rightHandSide)
|
float manhattanDistance(pro_maat::GridPos leftHandSide, pro_maat::GridPos rightHandSide);
|
||||||
{
|
|
||||||
// The *0.01 helps with breaking ties and minimizing exploration
|
|
||||||
// As per http://theory.stanford.edu/~amitp/GameProgramming/Heuristics.html#breaking-ties
|
|
||||||
return (std::abs(rightHandSide.first-leftHandSide.first)+std::abs(rightHandSide.second-leftHandSide.second))*1.01;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue