In the current code, the first couple of if statements (Unit.cpp, lines
80-92 will be ignored as result will get overwritten by remainder of the
function. You get some odd results like those attached.
I think all it should need is to combine the two outermost ifs with an &&
and stick in an else or two
ie something like
===
if (this->getPosition().y - this->getType().dimensionUp() <=
unit->getPosition().y + unit->getType().dimensionDown()
&& (this->getPosition().y + this->getType().dimensionDown() >=
unit->getPosition().y - unit->getType().dimensionUp())
if (this->getPosition().x > unit->getPosition().x)
result = this->getPosition().x - this->getType().dimensionLeft()
- unit->getPosition().x - unit->getType().dimensionRight();
else
result = unit->getPosition().x - unit->getType().dimensionRight()
- this->getPosition().x - this->getType().dimensionLeft();
else if (this->getPosition().x - this->getType().dimensionLeft() <=
unit->getPosition().x + unit->getType().dimensionRight()
&& (this->getPosition().x + this->getType().dimensionRight() >=
unit->getPosition().x - unit->getType().dimensionLeft())
if (this->getPosition().y > unit->getPosition().y)
result = this->getPosition().y - this->getType().dimensionUp() -
unit->getPosition().y - unit->getType().dimensionDown();
else
result = unit->getPosition().y - unit->getType().dimensionDown()
- this->getPosition().y - this->getType().dimensionUp();
else if (this->getPosition().x > unit->getPosition().x)
...
Original issue reported on code.google.com by danielst...@gmail.com on 30 Dec 2009 at 8:18
Original issue reported on code.google.com by
danielst...@gmail.com
on 30 Dec 2009 at 8:18Attachments: