Fix player spawn locations being a whole tile off. Change map background scrolling to not be fixed, but to utilize the entire image across the span of a map. Add a foreground background layer to provide 2 potential parallax backgrounds. Release Build 9091.

pull/57/head
sigonasr2 10 months ago
parent 00b18355c1
commit 76c1396fec
  1. 4
      Adventures in Lestoria/Adventures in Lestoria.tiled-project
  2. 32
      Adventures in Lestoria/AdventuresInLestoria.cpp
  3. 1
      Adventures in Lestoria/DEFINES.h
  4. 1
      Adventures in Lestoria/Map.cpp
  5. 1
      Adventures in Lestoria/Monster.cpp
  6. 2
      Adventures in Lestoria/TMXParser.h
  7. 2
      Adventures in Lestoria/Version.h
  8. 6
      Adventures in Lestoria/assets/Campaigns/2_1.tmx
  9. 8
      Adventures in Lestoria/assets/config/gfx/backdrops.txt
  10. BIN
      Adventures in Lestoria/assets/gamepack.pak
  11. BIN
      x64/Release/Adventures in Lestoria.exe

@ -36,7 +36,9 @@
"type": "enum", "type": "enum",
"values": [ "values": [
"None", "None",
"forest" "forest",
"mountain_day",
"mountain_night"
], ],
"valuesAsFlags": false "valuesAsFlags": false
}, },

