Implement multi-layer map rendering. Fix bug with GetLayers() returning a reference to a temporary copy of MapData. For whatever reason...oops.

main
sigonasr2 3 months ago
parent 972dd827e9
commit 6822a4916c
  1. 50
      assets/HamsterGame.tiled-project
  2. 19
      assets/HamsterGame.tiled-session
  3. 6446
      assets/Terrain.tsx
  4. 74
      assets/TestLevel.tmx
  5. 76
      assets/TreeTemplates.tmx
  6. BIN
      assets/gametiles.png
  7. 5
      src/HamsterGame.cpp
  8. 4
      src/TMXParser.h
  9. 8
      src/TODO.txt

@ -10,5 +10,55 @@
"properties": [ "properties": [
], ],
"propertyTypes": [ "propertyTypes": [
{
"id": 1,
"name": "TerrainType",
"storageType": "string",
"type": "enum",
"values": [
"Rock",
"Grass",
"Sand",
"Swamp",
"Lava",
"Shore",
"Ocean",
"Forest",
"Tunnel",
"Ice"
],
"valuesAsFlags": false
},
{
"color": "#ffa0a0a4",
"drawFill": true,
"id": 2,
"members": [
{
"name": "Solid",
"type": "bool",
"value": false
},
{
"name": "Terrain Type",
"propertyType": "TerrainType",
"type": "string",
"value": "Rock"
}
],
"name": "TileProps",
"type": "class",
"useAs": [
"property",
"map",
"layer",
"object",
"tile",
"tileset",
"wangcolor",
"wangset",
"project"
]
}
] ]
} }

@ -7,13 +7,32 @@
"expandedProjectPaths": [ "expandedProjectPaths": [
], ],
"fileStates": { "fileStates": {
"TestLevel.tmx": {
"scale": 4,
"selectedLayer": 1,
"viewCenter": {
"x": 174.625,
"y": 138.625
}
},
"TreeTemplates.tmx": {
"scale": 4,
"selectedLayer": 0,
"viewCenter": {
"x": 192.125,
"y": 87.875
}
}
}, },
"frame.defaultDuration": 200, "frame.defaultDuration": 200,
"last.imagePath": "C:/Users/sigon/source/repos/hamster/assets", "last.imagePath": "C:/Users/sigon/source/repos/hamster/assets",
"map.lastUsedFormat": "tmx", "map.lastUsedFormat": "tmx",
"map.tileHeight": 16,
"map.tileWidth": 16,
"openFiles": [ "openFiles": [
], ],
"project": "HamsterGame.tiled-project", "project": "HamsterGame.tiled-project",
"property.type": "TerrainType",
"recentFiles": [ "recentFiles": [
], ],
"tileset.lastUsedFormat": "tsx", "tileset.lastUsedFormat": "tsx",

File diff suppressed because it is too large Load Diff

@ -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.2" orientation="orthogonal" renderorder="right-down" width="30" height="20" tilewidth="16" tileheight="16" infinite="0" nextlayerid="2" nextobjectid="1"> <map version="1.10" tiledversion="1.10.2" orientation="orthogonal" renderorder="right-down" width="30" height="20" tilewidth="16" tileheight="16" infinite="0" nextlayerid="5" nextobjectid="1">
<tileset firstgid="1" source="Terrain.tsx"/> <tileset firstgid="1" source="Terrain.tsx"/>
<layer id="1" name="Tile Layer 1" width="30" height="20"> <layer id="1" name="Tile Layer 1" width="30" height="20">
<data encoding="csv"> <data encoding="csv">
@ -23,6 +23,78 @@
1237,1149,1177,494,494,494,494,1238,1178,1328,1380,1385,1385,1385,1385,1385,1385,1382,1328,1386,1386,1110,1413,1413,1413,1081,494,1149,1235,1152, 1237,1149,1177,494,494,494,494,1238,1178,1328,1380,1385,1385,1385,1385,1385,1385,1382,1328,1386,1386,1110,1413,1413,1413,1081,494,1149,1235,1152,
494,1121,1149,1121,494,1149,1179,1266,1206,1328,1408,1381,1381,1381,1381,1381,1381,1410,1328,494,1238,1107,1108,1108,1108,1109,494,494,494,1149, 494,1121,1149,1121,494,1149,1179,1266,1206,1328,1408,1381,1381,1381,1381,1381,1381,1410,1328,494,1238,1107,1108,1108,1108,1109,494,494,494,1149,
494,494,494,494,494,494,1235,1154,1234,1328,1328,1328,1328,1328,1328,1328,1328,1328,1328,494,1210,1209,494,1177,494,494,1149,1121,1121,494 494,494,494,494,494,494,1235,1154,1234,1328,1328,1328,1328,1328,1328,1328,1328,1328,1328,494,1210,1209,494,1177,494,494,1149,1121,1121,494
</data>
</layer>
<layer id="2" name="Tile Layer 2" width="30" height="20">
<data encoding="csv">
0,0,0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1247,1248,1247,1248,1247,1248,1241,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,1268,1275,1276,1275,1276,1275,1276,1269,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,1303,1304,1303,1304,1303,1304,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</data> </data>
</layer> </layer>
</map> </map>

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.10.2" orientation="orthogonal" renderorder="right-down" width="30" height="20" tilewidth="16" tileheight="16" infinite="0" nextlayerid="5" nextobjectid="1">
<tileset firstgid="1" source="Terrain.tsx"/>
<layer id="2" name="Tile Layer 2" width="30" height="20">
<data encoding="csv">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,1240,1247,1248,1247,1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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</data>
</layer>
<layer id="3" name="Tile Layer 3" width="30" height="20">
<data encoding="csv">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,1240,1247,1248,1247,1248,1247,1248,1241,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,1268,1275,1276,1275,1276,1275,1276,1269,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1303,1304,1303,1304,1303,1304,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,1240,1247,1248,1247,1248,1247,1248,1241,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,1268,1275,1276,1275,1276,1275,1276,1269,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1303,1304,1303,1304,1303,1304,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,1240,1247,1248,1247,1248,1247,1248,1241,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,1268,1275,1276,1275,1276,1275,1276,1269,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1303,1304,1303,1304,1303,1304,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</data>
</layer>
</map>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 70 KiB

