Added an end zone ring graphic.

pull/28/head
sigonasr2 1 year ago
parent ce3be8b05d
commit eeb24934a3
  1. 42
      Crawler/Crawler.cpp
  2. 3
      Crawler/Crawler.h
  3. 5
      Crawler/Crawler.tiled-project
  4. 10
      Crawler/Monster.cpp
  5. 10
      Crawler/Player.cpp
  6. 31
      Crawler/TMXParser.h
  7. 2
      Crawler/Version.h
  8. 10
      Crawler/assets/Campaigns/1_1_v2.tmx
  9. 1
      Crawler/assets/config/gfx/gfx.txt
  10. BIN
      Crawler/assets/finishring.png

@ -550,6 +550,8 @@ void Crawler::PopulateRenderLists(){
backgroundEffectsUpper.clear(); backgroundEffectsUpper.clear();
foregroundEffectsLower.clear(); foregroundEffectsLower.clear();
foregroundEffectsUpper.clear(); foregroundEffectsUpper.clear();
endZones.clear();
upperEndZones.clear();
tilePreparationList.clear(); tilePreparationList.clear();
tileForegroundList.clear(); tileForegroundList.clear();
@ -595,6 +597,15 @@ void Crawler::PopulateRenderLists(){
backgroundEffectsLower.push_back(e); backgroundEffectsLower.push_back(e);
} }
} }
for(ZoneData&zone:MAP_DATA[GetCurrentLevel()].ZoneData["EndZone"]){
if(zone.isUpper){
upperEndZones.push_back(zone);
}else{
endZones.push_back(zone);
}
}
std::sort(monstersBeforeUpper.begin(),monstersBeforeUpper.end(),[](Monster*m1,Monster*m2){return m1->GetPos().y<m2->GetPos().y;}); std::sort(monstersBeforeUpper.begin(),monstersBeforeUpper.end(),[](Monster*m1,Monster*m2){return m1->GetPos().y<m2->GetPos().y;});
std::sort(monstersBeforeLower.begin(),monstersBeforeLower.end(),[](Monster*m1,Monster*m2){return m1->GetPos().y<m2->GetPos().y;}); std::sort(monstersBeforeLower.begin(),monstersBeforeLower.end(),[](Monster*m1,Monster*m2){return m1->GetPos().y<m2->GetPos().y;});
std::sort(monstersAfterUpper.begin(),monstersAfterUpper.end(),[](Monster*m1,Monster*m2){return m1->GetPos().y<m2->GetPos().y;}); std::sort(monstersAfterUpper.begin(),monstersAfterUpper.end(),[](Monster*m1,Monster*m2){return m1->GetPos().y<m2->GetPos().y;});
@ -652,6 +663,12 @@ void Crawler::RenderWorld(float fElapsedTime){
} }
}; };
auto RenderZone=[&](geom2d::rect<int>&zone){
game->SetDecalMode(DecalMode::ADDITIVE);
view.DrawDecal(zone.pos,GFX["finishring.png"].Decal(),vf2d(zone.size)/vf2d(GFX["finishring.png"].Sprite()->Size()),{255,255,255,uint8_t(abs(sin(game->levelTime))*255)});
game->SetDecalMode(DecalMode::NORMAL);
};
enum class RenderMode{ enum class RenderMode{
REFLECTIVE_TILES, REFLECTIVE_TILES,
NORMAL_TILES, NORMAL_TILES,
@ -785,6 +802,9 @@ void Crawler::RenderWorld(float fElapsedTime){
for(Effect*e:backgroundEffectsLower){ for(Effect*e:backgroundEffectsLower){
e->rendered=false; e->rendered=false;
} }
for(ZoneData&zone:endZones){
RenderZone(zone.zone);
}
for(Monster*m:monstersBeforeLower){ for(Monster*m:monstersBeforeLower){
m->Draw(); m->Draw();
} }
@ -933,6 +953,9 @@ void Crawler::RenderWorld(float fElapsedTime){
for(Effect*e:backgroundEffectsUpper){ for(Effect*e:backgroundEffectsUpper){
e->rendered=false; e->rendered=false;
} }
for(ZoneData&zone:upperEndZones){
RenderZone(zone.zone);
}
for(Monster*m:monstersBeforeUpper){ for(Monster*m:monstersBeforeUpper){
m->Draw(); m->Draw();
} }
@ -1288,14 +1311,13 @@ void Crawler::LoadLevel(MapName map){
return zoneSet.second; return zoneSet.second;
} }
} }
return std::vector<geom2d::rect<int>>{}; return std::vector<ZoneData>{};
}; };
for(ZoneData&zone:GetUpperZones()){
for(geom2d::rect<int>&zone:GetUpperZones()){ int zoneX=zone.zone.pos.x/game->GetCurrentMap().tilewidth; //snap to grid
int zoneX=zone.pos.x/game->GetCurrentMap().tilewidth; //snap to grid int zoneY=zone.zone.pos.y/game->GetCurrentMap().tilewidth;
int zoneY=zone.pos.y/game->GetCurrentMap().tilewidth; int zoneW=zone.zone.right().start.x/game->GetCurrentMap().tilewidth-zoneX;
int zoneW=zone.right().start.x/game->GetCurrentMap().tilewidth-zoneX; int zoneH=zone.zone.bottom().start.y/game->GetCurrentMap().tilewidth-zoneY;
int zoneH=zone.bottom().start.y/game->GetCurrentMap().tilewidth-zoneY;
for(int x=zoneX;x<zoneX+zoneW;x++){ for(int x=zoneX;x<zoneX+zoneW;x++){
for(int y=zoneY;y<zoneY+zoneH;y++){ for(int y=zoneY;y<zoneY+zoneH;y++){
for(LayerTag&layer:MAP_DATA[map].LayerData){ for(LayerTag&layer:MAP_DATA[map].LayerData){
@ -1460,8 +1482,8 @@ geom2d::rect<int>Crawler::GetTileCollision(MapName map,vf2d pos,bool upperLevel)
if(pos.x<0||pos.y<0||pos.x>=GetCurrentMap().width*game->GetCurrentMap().tilewidth||pos.y>=GetCurrentMap().height*game->GetCurrentMap().tilewidth)return NO_COLLISION; if(pos.x<0||pos.y<0||pos.x>=GetCurrentMap().width*game->GetCurrentMap().tilewidth||pos.y>=GetCurrentMap().height*game->GetCurrentMap().tilewidth)return NO_COLLISION;
#pragma region Lower Bridge Collision Check #pragma region Lower Bridge Collision Check
if(!upperLevel){ //We are looking for lower bridge collisions. if(!upperLevel){ //We are looking for lower bridge collisions.
for(geom2d::rect<int>&zone:MAP_DATA[map].ZoneData["LowerBridgeCollision"]){ for(ZoneData&zone:MAP_DATA[map].ZoneData["LowerBridgeCollision"]){
if(geom2d::contains(zone,pos)){ if(geom2d::contains(zone.zone,pos)){
return {{0,0},{game->GetCurrentMap().tilewidth,game->GetCurrentMap().tilewidth}}; return {{0,0},{game->GetCurrentMap().tilewidth,game->GetCurrentMap().tilewidth}};
} }
} }
@ -1505,7 +1527,7 @@ MapName Crawler::GetCurrentLevel(){
return currentLevel; return currentLevel;
} }
std::map<std::string,std::vector<geom2d::rect<int>>>&Crawler::GetZoneData(MapName map){ std::map<std::string,std::vector<ZoneData>>&Crawler::GetZoneData(MapName map){
return MAP_DATA[map].ZoneData; return MAP_DATA[map].ZoneData;
} }

@ -63,6 +63,7 @@ public:
private: private:
std::vector<std::unique_ptr<Effect>>foregroundEffects,backgroundEffects,foregroundEffectsToBeInserted,backgroundEffectsToBeInserted; std::vector<std::unique_ptr<Effect>>foregroundEffects,backgroundEffects,foregroundEffectsToBeInserted,backgroundEffectsToBeInserted;
std::vector<TileRenderData*>tilePreparationList,tileForegroundList; std::vector<TileRenderData*>tilePreparationList,tileForegroundList;
std::vector<ZoneData>endZones,upperEndZones;
std::vector<vf2d>circleCooldownPoints; std::vector<vf2d>circleCooldownPoints;
std::map<std::string,TilesetData>MAP_TILESETS; std::map<std::string,TilesetData>MAP_TILESETS;
vf2d worldShake={}; vf2d worldShake={};
@ -139,7 +140,7 @@ public:
bool HasTileCollision(MapName map,vf2d pos,bool upperLevel=false); bool HasTileCollision(MapName map,vf2d pos,bool upperLevel=false);
MapName GetCurrentLevel(); MapName GetCurrentLevel();
bool IsBridgeLayer(LayerTag&layer); bool IsBridgeLayer(LayerTag&layer);
std::map<std::string,std::vector<geom2d::rect<int>>>&GetZoneData(MapName map); std::map<std::string,std::vector<ZoneData>>&GetZoneData(MapName map);
void PopulateRenderLists(); void PopulateRenderLists();
void ChangePlayerClass(Class cl); void ChangePlayerClass(Class cl);
std::string GetString(std::string key); std::string GetString(std::string key);

@ -66,6 +66,11 @@
"drawFill": true, "drawFill": true,
"id": 23, "id": 23,
"members": [ "members": [
{
"name": "Upper?",
"type": "bool",
"value": false
}
], ],
"name": "EndZone", "name": "EndZone",
"type": "class", "type": "class",

@ -257,14 +257,14 @@ bool Monster::SetPos(vf2d pos){
return resultX|resultY; return resultX|resultY;
} }
void Monster::Moved(){ void Monster::Moved(){
ZoneData&zoneData=game->GetZoneData(game->GetCurrentLevel()); std::map<std::string,std::vector<ZoneData>>&zoneData=game->GetZoneData(game->GetCurrentLevel());
for(geom2d::rect<int>&upperLevelZone:zoneData["UpperZone"]){ for(ZoneData&upperLevelZone:zoneData["UpperZone"]){
if(geom2d::overlaps(upperLevelZone,pos)){ if(geom2d::overlaps(upperLevelZone.zone,pos)){
upperLevel=true; upperLevel=true;
} }
} }
for(geom2d::rect<int>&lowerLevelZone:zoneData["LowerZone"]){ for(ZoneData&lowerLevelZone:zoneData["LowerZone"]){
if(geom2d::overlaps(lowerLevelZone,pos)){ if(geom2d::overlaps(lowerLevelZone.zone,pos)){
upperLevel=false; upperLevel=false;
} }
} }

@ -604,14 +604,14 @@ void Player::Moved(){
spawner.SetTriggered(true); spawner.SetTriggered(true);
} }
} }
ZoneData&zoneData=game->GetZoneData(game->GetCurrentLevel()); std::map<std::string,std::vector<ZoneData>>&zoneData=game->GetZoneData(game->GetCurrentLevel());
for(geom2d::rect<int>&upperLevelZone:zoneData["UpperZone"]){ for(ZoneData&upperLevelZone:zoneData["UpperZone"]){
if(geom2d::overlaps(upperLevelZone,pos)){ if(geom2d::overlaps(upperLevelZone.zone,pos)){
upperLevel=true; upperLevel=true;
} }
} }
for(geom2d::rect<int>&lowerLevelZone:zoneData["LowerZone"]){ for(ZoneData&lowerLevelZone:zoneData["LowerZone"]){
if(geom2d::overlaps(lowerLevelZone,pos)){ if(geom2d::overlaps(lowerLevelZone.zone,pos)){
upperLevel=false; upperLevel=false;
} }
} }

@ -76,6 +76,11 @@ struct SpawnerTag{
friend std::ostream& operator << (std::ostream& os, SpawnerTag& rhs); friend std::ostream& operator << (std::ostream& os, SpawnerTag& rhs);
}; };
struct ZoneData{
geom2d::rect<int>zone;
bool isUpper=false;
};
struct Map{ struct Map{
MapTag MapData; MapTag MapData;
std::string name; std::string name;
@ -85,7 +90,7 @@ struct Map{
std::string mapType=""; std::string mapType="";
std::set<int>spawns; std::set<int>spawns;
std::map<int,SpawnerTag> SpawnerData; //Spawn groups have IDs, mobs associate which spawner they are tied to via this ID. std::map<int,SpawnerTag> SpawnerData; //Spawn groups have IDs, mobs associate which spawner they are tied to via this ID.
std::map<std::string,std::vector<geom2d::rect<int>>> ZoneData; std::map<std::string,std::vector<ZoneData>> ZoneData;
std::string FormatLayerData(std::ostream& os, std::vector<LayerTag>tiles); std::string FormatLayerData(std::ostream& os, std::vector<LayerTag>tiles);
std::string FormatSpawnerData(std::ostream& os, std::map<int,SpawnerTag>tiles); std::string FormatSpawnerData(std::ostream& os, std::map<int,SpawnerTag>tiles);
friend std::ostream& operator << (std::ostream& os, Map& rhs); friend std::ostream& operator << (std::ostream& os, Map& rhs);
@ -114,6 +119,7 @@ class TMXParser{
bool buildingSpawner=false; bool buildingSpawner=false;
SpawnerTag obj; SpawnerTag obj;
int prevSpawner; int prevSpawner;
ZoneData*prevZoneData=nullptr;
void ParseTag(std::string tag); void ParseTag(std::string tag);
int monsterPropertyTagCount=-1; int monsterPropertyTagCount=-1;
XMLTag monsterTag; XMLTag monsterTag;
@ -126,7 +132,6 @@ class TMXParser{
TMXParser(std::string file); TMXParser(std::string file);
}; };
typedef std::map<std::string,std::vector<geom2d::rect<int>>> ZoneData;
//#define TMX_PARSER_SETUP //Toggle for code-writing. //#define TMX_PARSER_SETUP //Toggle for code-writing.
#ifdef TMX_PARSER_SETUP #ifdef TMX_PARSER_SETUP
@ -161,7 +166,7 @@ typedef std::map<std::string,std::vector<geom2d::rect<int>>> ZoneData;
return std::stod(data[dataTag]); return std::stod(data[dataTag]);
} }
bool XMLTag::GetBool(std::string dataTag) { bool XMLTag::GetBool(std::string dataTag) {
if (data[dataTag]=="0") { if (data[dataTag]=="0"||data[dataTag]=="false") {
return false; return false;
} else { } else {
return true; return true;
@ -315,6 +320,9 @@ typedef std::map<std::string,std::vector<geom2d::rect<int>>> ZoneData;
prevSpawner=newTag.GetInteger("id"); prevSpawner=newTag.GetInteger("id");
} }
} else } else
if(newTag.tag=="property"&&newTag.data["name"]=="Upper?"&&prevZoneData!=nullptr){
prevZoneData->isUpper=newTag.GetBool("value");
}else
if (newTag.tag=="property"&&newTag.data["name"]=="Optimize"&&newTag.data["value"]=="true") { if (newTag.tag=="property"&&newTag.data["name"]=="Optimize"&&newTag.data["value"]=="true") {
parsedMapInfo.MapData.optimized=true; parsedMapInfo.MapData.optimized=true;
} else } else
@ -357,12 +365,13 @@ typedef std::map<std::string,std::vector<geom2d::rect<int>>> ZoneData;
if (newTag.tag=="object"&&newTag.data.find("type")!=newTag.data.end()){ if (newTag.tag=="object"&&newTag.data.find("type")!=newTag.data.end()){
//This is an object with a type that doesn't fit into other categories, we can add it to ZoneData. //This is an object with a type that doesn't fit into other categories, we can add it to ZoneData.
if(parsedMapInfo.ZoneData.find(newTag.data["type"])!=parsedMapInfo.ZoneData.end()){ if(parsedMapInfo.ZoneData.find(newTag.data["type"])!=parsedMapInfo.ZoneData.end()){
std::vector<geom2d::rect<int>>&zones=parsedMapInfo.ZoneData[newTag.data["type"]]; std::vector<ZoneData>&zones=parsedMapInfo.ZoneData.at(newTag.data["type"]);
zones.push_back({{newTag.GetInteger("x"),newTag.GetInteger("y")},{newTag.GetInteger("width"),newTag.GetInteger("height")}}); zones.emplace_back(geom2d::rect<int>{{newTag.GetInteger("x"),newTag.GetInteger("y")},{newTag.GetInteger("width"),newTag.GetInteger("height")}});
prevZoneData=&zones.back();
} else { } else {
std::vector<geom2d::rect<int>>zones; std::vector<ZoneData>&zones=parsedMapInfo.ZoneData[newTag.data["type"]];
zones.push_back({{newTag.GetInteger("x"),newTag.GetInteger("y")},{newTag.GetInteger("width"),newTag.GetInteger("height")}}); zones.emplace_back(geom2d::rect<int>{{newTag.GetInteger("x"),newTag.GetInteger("y")},{newTag.GetInteger("width"),newTag.GetInteger("height")}});
parsedMapInfo.ZoneData[newTag.data["type"]]=zones; prevZoneData=&zones.back();
} }
}else{ }else{
if(_DEBUG_MAP_LOAD_INFO)std::cout<<"Unsupported tag format! Ignoring."<<"\n"; if(_DEBUG_MAP_LOAD_INFO)std::cout<<"Unsupported tag format! Ignoring."<<"\n";
@ -423,9 +432,9 @@ typedef std::map<std::string,std::vector<geom2d::rect<int>>> ZoneData;
SpawnerTag&spawner=spawnerData.second; SpawnerTag&spawner=spawnerData.second;
for(auto&zoneData:parsedMapInfo.ZoneData){ for(auto&zoneData:parsedMapInfo.ZoneData){
if(zoneData.first=="UpperZone"){ if(zoneData.first=="UpperZone"){
std::vector<geom2d::rect<int>>&zones=zoneData.second; std::vector<ZoneData>&zones=zoneData.second;
for(geom2d::rect<int>&zone:zones){ for(ZoneData&zone:zones){
if(geom2d::overlaps(zone,geom2d::rect<int>{{spawner.ObjectData.GetInteger("x"),spawner.ObjectData.GetInteger("y")},{spawner.ObjectData.GetInteger("width"),spawner.ObjectData.GetInteger("height")}})){ if(geom2d::overlaps(zone.zone,geom2d::rect<int>{{spawner.ObjectData.GetInteger("x"),spawner.ObjectData.GetInteger("y")},{spawner.ObjectData.GetInteger("width"),spawner.ObjectData.GetInteger("height")}})){
spawner.upperLevel=true; spawner.upperLevel=true;
goto continueSpawnerLoop; goto continueSpawnerLoop;
} }

@ -33,7 +33,7 @@ SUCH DAMAGE.
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 2 #define VERSION_MINOR 2
#define VERSION_PATCH 1 #define VERSION_PATCH 1
#define VERSION_BUILD 2886 #define VERSION_BUILD 2903
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.10.1" class="Map" orientation="orthogonal" renderorder="right-down" width="205" height="205" tilewidth="24" tileheight="24" infinite="0" backgroundcolor="#475500" nextlayerid="9" nextobjectid="139"> <map version="1.10" tiledversion="1.10.1" class="Map" orientation="orthogonal" renderorder="right-down" width="205" height="205" tilewidth="24" tileheight="24" infinite="0" backgroundcolor="#475500" nextlayerid="9" nextobjectid="140">
<properties> <properties>
<property name="Level Type" propertytype="LevelType" value="Dungeon"/> <property name="Level Type" propertytype="LevelType" value="Dungeon"/>
</properties> </properties>
@ -1269,7 +1269,11 @@
<object id="122" type="LowerBridgeCollision" x="4032" y="2232" width="24" height="144"/> <object id="122" type="LowerBridgeCollision" x="4032" y="2232" width="24" height="144"/>
<object id="123" name="Upper Zone" type="UpperZone" x="4056" y="1938" width="816" height="780"/> <object id="123" name="Upper Zone" type="UpperZone" x="4056" y="1938" width="816" height="780"/>
<object id="124" name="Upper Zone" type="UpperZone" x="4176" y="1848" width="534" height="90"/> <object id="124" name="Upper Zone" type="UpperZone" x="4176" y="1848" width="534" height="90"/>
<object id="138" name="End Zone" type="EndZone" x="4728" y="2184" width="192" height="168"/> <object id="138" name="End Zone" type="EndZone" x="4728" y="2184" width="192" height="168">
<properties>
<property name="Upper?" type="bool" value="true"/>
</properties>
</object>
</objectgroup> </objectgroup>
<objectgroup id="5" name="Spawn Groups"> <objectgroup id="5" name="Spawn Groups">
<object id="2" name="Spawn Group 1" type="SpawnGroup" x="870" y="4008" width="558.667" height="576"> <object id="2" name="Spawn Group 1" type="SpawnGroup" x="870" y="4008" width="558.667" height="576">
@ -1965,6 +1969,6 @@
</properties> </properties>
<point/> <point/>
</object> </object>
<object id="137" name="Player Spawn" type="PlayerSpawnLocation" x="624" y="4248" width="24" height="24"/> <object id="137" name="Player Spawn" type="PlayerSpawnLocation" x="4812" y="2274" width="24" height="24"/>
</objectgroup> </objectgroup>
</map> </map>

@ -38,6 +38,7 @@ Images
GFX_SlimeKing_Cast = monsters/Slime King - Cast.png GFX_SlimeKing_Cast = monsters/Slime King - Cast.png
GFX_SkillOverlayIcon = skill_overlay_icon.png GFX_SkillOverlayIcon = skill_overlay_icon.png
GFX_SkillOverlayIconOverlay = skill_overlay_icon_overlay.png GFX_SkillOverlayIconOverlay = skill_overlay_icon_overlay.png
GFX_FinishRing = finishring.png
# Ability Icons # Ability Icons
GFX_Warrior_BattleCry_Icon = Ability Icons/battlecry.png GFX_Warrior_BattleCry_Icon = Ability Icons/battlecry.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Loading…
Cancel
Save