Zones caused the player to swap between upper and lower levels.

pull/28/head
sigonasr2 2 years ago
parent b2a5f3fbfe
commit 69fac079f7
  1. 9
      Crawler/Crawler.cpp
  2. 1
      Crawler/Crawler.h
  3. 15
      Crawler/Player.cpp
  4. 5
      Crawler/TMXParser.h
  5. 2
      Crawler/Version.h
  6. 11271
      Crawler/pge.data
  7. 2
      Crawler/pge.js
  8. BIN
      Crawler/pge.wasm

@ -32,8 +32,6 @@ Crawler::Crawler()
bool Crawler::OnUserCreate(){
InitializeLevel("assets/maps/Level1.tmx",LEVEL1);
InitializeLevel("assets/maps/Level2.tmx",LEVEL2);
InitializeLevel("assets/Campaigns/1_1_test.tmx",CAMPAIGN_1_1);
ClassData::InitializeClassData();
@ -592,9 +590,6 @@ void Crawler::HandleUserInput(float fElapsedTime){
player.UpdateIdleAnimation(DOWN);
}
}
} else {
//We have moved.
player.Moved();
}
}
@ -1108,6 +1103,10 @@ MapName Crawler::GetCurrentLevel(){
return currentLevel;
}
std::map<std::string,std::vector<geom2d::rect<int>>>&Crawler::GetZoneData(MapName map){
return MAP_DATA[map].ZoneData;
}
int main()
{
Crawler demo;

@ -85,4 +85,5 @@ public:
bool HasTileCollision(MapName map,vf2d pos,bool upperLevel=false);
MapName GetCurrentLevel();
bool IsBridgeLayer(LayerTag&layer);
std::map<std::string,std::vector<geom2d::rect<int>>>&GetZoneData(MapName map);
};

@ -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(){

@ -59,6 +59,9 @@ class TMXParser{
public:
TMXParser(std::string file);
};
typedef std::map<std::string,std::vector<geom2d::rect<int>>> ZoneData;
#ifdef TMX_PARSER_SETUP
#undef TMX_PARSER_SETUP
const std::string XMLTag::FormatTagData(std::map<std::string,std::string>tiles){
@ -224,7 +227,7 @@ class TMXParser{
zones.push_back({{newTag.GetInteger("x"),newTag.GetInteger("y")},{newTag.GetInteger("width"),newTag.GetInteger("height")}});
parsedMapInfo.ZoneData[newTag.data["type"]]=zones;
}
}
}else
if (newTag.tag=="property"&&buildingSpawner) {
if(newTag.data["propertytype"]=="MonsterName"){
obj.properties.push_back(newTag);

@ -2,7 +2,7 @@
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 0
#define VERSION_BUILD 492
#define VERSION_BUILD 498
#define stringify(a) stringify_(a)
#define stringify_(a) #a

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

Binary file not shown.
Loading…
Cancel
Save