Layering rendering now proper.
This commit is contained in:
+18
-1
@@ -65,12 +65,14 @@ bool Monster::SetX(float x){
|
||||
geom2d::rect<int>collisionRect=game->GetTileCollision(game->GetCurrentLevel(),newPos,upperLevel);
|
||||
if(collisionRect.pos==vi2d{0,0}&&collisionRect.size==vi2d{1,1}){
|
||||
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};
|
||||
collision.pos+=tilePos;
|
||||
if(!geom2d::overlaps(newPos,collision)){
|
||||
pos.x=std::clamp(x,12.f*GetSizeMult(),float(game->WORLD_SIZE.x*24-12*GetSizeMult()));
|
||||
Moved();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -82,12 +84,14 @@ bool Monster::SetY(float y){
|
||||
geom2d::rect<int>collisionRect=game->GetTileCollision(game->GetCurrentLevel(),newPos,upperLevel);
|
||||
if(collisionRect.pos==vi2d{0,0}&&collisionRect.size==vi2d{1,1}){
|
||||
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};
|
||||
collision.pos+=tilePos;
|
||||
if(!geom2d::overlaps(newPos,collision)){
|
||||
pos.y=std::clamp(y,12.f*GetSizeMult(),float(game->WORLD_SIZE.y*24-12*GetSizeMult()));
|
||||
Moved();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -155,7 +159,7 @@ bool Monster::Update(float fElapsedTime){
|
||||
if(queueShotTimer<0){
|
||||
queueShotTimer=0;
|
||||
{
|
||||
BULLET_LIST.push_back(std::make_unique<Bullet>(Bullet(pos + vf2d{ 0,-4 }, geom2d::line(pos + vf2d{ 0,-4 }, game->GetPlayer().GetPos()).vector().norm() * 24 * 3.f, 2, GetAttack(),false, { 75 / 2,162 / 2,225 / 2 })));
|
||||
BULLET_LIST.push_back(std::make_unique<Bullet>(Bullet(pos + vf2d{ 0,-4 }, geom2d::line(pos + vf2d{ 0,-4 }, game->GetPlayer().GetPos()).vector().norm() * 24 * 3.f, 2, GetAttack(),upperLevel,false, { 75 / 2,162 / 2,225 / 2 })));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -281,6 +285,19 @@ bool Monster::SetPosition(vf2d pos){
|
||||
}
|
||||
return resultX|resultY;
|
||||
}
|
||||
void Monster::Moved(){
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
AnimationState Monster::GetDeathAnimationName(){
|
||||
return MONSTER_DATA[type].GetDeathAnimation();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user