AreaHighlightTest branch created. Added test code for highlighting arbitrary areas via polygons within a map using optimization map rendering. Release Build 9561.

mac-build
sigonasr2 9 months ago
parent efcd3f0bf8
commit 27d0e16a94
  1. 5
      Adventures in Lestoria/Adventures in Lestoria.tiled-project
  2. 25
      Adventures in Lestoria/AdventuresInLestoria.cpp
  3. 1
      Adventures in Lestoria/State_GameRun.cpp
  4. 8
      Adventures in Lestoria/TMXParser.h
  5. 2
      Adventures in Lestoria/Version.h
  6. 1169
      Adventures in Lestoria/assets/Campaigns/Boss_2.tmx
  7. 2
      Adventures in Lestoria/assets/config/levels.txt
  8. BIN
      x64/Release/Adventures in Lestoria.exe

@ -330,6 +330,11 @@
"type": "string",
"value": "None"
},
{
"name": "Create Optimization Map (Override)",
"type": "bool",
"value": false
},
{
"name": "Dev Completion Time - Ranger (s)",
"type": "float",

@ -970,6 +970,23 @@ void AiL::RenderWorld(float fElapsedTime){
PopulateRenderLists();
auto RenderPlayer=[&](vf2d pos,vf2d scale){
if(GetCurrentMapData().provideOptimization){
std::vector<vf2d>points{
GetMousePos()-vf2d{50,50},
GetMousePos()+vf2d{100,-20},
GetMousePos()+vf2d{200,200},
GetMousePos()+vf2d{-50,150},
GetMousePos()+vf2d{-120,90},};
std::vector<vf2d>uvs;
std::transform(points.begin(),points.end(),std::back_inserter(uvs),[&](const vf2d&point){return view.ScreenToWorld(point)/GetCurrentMap().GetOptimizedMap()->Sprite()->Size();});
DrawPolygonDecal(GetCurrentMap().GetOptimizedMap()->Decal(),points,uvs);
SetDecalMode(DecalMode::WIREFRAME);
DrawPolygonDecal(nullptr,points,uvs,RED);
SetDecalMode(DecalMode::NORMAL);
}
if(player->IsInvisible())return;
vf2d playerScale=vf2d(player->GetSizeMult(),player->GetSizeMult());
int count=0;
@ -2217,7 +2234,7 @@ void AiL::InitializeLevel(std::string mapFile,MapName map){
}
}
if(MAP_DATA[map].MapData.optimized){
if(MAP_DATA[map].MapData.optimized||MAP_DATA[map].MapData.provideOptimization){
LOG("Generating optimized map for Map "<<map);
MAP_DATA[map].optimizedTile=NEW Renderable();
MAP_DATA[map].optimizedTile->Create(MAP_DATA[map].MapData.width*MAP_DATA[map].MapData.tilewidth,MAP_DATA[map].MapData.height*MAP_DATA[map].MapData.tileheight);
@ -2245,8 +2262,10 @@ void AiL::InitializeLevel(std::string mapFile,MapName map){
SetPixelMode(prevMode);
MAP_DATA[map].optimizedTile->Decal()->Update();
SetDrawTarget(nullptr);
LOG(" Clearing Layer Data...");
if(!MAP_DATA[map].MapData.provideOptimization){
MAP_DATA[map].LayerData.clear();
LOG(" Clearing Layer Data...");
}
}
}
@ -2732,7 +2751,7 @@ bool AiL::IsOverlayLayer(LayerTag&layer){
const geom2d::rect<float>AiL::GetTileCollision(MapName map,vf2d pos,bool upperLevel)const{
const MapTag&mapData=MAP_DATA.at(map).MapData;
if(pos.x<0||pos.y<0||pos.x>=mapData.width*mapData.tilewidth||pos.y>=mapData.height*mapData.tilewidth)return NO_COLLISION;
if(MAP_DATA.at(map).optimizedTile)return NO_COLLISION; //Overworld map has no collision.
if(GetCurrentMapData().optimized)return NO_COLLISION; //Overworld map has no collision.
bool hasTerrain=false;
for(const LayerTag&layer:MAP_DATA.at(map).LayerData){ //Figure out if any tile at this position is terrain. If so, we have a collision box to check.

@ -86,6 +86,7 @@ void State_GameRun::OnUserUpdate(AiL*game){
game->UpdateCamera(game->GetElapsedTime());
}
void State_GameRun::Draw(AiL*game){
game->SetWorldColor(DARK_BLUE);
game->RenderWorld(game->GetElapsedTime());
game->RenderHud();
Tutorial::Draw();

@ -76,6 +76,7 @@ struct MapTag{
int width=0,height=0;
int tilewidth=0,tileheight=0;
bool optimized=false; //An optimized map will require us to flatten it out and use it as a single tile.
bool provideOptimization=false; //An optimized map will require us to flatten it out and use it as a single tile.
vi2d playerSpawnLocation;
vi2d MapSize; //The number of tiles in width and height of this map.
vi2d TileSize; //How large in pixels the map's tiles are.
@ -150,6 +151,7 @@ public:
const std::string_view GetMapDisplayName()const;
const bool HasMoreSpawns()const; //Returns whether or not there are more spawns for the spawn controller.
const int Spawn_pop(); //Grabs the next spawn controller ID and removes it from the stack.
const Renderable const*GetOptimizedMap()const;
std::string FormatLayerData(std::ostream& os, std::vector<LayerTag>tiles);
std::string FormatSpawnerData(std::ostream& os, std::map<int,SpawnerTag>tiles);
friend std::ostream& operator << (std::ostream& os, Map& rhs);
@ -326,6 +328,9 @@ class TMXParser{
spawnControllerIDs.value().pop();
return nextSpawnId;
}
const Renderable const*Map::GetOptimizedMap()const{
return optimizedTile;
}
NPCData::NPCData(){}
NPCData::NPCData(XMLTag npcTag){
const std::array<std::string,7>tags={"Function","NPC Name","Roaming Range","Unlock Condition","Spritesheet","x","y"};
@ -487,6 +492,9 @@ class TMXParser{
if (newTag.tag=="property"&&newTag.data["name"]=="Optimize"&&newTag.data["value"]=="true") {
parsedMapInfo.MapData.optimized=true;
}else
if (newTag.tag=="property"&&newTag.data["name"]=="Create Optimization Map (Override)"&&newTag.data["value"]=="true") {
parsedMapInfo.MapData.provideOptimization=true;
}else
if (newTag.tag=="property"&&newTag.data["name"]=="Boss Title Display") {
parsedMapInfo.SpawnerData[prevSpawner].bossNameDisplay=newTag.data["value"];
}else

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1
#define VERSION_MINOR 2
#define VERSION_PATCH 3
#define VERSION_BUILD 9554
#define VERSION_BUILD 9561
#define stringify(a) stringify_(a)
#define stringify_(a) #a

File diff suppressed because it is too large Load Diff

@ -148,7 +148,7 @@ Levels
}
BOSS_2_B
{
Map File = Boss_2_B.tmx
Map File = Boss_2.tmx
# Specify item, min quantity, and max quantity of items. Optionally specify a % drop chance per item.
# Loot[0] = Berries, 1, 5, 100%
}

Loading…
Cancel
Save