Implement map tile repeating factors and implement animated blocked off map region animation frames. Release Build 8917.

mac-build
sigonasr2 8 months ago
parent 5b35ca5c52
commit 188f2f28b2
  1. 26
      Adventures in Lestoria/Adventures in Lestoria.tiled-project
  2. 33
      Adventures in Lestoria/AdventuresInLestoria.cpp
  3. 9
      Adventures in Lestoria/Map.h
  4. 19
      Adventures in Lestoria/TSXParser.h
  5. 2
      Adventures in Lestoria/Version.h
  6. BIN
      Adventures in Lestoria/assets/gamepack.pak
  7. BIN
      Adventures in Lestoria/assets/maps/chapter2-props.png
  8. 14
      Adventures in Lestoria/assets/maps/objects.tsx
  9. BIN
      x64/Release/Adventures in Lestoria.exe

@ -7,6 +7,8 @@
"folders": [
"."
],
"properties": [
],
"propertyTypes": [
{
"color": "#ff3af8eb",
@ -90,6 +92,30 @@
"layer"
]
},
{
"color": "#ffa0a0a4",
"drawFill": true,
"id": 41,
"members": [
{
"name": "TileRepeatFactor X",
"type": "int",
"value": 1
},
{
"name": "TileRepeatFactor Y",
"type": "int",
"value": 1
}
],
"name": "CustomTile",
"type": "class",
"useAs": [
"property",
"tile",
"project"
]
},
{
"color": "#ffbdc34c",
"drawFill": true,

@ -940,9 +940,21 @@ void AiL::RenderTile(vi2d pos,TilesheetData tileSheet,int tileSheetIndex,vi2d ti
int tileSheetWidth=tileSheet.tileset->tileset->Sprite()->width/tileSheet.tileset->tilewidth;
int tileSheetX=animatedIndex%tileSheetWidth;
int tileSheetY=animatedIndex/tileSheetWidth;
view.DrawPartialDecal(pos*game->GetCurrentMapData().tilewidth,{float(tileSheet.tileset->tilewidth),float(tileSheet.tileset->tileheight)},tileSheet.tileset->tileset->Decal(),vi2d{tileSheetX,tileSheetY}*tileSheet.tileset->tilewidth,{float(tileSheet.tileset->tilewidth),float(tileSheet.tileset->tileheight)},tempCol);
if(tileSheet.tileset->tileRepeatData.count(tileSheetIndex)){
for(int y=0;y<tileSheet.tileset->tileRepeatData[tileSheetIndex].y;y++){
for(int x=0;x<tileSheet.tileset->tileRepeatData[tileSheetIndex].x;x++){
view.DrawPartialDecal(pos*game->GetCurrentMapData().tilewidth+vf2d{float(x),float(y)}*game->GetCurrentMapData().tilewidth/vf2d{tileSheet.tileset->tileRepeatData[tileSheetIndex]},vf2d{float(tileSheet.tileset->tilewidth),float(tileSheet.tileset->tileheight)}/vf2d{tileSheet.tileset->tileRepeatData[tileSheetIndex]},tileSheet.tileset->tileset->Decal(),vi2d{tileSheetX,tileSheetY}*tileSheet.tileset->tilewidth,{float(tileSheet.tileset->tilewidth),float(tileSheet.tileset->tileheight)},tempCol);
}
}
}else view.DrawPartialDecal(pos*game->GetCurrentMapData().tilewidth,{float(tileSheet.tileset->tilewidth),float(tileSheet.tileset->tileheight)},tileSheet.tileset->tileset->Decal(),vi2d{tileSheetX,tileSheetY}*tileSheet.tileset->tilewidth,{float(tileSheet.tileset->tilewidth),float(tileSheet.tileset->tileheight)},tempCol);
}else{
view.DrawPartialDecal(pos*game->GetCurrentMapData().tilewidth,{float(tileSheet.tileset->tilewidth),float(tileSheet.tileset->tileheight)},tileSheet.tileset->tileset->Decal(),tileSheetPos*tileSheet.tileset->tilewidth,{float(tileSheet.tileset->tilewidth),float(tileSheet.tileset->tileheight)},tempCol);
if(tileSheet.tileset->tileRepeatData.count(tileSheetIndex)){
for(int y=0;y<tileSheet.tileset->tileRepeatData[tileSheetIndex].y;y++){
for(int x=0;x<tileSheet.tileset->tileRepeatData[tileSheetIndex].x;x++){
view.DrawPartialDecal(pos*game->GetCurrentMapData().tilewidth+vi2d{x,y}*game->GetCurrentMapData().tilewidth/tileSheet.tileset->tileRepeatData[tileSheetIndex],{float(tileSheet.tileset->tilewidth),float(tileSheet.tileset->tileheight)},tileSheet.tileset->tileset->Decal(),tileSheetPos*tileSheet.tileset->tilewidth,vf2d{float(tileSheet.tileset->tilewidth),float(tileSheet.tileset->tileheight)}/tileSheet.tileset->tileRepeatData[tileSheetIndex],tempCol);
}
}
}else view.DrawPartialDecal(pos*game->GetCurrentMapData().tilewidth,{float(tileSheet.tileset->tilewidth),float(tileSheet.tileset->tileheight)},tileSheet.tileset->tileset->Decal(),tileSheetPos*tileSheet.tileset->tilewidth,{float(tileSheet.tileset->tilewidth),float(tileSheet.tileset->tileheight)},tempCol);
}
}
@ -953,9 +965,21 @@ void AiL::RenderTile(TileRenderData&tileSheet,Pixel col){
int tileSheetWidth=tileSheet.tileSheet.tileset->tileset->Sprite()->width/tileSheet.tileSheet.tileset->tilewidth;
int tileSheetX=animatedIndex%tileSheetWidth;
int tileSheetY=animatedIndex/tileSheetWidth;
view.DrawPartialDecal(tileSheet.pos,{float(tileSheet.tileSheet.tileset->tilewidth),float(tileSheet.tileSheet.tileset->tileheight)},tileSheet.tileSheet.tileset->tileset->Decal(),vi2d{tileSheetX,tileSheetY}*vf2d{float(tileSheet.tileSheet.tileset->tilewidth),float(tileSheet.tileSheet.tileset->tileheight)},{float(tileSheet.tileSheet.tileset->tilewidth),float(tileSheet.tileSheet.tileset->tileheight)},col);
if(tileSheet.tileSheet.tileset->tileRepeatData.count(animatedIndex)){
for(int y=0;y<tileSheet.tileSheet.tileset->tileRepeatData[animatedIndex].y;y++){
for(int x=0;x<tileSheet.tileSheet.tileset->tileRepeatData[animatedIndex].x;x++){
view.DrawPartialDecal(tileSheet.pos+vi2d{x,y}*game->GetCurrentMapData().tilewidth/tileSheet.tileSheet.tileset->tileRepeatData[animatedIndex],{float(tileSheet.tileSheet.tileset->tilewidth),float(tileSheet.tileSheet.tileset->tileheight)},tileSheet.tileSheet.tileset->tileset->Decal(),vi2d{tileSheetX,tileSheetY}*vf2d{float(tileSheet.tileSheet.tileset->tilewidth),float(tileSheet.tileSheet.tileset->tileheight)},vf2d{float(tileSheet.tileSheet.tileset->tilewidth),float(tileSheet.tileSheet.tileset->tileheight)}/tileSheet.tileSheet.tileset->tileRepeatData[animatedIndex],col);
}
}
}else view.DrawPartialDecal(tileSheet.pos,{float(tileSheet.tileSheet.tileset->tilewidth),float(tileSheet.tileSheet.tileset->tileheight)},tileSheet.tileSheet.tileset->tileset->Decal(),vi2d{tileSheetX,tileSheetY}*vf2d{float(tileSheet.tileSheet.tileset->tilewidth),float(tileSheet.tileSheet.tileset->tileheight)},{float(tileSheet.tileSheet.tileset->tilewidth),float(tileSheet.tileSheet.tileset->tileheight)},col);
}else{
view.DrawPartialDecal(tileSheet.pos,{float(tileSheet.tileSheet.tileset->tilewidth),float(tileSheet.tileSheet.tileset->tileheight)},tileSheet.tileSheet.tileset->tileset->Decal(),tileSheet.tileSheetPos,{float(tileSheet.tileSheet.tileset->tilewidth),float(tileSheet.tileSheet.tileset->tileheight)},col);
if(tileSheet.tileSheet.tileset->tileRepeatData.count(tileSheet.tileID)){
for(int y=0;y<tileSheet.tileSheet.tileset->tileRepeatData[tileSheet.tileID].y;y++){
for(int x=0;x<tileSheet.tileSheet.tileset->tileRepeatData[tileSheet.tileID].x;x++){
view.DrawPartialDecal(tileSheet.pos+vi2d{x,y}*game->GetCurrentMapData().tilewidth/tileSheet.tileSheet.tileset->tileRepeatData[tileSheet.tileID],{float(tileSheet.tileSheet.tileset->tilewidth),float(tileSheet.tileSheet.tileset->tileheight)},tileSheet.tileSheet.tileset->tileset->Decal(),tileSheet.tileSheetPos,vf2d{float(tileSheet.tileSheet.tileset->tilewidth),float(tileSheet.tileSheet.tileset->tileheight)}/tileSheet.tileSheet.tileset->tileRepeatData[tileSheet.tileID],col);
}
}
}else view.DrawPartialDecal(tileSheet.pos,{float(tileSheet.tileSheet.tileset->tilewidth),float(tileSheet.tileSheet.tileset->tileheight)},tileSheet.tileSheet.tileset->tileset->Decal(),tileSheet.tileSheetPos,{float(tileSheet.tileSheet.tileset->tilewidth),float(tileSheet.tileSheet.tileset->tileheight)},col);
}
}
@ -2012,6 +2036,7 @@ void AiL::InitializeLevel(std::string mapFile,MapName map){
MAP_TILESETS["assets/maps/"+baseSourceDir].staircaseTiles=tileset.GetData().StaircaseData;
MAP_TILESETS["assets/maps/"+baseSourceDir].animationData=tileset.GetData().AnimationData;
MAP_TILESETS["assets/maps/"+baseSourceDir].reflectiveData=tileset.GetData().ReflectiveData;
MAP_TILESETS["assets/maps/"+baseSourceDir].tileRepeatData=tileset.GetData().TileRepeatData;
MAP_TILESETS["assets/maps/"+baseSourceDir].isTerrain=tileset.GetData().isTerrain;
MAP_TILESETS["assets/maps/"+baseSourceDir].collision.SetInitialized();
LOG("assets/maps/"+baseSourceDir<<" Animation Data Size: "<<MAP_TILESETS["assets/maps/"+baseSourceDir].animationData.size());

@ -58,11 +58,12 @@ struct TilesetData{
Renderable*tileset=nullptr;
int tilewidth=0,tileheight=0;
bool isTerrain=false;
std::map<int,ForegroundTileTag>foregroundTiles;
std::map<int,ForegroundTileTag>upperForegroundTiles;
std::unordered_map<int,ForegroundTileTag>foregroundTiles;
std::unordered_map<int,ForegroundTileTag>upperForegroundTiles;
safemap<int,TileCollisionData>collision;
std::map<int,XMLTag>staircaseTiles;
std::map<int,std::vector<int>>animationData;
std::unordered_map<int,XMLTag>staircaseTiles;
std::unordered_map<int,std::vector<int>>animationData;
std::unordered_map<int,vi2d>tileRepeatData;
std::set<int>reflectiveData;
std::vector<Pixel>tilecols;
};

@ -49,12 +49,13 @@ struct Tileset{
int tilewidth=0,tileheight=0;
int imagewidth=0,imageheight=0;
bool isTerrain=false;
std::map<int,ForegroundTileTag> ForegroundTileData;
std::map<int,ForegroundTileTag> UpperForegroundTileData;
std::unordered_map<int,ForegroundTileTag> ForegroundTileData;
std::unordered_map<int,ForegroundTileTag> UpperForegroundTileData;
safemap<int,TileCollisionData> CollisionData;
std::map<int,XMLTag> StaircaseData;
std::map<int,std::vector<int>> AnimationData;
std::unordered_map<int,XMLTag> StaircaseData;
std::unordered_map<int,std::vector<int>> AnimationData;
std::set<int> ReflectiveData;
std::unordered_map<int,vi2d> TileRepeatData;
friend std::ostream& operator << (std::ostream& os, Tileset& rhs);
};
@ -158,10 +159,20 @@ class TSXParser{
parsedTilesetInfo.UpperForegroundTileData[newTag.GetInteger("id")].tag=newTag.tag;
parsedTilesetInfo.UpperForegroundTileData[newTag.GetInteger("id")].data=newTag.data;
} else
if (newTag.tag=="property"&&newTag.data["name"]=="TileRepeatFactor X"){
parsedTilesetInfo.TileRepeatData[previousTagID].x=newTag.GetInteger("value");
}else
if (newTag.tag=="property"&&newTag.data["name"]=="TileRepeatFactor Y"){
parsedTilesetInfo.TileRepeatData[previousTagID].y=newTag.GetInteger("value");
}else
if (newTag.tag=="property"&&newTag.data["name"]=="Hide?"){
if(currentTileTag==nullptr)ERR("WARNING! Cannot set hide value for a nullptr currentTileTag! THIS SHOULD NOT BE HAPPENING!");
currentTileTag->hide=newTag.GetBool("value");
}else
if (newTag.tag=="tile"&&newTag.data["type"]=="CustomTile"){
previousTag=newTag.tag;
previousTagID=newTag.GetInteger("id");
} else
if (newTag.tag=="tile"&&newTag.data["type"]=="Staircase"){
previousTag=newTag.tag;
staircaseTag=newTag.tag;

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

@ -1,9 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.10" tiledversion="1.10.1" name="objects" tilewidth="24" tileheight="24" tilecount="783" columns="29">
<tileset version="1.10" tiledversion="1.10.2" name="objects" tilewidth="24" tileheight="24" tilecount="783" columns="29">
<transformations hflip="0" vflip="0" rotate="0" preferuntransformed="1"/>
<image source="chapter2-props.png" width="696" height="648"/>
<tile id="2">
<tile id="2" type="CustomTile">
<properties>
<property name="TileRepeatFactor X" type="int" value="2"/>
<property name="TileRepeatFactor Y" type="int" value="2"/>
</properties>
<objectgroup draworder="index" id="3">
<object id="5" x="0" y="0" width="24" height="24"/>
</objectgroup>
<animation>
<frame tileid="2" duration="300"/>
<frame tileid="3" duration="300"/>
<frame tileid="4" duration="300"/>
</animation>
</tile>
</tileset>

Loading…
Cancel
Save