|
|
@ -199,7 +199,8 @@ bool Player::_SetX(float x,MoveFlag::MoveFlag flags,const bool playerInvoked){ |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
}else |
|
|
|
}else |
|
|
|
if(playerInvoked){ //If player invoked, we'll try the smart move system.
|
|
|
|
if(playerInvoked){ //If player invoked, we'll try the smart move system.
|
|
|
|
vf2d pushDir=geom2d::line<float>(collision.middle(),pos).vector().norm(); |
|
|
|
vf2d pushDir=vf2d{1.f,util::random(2*PI)}.cart(); |
|
|
|
|
|
|
|
if(collision.middle()!=pos)pushDir=geom2d::line<float>(collision.middle(),pos).vector().norm(); |
|
|
|
newPos={newPos.x,pos.y+pushDir.y*12}; |
|
|
|
newPos={newPos.x,pos.y+pushDir.y*12}; |
|
|
|
if(NoPlayerCollisionWithTile()){ |
|
|
|
if(NoPlayerCollisionWithTile()){ |
|
|
|
return _SetY(pos.y+pushDir.y*game->GetElapsedTime()*12,flags,false); |
|
|
|
return _SetY(pos.y+pushDir.y*game->GetElapsedTime()*12,flags,false); |
|
|
@ -232,7 +233,8 @@ bool Player::_SetY(float y,MoveFlag::MoveFlag flags,const bool playerInvoked){ |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
}else |
|
|
|
}else |
|
|
|
if(playerInvoked){ //If player invoked, we'll try the smart move system.{
|
|
|
|
if(playerInvoked){ //If player invoked, we'll try the smart move system.{
|
|
|
|
vf2d pushDir=geom2d::line<float>(collision.middle(),pos).vector().norm(); |
|
|
|
vf2d pushDir=vf2d{1.f,util::random(2*PI)}.cart(); |
|
|
|
|
|
|
|
if(collision.middle()!=pos)geom2d::line<float>(collision.middle(),pos).vector().norm(); |
|
|
|
newPos={pos.x+pushDir.x*12,newPos.y}; |
|
|
|
newPos={pos.x+pushDir.x*12,newPos.y}; |
|
|
|
if(NoPlayerCollisionWithTile()){ |
|
|
|
if(NoPlayerCollisionWithTile()){ |
|
|
|
return _SetX(pos.x+pushDir.x*game->GetElapsedTime()*12,flags,false); |
|
|
|
return _SetX(pos.x+pushDir.x*game->GetElapsedTime()*12,flags,false); |
|
|
|