@ -90,6 +90,7 @@ void HamsterGame::DrawGame(){
} }
void HamsterGame::DrawLevelTiles(){ void HamsterGame::DrawLevelTiles(){
for(const LayerTag&layer:currentMap.value().GetData().GetLayers()){
for(float y=tv.GetWorldTL().y-16;y<=tv.GetWorldBR().y+16;y+=16){ for(float y=tv.GetWorldTL().y-16;y<=tv.GetWorldBR().y+16;y+=16){
for(float x=tv.GetWorldTL().x-1+SCREEN_FRAME.pos.x;x<=tv.GetWorldBR().x+16+SCREEN_FRAME.pos.x;x+=16){ for(float x=tv.GetWorldTL().x-1+SCREEN_FRAME.pos.x;x<=tv.GetWorldBR().x+16+SCREEN_FRAME.pos.x;x+=16){
if(x<=0.f||y<=0.f||x>=currentMap.value().GetData().GetMapData().width*16||y>=currentMap.value().GetData().GetMapData().height*16)continue; if(x<=0.f||y<=0.f||x>=currentMap.value().GetData().GetMapData().width*16||y>=currentMap.value().GetData().GetMapData().height*16)continue;
@ -98,7 +99,8 @@ void HamsterGame::DrawLevelTiles(){
int tileX{int(floor(x)/16)}; int tileX{int(floor(x)/16)};
int tileY{int(floor(y)/16)}; int tileY{int(floor(y)/16)};
int tileID{currentMap.value().GetData().GetLayers()[0].tiles[tileY][tileX]-1}; int tileID{layer.tiles[tileY][tileX]-1};
if(tileID==-1)continue;
int imgTileX{tileID%numTilesWide}; int imgTileX{tileID%numTilesWide};
int imgTileY{tileID/numTilesWide}; int imgTileY{tileID/numTilesWide};
@ -111,6 +113,7 @@ void HamsterGame::DrawLevelTiles(){
} }
} }
} }
}
} }
bool HamsterGame::OnUserUpdate(float fElapsedTime){ bool HamsterGame::OnUserUpdate(float fElapsedTime){

@ -129,7 +129,7 @@ struct Property{
class TMXParser{ class TMXParser{
public: public:
Map GetData(); Map&GetData();
private: private:
Map parsedMapInfo; Map parsedMapInfo;
std::string fileName; std::string fileName;
@ -256,7 +256,7 @@ class TMXParser{
rhs.FormatLayerData(os,rhs.LayerData) <<"\n"; rhs.FormatLayerData(os,rhs.LayerData) <<"\n";
return os; return os;
} }
Map TMXParser::GetData() { Map&TMXParser::GetData() {
return parsedMapInfo; return parsedMapInfo;
} }
void TMXParser::ParseTag(std::string tag) { void TMXParser::ParseTag(std::string tag) {

@ -8,6 +8,8 @@ Swamp - 50%, after 5 seconds: Hamster sinks and respawns.
Hardness: SOFT Hardness: SOFT
Lava - Hamster melts (*dies*) and respawns. Lava - Hamster melts (*dies*) and respawns.
Hardness: SOFT Hardness: SOFT
Ice - Very Slippery, acceleration massively reduced.
Hardness: HARD
Shore - 80% Shore - 80%
Hardness: MEDIUM Hardness: MEDIUM
Deep Water - 10%, after 5 seconds: Hamster drowns and respawns. Deep Water - 10%, after 5 seconds: Hamster drowns and respawns.
@ -17,6 +19,11 @@ Forests - 50%
Tunnels - Transports you from Point A to Point B. Takes a small animation to enter/exit Tunnels - Transports you from Point A to Point B. Takes a small animation to enter/exit
Hardness: HARD Hardness: HARD
When walking on tiles, particles left behind will use colors from the tile we are walking on.
Solid Tiles
Forest overrides whatever it's layered on.
Radar - Display nearby upgrades as icons. Also displays checkpoints. Radar - Display nearby upgrades as icons. Also displays checkpoints.
Hamster Wheel - Enhances Speed Hamster Wheel - Enhances Speed
@ -26,6 +33,7 @@ Upgrades -
Swamp - 80%, no more sinking Swamp - 80%, no more sinking
Lava - Fire-resistant, can run on lava. Lava - Fire-resistant, can run on lava.
Forest - No slowdown in forests Forest - No slowdown in forests
Ice - Normal Grip on Ice, normal acceleration.
Penalties - Penalties -
If you have to get shuttled by the Hamster Rescue Boat, you lose all upgrades If you have to get shuttled by the Hamster Rescue Boat, you lose all upgrades

Loading…
Cancel
Save