|
|
@ -39,9 +39,7 @@ bool Crawler::OnUserCreate(){ |
|
|
|
|
|
|
|
|
|
|
|
InitializeLevel("assets/Campaigns/1_1.tmx",CAMPAIGN_1_1); |
|
|
|
InitializeLevel("assets/Campaigns/1_1.tmx",CAMPAIGN_1_1); |
|
|
|
|
|
|
|
|
|
|
|
std::cout<<"Player loading."<<std::endl; |
|
|
|
|
|
|
|
player=std::make_unique<Warrior>(); |
|
|
|
player=std::make_unique<Warrior>(); |
|
|
|
std::cout<<"Player loaded."<<std::endl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Initialize Camera.
|
|
|
|
//Initialize Camera.
|
|
|
|
camera=Camera2D{WINDOW_SIZE}; |
|
|
|
camera=Camera2D{WINDOW_SIZE}; |
|
|
@ -50,7 +48,6 @@ bool Crawler::OnUserCreate(){ |
|
|
|
camera.SetWorldBoundary({0,0},WORLD_SIZE*24); |
|
|
|
camera.SetWorldBoundary({0,0},WORLD_SIZE*24); |
|
|
|
camera.EnableWorldBoundary(false); |
|
|
|
camera.EnableWorldBoundary(false); |
|
|
|
|
|
|
|
|
|
|
|
std::cout<<"Camera loaded."<<std::endl; |
|
|
|
|
|
|
|
//Graphics
|
|
|
|
//Graphics
|
|
|
|
GFX_Warrior_Sheet.Load("assets/nico-warrior.png"); |
|
|
|
GFX_Warrior_Sheet.Load("assets/nico-warrior.png"); |
|
|
|
GFX_Slime_Sheet.Load("assets/slime.png"); |
|
|
|
GFX_Slime_Sheet.Load("assets/slime.png"); |
|
|
@ -77,7 +74,6 @@ bool Crawler::OnUserCreate(){ |
|
|
|
GFX_ChainLightning.Load("assets/chain_lightning.png"); |
|
|
|
GFX_ChainLightning.Load("assets/chain_lightning.png"); |
|
|
|
GFX_LightningSplash.Load("assets/lightning_splash_effect.png"); |
|
|
|
GFX_LightningSplash.Load("assets/lightning_splash_effect.png"); |
|
|
|
GFX_Meteor.Load("assets/meteor.png"); |
|
|
|
GFX_Meteor.Load("assets/meteor.png"); |
|
|
|
std::cout<<"Images loaded."<<std::endl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Animations
|
|
|
|
//Animations
|
|
|
|
sig::Animation::InitializeAnimations(); |
|
|
|
sig::Animation::InitializeAnimations(); |
|
|
@ -86,9 +82,7 @@ bool Crawler::OnUserCreate(){ |
|
|
|
view=TileTransformedView{GetScreenSize(),{1,1}}; |
|
|
|
view=TileTransformedView{GetScreenSize(),{1,1}}; |
|
|
|
|
|
|
|
|
|
|
|
LoadLevel(CAMPAIGN_1_1); |
|
|
|
LoadLevel(CAMPAIGN_1_1); |
|
|
|
std::cout<<"Done Loading."<<std::endl; |
|
|
|
ChangePlayerClass(WARRIOR); |
|
|
|
//ChangePlayerClass(WARRIOR);
|
|
|
|
|
|
|
|
std::cout<<"Set player class."<<std::endl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
@ -753,7 +747,7 @@ void Crawler::SetupWorldShake(float duration){ |
|
|
|
|
|
|
|
|
|
|
|
void Crawler::InitializeLevel(std::string mapFile,MapName map){ |
|
|
|
void Crawler::InitializeLevel(std::string mapFile,MapName map){ |
|
|
|
TMXParser level(mapFile); |
|
|
|
TMXParser level(mapFile); |
|
|
|
std::cout<<"Done parsing."<<std::endl; |
|
|
|
|
|
|
|
size_t slashMarker = mapFile.find_last_of('/'); |
|
|
|
size_t slashMarker = mapFile.find_last_of('/'); |
|
|
|
std::string baseDir=mapFile.substr(0,slashMarker+1); |
|
|
|
std::string baseDir=mapFile.substr(0,slashMarker+1); |
|
|
|
MAP_DATA[map]=level.GetData(); |
|
|
|
MAP_DATA[map]=level.GetData(); |
|
|
@ -762,7 +756,6 @@ void Crawler::InitializeLevel(std::string mapFile,MapName map){ |
|
|
|
std::string baseSourceDir=tag.data["source"].substr(slashMarkerSourceDir+1); |
|
|
|
std::string baseSourceDir=tag.data["source"].substr(slashMarkerSourceDir+1); |
|
|
|
if(MAP_TILESETS.find("assets/maps/"+baseSourceDir)==MAP_TILESETS.end()){ |
|
|
|
if(MAP_TILESETS.find("assets/maps/"+baseSourceDir)==MAP_TILESETS.end()){ |
|
|
|
TSXParser tileset(baseDir+tag.data["source"]); |
|
|
|
TSXParser tileset(baseDir+tag.data["source"]); |
|
|
|
std::cout<<"Done parsing tex. "<<std::endl; |
|
|
|
|
|
|
|
Renderable*r=new Renderable(); |
|
|
|
Renderable*r=new Renderable(); |
|
|
|
MAP_TILESETS["assets/maps/"+baseSourceDir].tileset=r; |
|
|
|
MAP_TILESETS["assets/maps/"+baseSourceDir].tileset=r; |
|
|
|
MAP_TILESETS["assets/maps/"+baseSourceDir].foregroundTiles=tileset.GetData().ForegroundTileData; |
|
|
|
MAP_TILESETS["assets/maps/"+baseSourceDir].foregroundTiles=tileset.GetData().ForegroundTileData; |
|
|
@ -770,10 +763,8 @@ void Crawler::InitializeLevel(std::string mapFile,MapName map){ |
|
|
|
MAP_TILESETS["assets/maps/"+baseSourceDir].collision=tileset.GetData().CollisionData; |
|
|
|
MAP_TILESETS["assets/maps/"+baseSourceDir].collision=tileset.GetData().CollisionData; |
|
|
|
MAP_TILESETS["assets/maps/"+baseSourceDir].staircaseTiles=tileset.GetData().StaircaseData; |
|
|
|
MAP_TILESETS["assets/maps/"+baseSourceDir].staircaseTiles=tileset.GetData().StaircaseData; |
|
|
|
r->Load("assets/maps/"+tileset.GetData().ImageData.data["source"]); |
|
|
|
r->Load("assets/maps/"+tileset.GetData().ImageData.data["source"]); |
|
|
|
std::cout<<"Done loading. "<<std::endl; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
std::cout<<"Function done. "<<std::endl; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Crawler::LoadLevel(MapName map){ |
|
|
|
void Crawler::LoadLevel(MapName map){ |
|
|
@ -781,7 +772,7 @@ void Crawler::LoadLevel(MapName map){ |
|
|
|
foregroundTileGroups.clear(); |
|
|
|
foregroundTileGroups.clear(); |
|
|
|
currentLevel=map; |
|
|
|
currentLevel=map; |
|
|
|
WORLD_SIZE={MAP_DATA[map].MapData.width,MAP_DATA[map].MapData.height}; |
|
|
|
WORLD_SIZE={MAP_DATA[map].MapData.width,MAP_DATA[map].MapData.height}; |
|
|
|
std::cout<<"Setup world size."<<std::endl; |
|
|
|
|
|
|
|
for(auto key:MAP_DATA[map].SpawnerData){ |
|
|
|
for(auto key:MAP_DATA[map].SpawnerData){ |
|
|
|
SpawnerTag&spawnData=MAP_DATA[map].SpawnerData[key.first]; |
|
|
|
SpawnerTag&spawnData=MAP_DATA[map].SpawnerData[key.first]; |
|
|
|
std::vector<std::pair<MonsterName,vf2d>>monster_list; |
|
|
|
std::vector<std::pair<MonsterName,vf2d>>monster_list; |
|
|
@ -795,7 +786,7 @@ void Crawler::LoadLevel(MapName map){ |
|
|
|
} |
|
|
|
} |
|
|
|
SPAWNER_LIST.push_back(MonsterSpawner{{spawnData.ObjectData.GetFloat("x"),spawnData.ObjectData.GetFloat("y")},spawnerRadius*2,monster_list,spawnData.upperLevel}); |
|
|
|
SPAWNER_LIST.push_back(MonsterSpawner{{spawnData.ObjectData.GetFloat("x"),spawnData.ObjectData.GetFloat("y")},spawnerRadius*2,monster_list,spawnData.upperLevel}); |
|
|
|
} |
|
|
|
} |
|
|
|
std::cout<<"Spawner lists done."<<std::endl; |
|
|
|
|
|
|
|
std::set<vi2d>foregroundTilesAdded,upperForegroundTilesAdded; |
|
|
|
std::set<vi2d>foregroundTilesAdded,upperForegroundTilesAdded; |
|
|
|
for(int x=0;x<WORLD_SIZE.x;x++){ |
|
|
|
for(int x=0;x<WORLD_SIZE.x;x++){ |
|
|
|
for(int y=0;y<WORLD_SIZE.y;y++){ |
|
|
|
for(int y=0;y<WORLD_SIZE.y;y++){ |
|
|
@ -877,7 +868,7 @@ void Crawler::LoadLevel(MapName map){ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
std::cout<<"Done preparing tilesheet reads"<<std::endl; |
|
|
|
|
|
|
|
int counter=0; |
|
|
|
int counter=0; |
|
|
|
bridgeLayerIndex=-1; |
|
|
|
bridgeLayerIndex=-1; |
|
|
|
for(LayerTag&layer:MAP_DATA[map].LayerData){ |
|
|
|
for(LayerTag&layer:MAP_DATA[map].LayerData){ |
|
|
@ -886,10 +877,10 @@ void Crawler::LoadLevel(MapName map){ |
|
|
|
} |
|
|
|
} |
|
|
|
counter++; |
|
|
|
counter++; |
|
|
|
} |
|
|
|
} |
|
|
|
std::cout<<"Bridge Layer indexing done."<<std::endl; |
|
|
|
|
|
|
|
player->upperLevel=false; //Assume player starts on lower level.
|
|
|
|
player->upperLevel=false; //Assume player starts on lower level.
|
|
|
|
player->SetPos(MAP_DATA[map].MapData.playerSpawnLocation); |
|
|
|
player->SetPos(MAP_DATA[map].MapData.playerSpawnLocation); |
|
|
|
std::cout<<"Player spawn info set."<<std::endl; |
|
|
|
|
|
|
|
pathfinder.Initialize(); |
|
|
|
pathfinder.Initialize(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -982,24 +973,26 @@ std::map<std::string,std::vector<geom2d::rect<int>>>&Crawler::GetZoneData(MapNam |
|
|
|
void Crawler::ChangePlayerClass(Class cl){ |
|
|
|
void Crawler::ChangePlayerClass(Class cl){ |
|
|
|
switch(cl){ |
|
|
|
switch(cl){ |
|
|
|
case WARRIOR:{ |
|
|
|
case WARRIOR:{ |
|
|
|
player.reset(new Warrior()); |
|
|
|
player.reset(new Warrior(player.get())); |
|
|
|
}break; |
|
|
|
}break; |
|
|
|
case THIEF:{ |
|
|
|
case THIEF:{ |
|
|
|
player.reset(new Thief()); |
|
|
|
player.reset(new Thief(player.get())); |
|
|
|
}break; |
|
|
|
}break; |
|
|
|
case TRAPPER:{ |
|
|
|
case TRAPPER:{ |
|
|
|
player.reset(new Trapper()); |
|
|
|
player.reset(new Trapper(player.get())); |
|
|
|
}break; |
|
|
|
}break; |
|
|
|
case RANGER:{ |
|
|
|
case RANGER:{ |
|
|
|
player.reset(new Ranger()); |
|
|
|
player.reset(new Ranger(player.get())); |
|
|
|
}break; |
|
|
|
}break; |
|
|
|
case WIZARD:{ |
|
|
|
case WIZARD:{ |
|
|
|
player.reset(new Wizard()); |
|
|
|
player.reset(new Wizard(player.get())); |
|
|
|
}break; |
|
|
|
}break; |
|
|
|
case WITCH:{ |
|
|
|
case WITCH:{ |
|
|
|
player.reset(new Witch()); |
|
|
|
player.reset(new Witch(player.get())); |
|
|
|
}break; |
|
|
|
}break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
sig::Animation::SetupPlayerAnimations(); |
|
|
|
|
|
|
|
GetPlayer()->InitializeClassAbilities(); |
|
|
|
GetPlayer()->UpdateIdleAnimation(DOWN); |
|
|
|
GetPlayer()->UpdateIdleAnimation(DOWN); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|