From 132710d800e971c0b713484a7bbbead2e04f4319 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Sun, 18 Aug 2024 15:38:38 -0500 Subject: [PATCH] Fix bug with terrain collisions not being read properly. Added movement resolution and collisions. Made boundary solid. Make blank tiles be solid. Add water void. --- .gitignore | 1 + HamsterJet.h | 42 ++++++++++++++++++++++++++++++++ assets/HamsterGame.tiled-session | 12 ++++----- assets/TestLevel.tmx | 24 +++++++++--------- src/Hamster.cpp | 24 +++++++++++++----- src/Hamster.h | 2 ++ src/HamsterGame.cpp | 29 ++++++++++++++++++++++ src/HamsterGame.h | 3 +++ src/TSXParser.h | 2 +- 9 files changed, 114 insertions(+), 25 deletions(-) create mode 100644 HamsterJet.h diff --git a/.gitignore b/.gitignore index 1e8415f..a6a541b 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ vs-build /.vs /CMakeCache.txt /cmake_install.cmake +/hamster.vcxproj.user diff --git a/HamsterJet.h b/HamsterJet.h new file mode 100644 index 0000000..0d46c3f --- /dev/null +++ b/HamsterJet.h @@ -0,0 +1,42 @@ +#pragma region License +/* +License (OLC-3) +~~~~~~~~~~~~~~~ + +Copyright 2024 Joshua Sigona + +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 + +class HamsterJet{ + +}; \ No newline at end of file diff --git a/assets/HamsterGame.tiled-session b/assets/HamsterGame.tiled-session index 36e605e..b8ab79a 100644 --- a/assets/HamsterGame.tiled-session +++ b/assets/HamsterGame.tiled-session @@ -8,19 +8,19 @@ ], "fileStates": { "TestLevel.tmx": { - "scale": 4, + "scale": 3, "selectedLayer": 0, "viewCenter": { - "x": 174.625, - "y": 138.625 + "x": 761.1666666666666, + "y": 278.8333333333333 } }, "TreeTemplates.tmx": { - "scale": 4, + "scale": 3, "selectedLayer": 0, "viewCenter": { - "x": 192.125, - "y": 87.875 + "x": 113.83333333333331, + "y": 200.5 } } }, diff --git a/assets/TestLevel.tmx b/assets/TestLevel.tmx index bae49d3..b0f9c56 100644 --- a/assets/TestLevel.tmx +++ b/assets/TestLevel.tmx @@ -16,18 +16,18 @@ 1235,1153,1154,1234,1207,1234,494,1177,494,494,494,494,494,494,1021,298,1021,298,1051,1137,1138,1106,993,1021,1110,1134,1138,1022,1109,1082,494,494,494,1177,494,1121,1149,494,494,494,494,1177,494,1149,1121,494,1149,1177,1149,1182,1209,494,494,494,494,1235,1237,1121,494,494,494,1149,494,1121,494,1182,1150,1154,1150,1237,1210,1262,1180,1265,1264,1266,1209,1179,1265,1264,1264,1180,1264,1263,1180,1266,1150,1154,1150,1152,1236,1153,1237,1177,494,494,494,1121,494,494,1182,1178,1177,1207,1234,1235,1237,1177,494,1121,494,1149,494,1177,494,494,1182,1150,1237,1238,1262,1265,1265,1265,1181,1149,494,494,494,494,494,1182,1206,1121,494,494,494,494,1207,1209,494,1177,1182,1262,1180,1266,1234,1177,494,494,1182,1206,494,1210,1234,1121,494,494,494,494,1182,1206,494,494,494,1179,1263,1266,1150,1153,1154,1150,1236,1151,1237,494,494,494,1235,1154,1178,1121,1177,1121,494,494,494,494,494,1235,1237,494,1207,1206,494,494,494,494,1149,1177, 1181,1179,1266,1178,1182,1234,494,494,494,1149,494,1179,1181,494,1051,1136,1137,1137,1138,1022,1025,1109,993,993,1110,1022,1026,1134,1137,1138,1149,1177,494,494,494,494,494,494,1177,494,494,494,1149,494,494,494,1177,494,1177,1235,1237,1149,494,494,1179,1264,1264,1180,1263,1263,1263,1181,1179,1263,1265,1266,1206,1210,1178,1177,1207,1150,1152,1151,1154,1150,1237,1182,1150,1151,1236,1152,1153,1153,1154,1150,1237,1182,1178,494,1177,494,1177,1177,1121,494,1177,494,1179,1265,1266,1234,1149,1210,1209,494,494,494,1121,494,494,1149,1177,494,1121,494,1210,1209,494,1238,1150,1153,1236,1151,1237,494,494,494,494,494,494,1182,1206,1149,494,1149,1179,1181,1238,1206,1121,494,1238,1150,1151,1151,1237,494,494,494,1235,1237,494,1182,1234,1177,494,1149,494,494,1235,1237,494,494,494,1210,1150,1154,1262,1263,1266,1209,1177,494,1121,494,1121,494,1149,1207,1209,494,494,1149,1149,494,494,494,494,494,1177,1149,1238,1209,1121,1121,494,494,494,1121, 1234,1235,1151,1237,1266,1209,1149,1179,1180,1180,1263,1266,1209,494,1107,1108,1108,1108,1108,1109,993,1021,1080,298,1107,1109,1107,1108,1108,1108,494,494,1121,1149,494,494,494,494,494,494,494,1177,1121,494,494,1179,1180,1263,1181,1121,1121,494,494,494,1182,1150,1153,1152,1152,1153,1236,1237,1235,1153,1153,1154,1206,1210,1206,494,1235,1237,1149,494,1207,1234,1149,1210,1262,1263,1263,1180,1264,1264,1266,1178,494,1210,1234,494,494,1149,1177,494,494,1177,1177,1121,1235,1152,1236,1237,1177,1210,1234,1179,1264,1181,494,494,1121,1149,494,494,1121,1149,1182,1234,1149,1210,1206,494,1177,494,494,1149,1121,494,1149,494,494,1207,1178,1177,494,1121,1210,1262,1266,1262,1181,494,1207,1178,494,1149,494,494,494,494,494,494,494,1238,1234,1121,494,1121,1149,494,494,1177,1121,1179,1263,1266,1234,1238,1150,1153,1236,1237,494,494,494,1177,1121,494,1121,1210,1234,494,1121,1179,1265,1264,1265,1181,494,494,494,494,1182,1209,1149,494,494,1177,494,494, -1206,1149,1121,1238,1266,1262,1264,1266,1150,1328,1328,1328,1328,1328,1328,1328,1328,1328,1328,494,494,494,494,494,494,494,494,494,494,494,494,1177,494,494,494,494,1121,494,494,494,1177,1177,494,494,494,1210,1150,1152,1237,494,494,494,1149,1179,1266,1209,494,494,494,1177,1121,494,494,494,494,1238,1206,1235,1237,494,494,494,1149,494,1238,1262,1264,1266,1150,1153,1153,1153,1153,1153,1152,1237,1121,1182,1178,494,494,494,494,494,1149,494,494,494,494,1149,494,494,1149,1238,1262,1266,1150,1237,494,1121,1121,494,1149,1121,494,494,1238,1262,1265,1266,1178,1121,494,1179,1180,1265,1180,1265,1181,1177,494,1182,1209,494,494,1121,1210,1150,1152,1152,1237,494,1207,1206,494,1177,494,1121,1177,1121,494,1121,494,1238,1262,1265,1264,1264,1264,1180,1181,494,494,1235,1236,1152,1237,1210,1209,494,1149,1121,1149,494,1121,494,1149,494,494,1207,1206,494,494,1182,1150,1153,1152,1237,494,494,494,1121,1210,1209,494,494,494,494,494,494, -1209,494,1177,1210,1150,1153,1152,1154,1206,1328,1352,1381,1381,1381,1381,1381,1381,1354,1328,1181,1207,1051,1135,1136,1137,1053,1149,494,494,1121,1179,1265,1265,1263,1264,1181,1179,1264,1265,1264,1181,494,494,494,494,1207,1262,1180,1181,1149,494,1177,494,1238,1150,1237,494,494,494,1121,494,1121,1121,1177,494,1207,1262,1263,1180,1263,1180,1181,1121,494,1207,1150,1236,1153,1237,494,494,494,494,494,494,494,1121,1235,1237,494,1149,494,494,1177,494,494,1177,1149,494,494,494,494,494,1238,1150,1154,1262,1265,1263,1180,1263,1181,494,494,494,494,1210,1150,1152,1153,1237,1121,494,1238,1150,1153,1236,1153,1237,494,494,1235,1237,494,494,494,1207,1206,494,494,494,494,1235,1237,494,494,494,1121,494,494,494,494,1149,1238,1150,1154,1150,1151,1154,1150,1237,1177,494,1149,494,494,494,1210,1234,494,494,494,1177,494,494,494,494,1149,494,1210,1262,1263,1180,1266,1178,1149,1149,494,494,1121,1149,1149,1238,1209,1179,1264,1180,1264,1264,1263, -1209,494,1177,1235,1237,1121,1177,1207,1234,1328,1380,1385,1385,1385,1385,1385,1385,1382,1328,1386,1386,1054,1413,1413,1413,1081,494,494,494,1149,1207,1150,1236,1152,1154,1206,1210,1150,1152,1152,1237,1149,1177,1177,494,1182,1150,1154,1234,494,494,1149,494,1210,1209,494,494,494,1177,494,494,1177,494,494,494,1182,1150,1151,1153,1236,1153,1237,494,1177,1207,1262,1181,494,494,1121,494,494,494,1149,1177,494,1177,494,494,494,494,1177,1177,494,494,494,1121,1121,494,494,494,494,1121,1182,1234,1235,1236,1151,1154,1150,1236,1237,494,494,494,494,1210,1234,494,1179,1180,1180,1264,1266,1206,1177,494,494,494,1149,1177,1121,494,1149,494,494,1210,1262,1265,1180,1265,1265,1264,1180,1263,1181,494,1121,1179,1265,1265,1180,1181,1207,1262,1266,1178,494,1235,1237,494,1177,494,494,1179,1263,1263,1266,1234,494,494,1149,494,1177,1121,494,1177,1121,494,1210,1150,1236,1151,1151,1237,494,1149,1121,1177,1177,1149,1121,1182,1206,1207,1150,1236,1152,1236,1154, -1178,494,494,494,1121,494,1121,1238,1209,1328,1380,1385,1385,1385,1385,1385,1385,1382,1328,1386,1386,1082,1413,1413,1413,1081,494,494,1179,1264,1266,1262,1181,494,1235,1237,1235,1237,1149,1177,494,1149,494,494,494,1238,1209,1235,1237,494,1149,1121,1149,1238,1234,1149,494,494,494,494,494,494,1121,494,494,1238,1206,494,494,1121,494,1177,1177,494,1238,1150,1237,494,494,494,494,1121,494,494,1177,494,1149,494,1177,494,494,1149,1177,494,494,494,1177,494,1121,494,1149,494,494,1235,1237,1177,494,1177,1207,1206,494,494,494,1179,1181,494,1207,1178,494,1235,1154,1150,1153,1236,1237,1149,494,494,494,1177,494,494,494,494,1149,494,1182,1150,1154,1150,1236,1154,1150,1154,1150,1237,494,494,1182,1150,1151,1154,1209,1182,1150,1236,1237,494,494,494,494,494,494,494,1210,1150,1154,1150,1237,494,1177,494,494,1177,494,1149,494,1179,1264,1266,1209,1149,494,1177,494,494,1149,1177,494,494,494,1121,1207,1178,1210,1178,1121,494,494,1235, -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,1236,1153,1237,494,1149,1177,494,494,494,494,494,1177,494,1149,494,1207,1209,1177,494,494,494,494,494,1207,1206,1149,1121,1149,1177,494,494,494,1149,494,494,1207,1234,494,494,1121,494,494,494,1121,1235,1237,494,494,1121,1149,1121,494,1121,494,494,494,494,494,494,494,494,494,1177,494,1121,1179,1180,1181,1121,494,494,1121,494,494,494,494,494,1149,1235,1237,494,494,494,1207,1178,1121,1207,1178,1121,1121,1207,1209,1149,494,494,494,494,1121,1121,1149,494,494,494,1177,1121,1177,1207,1178,1182,1206,494,1210,1178,1210,1234,494,494,494,1207,1234,494,1207,1262,1266,1206,494,1177,1177,494,494,1177,494,494,1121,1207,1178,1238,1178,494,494,494,1179,1263,1264,1181,494,494,1238,1150,1153,1237,494,494,1149,494,494,494,494,494,494,494,494,1235,1237,1238,1178,1177,494,494,1177, -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,1121,494,494,1177,494,494,494,1177,1177,494,494,1121,494,494,1121,1238,1209,1177,1177,494,1121,1149,1149,1207,1262,1265,1263,1181,1121,494,494,494,1177,494,494,1210,1234,494,494,1177,1177,1177,1149,494,1149,1149,1177,494,494,494,1121,494,494,1121,1149,1149,494,494,1121,1121,494,1121,494,1149,1177,1235,1151,1237,494,494,1121,1149,494,494,494,494,1179,1180,1181,1177,494,494,494,1207,1206,494,1210,1262,1263,1181,1235,1237,1121,494,494,1179,1264,1180,1265,1263,1263,1263,1264,1181,494,494,1235,1237,1182,1262,1181,1207,1234,1207,1178,494,1149,494,1207,1178,1149,1238,1150,1154,1206,494,494,1149,1177,494,1149,1121,494,494,1238,1178,1207,1206,494,494,494,1235,1236,1152,1237,1179,1265,1266,1209,494,494,494,494,494,1149,494,494,1149,494,1121,494,494,494,494,1210,1206,494,494,494,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,1121,1149,1149,494,494,1177,494,1149,1149,494,1149,494,494,494,1121,1210,1262,1263,1264,1263,1263,1263,1263,1266,1150,1152,1153,1237,494,1149,494,1177,494,494,1177,1182,1262,1263,1180,1264,1180,1264,1265,1265,1181,494,494,1179,1180,1181,494,494,494,1149,494,494,494,1121,494,1177,494,494,494,494,494,1121,494,1121,1177,494,494,1149,494,494,1177,1121,1182,1150,1237,494,1177,494,494,1182,1206,494,1238,1150,1151,1237,494,1149,494,494,494,1210,1150,1154,1150,1236,1236,1152,1151,1237,1179,1181,494,494,1238,1150,1237,1207,1234,1235,1237,1177,494,494,1210,1262,1180,1266,1209,1207,1206,1149,494,494,494,1121,494,494,494,494,1235,1237,1238,1234,1179,1181,1149,494,494,1177,494,1235,1236,1153,1237,494,1121,494,1149,494,494,494,494,494,1149,1121,1121,1121,494,1121,1182,1206,494,494,494,494, -1149,494,494,1177,1121,1177,494,1210,1178,1149,1121,494,494,1177,1210,1178,494,494,494,1121,1166,1166,1194,1167,1167,1194,1166,1149,1179,1264,1264,1264,1181,1149,1149,1179,1263,1180,1265,1264,1181,1149,494,494,1177,1182,1150,1153,1236,1236,1236,1153,1153,1151,1237,1177,1149,494,1149,494,494,1121,1121,494,494,1210,1150,1236,1152,1151,1152,1151,1151,1152,1237,1149,494,1235,1154,1178,494,494,494,494,494,494,494,1177,494,494,494,1149,494,1177,1121,494,1179,1181,1149,494,1177,494,1179,1265,1263,1181,1238,1209,1177,1121,1121,494,494,1182,1262,1263,1266,1234,1121,494,494,494,1177,1149,494,1238,1262,1266,1178,494,494,1121,1177,1149,1182,1209,1149,494,1238,1209,1177,1210,1206,494,494,494,1177,494,1235,1152,1153,1152,1237,1207,1206,494,1177,494,494,1149,494,1179,1181,494,494,1149,1207,1209,1238,1178,1177,494,1149,494,1149,494,1177,1149,1179,1263,1180,1265,1181,1179,1181,494,1177,1121,1177,494,494,1177,494,1121,1182,1178,1149,1121,494,494, -494,1149,1121,1149,494,1121,494,1238,1178,494,494,494,494,494,1210,1206,494,1149,494,1121,1167,1167,1166,1167,1167,1166,1166,1121,1238,1150,1151,1152,1237,1177,1149,1238,1150,1151,1236,1152,1237,494,494,1177,1179,1266,1234,1179,1264,1264,1265,1180,1263,1180,1263,1264,1264,1265,1181,494,494,494,494,494,494,1207,1206,494,1149,1149,494,494,1121,494,494,494,494,1177,1182,1262,1263,1180,1264,1263,1180,1180,1265,1181,494,1121,494,1177,494,494,494,1149,1182,1262,1180,1263,1265,1264,1266,1150,1153,1237,1235,1237,1149,494,494,494,1177,1207,1150,1236,1236,1237,494,494,494,1177,494,1179,1265,1266,1150,1151,1237,1121,494,494,1177,1177,1207,1262,1264,1263,1266,1178,494,1235,1237,494,1121,1149,1121,1177,1149,1149,1149,494,494,1210,1206,1149,494,494,1177,494,1121,1235,1237,494,1177,1177,1238,1209,1235,1237,494,494,1121,494,494,494,494,494,1182,1150,1152,1151,1237,1235,1237,494,494,494,494,1149,1121,494,1177,494,1235,1237,494,1149,1121,494, -494,494,1177,1121,494,494,1121,1210,1206,494,494,1121,494,1121,1235,1237,1177,494,494,494,1167,1166,1224,1225,1226,1167,1167,1149,1207,1262,1181,1149,494,494,1177,1210,1209,1177,1149,494,494,494,494,494,1235,1151,1237,1238,1150,1153,1236,1151,1153,1154,1150,1236,1236,1153,1237,494,494,494,494,1179,1180,1266,1234,1179,1265,1180,1181,494,1177,494,494,494,494,1149,1207,1150,1153,1236,1236,1154,1150,1152,1153,1237,1177,1149,1177,494,1177,1121,1149,494,1207,1150,1153,1153,1153,1153,1153,1237,494,1149,1179,1263,1265,1265,1180,1264,1181,1235,1237,1121,1121,494,494,1149,1177,1149,494,1207,1150,1236,1237,494,494,494,494,1121,494,1121,1238,1150,1151,1151,1151,1237,1149,1149,494,1121,494,494,1177,1149,494,494,494,1149,494,1207,1209,494,1121,1177,494,494,494,494,494,1177,1177,1177,1207,1178,494,494,494,494,1149,1121,1149,494,1149,494,1235,1237,1149,494,1149,1177,494,494,494,494,494,494,494,494,494,494,494,494,494,1149,1149,1149, -1149,494,1177,494,1177,494,494,1182,1234,494,494,494,1177,1121,1121,494,494,494,494,1149,1194,1194,1252,1253,1254,1167,1167,1121,1207,1150,1237,1177,494,494,494,1238,1262,1263,1264,1263,1263,1264,1265,1264,1181,1149,494,1182,1206,494,1121,1149,1149,1238,1209,494,1177,494,1121,494,494,494,494,1207,1150,1151,1237,1207,1150,1151,1237,494,494,1149,1177,1121,494,494,1210,1262,1265,1180,1265,1266,1262,1265,1264,1264,1265,1263,1181,494,1149,1149,1177,494,1238,1262,1265,1180,1263,1264,1263,1180,1263,1265,1266,1150,1236,1152,1152,1154,1178,494,1179,1181,494,494,494,1177,494,494,1149,1238,1209,494,1121,494,494,494,494,1149,1121,1121,1235,1237,494,494,1121,1149,494,494,494,494,494,1121,494,1121,1121,1121,494,1121,494,1238,1178,494,494,494,1121,1121,494,494,494,494,1121,1179,1266,1209,494,494,1179,1264,1264,1180,1264,1265,1263,1264,1264,1263,1264,1181,1177,494,1149,494,494,494,1149,494,494,494,1121,494,494,494,494,494,494,494, -494,1149,494,494,494,494,1121,1238,1209,1121,494,494,1149,494,494,1121,1121,1179,1180,1180,1194,1194,1280,1281,1282,1167,1166,1263,1266,1262,1180,1181,1149,494,494,1238,1150,1153,1236,1236,1152,1236,1152,1152,1237,494,1121,1210,1262,1263,1265,1264,1263,1266,1178,494,1177,1121,494,494,1121,494,1177,1238,1209,494,1121,1238,1262,1180,1264,1181,494,1149,1177,494,494,494,1182,1150,1154,1150,1154,1150,1154,1150,1152,1152,1154,1150,1237,494,494,1149,1177,494,1207,1150,1152,1154,1150,1153,1152,1151,1151,1153,1153,1237,1149,494,1149,1210,1178,1121,1182,1178,494,1121,1121,1149,494,1149,1177,1182,1262,1264,1181,1177,494,494,1177,494,1149,494,494,1149,494,494,494,1149,1121,494,494,1149,1121,494,494,494,494,494,494,1149,494,1235,1237,1177,494,494,1149,494,494,494,1149,494,494,1182,1150,1237,1121,494,1210,1150,1152,1151,1152,1151,1154,1150,1154,1150,1151,1237,1121,494,494,494,494,494,494,1177,494,1121,1179,1265,1263,1264,1264,1263,1265,1265, +1206,1149,1121,1238,1266,1262,1264,1266,1150,1328,1328,1328,1328,1328,1328,1328,1328,1328,1328,494,494,494,494,494,494,494,494,494,494,494,494,1177,494,494,494,494,1121,494,494,494,393,394,395,395,395,395,395,395,396,397,398,399,1149,1179,1266,1209,494,494,494,1177,1121,494,494,494,494,1238,1206,1235,1237,494,494,494,1149,494,1238,1262,1264,1266,1150,1153,1153,1153,1153,1153,1152,1237,1121,1182,1178,494,494,494,494,494,1149,494,494,494,494,1149,494,494,1149,1238,1262,1266,1150,1237,494,1121,1121,494,1149,1121,494,494,1238,1262,1265,1266,1178,1121,494,1179,1180,1265,1180,1265,1181,1177,494,1182,1209,494,494,1121,1210,1150,1152,1152,1237,494,1207,1206,494,1177,494,1121,1177,1121,494,1121,494,1238,1262,1265,1264,1264,1264,1180,1181,494,494,1235,1236,1152,1237,1210,1209,494,1149,1121,1149,494,1121,494,1149,494,494,1207,1206,494,494,1182,1150,1153,1152,1237,494,494,494,1121,1210,1209,494,494,494,494,494,494, +1209,494,1177,1210,1150,1153,1152,1154,1206,1328,1352,1381,1381,1381,1381,1381,1381,1354,1328,1181,1207,1051,1135,1136,1137,1053,1149,494,494,1121,1179,1265,1265,1263,1264,1181,1179,1264,1265,1264,421,422,423,423,423,423,423,423,424,425,426,427,494,1238,1150,1237,494,494,494,1121,494,1121,1121,1177,494,1207,1262,1263,1180,1263,1180,1181,1121,494,1207,1150,1236,1153,1237,494,494,494,494,494,494,494,1121,1235,1237,494,1149,494,494,1177,494,494,1177,1149,494,494,494,494,494,1238,1150,1154,1262,1265,1263,1180,1263,1181,494,494,494,494,1210,1150,1152,1153,1237,1121,494,1238,1150,1153,1236,1153,1237,494,494,1235,1237,494,494,494,1207,1206,494,494,494,494,1235,1237,494,494,494,1121,494,494,494,494,1149,1238,1150,1154,1150,1151,1154,1150,1237,1177,494,1149,494,494,494,1210,1234,494,494,494,1177,494,494,494,494,1149,494,1210,1262,1263,1180,1266,1178,1149,1149,494,494,1121,1149,1149,1238,1209,1179,1264,1180,1264,1264,1263, +1209,494,1177,1235,1237,1121,1177,1207,1234,1328,1380,1385,1385,1385,1385,1385,1385,1382,1328,1386,1386,1054,1413,1413,1413,1081,494,494,494,1149,1207,1150,1236,1152,1154,1206,1210,1150,1152,1152,449,450,1016,1017,1017,1019,1019,1019,1017,1020,454,455,494,1210,1209,494,494,494,1177,494,494,1177,494,494,494,1182,1150,1151,1153,1236,1153,1237,494,1177,1207,1262,1181,494,494,1121,494,494,494,1149,1177,494,1177,494,494,494,494,1177,1177,494,494,494,1121,1121,494,494,494,494,1121,1182,1234,1235,1236,1151,1154,1150,1236,1237,494,494,494,494,1210,1234,494,1179,1180,1180,1264,1266,1206,1177,494,494,494,1149,1177,1121,494,1149,494,494,1210,1262,1265,1180,1265,1265,1264,1180,1263,1181,494,1121,1179,1265,1265,1180,1181,1207,1262,1266,1178,494,1235,1237,494,1177,494,494,1179,1263,1263,1266,1234,494,494,1149,494,1177,1121,494,1177,1121,494,1210,1150,1236,1151,1151,1237,494,1149,1121,1177,1177,1149,1121,1182,1206,1207,1150,1236,1152,1236,1154, +1178,494,494,494,1121,494,1121,1238,1209,1328,1380,1385,1385,1385,1385,1385,1385,1382,1328,1386,1386,1082,1413,1413,1413,1081,494,494,1179,1264,1266,1262,1181,494,1235,1237,1235,1237,1149,1177,449,450,1100,480,987,480,987,987,480,1104,482,483,1149,1238,1234,1149,494,494,494,494,494,494,1121,494,494,1238,1206,494,494,1121,494,1177,1177,494,1238,1150,1237,494,494,494,494,1121,494,494,1177,494,1149,494,1177,494,494,1149,1177,494,494,494,1177,494,1121,494,1149,494,494,1235,1237,1177,494,1177,1207,1206,494,494,494,1179,1181,494,1207,1178,494,1235,1154,1150,1153,1236,1237,1149,494,494,494,1177,494,494,494,494,1149,494,1182,1150,1154,1150,1236,1154,1150,1154,1150,1237,494,494,1182,1150,1151,1154,1209,1182,1150,1236,1237,494,494,494,494,494,494,494,1210,1150,1154,1150,1237,494,1177,494,494,1177,494,1149,494,1179,1264,1266,1209,1149,494,1177,494,494,1149,1177,494,494,494,1121,1207,1178,1210,1178,1121,494,494,1235, +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,1236,1153,1237,494,1149,1177,494,494,494,494,477,478,1100,480,480,480,1074,1074,987,1076,510,511,494,1207,1206,1149,1121,1149,1177,494,494,494,1149,494,494,1207,1234,494,494,1121,494,494,494,1121,1235,1237,494,494,1121,1149,1121,494,1121,494,494,494,494,494,494,494,494,494,1177,494,1121,1179,1180,1181,1121,494,494,1121,494,494,494,494,494,1149,1235,1237,494,494,494,1207,1178,1121,1207,1178,1121,1121,1207,1209,1149,494,494,494,494,1121,1121,1149,494,494,494,1177,1121,1177,1207,1178,1182,1206,494,1210,1178,1210,1234,494,494,494,1207,1234,494,1207,1262,1266,1206,494,1177,1177,494,494,1177,494,494,1121,1207,1178,1238,1178,494,494,494,1179,1263,1264,1181,494,494,1238,1150,1153,1237,494,494,1149,494,494,494,494,494,494,494,494,1235,1237,1238,1178,1177,494,494,1177, +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,1121,494,494,1177,494,494,494,1177,1177,494,1102,1102,1103,1074,480,987,480,480,1074,1104,510,511,1149,1207,1262,1265,1263,1181,1121,494,494,494,1177,494,494,1210,1234,494,494,1177,1177,1177,1149,494,1149,1149,1177,494,494,494,1121,494,494,1121,1149,1149,494,494,1121,1121,494,1121,494,1149,1177,1235,1151,1237,494,494,1121,1149,494,494,494,494,1179,1180,1181,1177,494,494,494,1207,1206,494,1210,1262,1263,1181,1235,1237,1121,494,494,1179,1264,1180,1265,1263,1263,1263,1264,1181,494,494,1235,1237,1182,1262,1181,1207,1234,1207,1178,494,1149,494,1207,1178,1149,1238,1150,1154,1206,494,494,1149,1177,494,1149,1121,494,494,1238,1178,1207,1206,494,494,494,1235,1236,1152,1237,1179,1265,1266,1209,494,494,494,494,494,1149,494,494,1149,494,1121,494,494,494,494,1210,1206,494,494,494,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,1121,1149,1149,494,494,1177,494,1149,1149,494,1046,1046,1047,480,480,480,480,1015,987,1104,510,511,1263,1266,1150,1152,1153,1237,494,1149,494,1177,494,494,1177,1182,1262,1263,1180,1264,1180,1264,1265,1265,1181,494,494,1179,1180,1181,494,494,494,1149,494,494,494,1121,494,1177,494,494,494,494,494,1121,494,1121,1177,494,494,1149,494,494,1177,1121,1182,1150,1237,494,1177,494,494,1182,1206,494,1238,1150,1151,1237,494,1149,494,494,494,1210,1150,1154,1150,1236,1236,1152,1151,1237,1179,1181,494,494,1238,1150,1237,1207,1234,1235,1237,1177,494,494,1210,1262,1180,1266,1209,1207,1206,1149,494,494,494,1121,494,494,494,494,1235,1237,1238,1234,1179,1181,1149,494,494,1177,494,1235,1236,1153,1237,494,1121,494,1149,494,494,494,494,494,1149,1121,1121,1121,494,1121,1182,1206,494,494,494,494, +1149,494,494,1177,1121,1177,494,1210,1178,1149,1121,494,494,1177,1210,1178,494,494,494,1121,1166,1166,1194,1167,1167,1194,1166,1149,1179,1264,1264,1264,1181,1149,1149,1179,1263,1180,1265,1264,449,450,1100,1015,987,480,480,480,480,1104,510,511,1153,1151,1237,1177,1149,494,1149,494,494,1121,1121,494,494,1210,1150,1236,1152,1151,1152,1151,1151,1152,1237,1149,494,1235,1154,1178,494,494,494,494,494,494,494,1177,494,494,494,1149,494,1177,1121,494,1179,1181,1149,494,1177,494,1179,1265,1263,1181,1238,1209,1177,1121,1121,494,494,1182,1262,1263,1266,1234,1121,494,494,494,1177,1149,494,1238,1262,1266,1178,494,494,1121,1177,1149,1182,1209,1149,494,1238,1209,1177,1210,1206,494,494,494,1177,494,1235,1152,1153,1152,1237,1207,1206,494,1177,494,494,1149,494,1179,1181,494,494,1149,1207,1209,1238,1178,1177,494,1149,494,1149,494,1177,1149,1179,1263,1180,1265,1181,1179,1181,494,1177,1121,1177,494,494,1177,494,1121,1182,1178,1149,1121,494,494, +494,1149,1121,1149,494,1121,494,1238,1178,494,494,494,494,494,1210,1206,494,1149,494,1121,1167,1167,1166,1167,1167,1166,1166,1121,1238,1150,1151,1152,1237,1177,1149,1238,1150,1151,1236,1152,477,478,1100,1015,1074,480,1015,480,987,1048,510,511,1263,1180,1263,1264,1264,1265,1181,494,494,494,494,494,494,1207,1206,494,1149,1149,494,494,1121,494,494,494,494,1177,1182,1262,1263,1180,1264,1263,1180,1180,1265,1181,494,1121,494,1177,494,494,494,1149,1182,1262,1180,1263,1265,1264,1266,1150,1153,1237,1235,1237,1149,494,494,494,1177,1207,1150,1236,1236,1237,494,494,494,1177,494,1179,1265,1266,1150,1151,1237,1121,494,494,1177,1177,1207,1262,1264,1263,1266,1178,494,1235,1237,494,1121,1149,1121,1177,1149,1149,1149,494,494,1210,1206,1149,494,494,1177,494,1121,1235,1237,494,1177,1177,1238,1209,1235,1237,494,494,1121,494,494,494,494,494,1182,1150,1152,1151,1237,1235,1237,494,494,494,494,1149,1121,494,1177,494,1235,1237,494,1149,1121,494, +494,494,1177,1121,494,494,1121,1210,1206,494,494,1121,494,1121,1235,1237,1177,494,494,494,1167,1166,1224,1225,1226,1167,1167,1149,1207,1262,1181,1149,494,494,1177,1210,1209,1177,1149,494,505,506,1128,1131,1131,1131,1131,1131,1131,1132,510,511,1153,1154,1150,1236,1236,1153,1237,494,494,494,494,1179,1180,1266,1234,1179,1265,1180,1181,494,1177,494,494,494,494,1149,1207,1150,1153,1236,1236,1154,1150,1152,1153,1237,1177,1149,1177,494,1177,1121,1149,494,1207,1150,1153,1153,1153,1153,1153,1237,494,1149,1179,1263,1265,1265,1180,1264,1181,1235,1237,1121,1121,494,494,1149,1177,1149,494,1207,1150,1236,1237,494,494,494,494,1121,494,1121,1238,1150,1151,1151,1151,1237,1149,1149,494,1121,494,494,1177,1149,494,494,494,1149,494,1207,1209,494,1121,1177,494,494,494,494,494,1177,1177,1177,1207,1178,494,494,494,494,1149,1121,1149,494,1149,494,1235,1237,1149,494,1149,1177,494,494,494,494,494,494,494,494,494,494,494,494,494,1149,1149,1149, +1149,494,1177,494,1177,494,494,1182,1234,494,494,494,1177,1121,1121,494,494,494,494,1149,1194,1194,1252,1253,1254,1167,1167,1121,1207,1150,1237,1177,494,494,494,1238,1262,1263,1264,1263,533,534,535,535,535,535,535,535,536,537,538,539,1149,1238,1209,494,1177,494,1121,494,494,494,494,1207,1150,1151,1237,1207,1150,1151,1237,494,494,1149,1177,1121,494,494,1210,1262,1265,1180,1265,1266,1262,1265,1264,1264,1265,1263,1181,494,1149,1149,1177,494,1238,1262,1265,1180,1263,1264,1263,1180,1263,1265,1266,1150,1236,1152,1152,1154,1178,494,1179,1181,494,494,494,1177,494,494,1149,1238,1209,494,1121,494,494,494,494,1149,1121,1121,1235,1237,494,494,1121,1149,494,494,494,494,494,1121,494,1121,1121,1121,494,1121,494,1238,1178,494,494,494,1121,1121,494,494,494,494,1121,1179,1266,1209,494,494,1179,1264,1264,1180,1264,1265,1263,1264,1264,1263,1264,1181,1177,494,1149,494,494,494,1149,494,494,494,1121,494,494,494,494,494,494,494, +494,1149,494,494,494,494,1121,1238,1209,1121,494,494,1149,494,494,1121,1121,1179,1180,1180,1194,1194,1280,1281,1282,1167,1166,1263,1266,1262,1180,1181,1149,494,494,1238,1150,1153,1236,1236,561,562,563,563,563,563,563,563,564,565,566,567,1263,1266,1178,494,1177,1121,494,494,1121,494,1177,1238,1209,494,1121,1238,1262,1180,1264,1181,494,1149,1177,494,494,494,1182,1150,1154,1150,1154,1150,1154,1150,1152,1152,1154,1150,1237,494,494,1149,1177,494,1207,1150,1152,1154,1150,1153,1152,1151,1151,1153,1153,1237,1149,494,1149,1210,1178,1121,1182,1178,494,1121,1121,1149,494,1149,1177,1182,1262,1264,1181,1177,494,494,1177,494,1149,494,494,1149,494,494,494,1149,1121,494,494,1149,1121,494,494,494,494,494,494,1149,494,1235,1237,1177,494,494,1149,494,494,494,1149,494,494,1182,1150,1237,1121,494,1210,1150,1152,1151,1152,1151,1154,1150,1154,1150,1151,1237,1121,494,494,494,494,494,494,1177,494,1121,1179,1265,1263,1264,1264,1263,1265,1265, 1179,1263,1264,1264,1010,1012,1012,1012,1014,1149,494,494,494,1121,1177,494,1177,1210,1150,1236,1167,1167,1167,1166,1166,1167,1167,1154,1150,1151,1152,1237,494,1177,494,1182,1209,494,1177,1177,1121,494,1121,494,494,494,1177,1182,1150,1152,1153,1152,1151,1154,1234,1177,1177,1121,1177,494,494,1177,494,1238,1262,1265,1180,1266,1150,1152,1154,1178,494,494,494,494,1177,1177,1210,1209,1207,1178,1210,1209,1182,1209,1149,494,1210,1262,1265,1180,1181,494,1179,1263,1266,1234,1177,1207,1234,494,1149,1121,1121,494,1121,494,494,494,494,1238,1262,1263,1266,1262,1181,1177,494,494,494,1121,494,1210,1150,1153,1237,1149,494,1179,1263,1180,1264,1180,1263,1263,1263,1263,1264,1263,1181,1177,494,494,1177,1121,494,1121,494,494,494,494,494,1121,494,494,494,494,494,1149,1121,1177,1149,494,1177,1235,1237,494,494,494,1207,1209,494,1149,494,1179,1266,1206,1235,1237,1179,1180,1264,1263,1265,1265,1181,494,1149,1177,1121,494,1207,1150,1236,1153,1151,1236,1154,1150, 1235,1151,1151,1152,1038,102,981,102,1070,1177,1177,1179,1263,1180,1264,1263,1264,1266,1178,494,1167,1167,1167,1167,1167,1194,1167,1266,1209,1121,494,494,494,494,1177,1182,1178,1149,494,1121,1179,1263,1265,1263,1263,1181,494,1210,1262,1263,1265,1180,1181,1210,1178,494,494,494,1177,494,494,1121,1121,1210,1150,1154,1150,1153,1237,494,1238,1178,1177,494,1121,494,494,1149,1182,1206,1210,1262,1266,1209,1210,1209,1177,494,1207,1150,1236,1153,1237,494,1182,1150,1236,1237,494,1235,1237,494,1177,1121,1177,1177,494,1121,494,494,494,1238,1150,1153,1153,1152,1237,494,1121,494,494,1121,494,1235,1237,494,494,1177,494,1235,1152,1153,1154,1150,1151,1153,1154,1150,1154,1150,1237,494,1177,1121,1149,1177,494,494,1149,494,494,494,494,494,1179,1264,1264,1264,1263,1264,1263,1181,1149,1179,1180,1265,1180,1181,1149,1149,1238,1262,1181,494,494,1210,1150,1237,1177,1177,1238,1150,1151,1152,1151,1151,1237,494,494,1121,1179,1265,1266,1209,494,1121,494,1121,1207,1262, 494,494,494,494,1066,102,102,102,1042,494,494,1210,1150,1151,1151,1153,1154,1150,1237,494,1121,494,1149,494,494,1121,1207,1150,1237,1149,494,1177,494,1149,494,1235,1237,494,1177,494,1182,1150,1153,1151,1151,1237,1149,1238,1150,1153,1151,1152,1237,1238,1209,494,1177,494,494,494,1121,494,494,1238,1209,1182,1206,1179,1265,1265,1266,1178,494,494,494,1179,1180,1264,1266,1178,1238,1150,1152,1237,1210,1209,494,494,1210,1209,494,494,494,1149,1238,1178,494,1149,1179,1263,1181,494,494,494,1121,494,494,494,1177,494,494,1207,1206,1121,494,1149,1177,1177,494,1149,1121,494,494,1149,1177,494,1179,1265,1180,1265,1263,1181,1210,1234,1149,494,1207,1178,1210,1234,1149,494,494,494,494,1179,1264,1265,1265,1263,1180,1264,1181,494,1235,1152,1152,1236,1236,1154,1150,1237,1149,1182,1150,1152,1153,1237,494,494,1182,1150,1237,494,494,1207,1206,494,494,494,1235,1237,1177,1121,494,494,494,1149,494,494,1182,1150,1236,1237,1149,494,1177,1177,1210,1150, diff --git a/src/Hamster.cpp b/src/Hamster.cpp index f669ead..64e3c44 100644 --- a/src/Hamster.cpp +++ b/src/Hamster.cpp @@ -90,7 +90,7 @@ void Hamster::UpdateHamsters(const float fElapsedTime){ if(h.waitTimer<=0.f){ h.imgScale=1.f; h.drownTimer=0.f; - h.pos=h.lastSafeLocation; + h.SetPos(h.lastSafeLocation); h.state=NORMAL; h.RemoveAllPowerups(); } @@ -198,7 +198,7 @@ void Hamster::TurnTowardsTargetDirection(){ } void Hamster::MoveHamster(){ - pos+=vel*HamsterGame::Game().GetElapsedTime(); + SetPos(GetPos()+vel*HamsterGame::Game().GetElapsedTime()); distanceTravelled+=vel.mag()*HamsterGame::Game().GetElapsedTime(); @@ -218,8 +218,8 @@ void Hamster::HandleCollision(){ float randDir{util::random(2*geom2d::pi)}; vf2d collisionResolve1{GetPos()+vf2d{GetRadius(),randDir}.cart()}; vf2d collisionResolve2{h.GetPos()+vf2d{h.GetRadius(),float(randDir+geom2d::pi)}.cart()}; - pos=collisionResolve1; - h.pos=collisionResolve2; + SetPos(collisionResolve1); + h.SetPos(collisionResolve2); vel=vf2d{GetBumpAmount(),randDir}.cart(); h.vel=vf2d{GetBumpAmount(),float(randDir+geom2d::pi)}.cart(); }else{ @@ -229,8 +229,8 @@ void Hamster::HandleCollision(){ float bumpDistance{totalRadii-distance}; vf2d collisionResolve1{GetPos()+vf2d{bumpDistance/2.f,float(collisionLine.vector().polar().y+geom2d::pi)}.cart()}; vf2d collisionResolve2{h.GetPos()+vf2d{bumpDistance/2.f,collisionLine.vector().polar().y}.cart()}; - pos=collisionResolve1; - h.pos=collisionResolve2; + SetPos(collisionResolve1); + h.SetPos(collisionResolve2); vel=vf2d{GetBumpAmount(),float(collisionLine.vector().polar().y+geom2d::pi)}.cart(); h.vel=vf2d{GetBumpAmount(),collisionLine.vector().polar().y}.cart(); } @@ -254,6 +254,10 @@ const Terrain::TerrainType Hamster::GetTerrainStandingOn()const{ return HamsterGame::Game().GetTerrainTypeAtPos(GetPos()); } +const bool Hamster::IsTerrainStandingOnSolid()const{ + return HamsterGame::Game().IsTerrainSolid(GetPos()); +} + const float Hamster::GetTimeToMaxSpeed()const{ float finalTimeToMaxSpd{DEFAULT_TIME_TO_MAX_SPD}; if(!HasPowerup(Powerup::ICE)&&GetTerrainStandingOn()==Terrain::ICE)finalTimeToMaxSpd*=3; @@ -333,4 +337,12 @@ const float Hamster::GetBurnRatio()const{ const float&Hamster::GetZ()const{ return z; +} + +void Hamster::SetPos(const vf2d pos){ + if(state!=FLYING){ + if(!HamsterGame::Game().IsTerrainSolid(vf2d{this->pos.x,pos.y}))this->pos=vf2d{this->pos.x,pos.y}; + if(!HamsterGame::Game().IsTerrainSolid(vf2d{pos.x,this->pos.y}))this->pos=vf2d{pos.x,this->pos.y}; + if(!HamsterGame::Game().IsTerrainSolid(vf2d{this->pos.x,pos.y}))this->pos=vf2d{this->pos.x,pos.y}; + } } \ No newline at end of file diff --git a/src/Hamster.h b/src/Hamster.h index d14ec51..0c8b9b8 100644 --- a/src/Hamster.h +++ b/src/Hamster.h @@ -112,6 +112,7 @@ public: void HandleCollision(); const float GetRadius()const; const Terrain::TerrainType GetTerrainStandingOn()const; + const bool IsTerrainStandingOnSolid()const; const float GetTimeToMaxSpeed()const; const float GetMaxSpeed()const; const float GetFriction()const; @@ -125,4 +126,5 @@ public: const bool IsBurning()const; const float GetDrownRatio()const; const float GetBurnRatio()const; + void SetPos(const vf2d pos); }; \ No newline at end of file diff --git a/src/HamsterGame.cpp b/src/HamsterGame.cpp index 4e843a9..1311027 100644 --- a/src/HamsterGame.cpp +++ b/src/HamsterGame.cpp @@ -74,6 +74,10 @@ void HamsterGame::LoadAnimations(){ lavaAnimFrames.AddFrame(Animate2D::Frame{&GetGFX("gametiles.png"),{sourcePos,{16,16}}}); } LoadAnimation(JET_LIGHTS,"hamster_jet.png",{{0,48},{48,48}},0.3f); + + + animatedWaterTile.Create(16,16,false,false); + UpdateWaterTexture(); } void HamsterGame::LoadLevel(const std::string_view mapName){ @@ -118,6 +122,7 @@ void HamsterGame::LoadLevel(const std::string_view mapName){ void HamsterGame::UpdateGame(const float fElapsedTime){ UpdateMatrixTexture(); + UpdateWaterTexture(); camera.SetViewSize(tv.GetWorldVisibleArea()); camera.Update(fElapsedTime); tv.SetWorldOffset(tv.ScaleToWorld(-SCREEN_FRAME.pos)+camera.GetViewPosition()); @@ -127,6 +132,7 @@ void HamsterGame::UpdateGame(const float fElapsedTime){ } void HamsterGame::DrawGame(){ + tv.DrawPartialDecal({-3200,-3200},currentMap.value().GetData().GetMapData().MapSize*16+vf2d{3200,3200},animatedWaterTile.Decal(),{0,0},currentMap.value().GetData().GetMapData().MapSize*16+vf2d{3200,3200}); DrawLevelTiles(); Powerup::DrawPowerups(tv); Hamster::DrawHamsters(tv); @@ -176,6 +182,20 @@ const Terrain::TerrainType HamsterGame::GetTerrainTypeAtPos(const vf2d pos)const return tileType; } +const bool HamsterGame::IsTerrainSolid(const vf2d pos)const{ + if(pos.x<=0.f||pos.y<=0.f||pos.x>=currentMap.value().GetData().GetMapData().width*16||pos.y>=currentMap.value().GetData().GetMapData().height*16)return true; + bool tileIsBlank{true}; + for(const LayerTag&layer:currentMap.value().GetData().GetLayers()){ + int tileX{int(floor(pos.x)/16)}; + int tileY{int(floor(pos.y)/16)}; + int tileID{layer.tiles[tileY][tileX]-1}; + if(tileID==-1)continue; + tileIsBlank=false; + if(currentTileset.value().GetData().GetTerrainData().count(tileID)&¤tTileset.value().GetData().GetTerrainData().at(tileID).first==Terrain::SolidType::SOLID)return true; + } + return tileIsBlank; +} + void HamsterGame::DrawLevelTiles(){ float extendedBounds{SCREEN_FRAME.pos.x}; extendedBounds*=1/tv.GetWorldScale().x; @@ -286,6 +306,15 @@ void HamsterGame::UpdateMatrixTexture(){ std::erase_if(activeLetters,[](Letter&letter){return letter.pos.y<-32;}); } +void HamsterGame::UpdateWaterTexture(){ + const Animate2D::FrameSequence&waterAnimSequence{ANIMATED_TILE_IDS[1384]}; + const Animate2D::Frame&frame{waterAnimSequence.GetFrame(GetRuntime())}; + SetDrawTarget(animatedWaterTile.Sprite()); + DrawPartialSprite({},frame.GetSourceImage()->Sprite(),frame.GetSourceRect().pos,frame.GetSourceRect().size); + SetDrawTarget(nullptr); + animatedWaterTile.Decal()->Update(); +} + int main() { HamsterGame game; diff --git a/src/HamsterGame.h b/src/HamsterGame.h index a21d27b..b8cd8d9 100644 --- a/src/HamsterGame.h +++ b/src/HamsterGame.h @@ -78,6 +78,7 @@ public: static std::unordered_mapANIMATED_TILE_IDS; const double GetRuntime()const; const Terrain::TerrainType GetTerrainTypeAtPos(const vf2d pos)const; + const bool IsTerrainSolid(const vf2d pos)const; private: void UpdateGame(const float fElapsedTime); void DrawGame(); @@ -99,4 +100,6 @@ private: float matrixTimer; std::vectoractiveLetters; float updatePixelsTimer; + Renderable animatedWaterTile; + void UpdateWaterTexture(); }; \ No newline at end of file diff --git a/src/TSXParser.h b/src/TSXParser.h index 85a4e2d..f9642ef 100644 --- a/src/TSXParser.h +++ b/src/TSXParser.h @@ -164,7 +164,7 @@ class TSXParser{ tileData.second=Terrain::TerrainType(newTag.GetInteger("value")); } } else - if(newTag.tag=="property"&&newTag.data["propertytype"]=="Solid"){ + if(newTag.tag=="property"&&newTag.data["name"]=="Solid"){ //The way animation data is stored is every "animation_tile_precision" ms indicating which frame we should be on. for(int&tagID:previousTagID){ std::pair&tileData{parsedTilesetInfo.TerrainData[tagID]};