|
|
|
@ -38,6 +38,7 @@ bool Player::SetX(float x){ |
|
|
|
|
#pragma endregion |
|
|
|
|
if(NoTileCollisionExistsHere()){ |
|
|
|
|
pos.x=std::clamp(x,12.f*GetSizeMult(),float(game->WORLD_SIZE.x*24-12*GetSizeMult())); |
|
|
|
|
Moved(); |
|
|
|
|
return true; |
|
|
|
|
} else { |
|
|
|
|
geom2d::rect<float>collision={collisionRect.pos,collisionRect.size}; |
|
|
|
@ -47,6 +48,7 @@ bool Player::SetX(float x){ |
|
|
|
|
collision.pos+=tilePos; |
|
|
|
|
if(NoPlayerCollisionWithTile()){ |
|
|
|
|
pos.x=std::clamp(x,12.f*GetSizeMult(),float(game->WORLD_SIZE.x*24-12*GetSizeMult())); |
|
|
|
|
Moved(); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -62,6 +64,7 @@ bool Player::SetY(float y){ |
|
|
|
|
#pragma endregion |
|
|
|
|
if(NoTileCollisionExistsHere()){ |
|
|
|
|
pos.y=std::clamp(y,12.f*GetSizeMult(),float(game->WORLD_SIZE.y*24-12*GetSizeMult())); |
|
|
|
|
Moved(); |
|
|
|
|
return true; |
|
|
|
|
} else { |
|
|
|
|
geom2d::rect<float>collision={collisionRect.pos,collisionRect.size}; |
|
|
|
@ -71,6 +74,7 @@ bool Player::SetY(float y){ |
|
|
|
|
collision.pos+=tilePos; |
|
|
|
|
if(NoPlayerCollisionWithTile()){ |
|
|
|
|
pos.y=std::clamp(y,12.f*GetSizeMult(),float(game->WORLD_SIZE.y*24-12*GetSizeMult())); |
|
|
|
|
Moved(); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -392,6 +396,17 @@ void Player::Moved(){ |
|
|
|
|
spawner.SetTriggered(true); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
ZoneData&zoneData=game->GetZoneData(game->GetCurrentLevel()); |
|
|
|
|
for(geom2d::rect<int>&upperLevelZone:zoneData["UpperZone"]){ |
|
|
|
|
if(geom2d::overlaps(upperLevelZone,pos)){ |
|
|
|
|
upperLevel=true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
for(geom2d::rect<int>&lowerLevelZone:zoneData["LowerZone"]){ |
|
|
|
|
if(geom2d::overlaps(lowerLevelZone,pos)){ |
|
|
|
|
upperLevel=false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
float Player::GetAbility2Cooldown(){ |
|
|
|
|