|
|
|
@ -426,8 +426,27 @@ void Crawler::HandleUserInput(float fElapsedTime){ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(player.GetVelocity()==vf2d{0,0}){ |
|
|
|
|
auto GetPlayerStaircaseDirection=[&](){ |
|
|
|
|
for(LayerTag&layer:MAP_DATA[GetCurrentLevel()].LayerData){ |
|
|
|
|
int truncatedPlayerX=int(player.GetX())/24; |
|
|
|
|
int truncatedPlayerY=int(player.GetY())/24; |
|
|
|
|
int tileID=layer.tiles[truncatedPlayerY][truncatedPlayerX]; |
|
|
|
|
TilesheetData dat=GetTileSheet(GetCurrentLevel(),tileID); |
|
|
|
|
if (dat.tileset.staircaseTiles.find(tileID)!=dat.tileset.staircaseTiles.end()){ |
|
|
|
|
return dat.tileset.staircaseTiles[tileID].data["value"];
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return std::string("NONE"); |
|
|
|
|
}; |
|
|
|
|
std::string staircaseDirection=GetPlayerStaircaseDirection(); |
|
|
|
|
if(RightHeld()){ |
|
|
|
|
player.SetX(player.GetX()+fElapsedTime*100*player.GetMoveSpdMult()); |
|
|
|
|
if(staircaseDirection=="RIGHT"){ |
|
|
|
|
player.SetY(player.GetY()-60*fElapsedTime*player.GetMoveSpdMult()); |
|
|
|
|
} else
|
|
|
|
|
if(staircaseDirection=="LEFT"){ |
|
|
|
|
player.SetY(player.GetY()+60*fElapsedTime*player.GetMoveSpdMult()); |
|
|
|
|
} |
|
|
|
|
player.SetFacingDirection(RIGHT); |
|
|
|
|
if(player.GetState()==State::NORMAL){ |
|
|
|
|
player.UpdateWalkingAnimation(RIGHT); |
|
|
|
@ -436,6 +455,12 @@ void Crawler::HandleUserInput(float fElapsedTime){ |
|
|
|
|
} |
|
|
|
|
if(LeftHeld()){ |
|
|
|
|
player.SetX(player.GetX()-fElapsedTime*100*player.GetMoveSpdMult()); |
|
|
|
|
if(staircaseDirection=="RIGHT"){ |
|
|
|
|
player.SetY(player.GetY()+60*fElapsedTime*player.GetMoveSpdMult()); |
|
|
|
|
} else
|
|
|
|
|
if(staircaseDirection=="LEFT"){ |
|
|
|
|
player.SetY(player.GetY()-60*fElapsedTime*player.GetMoveSpdMult()); |
|
|
|
|
} |
|
|
|
|
if(setIdleAnimation){ |
|
|
|
|
player.SetFacingDirection(LEFT); |
|
|
|
|
if(player.GetState()==State::NORMAL){ |
|
|
|
@ -956,6 +981,7 @@ void Crawler::InitializeLevel(std::string mapFile,MapName map){ |
|
|
|
|
MAP_TILESETS["assets/maps/"+baseSourceDir].foregroundTiles=tileset.GetData().ForegroundTileData; |
|
|
|
|
MAP_TILESETS["assets/maps/"+baseSourceDir].upperForegroundTiles=tileset.GetData().UpperForegroundTileData; |
|
|
|
|
MAP_TILESETS["assets/maps/"+baseSourceDir].collision=tileset.GetData().CollisionData; |
|
|
|
|
MAP_TILESETS["assets/maps/"+baseSourceDir].staircaseTiles=tileset.GetData().StaircaseData; |
|
|
|
|
r->Load("assets/maps/"+tileset.GetData().ImageData.data["source"]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|