@ -85,6 +85,7 @@ All rights reserved.
INCLUDE_EMITTER_LIST INCLUDE_EMITTER_LIST
INCLUDE_ITEM_CATEGORIES INCLUDE_ITEM_CATEGORIES
INCLUDE_BACKDROP_DATA INCLUDE_BACKDROP_DATA
INCLUDE_FOREDROP_DATA
INCLUDE_MONSTER_DATA INCLUDE_MONSTER_DATA
INCLUDE_PACK_KEY INCLUDE_PACK_KEY
@ -1037,8 +1038,26 @@ void AiL::RenderWorld(float fElapsedTime){
} }
#pragma region Basic Tile Layer Rendering #pragma region Basic Tile Layer Rendering
const MapTag&currentMap=GetCurrentMapData();
vf2d backgroundToMapRatio;
vf2d backgroundExcessAmount;
vf2d backgroundSize;
vf2d foregroundExcessAmount;
vf2d foregroundSize;
vf2d foregroundToMapRatio;
const vf2d mapPixelSize=currentMap.MapSize*currentMap.TileSize;
if(GetCurrentMap().backdrop.length()>0){ if(GetCurrentMap().backdrop.length()>0){
DrawPartialDecal({0,0},WINDOW_SIZE,BACKDROP_DATA[GetCurrentMap().backdrop].Decal(),"Backdrop Config.Speed Ratio"_F*-camera.GetPosition()+view.GetWorldOffset(),WINDOW_SIZE); backgroundSize=BACKDROP_DATA[GetCurrentMap().backdrop].Sprite()->Size();
backgroundExcessAmount=backgroundSize-vf2d(WINDOW_SIZE); //Extends outside the boundaries of the screen. Essentially the background size minus the size of the screen and take half to get the amount that extends in any one direction.
backgroundToMapRatio=1-(backgroundExcessAmount/mapPixelSize); //Expected range is from -half map size to +half map size.
DrawPartialDecal({},BACKDROP_DATA[GetCurrentMap().backdrop].Decal(),backgroundToMapRatio*-camera.GetPosition()+view.GetWorldOffset()+WINDOW_SIZE/2,WINDOW_SIZE);
if(FOREDROP_DATA.count(GetCurrentMap().backdrop)){
foregroundSize=FOREDROP_DATA[GetCurrentMap().backdrop].Sprite()->Size();
foregroundExcessAmount=foregroundSize-vf2d(WINDOW_SIZE); //Extends outside the boundaries of the screen. Essentially the background size minus the size of the screen and take half to get the amount that extends in any one direction.
foregroundToMapRatio=1-(foregroundExcessAmount/mapPixelSize);
DrawPartialDecal({},FOREDROP_DATA[GetCurrentMap().backdrop].Decal(),foregroundToMapRatio*-camera.GetPosition()+view.GetWorldOffset()+WINDOW_SIZE/2,WINDOW_SIZE);
}
}else{ }else{
FillRectDecal({0,0},GetScreenSize(),{100,180,100}); FillRectDecal({0,0},GetScreenSize(),{100,180,100});
} }
@ -1144,7 +1163,8 @@ void AiL::RenderWorld(float fElapsedTime){
#pragma region Render Backdrop #pragma region Render Backdrop
if(GetCurrentMap().backdrop.length()>0){ if(GetCurrentMap().backdrop.length()>0){
vf2d tileWorldPos=vi2d{x,y}*GetCurrentMapData().tilewidth; vf2d tileWorldPos=vi2d{x,y}*GetCurrentMapData().tilewidth;
view.DrawPartialDecal(tileWorldPos,{float(GetCurrentMapData().tilewidth),float(GetCurrentMapData().tilewidth)},BACKDROP_DATA[GetCurrentMap().backdrop].Decal(),"Backdrop Config.Speed Ratio"_F*-camera.GetPosition()+tileWorldPos,{float(GetCurrentMapData().tilewidth),float(GetCurrentMapData().tilewidth)}); view.DrawPartialDecal(tileWorldPos,{float(GetCurrentMapData().tilewidth),float(GetCurrentMapData().tilewidth)},BACKDROP_DATA[GetCurrentMap().backdrop].Decal(),backgroundToMapRatio*-camera.GetPosition()+tileWorldPos+WINDOW_SIZE/2,{float(GetCurrentMapData().tilewidth),float(GetCurrentMapData().tilewidth)});
if(FOREDROP_DATA.count(GetCurrentMap().backdrop))view.DrawPartialDecal(tileWorldPos,{float(GetCurrentMapData().tilewidth),float(GetCurrentMapData().tilewidth)},FOREDROP_DATA[GetCurrentMap().backdrop].Decal(),foregroundToMapRatio*-camera.GetPosition()+tileWorldPos+WINDOW_SIZE/2,{float(GetCurrentMapData().tilewidth),float(GetCurrentMapData().tilewidth)});
}else{ }else{
view.FillRectDecal(vi2d{x,y}*GetCurrentMapData().tilewidth,{float(GetCurrentMapData().tilewidth),float(GetCurrentMapData().tilewidth)},{100,180,100}); view.FillRectDecal(vi2d{x,y}*GetCurrentMapData().tilewidth,{float(GetCurrentMapData().tilewidth),float(GetCurrentMapData().tilewidth)},{100,180,100});
} }
@ -1174,7 +1194,8 @@ void AiL::RenderWorld(float fElapsedTime){
}else{ }else{
if(GetCurrentMap().backdrop.length()>0){ if(GetCurrentMap().backdrop.length()>0){
vf2d tileWorldPos=vi2d{x,y}*GetCurrentMapData().tilewidth; vf2d tileWorldPos=vi2d{x,y}*GetCurrentMapData().tilewidth;
view.DrawPartialDecal(tileWorldPos,{float(GetCurrentMapData().tilewidth),float(GetCurrentMapData().tilewidth)},BACKDROP_DATA[GetCurrentMap().backdrop].Decal(),"Backdrop Config.Speed Ratio"_F*-camera.GetPosition()+tileWorldPos,{float(GetCurrentMapData().tilewidth),float(GetCurrentMapData().tilewidth)}); view.DrawPartialDecal(tileWorldPos,{float(GetCurrentMapData().tilewidth),float(GetCurrentMapData().tilewidth)},BACKDROP_DATA[GetCurrentMap().backdrop].Decal(),backgroundToMapRatio*-camera.GetPosition()+tileWorldPos+WINDOW_SIZE/2,{float(GetCurrentMapData().tilewidth),float(GetCurrentMapData().tilewidth)});
if(FOREDROP_DATA.count(GetCurrentMap().backdrop))view.DrawPartialDecal(tileWorldPos,{float(GetCurrentMapData().tilewidth),float(GetCurrentMapData().tilewidth)},FOREDROP_DATA[GetCurrentMap().backdrop].Decal(),foregroundToMapRatio*-camera.GetPosition()+tileWorldPos+WINDOW_SIZE/2,{float(GetCurrentMapData().tilewidth),float(GetCurrentMapData().tilewidth)});
}else{ }else{
view.FillRectDecal(vi2d{x,y}*GetCurrentMapData().tilewidth,{float(GetCurrentMapData().tilewidth),float(GetCurrentMapData().tilewidth)},{100,180,100}); view.FillRectDecal(vi2d{x,y}*GetCurrentMapData().tilewidth,{float(GetCurrentMapData().tilewidth),float(GetCurrentMapData().tilewidth)},{100,180,100});
} }
@ -3008,6 +3029,7 @@ bool AiL::OnUserDestroy(){
delete value; delete value;
} }
BACKDROP_DATA.clear(); BACKDROP_DATA.clear();
FOREDROP_DATA.clear();
return true; return true;
}else{ }else{
return false; //Something is preventing us from quitting. We wait patiently... return false; //Something is preventing us from quitting. We wait patiently...
@ -3047,6 +3069,10 @@ void AiL::InitializeLevels(){
Renderable&backdrop=BACKDROP_DATA[key]; Renderable&backdrop=BACKDROP_DATA[key];
LoadResource(backdrop,"backdrop_directory"_S+DATA["Backdrops"][key].GetString(),false,false); LoadResource(backdrop,"backdrop_directory"_S+DATA["Backdrops"][key].GetString(),false,false);
} }
for(auto&[key,size]:DATA["Foredrops"]){
Renderable&backdrop=FOREDROP_DATA[key];
LoadResource(backdrop,"backdrop_directory"_S+DATA["Foredrops"][key].GetString(),false,false);
}
Test::RunMapTests(); Test::RunMapTests();
} }

