Update graphics to match new palette. Powerup reading and parsing/spawning completed.

main
sigonasr2 6 months ago
parent 7cf2bb7c3a
commit cb16ce831a
  1. 48
      assets/HamsterGame.tiled-project
  2. 2
      assets/HamsterGame.tiled-session
  3. 304
      assets/Terrain.tsx
  4. 18
      assets/TestLevel.tmx
  5. BIN
      assets/gametiles.png
  6. BIN
      assets/gametiles.xcf
  7. BIN
      assets/gametiles_original.xcf
  8. BIN
      assets/hamster.png
  9. BIN
      assets/hamster.xcf
  10. 8
      hamster.vcxproj
  11. 6
      hamster.vcxproj.filters
  12. 18
      src/HamsterGame.cpp
  13. 96
      src/Powerup.cpp
  14. 78
      src/Powerup.h
  15. 15
      src/TSXParser.h
  16. 1
      src/olcUTIL_Geometry2D.h

@ -10,6 +10,54 @@
"properties": [
],
"propertyTypes": [
{
"color": "#ffa0a0a4",
"drawFill": true,
"id": 4,
"members": [
{
"name": "Powerup Type",
"propertyType": "PowerupType",
"type": "int",
"value": 0
},
{
"name": "Upper-Left",
"type": "bool",
"value": false
}
],
"name": "PowerupProps",
"type": "class",
"useAs": [
"property",
"map",
"layer",
"object",
"tile",
"tileset",
"wangcolor",
"wangset",
"project"
]
},
{
"id": 3,
"name": "PowerupType",
"storageType": "int",
"type": "enum",
"values": [
"WHEEL",
"GRASS",
"SAND",
"SWAMP",
"LAVA",
"FOREST",
"ICE",
"JET"
],
"valuesAsFlags": false
},
{
"id": 1,
"name": "TerrainType",

@ -33,7 +33,7 @@
"openFiles": [
],
"project": "HamsterGame.tiled-project",
"property.type": "TerrainType",
"property.type": "bool",
"recentFiles": [
],
"tileset.lastUsedFormat": "tsx",

@ -597,7 +597,7 @@
<property name="Terrain Type" type="int" propertytype="TerrainType" value="1"/>
</properties>
</tile>
<tile id="101" type="TileProps"/>
<tile id="101" type="TileProps" probability="20"/>
<tile id="102" type="TileProps">
<properties>
<property name="Solid" type="bool" value="true"/>
@ -1753,7 +1753,7 @@
<property name="Terrain Type" type="int" propertytype="TerrainType" value="1"/>
</properties>
</tile>
<tile id="297" type="TileProps">
<tile id="297" type="TileProps" probability="20">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="3"/>
</properties>
@ -2839,7 +2839,7 @@
<property name="Terrain Type" type="int" propertytype="TerrainType" value="1"/>
</properties>
</tile>
<tile id="479" type="TileProps">
<tile id="479" type="TileProps" probability="20">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="10"/>
</properties>
@ -4882,7 +4882,7 @@
<tile id="977" type="TileProps"/>
<tile id="978" type="TileProps"/>
<tile id="979" type="TileProps"/>
<tile id="980" type="TileProps">
<tile id="980" type="TileProps" probability="4">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="1"/>
</properties>
@ -4892,7 +4892,7 @@
<tile id="983" type="TileProps"/>
<tile id="984" type="TileProps"/>
<tile id="985" type="TileProps"/>
<tile id="986" type="TileProps">
<tile id="986" type="TileProps" probability="4">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="10"/>
</properties>
@ -4902,7 +4902,7 @@
<tile id="989" type="TileProps"/>
<tile id="990" type="TileProps"/>
<tile id="991" type="TileProps"/>
<tile id="992" type="TileProps">
<tile id="992" type="TileProps" probability="4">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="3"/>
</properties>
@ -4912,7 +4912,7 @@
<tile id="995" type="TileProps"/>
<tile id="996" type="TileProps"/>
<tile id="997" type="TileProps"/>
<tile id="998" type="TileProps">
<tile id="998" type="TileProps" probability="4">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="2"/>
</properties>
@ -4926,7 +4926,7 @@
<tile id="1005" type="TileProps"/>
<tile id="1006" type="TileProps"/>
<tile id="1007" type="TileProps"/>
<tile id="1008" type="TileProps">
<tile id="1008" type="TileProps" probability="4">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="1"/>
</properties>
@ -4956,7 +4956,7 @@
<property name="Terrain Type" type="int" propertytype="TerrainType" value="1"/>
</properties>
</tile>
<tile id="1014" type="TileProps">
<tile id="1014" type="TileProps" probability="4">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="10"/>
</properties>
@ -4986,7 +4986,7 @@
<property name="Terrain Type" type="int" propertytype="TerrainType" value="10"/>
</properties>
</tile>
<tile id="1020" type="TileProps">
<tile id="1020" type="TileProps" probability="4">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="3"/>
</properties>
@ -5016,7 +5016,7 @@
<property name="Terrain Type" type="int" propertytype="TerrainType" value="3"/>
</properties>
</tile>
<tile id="1026" type="TileProps">
<tile id="1026" type="TileProps" probability="4">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="2"/>
</properties>
@ -5128,7 +5128,7 @@
<property name="Terrain Type" type="int" propertytype="TerrainType" value="3"/>
</properties>
</tile>
<tile id="1054" type="TileProps">
<tile id="1054" type="TileProps" probability="4">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="2"/>
</properties>
@ -5173,7 +5173,7 @@
<property name="Terrain Type" type="int" propertytype="TerrainType" value="1"/>
</properties>
</tile>
<tile id="1067" type="TileProps">
<tile id="1067" type="TileProps" probability="10">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="1"/>
</properties>
@ -5199,7 +5199,7 @@
<property name="Terrain Type" type="int" propertytype="TerrainType" value="10"/>
</properties>
</tile>
<tile id="1073" type="TileProps">
<tile id="1073" type="TileProps" probability="10">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="10"/>
</properties>
@ -5225,7 +5225,7 @@
<property name="Terrain Type" type="int" propertytype="TerrainType" value="3"/>
</properties>
</tile>
<tile id="1079" type="TileProps">
<tile id="1079" type="TileProps" probability="10">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="3"/>
</properties>
@ -5251,7 +5251,7 @@
<property name="Terrain Type" type="int" propertytype="TerrainType" value="2"/>
</properties>
</tile>
<tile id="1085" type="TileProps">
<tile id="1085" type="TileProps" probability="10">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="2"/>
</properties>
@ -5878,8 +5878,16 @@
<property name="Terrain Type" type="int" propertytype="TerrainType" value="8"/>
</properties>
</tile>
<tile id="1248" type="TileProps"/>
<tile id="1249" type="TileProps"/>
<tile id="1248" type="TileProps">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="8"/>
</properties>
</tile>
<tile id="1249" type="TileProps">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="8"/>
</properties>
</tile>
<tile id="1250" type="TileProps">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="4"/>
@ -5907,8 +5915,16 @@
</tile>
<tile id="1255" type="TileProps"/>
<tile id="1256" type="TileProps"/>
<tile id="1257" type="TileProps"/>
<tile id="1258" type="TileProps"/>
<tile id="1257" type="TileProps">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="8"/>
</properties>
</tile>
<tile id="1258" type="TileProps">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="8"/>
</properties>
</tile>
<tile id="1259" type="TileProps"/>
<tile id="1260" type="TileProps"/>
<tile id="1261" type="TileProps">
@ -5978,8 +5994,16 @@
<property name="Terrain Type" type="int" propertytype="TerrainType" value="8"/>
</properties>
</tile>
<tile id="1276" type="TileProps"/>
<tile id="1277" type="TileProps"/>
<tile id="1276" type="TileProps">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="8"/>
</properties>
</tile>
<tile id="1277" type="TileProps">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="8"/>
</properties>
</tile>
<tile id="1278" type="TileProps">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="4"/>
@ -6007,8 +6031,16 @@
</tile>
<tile id="1283" type="TileProps"/>
<tile id="1284" type="TileProps"/>
<tile id="1285" type="TileProps"/>
<tile id="1286" type="TileProps"/>
<tile id="1285" type="TileProps">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="8"/>
</properties>
</tile>
<tile id="1286" type="TileProps">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="8"/>
</properties>
</tile>
<tile id="1287" type="TileProps"/>
<tile id="1288" type="TileProps"/>
<tile id="1289" type="TileProps"/>
@ -6046,8 +6078,16 @@
<property name="Terrain Type" type="int" propertytype="TerrainType" value="8"/>
</properties>
</tile>
<tile id="1304" type="TileProps"/>
<tile id="1305" type="TileProps"/>
<tile id="1304" type="TileProps">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="8"/>
</properties>
</tile>
<tile id="1305" type="TileProps">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="8"/>
</properties>
</tile>
<tile id="1306" type="TileProps">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="4"/>
@ -6075,8 +6115,16 @@
</tile>
<tile id="1311" type="TileProps"/>
<tile id="1312" type="TileProps"/>
<tile id="1313" type="TileProps"/>
<tile id="1314" type="TileProps"/>
<tile id="1313" type="TileProps">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="8"/>
</properties>
</tile>
<tile id="1314" type="TileProps">
<properties>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="8"/>
</properties>
</tile>
<tile id="1315" type="TileProps"/>
<tile id="1316" type="TileProps"/>
<tile id="1317" type="TileProps"/>
@ -6416,22 +6464,94 @@
<property name="Terrain Type" type="int" propertytype="TerrainType" value="7"/>
</properties>
</tile>
<tile id="1437" type="TileProps"/>
<tile id="1438" type="TileProps"/>
<tile id="1439" type="TileProps"/>
<tile id="1440" type="TileProps"/>
<tile id="1441" type="TileProps"/>
<tile id="1442" type="TileProps"/>
<tile id="1443" type="TileProps"/>
<tile id="1444" type="TileProps"/>
<tile id="1445" type="TileProps"/>
<tile id="1446" type="TileProps"/>
<tile id="1447" type="TileProps"/>
<tile id="1448" type="TileProps"/>
<tile id="1449" type="TileProps"/>
<tile id="1450" type="TileProps"/>
<tile id="1451" type="TileProps"/>
<tile id="1452" type="TileProps"/>
<tile id="1437" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="0"/>
<property name="Upper-Left" type="bool" value="true"/>
</properties>
</tile>
<tile id="1438" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="0"/>
</properties>
</tile>
<tile id="1439" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="1"/>
<property name="Upper-Left" type="bool" value="true"/>
</properties>
</tile>
<tile id="1440" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="1"/>
</properties>
</tile>
<tile id="1441" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="2"/>
<property name="Upper-Left" type="bool" value="true"/>
</properties>
</tile>
<tile id="1442" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="2"/>
</properties>
</tile>
<tile id="1443" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="3"/>
<property name="Upper-Left" type="bool" value="true"/>
</properties>
</tile>
<tile id="1444" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="3"/>
</properties>
</tile>
<tile id="1445" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="4"/>
<property name="Upper-Left" type="bool" value="true"/>
</properties>
</tile>
<tile id="1446" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="4"/>
</properties>
</tile>
<tile id="1447" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="5"/>
<property name="Upper-Left" type="bool" value="true"/>
</properties>
</tile>
<tile id="1448" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="5"/>
</properties>
</tile>
<tile id="1449" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="6"/>
<property name="Upper-Left" type="bool" value="true"/>
</properties>
</tile>
<tile id="1450" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="6"/>
</properties>
</tile>
<tile id="1451" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="7"/>
<property name="Upper-Left" type="bool" value="true"/>
</properties>
</tile>
<tile id="1452" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="7"/>
</properties>
</tile>
<tile id="1453" type="TileProps"/>
<tile id="1454" type="TileProps"/>
<tile id="1455" type="TileProps"/>
@ -6448,22 +6568,86 @@
<property name="Terrain Type" type="int" propertytype="TerrainType" value="7"/>
</properties>
</tile>
<tile id="1465" type="TileProps"/>
<tile id="1466" type="TileProps"/>
<tile id="1467" type="TileProps"/>
<tile id="1468" type="TileProps"/>
<tile id="1469" type="TileProps"/>
<tile id="1470" type="TileProps"/>
<tile id="1471" type="TileProps"/>
<tile id="1472" type="TileProps"/>
<tile id="1473" type="TileProps"/>
<tile id="1474" type="TileProps"/>
<tile id="1475" type="TileProps"/>
<tile id="1476" type="TileProps"/>
<tile id="1477" type="TileProps"/>
<tile id="1478" type="TileProps"/>
<tile id="1479" type="TileProps"/>
<tile id="1480" type="TileProps"/>
<tile id="1465" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="0"/>
</properties>
</tile>
<tile id="1466" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="0"/>
</properties>
</tile>
<tile id="1467" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="1"/>
</properties>
</tile>
<tile id="1468" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="1"/>
</properties>
</tile>
<tile id="1469" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="2"/>
</properties>
</tile>
<tile id="1470" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="2"/>
</properties>
</tile>
<tile id="1471" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="3"/>
</properties>
</tile>
<tile id="1472" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="3"/>
</properties>
</tile>
<tile id="1473" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="4"/>
</properties>
</tile>
<tile id="1474" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="4"/>
</properties>
</tile>
<tile id="1475" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="5"/>
</properties>
</tile>
<tile id="1476" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="5"/>
</properties>
</tile>
<tile id="1477" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="6"/>
</properties>
</tile>
<tile id="1478" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="6"/>
</properties>
</tile>
<tile id="1479" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="7"/>
</properties>
</tile>
<tile id="1480" type="PowerupProps">
<properties>
<property name="Powerup Type" type="int" propertytype="PowerupType" value="7"/>
</properties>
</tile>
<tile id="1481" type="TileProps"/>
<tile id="1482" type="TileProps"/>
<tile id="1483" type="TileProps"/>

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.10.2" orientation="orthogonal" renderorder="right-down" width="30" height="50" tilewidth="16" tileheight="16" infinite="0" nextlayerid="5" nextobjectid="1">
<map version="1.10" tiledversion="1.10.2" orientation="orthogonal" renderorder="right-down" width="30" height="50" tilewidth="16" tileheight="16" infinite="0" nextlayerid="6" nextobjectid="2">
<tileset firstgid="1" source="Terrain.tsx"/>
<layer id="1" name="Tile Layer 1" width="30" height="50">
<data encoding="csv">
@ -80,7 +80,11 @@
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1438,1439,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1466,1467,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1444,1445,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1472,1473,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@ -95,14 +99,10 @@
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1450,1451,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1478,1479,0,
0,0,0,0,0,1452,1453,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,1480,1481,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

@ -329,6 +329,10 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
</SubType>
</ClCompile>
<ClCompile Include="src\Hamster.cpp" />
<ClCompile Include="src\Powerup.cpp">
<SubType>
</SubType>
</ClCompile>
<ClCompile Include="src\Terrain.cpp">
<SubType>
</SubType>
@ -370,6 +374,10 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
<ClInclude Include="src\olcUTIL_Animate2D.h" />
<ClInclude Include="src\olcUTIL_Camera2D.h" />
<ClInclude Include="src\olcUTIL_Geometry2D.h" />
<ClInclude Include="src\Powerup.h">
<SubType>
</SubType>
</ClInclude>
<ClInclude Include="src\Terrain.h">
<SubType>
</SubType>

@ -22,6 +22,9 @@
<ClCompile Include="src\Terrain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\Powerup.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="C:\Users\sigon\source\repos\hamster\CMakeLists.txt" />
@ -88,5 +91,8 @@
<ClInclude Include="src\Terrain.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\Powerup.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

@ -22,6 +22,7 @@ bool HamsterGame::OnUserCreate(){
tv.SetWorldOffset(-SCREEN_FRAME.pos);
LoadGraphics();
LoadAnimations();
currentTileset=TSXParser{ASSETS_DIR+std::string("Terrain.tsx")};
LoadLevel("TestLevel.tmx"); //THIS IS TEMPORARY.
border.ChangeBorder(Border::DEFAULT);
@ -73,10 +74,22 @@ void HamsterGame::LoadLevel(const std::string_view mapName){
const vf2d levelSpawnLoc{50,50}; //TEMPORARY
currentMap=TMXParser{ASSETS_DIR+std::string(mapName)};
currentTileset=TSXParser{ASSETS_DIR+std::string("Terrain.tsx")};
Hamster::LoadHamsters(levelSpawnLoc);
camera.SetTarget(Hamster::GetPlayer().GetPos());
#pragma region Detect powerup tiles
std::vector<Powerup>mapPowerups;
for(const LayerTag&layer:currentMap.value().GetData().GetLayers()){
for(size_t y:std::ranges::iota_view(0U,layer.tiles.size())){
for(size_t x:std::ranges::iota_view(0U,layer.tiles[y].size())){
const int tileID{layer.tiles[y][x]-1};
if(Powerup::TileIDIsUpperLeftPowerupTile(tileID))mapPowerups.emplace_back(vf2d{float(x),float(y)}*16+vf2d{16,16},Powerup::TileIDPowerupType(tileID));
}
}
}
Powerup::Initialize(mapPowerups);
#pragma endregion
}
void HamsterGame::UpdateGame(const float fElapsedTime){
@ -88,6 +101,7 @@ void HamsterGame::UpdateGame(const float fElapsedTime){
void HamsterGame::DrawGame(){
DrawLevelTiles();
Powerup::DrawPowerups(tv);
Hamster::DrawHamsters(tv);
border.Draw();
DrawStringDecal(SCREEN_FRAME.pos+vf2d{1,1},"Terrain Type: "+Terrain::TerrainToString(Hamster::GetPlayer().GetTerrainStandingOn()),BLACK);
@ -118,7 +132,7 @@ void HamsterGame::DrawLevelTiles(){
int tileX{int(floor(x)/16)};
int tileY{int(floor(y)/16)};
int tileID{layer.tiles[tileY][tileX]-1};
if(tileID==-1)continue;
if(tileID==-1||Powerup::TileIDIsPowerupTile(tileID))continue;
int imgTileX{tileID%numTilesWide};
int imgTileY{tileID/numTilesWide};

@ -0,0 +1,96 @@
#pragma region License
/*
License (OLC-3)
~~~~~~~~~~~~~~~
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com>
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions or derivations of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions or derivative works in binary form must reproduce the above
copyright notice. This list of conditions and the following disclaimer must be
reproduced in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may
be used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
Portions of this software are copyright © 2024 The FreeType
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
All rights reserved.
*/
#pragma endregion
#include "HamsterGame.h"
#include "Powerup.h"
std::vector<Powerup>Powerup::powerupList;
std::unordered_map<int,std::pair<Powerup::PowerupType,Powerup::TileType>>Powerup::powerupIds;
const vf2d Powerup::POWERUP_TILESET_STARTING_POS{144.f,816.f};
Powerup::Powerup(const vf2d pos,const PowerupType type)
:pos(pos),type(type){}
void Powerup::Initialize(const std::vector<Powerup>&powerupList){
Powerup::powerupList.clear();
Powerup::powerupList=powerupList;
}
const vf2d&Powerup::GetPos()const{
return pos;
}
const Powerup::PowerupType&Powerup::GetType()const{
return type;
}
const std::vector<Powerup>&Powerup::GetPowerups(){
return powerupList;
}
void Powerup::AddOrUpdatePowerupIdList(const int powerupId,const PowerupType powerupType){
if(powerupIds.count(powerupId)){
powerupIds[powerupId].first=powerupType;
}else{
powerupIds[powerupId]={powerupType,TileType::DEFAULT};
}
}
void Powerup::AddOrUpdatePowerupIdList(const int powerupId,const TileType powerupTileType){
if(powerupIds.count(powerupId)){
powerupIds[powerupId].second=powerupTileType;
}else{
powerupIds[powerupId]={PowerupType::WHEEL,powerupTileType};
}
}
const bool Powerup::TileIDIsPowerupTile(const int tileId){
return powerupIds.count(tileId);
}
const bool Powerup::TileIDIsUpperLeftPowerupTile(const int tileId){
return powerupIds.count(tileId)&&powerupIds[tileId].second==TileType::IS_UPPERLEFT_TILE;
}
const Powerup::PowerupType Powerup::TileIDPowerupType(const int tileId){
return powerupIds.at(tileId).first;
}
void Powerup::DrawPowerups(TransformedView&tv){
for(const Powerup&powerup:powerupList){
geom2d::rect<float>spriteRect{POWERUP_TILESET_STARTING_POS+vf2d{int(powerup.GetType())*32.f,0.f},{32,32}};
tv.DrawPartialRotatedDecal(powerup.GetPos(),HamsterGame::GetGFX("gametiles.png").Decal(),0.f,{16,16},spriteRect.pos,spriteRect.size);
}
}

@ -0,0 +1,78 @@
#pragma region License
/*
License (OLC-3)
~~~~~~~~~~~~~~~
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com>
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions or derivations of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions or derivative works in binary form must reproduce the above
copyright notice. This list of conditions and the following disclaimer must be
reproduced in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may
be used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
Portions of this software are copyright © 2024 The FreeType
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
All rights reserved.
*/
#pragma endregion
#pragma once
#include <vector>
#include <unordered_map>
#include "olcUTIL_Geometry2D.h"
#include "olcPGEX_TransformedView.h"
class Powerup{
public:
enum PowerupType{
WHEEL,
GRASS,
SAND,
SWAMP,
LAVA,
FOREST,
ICE,
JET,
};
enum TileType{
IS_UPPERLEFT_TILE=true,
DEFAULT=false,
};
private:
static std::vector<Powerup>powerupList;
static std::unordered_map<int,std::pair<PowerupType,TileType>>powerupIds;
static const vf2d POWERUP_TILESET_STARTING_POS;
vf2d pos;
PowerupType type;
public:
Powerup(const vf2d pos,const PowerupType type);
static void Initialize(const std::vector<Powerup>&powerupList);
const vf2d&GetPos()const;
const PowerupType&GetType()const;
static const std::vector<Powerup>&GetPowerups();
static void AddOrUpdatePowerupIdList(const int powerupId,const PowerupType powerupType);
static void AddOrUpdatePowerupIdList(const int powerupId,const TileType powerupTileType);
static const bool TileIDIsPowerupTile(const int tileId);
static const bool TileIDIsUpperLeftPowerupTile(const int tileId);
static const PowerupType TileIDPowerupType(const int tileId);
static void DrawPowerups(TransformedView&tv);
};

@ -39,6 +39,7 @@ All rights reserved.
#include <sstream>
#include "TMXParser.h"
#include "Terrain.h"
#include "Powerup.h"
using namespace olc;
@ -169,7 +170,19 @@ class TSXParser{
std::pair<Terrain::SolidType,Terrain::TerrainType>&tileData{parsedTilesetInfo.TerrainData[tagID]};
tileData.first=Terrain::SolidType(newTag.GetBool("value"));
}
}
} else
if(newTag.tag=="property"&&newTag.data["propertytype"]=="PowerupType"){
//The way animation data is stored is every "animation_tile_precision" ms indicating which frame we should be on.
for(int&tagID:previousTagID){
Powerup::AddOrUpdatePowerupIdList(tagID,Powerup::PowerupType(newTag.GetInteger("value")));
}
} else
if(newTag.tag=="property"&&newTag.data["name"]=="Upper-Left"){
//The way animation data is stored is every "animation_tile_precision" ms indicating which frame we should be on.
for(int&tagID:previousTagID){
Powerup::AddOrUpdatePowerupIdList(tagID,Powerup::TileType(newTag.GetBool("value")));
}
} else
if (newTag.tag=="object"&&previousTag.size()>0&&previousTag[0]=="tile"){
for(int&tagID:previousTagID){
TileCollisionData data;

@ -2532,4 +2532,5 @@ namespace olc::utils::geom2d
#endif // PGE_VER
using namespace olc;
using namespace olc::utils;
Loading…
Cancel
Save