@ -62,6 +62,7 @@ using BackdropName=std::string;
#define INCLUDE_PACK_KEY extern std::string PACK_KEY; #define INCLUDE_PACK_KEY extern std::string PACK_KEY;
#define INCLUDE_BACKDROP_DATA extern std::map<BackdropName,Renderable>BACKDROP_DATA; #define INCLUDE_BACKDROP_DATA extern std::map<BackdropName,Renderable>BACKDROP_DATA;
#define INCLUDE_FOREDROP_DATA extern std::map<BackdropName,Renderable>FOREDROP_DATA;
#define INCLUDE_CENTERED extern const vf2d Menu::CENTERED; #define INCLUDE_CENTERED extern const vf2d Menu::CENTERED;

@ -46,6 +46,7 @@ using BackdropName=std::string;
float TileGroup::FADE_TIME=0.3f; float TileGroup::FADE_TIME=0.3f;
uint8_t TileGroup::FADE_AMT=160; uint8_t TileGroup::FADE_AMT=160;
std::map<BackdropName,Renderable>BACKDROP_DATA; std::map<BackdropName,Renderable>BACKDROP_DATA;
std::map<BackdropName,Renderable>FOREDROP_DATA;
Map&MapHelper::MapFromString(std::string mapName){ Map&MapHelper::MapFromString(std::string mapName){
return game->MAP_DATA.at(mapName); return game->MAP_DATA.at(mapName);

@ -886,4 +886,5 @@ const Direction Monster::GetFacingDirectionToTarget(vf2d target)const{
else if(targetDirection>=-3*PI/4&&targetDirection<-PI/4)return Direction::NORTH; else if(targetDirection>=-3*PI/4&&targetDirection<-PI/4)return Direction::NORTH;
ERR(std::format("WARNING! Target direction {} did not result in a proper facing direction!! THIS SHOULD NOT BE HAPPENING!",targetDirection)); ERR(std::format("WARNING! Target direction {} did not result in a proper facing direction!! THIS SHOULD NOT BE HAPPENING!",targetDirection));
return Direction::NORTH;
} }

@ -507,7 +507,7 @@ class TMXParser{
float height=1.f; float height=1.f;
if(newTag.data.count("width")>0)width=newTag.GetFloat("width"); if(newTag.data.count("width")>0)width=newTag.GetFloat("width");
if(newTag.data.count("height")>0)height=newTag.GetFloat("height"); if(newTag.data.count("height")>0)height=newTag.GetFloat("height");
parsedMapInfo.MapData.playerSpawnLocation={int(newTag.GetFloat("x")-width/2),int(newTag.GetFloat("y")-height/2)}; parsedMapInfo.MapData.playerSpawnLocation={int(newTag.GetFloat("x")+width/2),int(newTag.GetFloat("y")+height/2)};
}else }else
if (newTag.tag=="object"&&newTag.data["type"]=="NPC") { if (newTag.tag=="object"&&newTag.data["type"]=="NPC") {
if(inNPCTag)parsedMapInfo.npcs.push_back(NPCData{npcTag}); if(inNPCTag)parsedMapInfo.npcs.push_back(NPCData{npcTag});

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1 #define VERSION_MAJOR 1
#define VERSION_MINOR 2 #define VERSION_MINOR 2
#define VERSION_PATCH 0 #define VERSION_PATCH 0
#define VERSION_BUILD 9037 #define VERSION_BUILD 9091
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.10.2" class="Map" orientation="orthogonal" renderorder="right-down" width="238" height="369" tilewidth="24" tileheight="24" infinite="0" nextlayerid="7" nextobjectid="20"> <map version="1.10" tiledversion="1.10.2" class="Map" orientation="orthogonal" renderorder="right-down" width="238" height="369" tilewidth="24" tileheight="24" infinite="0" nextlayerid="7" nextobjectid="27">
<properties> <properties>
<property name="Backdrop" propertytype="Backdrop" value="None"/> <property name="Backdrop" propertytype="Backdrop" value="mountain_day"/>
<property name="Background Music" propertytype="BGM" value="foresty1_1"/> <property name="Background Music" propertytype="BGM" value="foresty1_1"/>
<property name="Level Type" propertytype="LevelType" value="Dungeon"/> <property name="Level Type" propertytype="LevelType" value="Dungeon"/>
</properties> </properties>
@ -1876,7 +1876,6 @@
</data> </data>
</layer> </layer>
<objectgroup id="5" name="Spawn Zones"> <objectgroup id="5" name="Spawn Zones">
<object id="1" name="Player Spawn" type="PlayerSpawnLocation" x="5112" y="8064" width="24" height="24"/>
<object id="2" name="Time Trial Clock" type="TrialClock" x="5112" y="8016" width="24" height="24"/> <object id="2" name="Time Trial Clock" type="TrialClock" x="5112" y="8016" width="24" height="24"/>
<object id="5" name="End Ring" type="EndZone" x="3349" y="165" width="145" height="145"/> <object id="5" name="End Ring" type="EndZone" x="3349" y="165" width="145" height="145"/>
<object id="15" name="Spawn Group 1" type="SpawnGroup" x="4439" y="7869" width="496" height="424"> <object id="15" name="Spawn Group 1" type="SpawnGroup" x="4439" y="7869" width="496" height="424">
@ -1897,5 +1896,6 @@
<property name="spawner" type="object" value="15"/> <property name="spawner" type="object" value="15"/>
</properties> </properties>
</object> </object>
<object id="26" name="Player Spawn" type="PlayerSpawnLocation" x="265" y="1848" width="24" height="24"/>
</objectgroup> </objectgroup>
</map> </map>

@ -1,10 +1,12 @@
Backdrops Backdrops
{ {
forest = forest_backdrop.png forest = forest_backdrop.png
mountain_day = commercial_assets/Mountain Range Day.png
mountain_night = commercial_assets/Mountain Range Night.png
} }
Backdrop Config Foredrops
{ {
# Amount to move per pixel of actual world space. mountain_day = commercial_assets/Mountain Range Day Foreground.png
Speed Ratio = 0.125 mountain_night = commercial_assets/Mountain Range Night Foreground.png
} }
Loading…
Cancel
Save