SDL_Game_CPP git · main
SDL game in C++
C++ 99.3%git clone https://git.christianimmanuel.de/sdl-graphics/SDL_Game_CPP.gitwget https://git.christianimmanuel.de/sdl-graphics/SDL_Game_CPP/archive/SDL_Game_CPP.tar.gzinit
.gitignore | 3 + Bird/Individual Sprites/Bird Sprites.aseprite | Bin 0 -> 4026 bytes Bird/Individual Sprites/BirdEating1.png | Bin 0 -> 430 bytes Bird/Individual Sprites/BirdEating2.png | Bin 0 -> 364 bytes Bird/Individual Sprites/BirdEating3.png | Bin 0 -> 369 bytes Bird/Individual Sprites/BirdFlying1.png | Bin 0 -> 407 bytes Bird/Individual Sprites/BirdFlying2.png | Bin 0 -> 436 bytes Bird/Individual Sprites/BirdFlying3.png | Bin 0 -> 340 bytes Bird/Individual Sprites/BirdFlying4.png | Bin 0 -> 397 bytes Bird/Individual Sprites/BirdFlying5.png | Bin 0 -> 437 bytes Bird/Individual Sprites/BirdFlying6.png | Bin 0 -> 401 bytes Bird/Individual Sprites/BirdFlying7.png | Bin 0 -> 356 bytes Bird/Individual Sprites/BirdFlying8.png | Bin 0 -> 431 bytes Bird/Individual Sprites/BirdIdle1.png | Bin 0 -> 456 bytes Bird/Individual Sprites/BirdIdle2.png | Bin 0 -> 397 bytes Bird/Individual Sprites/BirdWalking1.png | Bin 0 -> 380 bytes Bird/Individual Sprites/BirdWalking2.png | Bin 0 -> 389 bytes Bird/Individual Sprites/BirdWalking3.png | Bin 0 -> 389 bytes Bird/Spritesheet/Bird Spritesheet.aseprite | Bin 0 -> 1961 bytes Bird/Spritesheet/Bird Spritesheet.png | Bin 0 -> 3139 bytes CMakeLists.txt | 76 + .../Carry_Idle/Carry_Idle_Down-Sheet.png | Bin 0 -> 992 bytes .../Animations/Carry_Idle/Carry_Idle_Down.aseprite | Bin 0 -> 1991 bytes .../Carry_Idle/Carry_Idle_Side-Sheet.png | Bin 0 -> 1001 bytes .../Animations/Carry_Idle/Carry_Idle_Side.aseprite | Bin 0 -> 2072 bytes .../Animations/Carry_Idle/Carry_Idle_Up-Sheet.png | Bin 0 -> 827 bytes .../Animations/Carry_Idle/Carry_Idle_Up.aseprite | Bin 0 -> 1931 bytes .../Animations/Carry_Run/Carry_Run_Down-Sheet.png | Bin 0 -> 1375 bytes .../Animations/Carry_Run/Carry_Run_Down.aseprite | Bin 0 -> 2913 bytes .../Animations/Carry_Run/Carry_Run_Side-Sheet.png | Bin 0 -> 1369 bytes .../Animations/Carry_Run/Carry_Run_Side.aseprite | Bin 0 -> 3006 bytes .../Animations/Carry_Run/Carry_Run_Up-Sheet.png | Bin 0 -> 1073 bytes .../Animations/Carry_Run/Carry_Run_Up.aseprite | Bin 0 -> 2770 bytes .../Carry_Walk/Carry_Walk_Down-Sheet.png | Bin 0 -> 1283 bytes .../Animations/Carry_Walk/Carry_Walk_Down.aseprite | Bin 0 -> 2861 bytes .../Carry_Walk/Carry_Walk_Side-Sheet.png | Bin 0 -> 1367 bytes .../Animations/Carry_Walk/Carry_Walk_Side.aseprite | Bin 0 -> 3007 bytes .../Animations/Carry_Walk/Carry_Walk_Up-Sheet.png | Bin 0 -> 1123 bytes .../Animations/Carry_Walk/Carry_Walk_Up.aseprite | Bin 0 -> 2751 bytes .../Animations/Collect_Base/Collect_Down-Sheet.png | Bin 0 -> 1743 bytes .../Animations/Collect_Base/Collect_Down.aseprite | Bin 0 -> 3560 bytes .../Animations/Collect_Base/Collect_Side-Sheet.png | Bin 0 -> 2053 bytes .../Animations/Collect_Base/Collect_Side.aseprite | Bin 0 -> 3771 bytes .../Animations/Collect_Base/Collect_Up-Sheet.png | Bin 0 -> 1544 bytes .../Animations/Collect_Base/Collect_Up.aseprite | Bin 0 -> 3393 bytes .../Animations/Crush_Base/Crush_Down-Sheet.png | Bin 0 -> 2629 bytes .../Animations/Crush_Base/Crush_Down.aseprite | Bin 0 -> 4831 bytes .../Animations/Crush_Base/Crush_Side-Sheet.png | Bin 0 -> 2664 bytes .../Animations/Crush_Base/Crush_Side.aseprite | Bin 0 -> 4951 bytes .../Animations/Crush_Base/Crush_Up-Sheet.png | Bin 0 -> 2202 bytes .../Body_A/Animations/Crush_Base/Crush_Up.aseprite | Bin 0 -> 4455 bytes .../Animations/Death_Base/Death_Down-Sheet.png | Bin 0 -> 2017 bytes .../Animations/Death_Base/Death_Down.aseprite | Bin 0 -> 3476 bytes .../Animations/Death_Base/Death_Side-Sheet.png | Bin 0 -> 1803 bytes .../Animations/Death_Base/Death_Side.aseprite | Bin 0 -> 3599 bytes .../Animations/Death_Base/Death_Up-Sheet.png | Bin 0 -> 1692 bytes .../Body_A/Animations/Death_Base/Death_Up.aseprite | Bin 0 -> 3374 bytes .../Animations/Fishing_Base/Fishing_Down-Sheet.png | Bin 0 -> 2425 bytes .../Animations/Fishing_Base/Fishing_Down.aseprite | Bin 0 -> 4878 bytes .../Animations/Fishing_Base/Fishing_Side-Sheet.png | Bin 0 -> 2471 bytes .../Animations/Fishing_Base/Fishing_Side.aseprite | Bin 0 -> 5162 bytes .../Animations/Fishing_Base/Fishing_Up-Sheet.png | Bin 0 -> 2303 bytes .../Animations/Fishing_Base/Fishing_Up.aseprite | Bin 0 -> 4880 bytes .../Body_A/Animations/Hit_Base/Hit_Down-Sheet.png | Bin 0 -> 1163 bytes .../Body_A/Animations/Hit_Base/Hit_Down.aseprite | Bin 0 -> 1971 bytes .../Body_A/Animations/Hit_Base/Hit_Side-Sheet.png | Bin 0 -> 1169 bytes .../Body_A/Animations/Hit_Base/Hit_Side.aseprite | Bin 0 -> 2104 bytes .../Body_A/Animations/Hit_Base/Hit_Up-Sheet.png | Bin 0 -> 988 bytes .../Body_A/Animations/Hit_Base/Hit_Up.aseprite | Bin 0 -> 1896 bytes .../Animations/Idle_Base/Idle_Down-Sheet.png | Bin 0 -> 1026 bytes .../Body_A/Animations/Idle_Base/Idle_Down.aseprite | Bin 0 -> 1954 bytes .../Animations/Idle_Base/Idle_Side-Sheet.png | Bin 0 -> 1068 bytes .../Body_A/Animations/Idle_Base/Idle_Side.aseprite | Bin 0 -> 2144 bytes .../Body_A/Animations/Idle_Base/Idle_Up-Sheet.png | Bin 0 -> 863 bytes .../Body_A/Animations/Idle_Base/Idle_Up.aseprite | Bin 0 -> 1851 bytes .../Animations/Pierce_Base/Pierce_Down-Sheet.png | Bin 0 -> 2313 bytes .../Animations/Pierce_Base/Pierce_Down.aseprite | Bin 0 -> 4776 bytes .../Animations/Pierce_Base/Pierce_Side-Sheet.png | Bin 0 -> 2166 bytes .../Animations/Pierce_Base/Pierce_Side.aseprite | Bin 0 -> 5114 bytes .../Animations/Pierce_Base/Pierce_Top-Sheet.png | Bin 0 -> 1748 bytes .../Animations/Pierce_Base/Pierce_Top.aseprite | Bin 0 -> 4504 bytes .../Pierce_Base/Pierce_Wood_Down.aseprite | Bin 0 -> 4798 bytes .../Animations/Pierce_Base/Pierce_Wood_Down.png | Bin 0 -> 2313 bytes .../Pierce_Base/Pierce_Wood_Side.aseprite | Bin 0 -> 5136 bytes .../Animations/Pierce_Base/Pierce_Wood_Side.png | Bin 0 -> 2137 bytes .../Pierce_Base/Pierce_Wood_Top.aseprite | Bin 0 -> 4526 bytes .../Animations/Pierce_Base/Pierce_Wood_Top.png | Bin 0 -> 1754 bytes .../Animations/Pierce_Base/sword_wood.aseprite | Bin 0 -> 302 bytes .../Animations/Pierce_Blocking/Block_Side.aseprite | Bin 0 -> 2792 bytes .../Animations/Pierce_Blocking/Down.aseprite | Bin 0 -> 4920 bytes .../Body_A/Animations/Pierce_Blocking/Down.png | Bin 0 -> 2108 bytes .../Animations/Pierce_Blocking/Side.aseprite | Bin 0 -> 5287 bytes .../Body_A/Animations/Pierce_Blocking/Side.png | Bin 0 -> 2087 bytes .../Body_A/Animations/Pierce_Blocking/Up.aseprite | Bin 0 -> 4806 bytes .../Body_A/Animations/Pierce_Blocking/Up.png | Bin 0 -> 1615 bytes .../Body_A/Animations/Run_Base/Run_Down-Sheet.png | Bin 0 -> 1490 bytes .../Body_A/Animations/Run_Base/Run_Down.aseprite | Bin 0 -> 2930 bytes .../Body_A/Animations/Run_Base/Run_Side-Sheet.png | Bin 0 -> 1696 bytes .../Body_A/Animations/Run_Base/Run_Side.aseprite | Bin 0 -> 2963 bytes .../Body_A/Animations/Run_Base/Run_Up-Sheet.png | Bin 0 -> 1357 bytes .../Body_A/Animations/Run_Base/Run_Up.aseprite | Bin 0 -> 2730 bytes .../Animations/Slice_Base/Slice_Down.aseprite | Bin 0 -> 5011 bytes .../Body_A/Animations/Slice_Base/Slice_Down.png | Bin 0 -> 2780 bytes .../Animations/Slice_Base/Slice_Side.aseprite | Bin 0 -> 5354 bytes .../Body_A/Animations/Slice_Base/Slice_Side.png | Bin 0 -> 2871 bytes .../Body_A/Animations/Slice_Base/Slice_Up.aseprite | Bin 0 -> 4722 bytes .../Body_A/Animations/Slice_Base/Slice_Up.png | Bin 0 -> 2319 bytes .../Animations/Walk_Base/Walk_Down-Sheet.png | Bin 0 -> 1424 bytes .../Body_A/Animations/Walk_Base/Walk_Down.aseprite | Bin 0 -> 2828 bytes .../Animations/Walk_Base/Walk_Side-Sheet.png | Bin 0 -> 1414 bytes .../Body_A/Animations/Walk_Base/Walk_Side.aseprite | Bin 0 -> 2970 bytes .../Body_A/Animations/Walk_Base/Walk_Up-Sheet.png | Bin 0 -> 1319 bytes .../Body_A/Animations/Walk_Base/Walk_Up.aseprite | Bin 0 -> 2735 bytes .../Watering_Base/Watering_Down-Sheet.png | Bin 0 -> 1841 bytes .../Watering_Base/Watering_Down.aseprite | Bin 0 -> 5058 bytes .../Watering_Base/Watering_Side-Sheet.png | Bin 0 -> 2377 bytes .../Watering_Base/Watering_Side.aseprite | Bin 0 -> 5071 bytes .../Animations/Watering_Base/Watering_Up-Sheet.png | Bin 0 -> 1547 bytes .../Animations/Watering_Base/Watering_Up.aseprite | Bin 0 -> 4179 bytes .../Orc Crew/Orc - Rogue/Death/Death-Sheet.png | Bin 0 -> 3430 bytes .../Mobs/Orc Crew/Orc - Rogue/Death/Death.aseprite | Bin 0 -> 3037 bytes .../Mobs/Orc Crew/Orc - Rogue/Idle/Idle-Sheet.png | Bin 0 -> 1614 bytes .../Mobs/Orc Crew/Orc - Rogue/Idle/Idle.aseprite | Bin 0 -> 2406 bytes .../Mobs/Orc Crew/Orc - Rogue/Run/Run-Sheet.png | Bin 0 -> 2520 bytes .../Mobs/Orc Crew/Orc - Rogue/Run/Run.aseprite | Bin 0 -> 8397 bytes .../Orc Crew/Orc - Shaman/Death/Death-Sheet.png | Bin 0 -> 2777 bytes .../Orc Crew/Orc - Shaman/Death/Death.aseprite | Bin 0 -> 3306 bytes .../Mobs/Orc Crew/Orc - Shaman/Idle/Idle-Sheet.png | Bin 0 -> 1713 bytes .../Mobs/Orc Crew/Orc - Shaman/Idle/Idle.aseprite | Bin 0 -> 2448 bytes .../Mobs/Orc Crew/Orc - Shaman/Run/Run-Sheet.png | Bin 0 -> 2852 bytes .../Mobs/Orc Crew/Orc - Shaman/Run/Run.aseprite | Bin 0 -> 7381 bytes .../Orc Crew/Orc - Warrior/Death/Death-Sheet.png | Bin 0 -> 4416 bytes .../Orc Crew/Orc - Warrior/Death/Death.aseprite | Bin 0 -> 4131 bytes .../Orc Crew/Orc - Warrior/Idle/Idle-Sheet.png | Bin 0 -> 2075 bytes .../Mobs/Orc Crew/Orc - Warrior/Idle/Idle.aseprite | Bin 0 -> 2722 bytes .../Mobs/Orc Crew/Orc - Warrior/Run/Run-Sheet.png | Bin 0 -> 3248 bytes .../Mobs/Orc Crew/Orc - Warrior/Run/Run.aseprite | Bin 0 -> 8738 bytes .../Mobs/Orc Crew/Orc/Death/Death-Sheet.png | Bin 0 -> 3080 bytes .../Mobs/Orc Crew/Orc/Death/Death.aseprite | Bin 0 -> 2753 bytes .../Entities/Mobs/Orc Crew/Orc/Idle/Idle-Sheet.png | Bin 0 -> 1544 bytes .../Entities/Mobs/Orc Crew/Orc/Idle/Idle.aseprite | Bin 0 -> 2295 bytes .../Entities/Mobs/Orc Crew/Orc/Run/Run-Sheet.png | Bin 0 -> 2443 bytes .../Entities/Mobs/Orc Crew/Orc/Run/Run.aseprite | Bin 0 -> 6303 bytes .../Skeleton - Base/Attack/Attack-sheet.png | Bin 0 -> 2432 bytes .../Skeleton - Base/Attack/Attack.aseprite | Bin 0 -> 2831 bytes .../Skeleton - Base/Attack/Attack.png | Bin 0 -> 3935 bytes .../Skeleton - Base/Attack/Attack_Down.aseprite | Bin 0 -> 2835 bytes .../Skeleton - Base/Attack/Attack_Down.png | Bin 0 -> 4106 bytes .../Skeleton - Base/Attack/Attack_Up.aseprite | Bin 0 -> 3031 bytes .../Skeleton - Base/Attack/Attack_Up.png | Bin 0 -> 4205 bytes .../Skeleton - Base/Block/Block.aseprite | Bin 0 -> 1409 bytes .../Skeleton Crew/Skeleton - Base/Block/Block.png | Bin 0 -> 1727 bytes .../Skeleton - Base/Death/Death-Sheet.png | Bin 0 -> 3388 bytes .../Skeleton - Base/Death/Death-Sheet_padded.png | Bin 0 -> 367 bytes .../Death/Death-Sheet_processed.png | Bin 0 -> 1335 bytes .../Skeleton - Base/Death/Death-Sheet_shifted.png | Bin 0 -> 1359 bytes .../Skeleton - Base/Death/Death.aseprite | Bin 0 -> 3060 bytes .../Skeleton - Base/Idle/Idle-Sheet.png | Bin 0 -> 1248 bytes .../Skeleton - Base/Idle/Idle-Sheet_padded.png | Bin 0 -> 725 bytes .../Skeleton - Base/Idle/Idle.aseprite | Bin 0 -> 823 bytes .../Skeleton - Base/Idle/Idlet.aseprite | Bin 0 -> 823 bytes .../Skeleton - Base/Run/Run-Sheet-export.aseprite | Bin 0 -> 2308 bytes .../Skeleton - Base/Run/Run-Sheet-sheet.png | Bin 0 -> 2238 bytes .../Skeleton - Base/Run/Run-Sheet.png | Bin 0 -> 3306 bytes .../Skeleton - Base/Run/Run-Sheet_shifted.png | Bin 0 -> 918 bytes .../Skeleton - Base/Run/Run-sheet.png | Bin 0 -> 1913 bytes .../Skeleton Crew/Skeleton - Base/Run/Run.aseprite | Bin 0 -> 5786 bytes .../Mobs/Skeleton Crew/Skeleton - Base/Run/Run.png | Bin 0 -> 3306 bytes .../Skeleton - Base/Run/Run_Upt.aseprite | Bin 0 -> 2129 bytes .../Skeleton - Base/Run/Run_up-sheet.png | Bin 0 -> 2392 bytes .../Skeleton Crew/Skeleton - Base/Run/Run_up.png | Bin 0 -> 2910 bytes .../Skeleton - Mage/Death/Death-Sheet.png | Bin 0 -> 2881 bytes .../Skeleton - Mage/Death/Death.aseprite | Bin 0 -> 2699 bytes .../Skeleton - Mage/Idle/Idle-Sheet.png | Bin 0 -> 1453 bytes .../Skeleton - Mage/Idle/Idle.aseprite | Bin 0 -> 2310 bytes .../Skeleton - Mage/Run/Run-Sheet.png | Bin 0 -> 2218 bytes .../Skeleton Crew/Skeleton - Mage/Run/Run.aseprite | Bin 0 -> 5116 bytes .../Skeleton - Rogue/Death/Death-Sheet.png | Bin 0 -> 2962 bytes .../Skeleton - Rogue/Death/Death.aseprite | Bin 0 -> 2838 bytes .../Skeleton - Rogue/Idle/Idle-Sheet.png | Bin 0 -> 1432 bytes .../Skeleton - Rogue/Idle/Idle.aseprite | Bin 0 -> 2151 bytes .../Skeleton - Rogue/Run/Run-Sheet.png | Bin 0 -> 2314 bytes .../Skeleton - Rogue/Run/Run.aseprite | Bin 0 -> 9123 bytes .../Skeleton - Warrior/Death/Death-Sheet.png | Bin 0 -> 2908 bytes .../Skeleton - Warrior/Death/Death.aseprite | Bin 0 -> 2947 bytes .../Skeleton - Warrior/Idle/Idle-Sheet.png | Bin 0 -> 1506 bytes .../Skeleton - Warrior/Idle/Idle.aseprite | Bin 0 -> 2271 bytes .../Skeleton - Warrior/Run/Run-Sheet.png | Bin 0 -> 2495 bytes .../Skeleton - Warrior/Run/Run.aseprite | Bin 0 -> 7309 bytes .../Entities/Npc's/Knight/Death/Death-Sheet.png | Bin 0 -> 1943 bytes .../Entities/Npc's/Knight/Death/Death.aseprite | Bin 0 -> 2555 bytes .../Entities/Npc's/Knight/Idle/Idle-Sheet.png | Bin 0 -> 1102 bytes .../Entities/Npc's/Knight/Idle/Idle.aseprite | Bin 0 -> 1994 bytes .../Entities/Npc's/Knight/Run/Run-Sheet.png | Bin 0 -> 1933 bytes .../Entities/Npc's/Knight/Run/Run.aseprite | Bin 0 -> 2681 bytes .../Entities/Npc's/Rogue/Death/Death-Sheet.png | Bin 0 -> 2650 bytes .../Entities/Npc's/Rogue/Death/Death.aseprite | Bin 0 -> 2773 bytes .../Entities/Npc's/Rogue/Idle/Idle-Sheet.png | Bin 0 -> 1342 bytes .../Entities/Npc's/Rogue/Idle/Idle.aseprite | Bin 0 -> 2324 bytes .../Entities/Npc's/Rogue/Run/Run-Sheet.png | Bin 0 -> 2435 bytes .../Entities/Npc's/Rogue/Run/Run.aseprite | Bin 0 -> 7110 bytes .../Entities/Npc's/Wizzard/Death/Death-Sheet.png | Bin 0 -> 3465 bytes .../Entities/Npc's/Wizzard/Death/Death.aseprite | Bin 0 -> 3102 bytes .../Entities/Npc's/Wizzard/Idle/Idle-Sheet.png | Bin 0 -> 1507 bytes .../Entities/Npc's/Wizzard/Idle/Idle.aseprite | Bin 0 -> 2407 bytes .../Entities/Npc's/Wizzard/Run/Run-Sheet.png | Bin 0 -> 2547 bytes .../Entities/Npc's/Wizzard/Run/Run.aseprite | Bin 0 -> 6198 bytes .../Environment/Props/Animated/Pan_01-Sheet.png | Bin 0 -> 761 bytes .../Environment/Props/Animated/Pan_01.aseprite | Bin 0 -> 1542 bytes .../Environment/Props/Animated/Pan_02-Sheet.png | Bin 0 -> 634 bytes .../Environment/Props/Animated/Pan_02.aseprite | Bin 0 -> 1564 bytes .../Environment/Props/Animated/Pan_03-Sheet.png | Bin 0 -> 1670 bytes .../Environment/Props/Animated/Pan_03.aseprite | Bin 0 -> 4206 bytes .../Environment/Props/Animated/Pan_04-Sheet.png | Bin 0 -> 838 bytes .../Environment/Props/Animated/Pan_04.aseprite | Bin 0 -> 1512 bytes .../Environment/Props/Animated/Pan_05-Sheet.png | Bin 0 -> 1624 bytes .../Environment/Props/Animated/Pan_05.aseprite | Bin 0 -> 2348 bytes .../Props/Static/Dungeon_Props.aseprite | Bin 0 -> 2381 bytes .../Environment/Props/Static/Dungeon_Props.png | Bin 0 -> 4213 bytes .../Environment/Props/Static/Esoteric.aseprite | Bin 0 -> 2679 bytes .../Environment/Props/Static/Esoteric.png | Bin 0 -> 4885 bytes .../Environment/Props/Static/Farm.aseprite | Bin 0 -> 11972 bytes Pixel_Crawler/Environment/Props/Static/Farm.png | Bin 0 -> 22698 bytes .../Environment/Props/Static/Furniture.aseprite | Bin 0 -> 21204 bytes .../Environment/Props/Static/Furniture.png | Bin 0 -> 29445 bytes .../Environment/Props/Static/Meat.aseprite | Bin 0 -> 2081 bytes Pixel_Crawler/Environment/Props/Static/Meat.png | Bin 0 -> 3298 bytes .../Environment/Props/Static/Pan.aseprite | Bin 0 -> 3649 bytes Pixel_Crawler/Environment/Props/Static/Pan.png | Bin 0 -> 6799 bytes .../Environment/Props/Static/Resources.aseprite | Bin 0 -> 2532 bytes .../Environment/Props/Static/Resources.png | Bin 0 -> 4487 bytes .../Environment/Props/Static/Rocks.aseprite | Bin 0 -> 6029 bytes Pixel_Crawler/Environment/Props/Static/Rocks.png | Bin 0 -> 8436 bytes .../Environment/Props/Static/Shadows.aseprite | Bin 0 -> 2587 bytes Pixel_Crawler/Environment/Props/Static/Shadows.png | Bin 0 -> 3965 bytes .../Environment/Props/Static/Tools.aseprite | Bin 0 -> 7416 bytes Pixel_Crawler/Environment/Props/Static/Tools.png | Bin 0 -> 13491 bytes .../Props/Static/Trees/Model_01/Size_02.aseprite | Bin 0 -> 6851 bytes .../Props/Static/Trees/Model_01/Size_02.png | Bin 0 -> 10604 bytes .../Props/Static/Trees/Model_01/Size_03.aseprite | Bin 0 -> 11782 bytes .../Props/Static/Trees/Model_01/Size_03.png | Bin 0 -> 19583 bytes .../Props/Static/Trees/Model_01/Size_04.aseprite | Bin 0 -> 27909 bytes .../Props/Static/Trees/Model_01/Size_04.png | Bin 0 -> 47337 bytes .../Props/Static/Trees/Model_01/Size_05.aseprite | Bin 0 -> 31960 bytes .../Props/Static/Trees/Model_01/Size_05.png | Bin 0 -> 50559 bytes .../Props/Static/Trees/Model_02/Size_02.aseprite | Bin 0 -> 3235 bytes .../Props/Static/Trees/Model_02/Size_02.png | Bin 0 -> 4945 bytes .../Props/Static/Trees/Model_02/Size_03.aseprite | Bin 0 -> 5302 bytes .../Props/Static/Trees/Model_02/Size_03.png | Bin 0 -> 8168 bytes .../Props/Static/Trees/Model_02/Size_04.aseprite | Bin 0 -> 8374 bytes .../Props/Static/Trees/Model_02/Size_04.png | Bin 0 -> 12805 bytes .../Props/Static/Trees/Model_02/Size_05.aseprite | Bin 0 -> 18887 bytes .../Props/Static/Trees/Model_02/Size_05.png | Bin 0 -> 28032 bytes .../Props/Static/Trees/Model_03/Size_02.aseprite | Bin 0 -> 3997 bytes .../Props/Static/Trees/Model_03/Size_02.png | Bin 0 -> 5922 bytes .../Props/Static/Trees/Model_03/Size_03-export.png | Bin 0 -> 15338 bytes .../Props/Static/Trees/Model_03/Size_03.aseprite | Bin 0 -> 10122 bytes .../Props/Static/Trees/Model_03/Size_03.png | Bin 0 -> 15338 bytes .../Trees/Model_03/Size_04-export-export.png | Bin 0 -> 30240 bytes .../Props/Static/Trees/Model_03/Size_04-export.png | Bin 0 -> 30240 bytes .../Props/Static/Trees/Model_03/Size_04.aseprite | Bin 0 -> 19906 bytes .../Props/Static/Trees/Model_03/Size_04.png | Bin 0 -> 31102 bytes .../Props/Static/Trees/Model_03/Size_05.aseprite | Bin 0 -> 28068 bytes .../Props/Static/Trees/Model_03/Size_05.png | Bin 0 -> 41673 bytes .../Environment/Props/Static/Vegetation.aseprite | Bin 0 -> 19929 bytes .../Environment/Props/Static/Vegetation.png | Bin 0 -> 32871 bytes .../Structures/Buildings/Floors.aseprite | Bin 0 -> 382 bytes .../Environment/Structures/Buildings/Floors.png | Bin 0 -> 889 bytes .../Structures/Buildings/Props.aseprite | Bin 0 -> 4455 bytes .../Environment/Structures/Buildings/Props.png | Bin 0 -> 8364 bytes .../Structures/Buildings/Roofs.aseprite | Bin 0 -> 11410 bytes .../Environment/Structures/Buildings/Roofs.png | Bin 0 -> 11073 bytes .../Structures/Buildings/Shadows.aseprite | Bin 0 -> 910 bytes .../Environment/Structures/Buildings/Shadows.png | Bin 0 -> 1634 bytes .../Structures/Buildings/Walls.aseprite | Bin 0 -> 22267 bytes .../Environment/Structures/Buildings/Walls.png | Bin 0 -> 22524 bytes .../Structures/Stations/Alchemy/Alchemy.aseprite | Bin 0 -> 5656 bytes .../Stations/Alchemy/Alchemy_Table_01-Sheet.png | Bin 0 -> 13701 bytes .../Stations/Alchemy/Alchemy_Table_01.aseprite | Bin 0 -> 43799 bytes .../Stations/Alchemy/Alchemy_Table_02-Sheet.png | Bin 0 -> 16055 bytes .../Stations/Alchemy/Alchemy_Table_02.aseprite | Bin 0 -> 73077 bytes .../Stations/Alchemy/Alchemy_Table_03-Sheet.png | Bin 0 -> 24639 bytes .../Stations/Alchemy/Alchemy_Table_03.aseprite | Bin 0 -> 54879 bytes .../Structures/Stations/Anvil/Anvil.aseprite | Bin 0 -> 6815 bytes .../Structures/Stations/Anvil/Anvil.png | Bin 0 -> 7961 bytes .../Structures/Stations/Anvil/Anvil_01-Sheet.png | Bin 0 -> 14014 bytes .../Structures/Stations/Anvil/Anvil_01.aseprite | Bin 0 -> 42493 bytes .../Structures/Stations/Anvil/Anvil_02-Sheet.png | Bin 0 -> 27126 bytes .../Structures/Stations/Anvil/Anvil_02.aseprite | Bin 0 -> 73318 bytes .../Structures/Stations/Anvil/Anvil_03-Sheet.png | Bin 0 -> 39876 bytes .../Structures/Stations/Anvil/Anvil_03.aseprite | Bin 0 -> 102587 bytes .../Structures/Stations/Bonfire/Bonfire.aseprite | Bin 0 -> 4136 bytes .../Structures/Stations/Bonfire/Bonfire.png | Bin 0 -> 3919 bytes .../Stations/Bonfire/Bonfire_01-Sheet.png | Bin 0 -> 1049 bytes .../Stations/Bonfire/Bonfire_01.aseprite | Bin 0 -> 1640 bytes .../Stations/Bonfire/Bonfire_02-Sheet.png | Bin 0 -> 1169 bytes .../Stations/Bonfire/Bonfire_02.aseprite | Bin 0 -> 1745 bytes .../Stations/Bonfire/Bonfire_03-Sheet.png | Bin 0 -> 714 bytes .../Stations/Bonfire/Bonfire_03.aseprite | Bin 0 -> 1085 bytes .../Stations/Bonfire/Bonfire_04-Sheet.png | Bin 0 -> 689 bytes .../Stations/Bonfire/Bonfire_04.aseprite | Bin 0 -> 1141 bytes .../Stations/Bonfire/Bonfire_05-Sheet.png | Bin 0 -> 725 bytes .../Stations/Bonfire/Bonfire_05.aseprite | Bin 0 -> 1005 bytes .../Stations/Bonfire/Bonfire_06-Sheet.png | Bin 0 -> 353 bytes .../Stations/Bonfire/Bonfire_06.aseprite | Bin 0 -> 634 bytes .../Stations/Bonfire/Bonfire_07-Sheet.png | Bin 0 -> 692 bytes .../Stations/Bonfire/Bonfire_07.aseprite | Bin 0 -> 1137 bytes .../Stations/Bonfire/Bonfire_08-Sheet.png | Bin 0 -> 651 bytes .../Stations/Bonfire/Bonfire_08.aseprite | Bin 0 -> 966 bytes .../Stations/Bonfire/Bonfire_09-Sheet.png | Bin 0 -> 1809 bytes .../Stations/Bonfire/Bonfire_09.aseprite | Bin 0 -> 2699 bytes .../Stations/Bonfire/Bonfire_10-Sheet.png | Bin 0 -> 1179 bytes .../Stations/Bonfire/Bonfire_10.aseprite | Bin 0 -> 1908 bytes .../Structures/Stations/Bonfire/Fire_01-Sheet.png | Bin 0 -> 1417 bytes .../Structures/Stations/Bonfire/Fire_01.aseprite | Bin 0 -> 1309 bytes .../Structures/Stations/Bonfire/Fire_02-Sheet.png | Bin 0 -> 797 bytes .../Structures/Stations/Bonfire/Fire_02.aseprite | Bin 0 -> 891 bytes .../Structures/Stations/Bonfire/Smoke-Sheet.png | Bin 0 -> 554 bytes .../Structures/Stations/Bonfire/Smoke.aseprite | Bin 0 -> 2191 bytes .../Cooking Station/Butchery/Butchery_01-Sheet.png | Bin 0 -> 752 bytes .../Cooking Station/Butchery/Butchery_01.aseprite | Bin 0 -> 753 bytes .../Cooking Station/Butchery/Butchery_02.aseprite | Bin 0 -> 1035 bytes .../Cooking Station/Butchery/Butchery_02.png | Bin 0 -> 1150 bytes .../Cooking Station/Butchery/Butchery_03.aseprite | Bin 0 -> 1738 bytes .../Cooking Station/Butchery/Butchery_03.png | Bin 0 -> 2233 bytes .../Cooking Station/Butchery/Butchery_04.aseprite | Bin 0 -> 2320 bytes .../Cooking Station/Butchery/Butchery_04.png | Bin 0 -> 3020 bytes .../Cooking Station/Cooker/Cooker_01.aseprite | Bin 0 -> 543 bytes .../Stations/Cooking Station/Cooker/Cooker_01.png | Bin 0 -> 508 bytes .../Cooking Station/Cooker/Cooker_02.aseprite | Bin 0 -> 386 bytes .../Stations/Cooking Station/Cooker/Cooker_02.png | Bin 0 -> 336 bytes .../Cooking Station/Cooker/Cooker_03-Sheet.png | Bin 0 -> 909 bytes .../Cooking Station/Cooker/Cooker_03.aseprite | Bin 0 -> 1605 bytes .../Cooking Station/Cooker/Cooker_04-Sheet.png | Bin 0 -> 2897 bytes .../Cooking Station/Cooker/Cooker_04.aseprite | Bin 0 -> 5056 bytes .../Cooking Station/Cooking Station.aseprite | Bin 0 -> 11310 bytes .../Stations/Cooking Station/Cooking Station.png | Bin 0 -> 16528 bytes .../Stations/Cooking Station/Estructure.png | Bin 0 -> 6314 bytes .../Cooking Station/Grill/Grill_01-Sheet.png | Bin 0 -> 1564 bytes .../Cooking Station/Grill/Grill_01.aseprite | Bin 0 -> 3171 bytes .../Cooking Station/Grill/Grill_02-Sheet.png | Bin 0 -> 1708 bytes .../Cooking Station/Grill/Grill_02.aseprite | Bin 0 -> 3573 bytes .../Cooking Station/Grill/Grill_03-Sheet.png | Bin 0 -> 2249 bytes .../Cooking Station/Grill/Grill_03.aseprite | Bin 0 -> 4218 bytes .../Cooking Station/Grill/Grill_04-Sheet.png | Bin 0 -> 2787 bytes .../Cooking Station/Grill/Grill_04.aseprite | Bin 0 -> 4408 bytes .../Stations/Furnace/Bricks_01-Sheet.png | Bin 0 -> 1680 bytes .../Structures/Stations/Furnace/Bricks_01.aseprite | Bin 0 -> 2645 bytes .../Stations/Furnace/Bricks_02-Sheet.png | Bin 0 -> 2440 bytes .../Structures/Stations/Furnace/Bricks_02.aseprite | Bin 0 -> 3610 bytes .../Stations/Furnace/Bricks_03-Sheet.png | Bin 0 -> 2439 bytes .../Structures/Stations/Furnace/Bricks_03.aseprite | Bin 0 -> 4537 bytes .../Structures/Stations/Furnace/Furnace.aseprite | Bin 0 -> 13505 bytes .../Structures/Stations/Furnace/Furnace.png | Bin 0 -> 18229 bytes .../Structures/Stations/Furnace/Iron_01-Sheet.png | Bin 0 -> 1550 bytes .../Structures/Stations/Furnace/Iron_01.aseprite | Bin 0 -> 3146 bytes .../Structures/Stations/Furnace/Iron_02-Sheet.png | Bin 0 -> 2283 bytes .../Structures/Stations/Furnace/Iron_02.aseprite | Bin 0 -> 4062 bytes .../Structures/Stations/Furnace/Iron_03-Sheet.png | Bin 0 -> 3160 bytes .../Structures/Stations/Furnace/Iron_03.aseprite | Bin 0 -> 5252 bytes .../Structures/Stations/Furnace/Stone_01-Sheet.png | Bin 0 -> 1560 bytes .../Structures/Stations/Furnace/Stone_01.aseprite | Bin 0 -> 2566 bytes .../Structures/Stations/Furnace/Stone_02-Sheet.png | Bin 0 -> 1807 bytes .../Structures/Stations/Furnace/Stone_02.aseprite | Bin 0 -> 8251 bytes .../Structures/Stations/Furnace/Stone_03-Sheet.png | Bin 0 -> 2331 bytes .../Structures/Stations/Furnace/Stone_03.aseprite | Bin 0 -> 3675 bytes .../Structures/Stations/Sawmill/Base.aseprite | Bin 0 -> 5525 bytes .../Structures/Stations/Sawmill/Base.png | Bin 0 -> 7334 bytes .../Structures/Stations/Sawmill/Level_1.aseprite | Bin 0 -> 548 bytes .../Structures/Stations/Sawmill/Level_1.png | Bin 0 -> 614 bytes .../Structures/Stations/Sawmill/Level_2-Sheet.png | Bin 0 -> 31563 bytes .../Structures/Stations/Sawmill/Level_2.aseprite | Bin 0 -> 77849 bytes .../Structures/Stations/Sawmill/Level_3-Sheet.png | Bin 0 -> 50055 bytes .../Structures/Stations/Sawmill/Level_3.aseprite | Bin 0 -> 108107 bytes .../Stations/Workbench/Workbench.aseprite | Bin 0 -> 10800 bytes .../Structures/Stations/Workbench/Workbench.png | Bin 0 -> 13731 bytes .../Environment/Tilesets/Dungeon_Tiles.aseprite | Bin 0 -> 14007 bytes .../Environment/Tilesets/Dungeon_Tiles.png | Bin 0 -> 21113 bytes .../Environment/Tilesets/Floors_Tiles.aseprite | Bin 0 -> 16280 bytes .../Environment/Tilesets/Floors_Tiles.png | Bin 0 -> 21966 bytes .../Environment/Tilesets/Overlay_tiles.aseprite | Bin 0 -> 767 bytes .../Environment/Tilesets/Overlay_tiles.png | Bin 0 -> 1485 bytes .../Environment/Tilesets/Wall_Tiles.aseprite | Bin 0 -> 26629 bytes Pixel_Crawler/Environment/Tilesets/Wall_Tiles.png | Bin 0 -> 41057 bytes .../Environment/Tilesets/Wall_Variations.aseprite | Bin 0 -> 24573 bytes .../Environment/Tilesets/Wall_Variations.png | Bin 0 -> 36550 bytes Pixel_Crawler/Environment/Tilesets/Water.aseprite | Bin 0 -> 8806 bytes .../Environment/Tilesets/Water_tiles.aseprite | Bin 0 -> 9047 bytes Pixel_Crawler/Environment/Tilesets/Water_tiles.png | Bin 0 -> 12937 bytes Pixel_Crawler/Icons/Icons.aseprite | Bin 0 -> 4996 bytes Pixel_Crawler/Icons/Icons.png | Bin 0 -> 7786 bytes Pixel_Crawler/Icons/Resources.aseprite | Bin 0 -> 3369 bytes Pixel_Crawler/Icons/original.Resources.aseprite | Bin 0 -> 3463 bytes Pixel_Crawler/Terms.txt | 19 + Pixel_Crawler/Weapons/Bone/Bone.aseprite | Bin 0 -> 4481 bytes Pixel_Crawler/Weapons/Bone/Bone.png | Bin 0 -> 7285 bytes Pixel_Crawler/Weapons/Hands/Hands.aseprite | Bin 0 -> 1938 bytes Pixel_Crawler/Weapons/Hands/Hands.png | Bin 0 -> 1273 bytes Pixel_Crawler/Weapons/Wood/Wood.aseprite | Bin 0 -> 4295 bytes Pixel_Crawler/Weapons/Wood/Wood.png | Bin 0 -> 6479 bytes Pixel_Crawler/images/Alchemy_Table_01-Sheet.png | 1 + Pixel_Crawler/images/Alchemy_Table_02-Sheet.png | 1 + Pixel_Crawler/images/Alchemy_Table_03-Sheet.png | 1 + Pixel_Crawler/images/Anvil.png | 1 + Pixel_Crawler/images/Anvil_01-Sheet.png | 1 + Pixel_Crawler/images/Anvil_02-Sheet.png | 1 + Pixel_Crawler/images/Anvil_03-Sheet.png | 1 + Pixel_Crawler/images/Base.png | 1 + Pixel_Crawler/images/Bone.png | 1 + Pixel_Crawler/images/Bonfire.png | 1 + Pixel_Crawler/images/Bonfire_01-Sheet.png | 1 + Pixel_Crawler/images/Bonfire_02-Sheet.png | 1 + Pixel_Crawler/images/Bonfire_03-Sheet.png | 1 + Pixel_Crawler/images/Bonfire_04-Sheet.png | 1 + Pixel_Crawler/images/Bonfire_05-Sheet.png | 1 + Pixel_Crawler/images/Bonfire_06-Sheet.png | 1 + Pixel_Crawler/images/Bonfire_07-Sheet.png | 1 + Pixel_Crawler/images/Bonfire_08-Sheet.png | 1 + Pixel_Crawler/images/Bonfire_09-Sheet.png | 1 + Pixel_Crawler/images/Bonfire_10-Sheet.png | 1 + Pixel_Crawler/images/Bricks_01-Sheet.png | 1 + Pixel_Crawler/images/Bricks_02-Sheet.png | 1 + Pixel_Crawler/images/Bricks_03-Sheet.png | 1 + Pixel_Crawler/images/Butchery_01-Sheet.png | 1 + Pixel_Crawler/images/Butchery_02.png | 1 + Pixel_Crawler/images/Butchery_03.png | 1 + Pixel_Crawler/images/Butchery_04.png | 1 + Pixel_Crawler/images/Carry_Idle_Down-Sheet.png | 1 + Pixel_Crawler/images/Carry_Idle_Side-Sheet.png | 1 + Pixel_Crawler/images/Carry_Idle_Up-Sheet.png | 1 + Pixel_Crawler/images/Carry_Run_Down-Sheet.png | 1 + Pixel_Crawler/images/Carry_Run_Side-Sheet.png | 1 + Pixel_Crawler/images/Carry_Run_Up-Sheet.png | 1 + Pixel_Crawler/images/Carry_Walk_Down-Sheet.png | 1 + Pixel_Crawler/images/Carry_Walk_Side-Sheet.png | 1 + Pixel_Crawler/images/Carry_Walk_Up-Sheet.png | 1 + Pixel_Crawler/images/Collect_Down-Sheet.png | 1 + Pixel_Crawler/images/Collect_Side-Sheet.png | 1 + Pixel_Crawler/images/Collect_Up-Sheet.png | 1 + Pixel_Crawler/images/Cooker_01.png | 1 + Pixel_Crawler/images/Cooker_02.png | 1 + Pixel_Crawler/images/Cooker_03-Sheet.png | 1 + Pixel_Crawler/images/Cooker_04-Sheet.png | 1 + Pixel_Crawler/images/Cooking Station.png | 1 + Pixel_Crawler/images/Crush_Down-Sheet.png | 1 + Pixel_Crawler/images/Crush_Side-Sheet.png | 1 + Pixel_Crawler/images/Crush_Up-Sheet.png | 1 + Pixel_Crawler/images/Death-Sheet.png | 1 + Pixel_Crawler/images/Death_Down-Sheet.png | 1 + Pixel_Crawler/images/Death_Side-Sheet.png | 1 + Pixel_Crawler/images/Death_Up-Sheet.png | 1 + Pixel_Crawler/images/Dungeon_Props.png | 1 + Pixel_Crawler/images/Dungeon_Tiles.png | 1 + Pixel_Crawler/images/Esoteric.png | 1 + Pixel_Crawler/images/Estructure.png | 1 + Pixel_Crawler/images/Farm.png | 1 + Pixel_Crawler/images/Fire_01-Sheet.png | 1 + Pixel_Crawler/images/Fire_02-Sheet.png | 1 + Pixel_Crawler/images/Fishing_Down-Sheet.png | 1 + Pixel_Crawler/images/Fishing_Side-Sheet.png | 1 + Pixel_Crawler/images/Fishing_Up-Sheet.png | 1 + Pixel_Crawler/images/Floors.png | 1 + Pixel_Crawler/images/Floors_Tiles.png | 1 + Pixel_Crawler/images/Furnace.png | 1 + Pixel_Crawler/images/Furniture.png | 1 + Pixel_Crawler/images/Grill_01-Sheet.png | 1 + Pixel_Crawler/images/Grill_02-Sheet.png | 1 + Pixel_Crawler/images/Grill_03-Sheet.png | 1 + Pixel_Crawler/images/Grill_04-Sheet.png | 1 + Pixel_Crawler/images/Hands.png | 1 + Pixel_Crawler/images/Hit_Down-Sheet.png | 1 + Pixel_Crawler/images/Hit_Side-Sheet.png | 1 + Pixel_Crawler/images/Hit_Up-Sheet.png | 1 + Pixel_Crawler/images/Idle-Sheet.png | 1 + Pixel_Crawler/images/Idle_Down-Sheet.png | 1 + Pixel_Crawler/images/Idle_Side-Sheet.png | 1 + Pixel_Crawler/images/Idle_Up-Sheet.png | 1 + Pixel_Crawler/images/Iron_01-Sheet.png | 1 + Pixel_Crawler/images/Iron_02-Sheet.png | 1 + Pixel_Crawler/images/Iron_03-Sheet.png | 1 + Pixel_Crawler/images/Level_1.png | 1 + Pixel_Crawler/images/Level_2-Sheet.png | 1 + Pixel_Crawler/images/Level_3-Sheet.png | 1 + Pixel_Crawler/images/Meat.png | 1 + Pixel_Crawler/images/Pan.png | 1 + Pixel_Crawler/images/Pan_01-Sheet.png | 1 + Pixel_Crawler/images/Pan_02-Sheet.png | 1 + Pixel_Crawler/images/Pan_03-Sheet.png | 1 + Pixel_Crawler/images/Pan_04-Sheet.png | 1 + Pixel_Crawler/images/Pan_05-Sheet.png | 1 + Pixel_Crawler/images/Pierce_Down-Sheet.png | 1 + Pixel_Crawler/images/Pierce_Side-Sheet.png | 1 + Pixel_Crawler/images/Pierce_Top-Sheet.png | 1 + Pixel_Crawler/images/Props.png | 1 + Pixel_Crawler/images/Resources.png | 1 + Pixel_Crawler/images/Rocks.png | 1 + Pixel_Crawler/images/Roofs.png | 1 + Pixel_Crawler/images/Run-Sheet.png | 1 + Pixel_Crawler/images/Run_Down-Sheet.png | 1 + Pixel_Crawler/images/Run_Side-Sheet.png | 1 + Pixel_Crawler/images/Run_Up-Sheet.png | 1 + Pixel_Crawler/images/Shadows.png | 1 + Pixel_Crawler/images/Size_02.png | 1 + Pixel_Crawler/images/Size_03-export.png | 1 + Pixel_Crawler/images/Size_03.png | 1 + Pixel_Crawler/images/Size_04-export-export.png | 1 + Pixel_Crawler/images/Size_04-export.png | 1 + Pixel_Crawler/images/Size_04.png | 1 + Pixel_Crawler/images/Size_05.png | 1 + Pixel_Crawler/images/Slice_Down-Sheet.png | 1 + Pixel_Crawler/images/Slice_Side-Sheet.png | 1 + Pixel_Crawler/images/Slice_Up-Sheet.png | 1 + Pixel_Crawler/images/Smoke-Sheet.png | 1 + Pixel_Crawler/images/Stone_01-Sheet.png | 1 + Pixel_Crawler/images/Stone_02-Sheet.png | 1 + Pixel_Crawler/images/Stone_03-Sheet.png | 1 + Pixel_Crawler/images/Tools.png | 1 + Pixel_Crawler/images/Vegetation.png | 1 + Pixel_Crawler/images/Walk_Down-Sheet.png | 1 + Pixel_Crawler/images/Walk_Side-Sheet.png | 1 + Pixel_Crawler/images/Walk_Up-Sheet.png | 1 + Pixel_Crawler/images/Wall_Tiles.png | 1 + Pixel_Crawler/images/Wall_Variations.png | 1 + Pixel_Crawler/images/Walls.png | 1 + Pixel_Crawler/images/Water_tiles.png | 1 + Pixel_Crawler/images/Watering_Down-Sheet.png | 1 + Pixel_Crawler/images/Watering_Side-Sheet.png | 1 + Pixel_Crawler/images/Watering_Up-Sheet.png | 1 + Pixel_Crawler/images/Wood.png | 1 + Pixel_Crawler/images/Workbench.png | 1 + README.md | 8 + fonts/DejaVuSans-Bold.ttf | Bin 0 -> 705684 bytes fonts/DejaVuSansMono-Bold.ttf | Bin 0 -> 331992 bytes fonts/DejaVuSansMono.ttf | Bin 0 -> 340712 bytes fonts/SymbolsNerdFontMono-Regular.ttf | Bin 0 -> 2507556 bytes logo/Run_Side-Sheet.png | Bin 0 -> 1696 bytes logo/logo.aseprite | Bin 0 -> 1751 bytes logo/logo.png | Bin 0 -> 1177 bytes logo/props.aseprite | Bin 0 -> 4120 bytes logo/props.png | Bin 0 -> 3349 bytes main.cpp | 18 + music/bird.sing.wav | Bin 0 -> 168286 bytes music/character.attack.wav | Bin 0 -> 168286 bytes music/character.build.wav | Bin 0 -> 168286 bytes music/character.collect.wav | Bin 0 -> 168286 bytes music/character.craft.wav | Bin 0 -> 168286 bytes music/character.cultivate.wav | Bin 0 -> 168286 bytes music/character.dead.wav | Bin 0 -> 3080270 bytes music/character.die.wav | Bin 0 -> 168286 bytes music/character.drink.wav | Bin 0 -> 168286 bytes music/character.eat.wav | Bin 0 -> 168286 bytes music/character.hae.wav | Bin 0 -> 168286 bytes music/character.hit.wav | Bin 0 -> 80086 bytes music/character.plant.wav | Bin 0 -> 168286 bytes music/character.walk.wav | Bin 0 -> 53940 bytes music/enemy.attack.wav | Bin 0 -> 80086 bytes music/intro.wav | Bin 0 -> 1179726 bytes music/menu.hover.wav | Bin 0 -> 24654 bytes quit/quit_text_be.aseprite | Bin 0 -> 530 bytes quit/quit_text_be.png | Bin 0 -> 1222 bytes quit/quit_text_continued.aseprite | Bin 0 -> 1188 bytes quit/quit_text_continued.png | Bin 0 -> 1631 bytes quit/quit_text_nope.aseprite | Bin 0 -> 618 bytes quit/quit_text_nope.png | Bin 0 -> 1230 bytes quit/quit_text_to.aseprite | Bin 0 -> 472 bytes quit/quit_text_to.png | Bin 0 -> 1131 bytes saves/save.collissions | Bin 0 -> 256016 bytes saves/save.map | Bin 0 -> 986194 bytes saves/save.tileset_collissions | Bin 0 -> 214812 bytes saves/save.tileset_floortype | Bin 0 -> 7568 bytes saves/save.tileset_objects | Bin 0 -> 27810 bytes saves/save.tileset_recources | Bin 0 -> 1780 bytes scripts/audio/audio_normalize.sh | 30 + scripts/audio/audio_to_44100hz.sh | 16 + scripts/audio/intro.wav | Bin 0 -> 1606806 bytes scripts/audio/record.sh | 68 + scripts/sprites/image_fix_4x_32_to_64.sh | 22 + scripts/sprites/image_fix_96x64_to_64x64.sh | 21 + .../image_fix_remove_16_from_top_add_to_bottom.sh | 4 + .../image_fix_scale_down_and_add_transparent.sh | 11 + src/audio/audio.cpp | 93 + src/audio/audio.hpp | 34 + src/bird/bird.cpp | 471 ++++ src/bird/bird.hpp | 105 + src/building/building.cpp | 402 ++++ src/building/building.hpp | 77 + src/building/building_data.cpp | 696 ++++++ src/building/building_data.hpp | 122 + src/building/craft.cpp | 424 ++++ src/building/craft.hpp | 27 + src/building/research.cpp | 434 ++++ src/building/research.hpp | 43 + src/character/animation.cpp | 88 + src/character/animation.hpp | 59 + src/character/character.cpp | 2377 ++++++++++++++++++++ src/character/character.hpp | 348 +++ src/character/enemy.cpp | 1433 ++++++++++++ src/character/enemy.hpp | 270 +++ src/character/message.cpp | 424 ++++ src/character/message.hpp | 56 + src/cursor/animated_cursor.cpp | 283 +++ src/cursor/animated_cursor.hpp | 75 + src/defaults/defaults.cpp | 55 + src/defaults/defaults.hpp | 57 + src/defaults/icons.cpp | 80 + src/defaults/icons.hpp | 29 + src/defaults/input.cpp | 20 + src/defaults/input.hpp | 40 + src/defaults/shuffle_texture.hpp | 183 ++ src/defaults/ui.cpp | 526 +++++ src/defaults/ui.hpp | 36 + src/end_screen/end_screen.cpp | 245 ++ src/end_screen/end_screen.hpp | 72 + src/farm/farm.cpp | 194 ++ src/farm/farm.hpp | 12 + src/game/game.cpp | 446 ++++ src/game/game.hpp | 75 + src/game/game_state.cpp | 2 + src/game/game_state.hpp | 30 + src/game/state_menu_main.cpp | 190 ++ src/game/state_menu_main.hpp | 39 + src/game/state_modify.cpp | 193 ++ src/game/state_modify.hpp | 15 + src/game/state_playing.cpp | 335 +++ src/game/state_playing.hpp | 24 + src/inventory/inventory.cpp | 1340 +++++++++++ src/inventory/inventory.hpp | 174 ++ src/inventory/item.cpp | 301 +++ src/inventory/item.hpp | 92 + src/inventory/weapon.cpp | 71 + src/inventory/weapon.hpp | 57 + src/map/map.cpp | 1178 ++++++++++ src/map/map.hpp | 100 + src/map/path_finding.hpp | 247 ++ src/map/tile.cpp | 1569 +++++++++++++ src/map/tile.hpp | 231 ++ src/objects/object.cpp | 332 +++ src/objects/object.hpp | 133 ++ src/resource/resource.cpp | 12 + src/resource/resource.hpp | 36 + src/resource/resource_data.cpp | 276 +++ src/resource/resource_data.hpp | 57 + src/start_screen/start_screen.cpp | 331 +++ src/start_screen/start_screen.hpp | 92 + src/vegetables/vegetables.cpp | 165 ++ src/vegetables/vegetables.hpp | 97 + 646 files changed, 18556 insertions(+) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..45bd07f --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +compile_commands.json +game_saves/* +*.swp diff --git a/Bird/Individual Sprites/Bird Sprites.aseprite b/Bird/Individual Sprites/Bird Sprites.aseprite new file mode 100644 index 0000000..a2ccc47 Binary files /dev/null and b/Bird/Individual Sprites/Bird Sprites.aseprite differ diff --git a/Bird/Individual Sprites/BirdEating1.png b/Bird/Individual Sprites/BirdEating1.png new file mode 100644 index 0000000..7625e17 Binary files /dev/null and b/Bird/Individual Sprites/BirdEating1.png differ diff --git a/Bird/Individual Sprites/BirdEating2.png b/Bird/Individual Sprites/BirdEating2.png new file mode 100644 index 0000000..781fbf7 Binary files /dev/null and b/Bird/Individual Sprites/BirdEating2.png differ diff --git a/Bird/Individual Sprites/BirdEating3.png b/Bird/Individual Sprites/BirdEating3.png new file mode 100644 index 0000000..721dd94 Binary files /dev/null and b/Bird/Individual Sprites/BirdEating3.png differ diff --git a/Bird/Individual Sprites/BirdFlying1.png b/Bird/Individual Sprites/BirdFlying1.png new file mode 100644 index 0000000..62cd671 Binary files /dev/null and b/Bird/Individual Sprites/BirdFlying1.png differ diff --git a/Bird/Individual Sprites/BirdFlying2.png b/Bird/Individual Sprites/BirdFlying2.png new file mode 100644 index 0000000..fe181e2 Binary files /dev/null and b/Bird/Individual Sprites/BirdFlying2.png differ diff --git a/Bird/Individual Sprites/BirdFlying3.png b/Bird/Individual Sprites/BirdFlying3.png new file mode 100644 index 0000000..163c271 Binary files /dev/null and b/Bird/Individual Sprites/BirdFlying3.png differ diff --git a/Bird/Individual Sprites/BirdFlying4.png b/Bird/Individual Sprites/BirdFlying4.png new file mode 100644 index 0000000..9b5d281 Binary files /dev/null and b/Bird/Individual Sprites/BirdFlying4.png differ diff --git a/Bird/Individual Sprites/BirdFlying5.png b/Bird/Individual Sprites/BirdFlying5.png new file mode 100644 index 0000000..b1770ea Binary files /dev/null and b/Bird/Individual Sprites/BirdFlying5.png differ diff --git a/Bird/Individual Sprites/BirdFlying6.png b/Bird/Individual Sprites/BirdFlying6.png new file mode 100644 index 0000000..4ef183f Binary files /dev/null and b/Bird/Individual Sprites/BirdFlying6.png differ diff --git a/Bird/Individual Sprites/BirdFlying7.png b/Bird/Individual Sprites/BirdFlying7.png new file mode 100644 index 0000000..be8dc81 Binary files /dev/null and b/Bird/Individual Sprites/BirdFlying7.png differ diff --git a/Bird/Individual Sprites/BirdFlying8.png b/Bird/Individual Sprites/BirdFlying8.png new file mode 100644 index 0000000..c39ce77 Binary files /dev/null and b/Bird/Individual Sprites/BirdFlying8.png differ diff --git a/Bird/Individual Sprites/BirdIdle1.png b/Bird/Individual Sprites/BirdIdle1.png new file mode 100644 index 0000000..bea48e5 Binary files /dev/null and b/Bird/Individual Sprites/BirdIdle1.png differ diff --git a/Bird/Individual Sprites/BirdIdle2.png b/Bird/Individual Sprites/BirdIdle2.png new file mode 100644 index 0000000..87d6364 Binary files /dev/null and b/Bird/Individual Sprites/BirdIdle2.png differ diff --git a/Bird/Individual Sprites/BirdWalking1.png b/Bird/Individual Sprites/BirdWalking1.png new file mode 100644 index 0000000..7714a40 Binary files /dev/null and b/Bird/Individual Sprites/BirdWalking1.png differ diff --git a/Bird/Individual Sprites/BirdWalking2.png b/Bird/Individual Sprites/BirdWalking2.png new file mode 100644 index 0000000..48b5f3e Binary files /dev/null and b/Bird/Individual Sprites/BirdWalking2.png differ diff --git a/Bird/Individual Sprites/BirdWalking3.png b/Bird/Individual Sprites/BirdWalking3.png new file mode 100644 index 0000000..4e4faee Binary files /dev/null and b/Bird/Individual Sprites/BirdWalking3.png differ diff --git a/Bird/Spritesheet/Bird Spritesheet.aseprite b/Bird/Spritesheet/Bird Spritesheet.aseprite new file mode 100644 index 0000000..b37a77d Binary files /dev/null and b/Bird/Spritesheet/Bird Spritesheet.aseprite differ diff --git a/Bird/Spritesheet/Bird Spritesheet.png b/Bird/Spritesheet/Bird Spritesheet.png new file mode 100644 index 0000000..e61bb2f Binary files /dev/null and b/Bird/Spritesheet/Bird Spritesheet.png differ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..1790684 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,76 @@ +cmake_minimum_required(VERSION 3.10) +project(map_editor LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 23) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +set(ENABLE_OPTIMIZATION "" CACHE STRING "Build mode: empty, NOOPT, DEBUG, or OPTIMIZED") + +file(GLOB_RECURSE SRC_FILES + ${CMAKE_SOURCE_DIR}/src/*.cpp +) + +add_executable(map_editor + main.cpp + ${SRC_FILES} +) + +target_include_directories(map_editor + PRIVATE + ${CMAKE_SOURCE_DIR}/src +) + +target_link_libraries(map_editor + PRIVATE + SDL3 + SDL3_ttf + SDL3_image + SDL3_mixer +) + +target_compile_options(map_editor PRIVATE -Wall -Wextra) + +if(ENABLE_OPTIMIZATION STREQUAL "NOOPT") + target_compile_options(map_editor PRIVATE -fsanitize=address -fno-omit-frame-pointer -g -O0) + target_link_options(map_editor PRIVATE -fsanitize=address) + target_compile_definitions(map_editor PRIVATE) + +elseif(ENABLE_OPTIMIZATION STREQUAL "DEBUG") + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) + target_compile_options(map_editor PRIVATE -fsanitize=address -fno-omit-frame-pointer -g -O0) + target_link_options(map_editor PRIVATE -fsanitize=address) + target_compile_definitions(map_editor PRIVATE DEBUG_BUILD) + +elseif(ENABLE_OPTIMIZATION STREQUAL "OPTIMIZED") + set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE) + + target_compile_options(map_editor PRIVATE + -O3 + -march=native + -mtune=native + -flto + -fomit-frame-pointer + ) + + target_link_options(map_editor PRIVATE + -flto + ) + + target_compile_definitions(map_editor PRIVATE NDEBUG) +endif() + + +# At the end of your CMakeLists.txt + +add_custom_target(clean-all + COMMAND ${CMAKE_COMMAND} -E rm -rf + ${CMAKE_CURRENT_BINARY_DIR}/CMakeCache.txt + ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles + ${CMAKE_CURRENT_BINARY_DIR}/Makefile + ${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake + ${CMAKE_CURRENT_BINARY_DIR}/map_editor + ${CMAKE_CURRENT_BINARY_DIR}/map_editor.exe # Windows + COMMENT "Cleaning all build artifacts" +) + diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Idle/Carry_Idle_Down-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Idle/Carry_Idle_Down-Sheet.png new file mode 100644 index 0000000..d0a1dbf Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Idle/Carry_Idle_Down-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Idle/Carry_Idle_Down.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Idle/Carry_Idle_Down.aseprite new file mode 100644 index 0000000..551faa7 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Idle/Carry_Idle_Down.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Idle/Carry_Idle_Side-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Idle/Carry_Idle_Side-Sheet.png new file mode 100644 index 0000000..6eb1707 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Idle/Carry_Idle_Side-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Idle/Carry_Idle_Side.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Idle/Carry_Idle_Side.aseprite new file mode 100644 index 0000000..99166c7 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Idle/Carry_Idle_Side.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Idle/Carry_Idle_Up-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Idle/Carry_Idle_Up-Sheet.png new file mode 100644 index 0000000..6653b55 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Idle/Carry_Idle_Up-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Idle/Carry_Idle_Up.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Idle/Carry_Idle_Up.aseprite new file mode 100644 index 0000000..34c4c4c Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Idle/Carry_Idle_Up.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Run/Carry_Run_Down-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Run/Carry_Run_Down-Sheet.png new file mode 100644 index 0000000..7353495 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Run/Carry_Run_Down-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Run/Carry_Run_Down.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Run/Carry_Run_Down.aseprite new file mode 100644 index 0000000..ad2e38a Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Run/Carry_Run_Down.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Run/Carry_Run_Side-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Run/Carry_Run_Side-Sheet.png new file mode 100644 index 0000000..8e52868 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Run/Carry_Run_Side-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Run/Carry_Run_Side.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Run/Carry_Run_Side.aseprite new file mode 100644 index 0000000..1043450 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Run/Carry_Run_Side.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Run/Carry_Run_Up-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Run/Carry_Run_Up-Sheet.png new file mode 100644 index 0000000..df9a34b Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Run/Carry_Run_Up-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Run/Carry_Run_Up.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Run/Carry_Run_Up.aseprite new file mode 100644 index 0000000..d93a6f5 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Run/Carry_Run_Up.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Walk/Carry_Walk_Down-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Walk/Carry_Walk_Down-Sheet.png new file mode 100644 index 0000000..13d83dd Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Walk/Carry_Walk_Down-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Walk/Carry_Walk_Down.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Walk/Carry_Walk_Down.aseprite new file mode 100644 index 0000000..21ccef6 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Walk/Carry_Walk_Down.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Walk/Carry_Walk_Side-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Walk/Carry_Walk_Side-Sheet.png new file mode 100644 index 0000000..7e8a56f Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Walk/Carry_Walk_Side-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Walk/Carry_Walk_Side.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Walk/Carry_Walk_Side.aseprite new file mode 100644 index 0000000..bfba726 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Walk/Carry_Walk_Side.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Walk/Carry_Walk_Up-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Walk/Carry_Walk_Up-Sheet.png new file mode 100644 index 0000000..c627a55 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Walk/Carry_Walk_Up-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Walk/Carry_Walk_Up.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Walk/Carry_Walk_Up.aseprite new file mode 100644 index 0000000..3619097 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Carry_Walk/Carry_Walk_Up.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Down-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Down-Sheet.png new file mode 100644 index 0000000..51905cb Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Down-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Down.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Down.aseprite new file mode 100644 index 0000000..55affef Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Down.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Side-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Side-Sheet.png new file mode 100644 index 0000000..46946ec Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Side-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Side.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Side.aseprite new file mode 100644 index 0000000..2001176 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Side.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Up-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Up-Sheet.png new file mode 100644 index 0000000..039bcdb Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Up-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Up.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Up.aseprite new file mode 100644 index 0000000..d8e06c1 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Up.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Crush_Base/Crush_Down-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Crush_Base/Crush_Down-Sheet.png new file mode 100644 index 0000000..d9a1b10 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Crush_Base/Crush_Down-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Crush_Base/Crush_Down.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Crush_Base/Crush_Down.aseprite new file mode 100644 index 0000000..180c3dc Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Crush_Base/Crush_Down.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Crush_Base/Crush_Side-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Crush_Base/Crush_Side-Sheet.png new file mode 100644 index 0000000..9a453e9 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Crush_Base/Crush_Side-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Crush_Base/Crush_Side.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Crush_Base/Crush_Side.aseprite new file mode 100644 index 0000000..bdd5393 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Crush_Base/Crush_Side.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Crush_Base/Crush_Up-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Crush_Base/Crush_Up-Sheet.png new file mode 100644 index 0000000..03a1551 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Crush_Base/Crush_Up-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Crush_Base/Crush_Up.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Crush_Base/Crush_Up.aseprite new file mode 100644 index 0000000..9c6385e Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Crush_Base/Crush_Up.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Death_Base/Death_Down-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Death_Base/Death_Down-Sheet.png new file mode 100644 index 0000000..c1897bb Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Death_Base/Death_Down-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Death_Base/Death_Down.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Death_Base/Death_Down.aseprite new file mode 100644 index 0000000..5c6a2fd Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Death_Base/Death_Down.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Death_Base/Death_Side-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Death_Base/Death_Side-Sheet.png new file mode 100644 index 0000000..525c813 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Death_Base/Death_Side-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Death_Base/Death_Side.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Death_Base/Death_Side.aseprite new file mode 100644 index 0000000..f4184c1 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Death_Base/Death_Side.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Death_Base/Death_Up-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Death_Base/Death_Up-Sheet.png new file mode 100644 index 0000000..07b0b9c Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Death_Base/Death_Up-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Death_Base/Death_Up.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Death_Base/Death_Up.aseprite new file mode 100644 index 0000000..ef172d1 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Death_Base/Death_Up.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Fishing_Base/Fishing_Down-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Fishing_Base/Fishing_Down-Sheet.png new file mode 100644 index 0000000..af9b71f Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Fishing_Base/Fishing_Down-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Fishing_Base/Fishing_Down.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Fishing_Base/Fishing_Down.aseprite new file mode 100644 index 0000000..89053ff Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Fishing_Base/Fishing_Down.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Fishing_Base/Fishing_Side-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Fishing_Base/Fishing_Side-Sheet.png new file mode 100644 index 0000000..fb80681 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Fishing_Base/Fishing_Side-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Fishing_Base/Fishing_Side.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Fishing_Base/Fishing_Side.aseprite new file mode 100644 index 0000000..b0fd826 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Fishing_Base/Fishing_Side.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Fishing_Base/Fishing_Up-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Fishing_Base/Fishing_Up-Sheet.png new file mode 100644 index 0000000..17d97a6 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Fishing_Base/Fishing_Up-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Fishing_Base/Fishing_Up.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Fishing_Base/Fishing_Up.aseprite new file mode 100644 index 0000000..52bb7ed Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Fishing_Base/Fishing_Up.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Hit_Base/Hit_Down-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Hit_Base/Hit_Down-Sheet.png new file mode 100644 index 0000000..b948c19 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Hit_Base/Hit_Down-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Hit_Base/Hit_Down.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Hit_Base/Hit_Down.aseprite new file mode 100644 index 0000000..40ea9ec Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Hit_Base/Hit_Down.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Hit_Base/Hit_Side-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Hit_Base/Hit_Side-Sheet.png new file mode 100644 index 0000000..e2c2e29 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Hit_Base/Hit_Side-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Hit_Base/Hit_Side.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Hit_Base/Hit_Side.aseprite new file mode 100644 index 0000000..4718edc Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Hit_Base/Hit_Side.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Hit_Base/Hit_Up-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Hit_Base/Hit_Up-Sheet.png new file mode 100644 index 0000000..0aa6fcf Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Hit_Base/Hit_Up-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Hit_Base/Hit_Up.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Hit_Base/Hit_Up.aseprite new file mode 100644 index 0000000..90f878d Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Hit_Base/Hit_Up.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Idle_Base/Idle_Down-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Idle_Base/Idle_Down-Sheet.png new file mode 100644 index 0000000..609403f Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Idle_Base/Idle_Down-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Idle_Base/Idle_Down.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Idle_Base/Idle_Down.aseprite new file mode 100644 index 0000000..42a1180 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Idle_Base/Idle_Down.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Idle_Base/Idle_Side-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Idle_Base/Idle_Side-Sheet.png new file mode 100644 index 0000000..ecfd78e Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Idle_Base/Idle_Side-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Idle_Base/Idle_Side.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Idle_Base/Idle_Side.aseprite new file mode 100644 index 0000000..5052b86 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Idle_Base/Idle_Side.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Idle_Base/Idle_Up-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Idle_Base/Idle_Up-Sheet.png new file mode 100644 index 0000000..6272054 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Idle_Base/Idle_Up-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Idle_Base/Idle_Up.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Idle_Base/Idle_Up.aseprite new file mode 100644 index 0000000..7101249 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Idle_Base/Idle_Up.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Down-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Down-Sheet.png new file mode 100644 index 0000000..b218f3d Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Down-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Down.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Down.aseprite new file mode 100644 index 0000000..e6ca21d Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Down.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Side-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Side-Sheet.png new file mode 100644 index 0000000..850a30b Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Side-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Side.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Side.aseprite new file mode 100644 index 0000000..9343686 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Side.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Top-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Top-Sheet.png new file mode 100644 index 0000000..df9de2b Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Top-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Top.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Top.aseprite new file mode 100644 index 0000000..537340d Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Top.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Wood_Down.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Wood_Down.aseprite new file mode 100644 index 0000000..dd23879 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Wood_Down.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Wood_Down.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Wood_Down.png new file mode 100644 index 0000000..301e61b Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Wood_Down.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Wood_Side.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Wood_Side.aseprite new file mode 100644 index 0000000..9f89ac0 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Wood_Side.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Wood_Side.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Wood_Side.png new file mode 100644 index 0000000..73e04ec Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Wood_Side.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Wood_Top.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Wood_Top.aseprite new file mode 100644 index 0000000..0625e0f Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Wood_Top.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Wood_Top.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Wood_Top.png new file mode 100644 index 0000000..5c67958 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Wood_Top.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/sword_wood.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/sword_wood.aseprite new file mode 100644 index 0000000..40a94ff Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/sword_wood.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Blocking/Block_Side.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Blocking/Block_Side.aseprite new file mode 100644 index 0000000..2cf622a Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Blocking/Block_Side.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Blocking/Down.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Blocking/Down.aseprite new file mode 100644 index 0000000..0870f76 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Blocking/Down.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Blocking/Down.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Blocking/Down.png new file mode 100644 index 0000000..ca92462 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Blocking/Down.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Blocking/Side.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Blocking/Side.aseprite new file mode 100644 index 0000000..4701328 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Blocking/Side.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Blocking/Side.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Blocking/Side.png new file mode 100644 index 0000000..afc3972 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Blocking/Side.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Blocking/Up.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Blocking/Up.aseprite new file mode 100644 index 0000000..ec1a9ff Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Blocking/Up.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Blocking/Up.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Blocking/Up.png new file mode 100644 index 0000000..2c834c3 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Blocking/Up.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Run_Base/Run_Down-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Run_Base/Run_Down-Sheet.png new file mode 100644 index 0000000..3414905 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Run_Base/Run_Down-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Run_Base/Run_Down.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Run_Base/Run_Down.aseprite new file mode 100644 index 0000000..76846e6 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Run_Base/Run_Down.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Run_Base/Run_Side-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Run_Base/Run_Side-Sheet.png new file mode 100644 index 0000000..d6721fa Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Run_Base/Run_Side-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Run_Base/Run_Side.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Run_Base/Run_Side.aseprite new file mode 100644 index 0000000..5a8586f Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Run_Base/Run_Side.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Run_Base/Run_Up-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Run_Base/Run_Up-Sheet.png new file mode 100644 index 0000000..3cca916 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Run_Base/Run_Up-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Run_Base/Run_Up.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Run_Base/Run_Up.aseprite new file mode 100644 index 0000000..80cdacc Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Run_Base/Run_Up.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Slice_Base/Slice_Down.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Slice_Base/Slice_Down.aseprite new file mode 100644 index 0000000..662f3c2 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Slice_Base/Slice_Down.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Slice_Base/Slice_Down.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Slice_Base/Slice_Down.png new file mode 100644 index 0000000..ca39e1b Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Slice_Base/Slice_Down.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Slice_Base/Slice_Side.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Slice_Base/Slice_Side.aseprite new file mode 100644 index 0000000..e55845d Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Slice_Base/Slice_Side.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Slice_Base/Slice_Side.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Slice_Base/Slice_Side.png new file mode 100644 index 0000000..c13f845 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Slice_Base/Slice_Side.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Slice_Base/Slice_Up.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Slice_Base/Slice_Up.aseprite new file mode 100644 index 0000000..5be023f Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Slice_Base/Slice_Up.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Slice_Base/Slice_Up.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Slice_Base/Slice_Up.png new file mode 100644 index 0000000..401a2df Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Slice_Base/Slice_Up.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Walk_Base/Walk_Down-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Walk_Base/Walk_Down-Sheet.png new file mode 100644 index 0000000..c74fc1b Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Walk_Base/Walk_Down-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Walk_Base/Walk_Down.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Walk_Base/Walk_Down.aseprite new file mode 100644 index 0000000..a6ec9ca Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Walk_Base/Walk_Down.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Walk_Base/Walk_Side-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Walk_Base/Walk_Side-Sheet.png new file mode 100644 index 0000000..94d6c1b Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Walk_Base/Walk_Side-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Walk_Base/Walk_Side.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Walk_Base/Walk_Side.aseprite new file mode 100644 index 0000000..75e5733 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Walk_Base/Walk_Side.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Walk_Base/Walk_Up-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Walk_Base/Walk_Up-Sheet.png new file mode 100644 index 0000000..6145681 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Walk_Base/Walk_Up-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Walk_Base/Walk_Up.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Walk_Base/Walk_Up.aseprite new file mode 100644 index 0000000..a0d6d40 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Walk_Base/Walk_Up.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Watering_Base/Watering_Down-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Watering_Base/Watering_Down-Sheet.png new file mode 100644 index 0000000..3b04d27 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Watering_Base/Watering_Down-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Watering_Base/Watering_Down.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Watering_Base/Watering_Down.aseprite new file mode 100644 index 0000000..913fe87 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Watering_Base/Watering_Down.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Watering_Base/Watering_Side-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Watering_Base/Watering_Side-Sheet.png new file mode 100644 index 0000000..8492a68 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Watering_Base/Watering_Side-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Watering_Base/Watering_Side.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Watering_Base/Watering_Side.aseprite new file mode 100644 index 0000000..0352530 Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Watering_Base/Watering_Side.aseprite differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Watering_Base/Watering_Up-Sheet.png b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Watering_Base/Watering_Up-Sheet.png new file mode 100644 index 0000000..8025d3f Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Watering_Base/Watering_Up-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Characters/Body_A/Animations/Watering_Base/Watering_Up.aseprite b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Watering_Base/Watering_Up.aseprite new file mode 100644 index 0000000..e76e92e Binary files /dev/null and b/Pixel_Crawler/Entities/Characters/Body_A/Animations/Watering_Base/Watering_Up.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Rogue/Death/Death-Sheet.png b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Rogue/Death/Death-Sheet.png new file mode 100644 index 0000000..2a10b98 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Rogue/Death/Death-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Rogue/Death/Death.aseprite b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Rogue/Death/Death.aseprite new file mode 100644 index 0000000..a97d202 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Rogue/Death/Death.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Rogue/Idle/Idle-Sheet.png b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Rogue/Idle/Idle-Sheet.png new file mode 100644 index 0000000..6902aa4 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Rogue/Idle/Idle-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Rogue/Idle/Idle.aseprite b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Rogue/Idle/Idle.aseprite new file mode 100644 index 0000000..dce736d Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Rogue/Idle/Idle.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Rogue/Run/Run-Sheet.png b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Rogue/Run/Run-Sheet.png new file mode 100644 index 0000000..1783b09 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Rogue/Run/Run-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Rogue/Run/Run.aseprite b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Rogue/Run/Run.aseprite new file mode 100644 index 0000000..aa4f621 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Rogue/Run/Run.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Shaman/Death/Death-Sheet.png b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Shaman/Death/Death-Sheet.png new file mode 100644 index 0000000..ec23abb Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Shaman/Death/Death-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Shaman/Death/Death.aseprite b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Shaman/Death/Death.aseprite new file mode 100644 index 0000000..ff479ed Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Shaman/Death/Death.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Shaman/Idle/Idle-Sheet.png b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Shaman/Idle/Idle-Sheet.png new file mode 100644 index 0000000..897d9b2 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Shaman/Idle/Idle-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Shaman/Idle/Idle.aseprite b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Shaman/Idle/Idle.aseprite new file mode 100644 index 0000000..188080d Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Shaman/Idle/Idle.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Shaman/Run/Run-Sheet.png b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Shaman/Run/Run-Sheet.png new file mode 100644 index 0000000..71fc767 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Shaman/Run/Run-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Shaman/Run/Run.aseprite b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Shaman/Run/Run.aseprite new file mode 100644 index 0000000..cf863f9 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Shaman/Run/Run.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Warrior/Death/Death-Sheet.png b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Warrior/Death/Death-Sheet.png new file mode 100644 index 0000000..2a87d9e Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Warrior/Death/Death-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Warrior/Death/Death.aseprite b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Warrior/Death/Death.aseprite new file mode 100644 index 0000000..a3f4df9 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Warrior/Death/Death.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Warrior/Idle/Idle-Sheet.png b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Warrior/Idle/Idle-Sheet.png new file mode 100644 index 0000000..602efff Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Warrior/Idle/Idle-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Warrior/Idle/Idle.aseprite b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Warrior/Idle/Idle.aseprite new file mode 100644 index 0000000..a3150b8 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Warrior/Idle/Idle.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Warrior/Run/Run-Sheet.png b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Warrior/Run/Run-Sheet.png new file mode 100644 index 0000000..dbeb740 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Warrior/Run/Run-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Warrior/Run/Run.aseprite b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Warrior/Run/Run.aseprite new file mode 100644 index 0000000..626e815 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc - Warrior/Run/Run.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc/Death/Death-Sheet.png b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc/Death/Death-Sheet.png new file mode 100644 index 0000000..56c323e Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc/Death/Death-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc/Death/Death.aseprite b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc/Death/Death.aseprite new file mode 100644 index 0000000..d1d4515 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc/Death/Death.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc/Idle/Idle-Sheet.png b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc/Idle/Idle-Sheet.png new file mode 100644 index 0000000..9a6b072 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc/Idle/Idle-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc/Idle/Idle.aseprite b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc/Idle/Idle.aseprite new file mode 100644 index 0000000..faf2699 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc/Idle/Idle.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc/Run/Run-Sheet.png b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc/Run/Run-Sheet.png new file mode 100644 index 0000000..2f24a2a Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc/Run/Run-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc/Run/Run.aseprite b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc/Run/Run.aseprite new file mode 100644 index 0000000..eba11bb Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Orc Crew/Orc/Run/Run.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Attack/Attack-sheet.png b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Attack/Attack-sheet.png new file mode 100644 index 0000000..bdaeb9a Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Attack/Attack-sheet.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Attack/Attack.aseprite b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Attack/Attack.aseprite new file mode 100644 index 0000000..f2f32ac Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Attack/Attack.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Attack/Attack.png b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Attack/Attack.png new file mode 100644 index 0000000..bf2e44c Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Attack/Attack.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Attack/Attack_Down.aseprite b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Attack/Attack_Down.aseprite new file mode 100644 index 0000000..8974099 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Attack/Attack_Down.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Attack/Attack_Down.png b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Attack/Attack_Down.png new file mode 100644 index 0000000..21d1af3 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Attack/Attack_Down.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Attack/Attack_Up.aseprite b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Attack/Attack_Up.aseprite new file mode 100644 index 0000000..c8ce2d2 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Attack/Attack_Up.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Attack/Attack_Up.png b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Attack/Attack_Up.png new file mode 100644 index 0000000..430ad14 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Attack/Attack_Up.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Block/Block.aseprite b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Block/Block.aseprite new file mode 100644 index 0000000..b2eeea1 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Block/Block.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Block/Block.png b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Block/Block.png new file mode 100644 index 0000000..7051bb9 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Block/Block.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Death/Death-Sheet.png b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Death/Death-Sheet.png new file mode 100644 index 0000000..1b5fcd3 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Death/Death-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Death/Death-Sheet_padded.png b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Death/Death-Sheet_padded.png new file mode 100644 index 0000000..4a6a920 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Death/Death-Sheet_padded.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Death/Death-Sheet_processed.png b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Death/Death-Sheet_processed.png new file mode 100644 index 0000000..7b1b13f Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Death/Death-Sheet_processed.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Death/Death-Sheet_shifted.png b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Death/Death-Sheet_shifted.png new file mode 100644 index 0000000..afe7f0f Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Death/Death-Sheet_shifted.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Death/Death.aseprite b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Death/Death.aseprite new file mode 100644 index 0000000..47530c2 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Death/Death.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Idle/Idle-Sheet.png b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Idle/Idle-Sheet.png new file mode 100644 index 0000000..4c4f552 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Idle/Idle-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Idle/Idle-Sheet_padded.png b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Idle/Idle-Sheet_padded.png new file mode 100644 index 0000000..6726151 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Idle/Idle-Sheet_padded.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Idle/Idle.aseprite b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Idle/Idle.aseprite new file mode 100644 index 0000000..a7ab77e Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Idle/Idle.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Idle/Idlet.aseprite b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Idle/Idlet.aseprite new file mode 100644 index 0000000..a7ab77e Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Idle/Idlet.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run-Sheet-export.aseprite b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run-Sheet-export.aseprite new file mode 100644 index 0000000..02d5b7b Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run-Sheet-export.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run-Sheet-sheet.png b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run-Sheet-sheet.png new file mode 100644 index 0000000..65525cf Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run-Sheet-sheet.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run-Sheet.png b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run-Sheet.png new file mode 100644 index 0000000..036a0a3 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run-Sheet_shifted.png b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run-Sheet_shifted.png new file mode 100644 index 0000000..93a3527 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run-Sheet_shifted.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run-sheet.png b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run-sheet.png new file mode 100644 index 0000000..83ed4d8 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run-sheet.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run.aseprite b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run.aseprite new file mode 100644 index 0000000..93a628f Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run.png b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run.png new file mode 100644 index 0000000..036a0a3 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run_Upt.aseprite b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run_Upt.aseprite new file mode 100644 index 0000000..3d2f282 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run_Upt.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run_up-sheet.png b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run_up-sheet.png new file mode 100644 index 0000000..a8a18b2 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run_up-sheet.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run_up.png b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run_up.png new file mode 100644 index 0000000..c439a1b Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run_up.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Mage/Death/Death-Sheet.png b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Mage/Death/Death-Sheet.png new file mode 100644 index 0000000..02d0832 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Mage/Death/Death-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Mage/Death/Death.aseprite b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Mage/Death/Death.aseprite new file mode 100644 index 0000000..8968d52 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Mage/Death/Death.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Mage/Idle/Idle-Sheet.png b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Mage/Idle/Idle-Sheet.png new file mode 100644 index 0000000..5911e16 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Mage/Idle/Idle-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Mage/Idle/Idle.aseprite b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Mage/Idle/Idle.aseprite new file mode 100644 index 0000000..590d59c Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Mage/Idle/Idle.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Mage/Run/Run-Sheet.png b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Mage/Run/Run-Sheet.png new file mode 100644 index 0000000..85bfb1e Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Mage/Run/Run-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Mage/Run/Run.aseprite b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Mage/Run/Run.aseprite new file mode 100644 index 0000000..e7c6991 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Mage/Run/Run.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Rogue/Death/Death-Sheet.png b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Rogue/Death/Death-Sheet.png new file mode 100644 index 0000000..70914dc Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Rogue/Death/Death-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Rogue/Death/Death.aseprite b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Rogue/Death/Death.aseprite new file mode 100644 index 0000000..5ba68e1 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Rogue/Death/Death.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Rogue/Idle/Idle-Sheet.png b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Rogue/Idle/Idle-Sheet.png new file mode 100644 index 0000000..a625ee1 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Rogue/Idle/Idle-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Rogue/Idle/Idle.aseprite b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Rogue/Idle/Idle.aseprite new file mode 100644 index 0000000..dc74f89 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Rogue/Idle/Idle.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Rogue/Run/Run-Sheet.png b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Rogue/Run/Run-Sheet.png new file mode 100644 index 0000000..740543b Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Rogue/Run/Run-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Rogue/Run/Run.aseprite b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Rogue/Run/Run.aseprite new file mode 100644 index 0000000..2040995 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Rogue/Run/Run.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Warrior/Death/Death-Sheet.png b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Warrior/Death/Death-Sheet.png new file mode 100644 index 0000000..4691ab8 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Warrior/Death/Death-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Warrior/Death/Death.aseprite b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Warrior/Death/Death.aseprite new file mode 100644 index 0000000..115743f Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Warrior/Death/Death.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Warrior/Idle/Idle-Sheet.png b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Warrior/Idle/Idle-Sheet.png new file mode 100644 index 0000000..e61ee1d Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Warrior/Idle/Idle-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Warrior/Idle/Idle.aseprite b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Warrior/Idle/Idle.aseprite new file mode 100644 index 0000000..527d885 Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Warrior/Idle/Idle.aseprite differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Warrior/Run/Run-Sheet.png b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Warrior/Run/Run-Sheet.png new file mode 100644 index 0000000..dc4cfcf Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Warrior/Run/Run-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Warrior/Run/Run.aseprite b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Warrior/Run/Run.aseprite new file mode 100644 index 0000000..f2e725c Binary files /dev/null and b/Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Warrior/Run/Run.aseprite differ diff --git a/Pixel_Crawler/Entities/Npc's/Knight/Death/Death-Sheet.png b/Pixel_Crawler/Entities/Npc's/Knight/Death/Death-Sheet.png new file mode 100644 index 0000000..1f6103a Binary files /dev/null and b/Pixel_Crawler/Entities/Npc's/Knight/Death/Death-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Npc's/Knight/Death/Death.aseprite b/Pixel_Crawler/Entities/Npc's/Knight/Death/Death.aseprite new file mode 100644 index 0000000..8e79cb6 Binary files /dev/null and b/Pixel_Crawler/Entities/Npc's/Knight/Death/Death.aseprite differ diff --git a/Pixel_Crawler/Entities/Npc's/Knight/Idle/Idle-Sheet.png b/Pixel_Crawler/Entities/Npc's/Knight/Idle/Idle-Sheet.png new file mode 100644 index 0000000..c5cf5c6 Binary files /dev/null and b/Pixel_Crawler/Entities/Npc's/Knight/Idle/Idle-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Npc's/Knight/Idle/Idle.aseprite b/Pixel_Crawler/Entities/Npc's/Knight/Idle/Idle.aseprite new file mode 100644 index 0000000..09e92f9 Binary files /dev/null and b/Pixel_Crawler/Entities/Npc's/Knight/Idle/Idle.aseprite differ diff --git a/Pixel_Crawler/Entities/Npc's/Knight/Run/Run-Sheet.png b/Pixel_Crawler/Entities/Npc's/Knight/Run/Run-Sheet.png new file mode 100644 index 0000000..42f7cc6 Binary files /dev/null and b/Pixel_Crawler/Entities/Npc's/Knight/Run/Run-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Npc's/Knight/Run/Run.aseprite b/Pixel_Crawler/Entities/Npc's/Knight/Run/Run.aseprite new file mode 100644 index 0000000..1812e1a Binary files /dev/null and b/Pixel_Crawler/Entities/Npc's/Knight/Run/Run.aseprite differ diff --git a/Pixel_Crawler/Entities/Npc's/Rogue/Death/Death-Sheet.png b/Pixel_Crawler/Entities/Npc's/Rogue/Death/Death-Sheet.png new file mode 100644 index 0000000..123942e Binary files /dev/null and b/Pixel_Crawler/Entities/Npc's/Rogue/Death/Death-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Npc's/Rogue/Death/Death.aseprite b/Pixel_Crawler/Entities/Npc's/Rogue/Death/Death.aseprite new file mode 100644 index 0000000..701a17e Binary files /dev/null and b/Pixel_Crawler/Entities/Npc's/Rogue/Death/Death.aseprite differ diff --git a/Pixel_Crawler/Entities/Npc's/Rogue/Idle/Idle-Sheet.png b/Pixel_Crawler/Entities/Npc's/Rogue/Idle/Idle-Sheet.png new file mode 100644 index 0000000..b36a641 Binary files /dev/null and b/Pixel_Crawler/Entities/Npc's/Rogue/Idle/Idle-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Npc's/Rogue/Idle/Idle.aseprite b/Pixel_Crawler/Entities/Npc's/Rogue/Idle/Idle.aseprite new file mode 100644 index 0000000..edf3740 Binary files /dev/null and b/Pixel_Crawler/Entities/Npc's/Rogue/Idle/Idle.aseprite differ diff --git a/Pixel_Crawler/Entities/Npc's/Rogue/Run/Run-Sheet.png b/Pixel_Crawler/Entities/Npc's/Rogue/Run/Run-Sheet.png new file mode 100644 index 0000000..f50017d Binary files /dev/null and b/Pixel_Crawler/Entities/Npc's/Rogue/Run/Run-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Npc's/Rogue/Run/Run.aseprite b/Pixel_Crawler/Entities/Npc's/Rogue/Run/Run.aseprite new file mode 100644 index 0000000..06c8a1b Binary files /dev/null and b/Pixel_Crawler/Entities/Npc's/Rogue/Run/Run.aseprite differ diff --git a/Pixel_Crawler/Entities/Npc's/Wizzard/Death/Death-Sheet.png b/Pixel_Crawler/Entities/Npc's/Wizzard/Death/Death-Sheet.png new file mode 100644 index 0000000..34b1e30 Binary files /dev/null and b/Pixel_Crawler/Entities/Npc's/Wizzard/Death/Death-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Npc's/Wizzard/Death/Death.aseprite b/Pixel_Crawler/Entities/Npc's/Wizzard/Death/Death.aseprite new file mode 100644 index 0000000..2fe7e9e Binary files /dev/null and b/Pixel_Crawler/Entities/Npc's/Wizzard/Death/Death.aseprite differ diff --git a/Pixel_Crawler/Entities/Npc's/Wizzard/Idle/Idle-Sheet.png b/Pixel_Crawler/Entities/Npc's/Wizzard/Idle/Idle-Sheet.png new file mode 100644 index 0000000..ff0fca4 Binary files /dev/null and b/Pixel_Crawler/Entities/Npc's/Wizzard/Idle/Idle-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Npc's/Wizzard/Idle/Idle.aseprite b/Pixel_Crawler/Entities/Npc's/Wizzard/Idle/Idle.aseprite new file mode 100644 index 0000000..a82d1d9 Binary files /dev/null and b/Pixel_Crawler/Entities/Npc's/Wizzard/Idle/Idle.aseprite differ diff --git a/Pixel_Crawler/Entities/Npc's/Wizzard/Run/Run-Sheet.png b/Pixel_Crawler/Entities/Npc's/Wizzard/Run/Run-Sheet.png new file mode 100644 index 0000000..70eed05 Binary files /dev/null and b/Pixel_Crawler/Entities/Npc's/Wizzard/Run/Run-Sheet.png differ diff --git a/Pixel_Crawler/Entities/Npc's/Wizzard/Run/Run.aseprite b/Pixel_Crawler/Entities/Npc's/Wizzard/Run/Run.aseprite new file mode 100644 index 0000000..1eebb53 Binary files /dev/null and b/Pixel_Crawler/Entities/Npc's/Wizzard/Run/Run.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Animated/Pan_01-Sheet.png b/Pixel_Crawler/Environment/Props/Animated/Pan_01-Sheet.png new file mode 100644 index 0000000..76bc2b7 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Animated/Pan_01-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Props/Animated/Pan_01.aseprite b/Pixel_Crawler/Environment/Props/Animated/Pan_01.aseprite new file mode 100644 index 0000000..1043812 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Animated/Pan_01.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Animated/Pan_02-Sheet.png b/Pixel_Crawler/Environment/Props/Animated/Pan_02-Sheet.png new file mode 100644 index 0000000..1305741 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Animated/Pan_02-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Props/Animated/Pan_02.aseprite b/Pixel_Crawler/Environment/Props/Animated/Pan_02.aseprite new file mode 100644 index 0000000..851196e Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Animated/Pan_02.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Animated/Pan_03-Sheet.png b/Pixel_Crawler/Environment/Props/Animated/Pan_03-Sheet.png new file mode 100644 index 0000000..7f2e124 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Animated/Pan_03-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Props/Animated/Pan_03.aseprite b/Pixel_Crawler/Environment/Props/Animated/Pan_03.aseprite new file mode 100644 index 0000000..77d8fe8 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Animated/Pan_03.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Animated/Pan_04-Sheet.png b/Pixel_Crawler/Environment/Props/Animated/Pan_04-Sheet.png new file mode 100644 index 0000000..2d665a2 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Animated/Pan_04-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Props/Animated/Pan_04.aseprite b/Pixel_Crawler/Environment/Props/Animated/Pan_04.aseprite new file mode 100644 index 0000000..9e66831 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Animated/Pan_04.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Animated/Pan_05-Sheet.png b/Pixel_Crawler/Environment/Props/Animated/Pan_05-Sheet.png new file mode 100644 index 0000000..1468351 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Animated/Pan_05-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Props/Animated/Pan_05.aseprite b/Pixel_Crawler/Environment/Props/Animated/Pan_05.aseprite new file mode 100644 index 0000000..186c602 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Animated/Pan_05.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Static/Dungeon_Props.aseprite b/Pixel_Crawler/Environment/Props/Static/Dungeon_Props.aseprite new file mode 100644 index 0000000..5dfe5ed Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Dungeon_Props.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Static/Dungeon_Props.png b/Pixel_Crawler/Environment/Props/Static/Dungeon_Props.png new file mode 100644 index 0000000..099a7f0 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Dungeon_Props.png differ diff --git a/Pixel_Crawler/Environment/Props/Static/Esoteric.aseprite b/Pixel_Crawler/Environment/Props/Static/Esoteric.aseprite new file mode 100644 index 0000000..07a73d4 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Esoteric.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Static/Esoteric.png b/Pixel_Crawler/Environment/Props/Static/Esoteric.png new file mode 100644 index 0000000..b973628 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Esoteric.png differ diff --git a/Pixel_Crawler/Environment/Props/Static/Farm.aseprite b/Pixel_Crawler/Environment/Props/Static/Farm.aseprite new file mode 100644 index 0000000..05bcf67 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Farm.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Static/Farm.png b/Pixel_Crawler/Environment/Props/Static/Farm.png new file mode 100644 index 0000000..5f6eccf Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Farm.png differ diff --git a/Pixel_Crawler/Environment/Props/Static/Furniture.aseprite b/Pixel_Crawler/Environment/Props/Static/Furniture.aseprite new file mode 100644 index 0000000..0a645a1 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Furniture.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Static/Furniture.png b/Pixel_Crawler/Environment/Props/Static/Furniture.png new file mode 100644 index 0000000..b8bdf1a Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Furniture.png differ diff --git a/Pixel_Crawler/Environment/Props/Static/Meat.aseprite b/Pixel_Crawler/Environment/Props/Static/Meat.aseprite new file mode 100644 index 0000000..44c0c26 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Meat.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Static/Meat.png b/Pixel_Crawler/Environment/Props/Static/Meat.png new file mode 100644 index 0000000..5901074 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Meat.png differ diff --git a/Pixel_Crawler/Environment/Props/Static/Pan.aseprite b/Pixel_Crawler/Environment/Props/Static/Pan.aseprite new file mode 100644 index 0000000..07b8883 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Pan.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Static/Pan.png b/Pixel_Crawler/Environment/Props/Static/Pan.png new file mode 100644 index 0000000..783ed3d Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Pan.png differ diff --git a/Pixel_Crawler/Environment/Props/Static/Resources.aseprite b/Pixel_Crawler/Environment/Props/Static/Resources.aseprite new file mode 100644 index 0000000..1a74c02 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Resources.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Static/Resources.png b/Pixel_Crawler/Environment/Props/Static/Resources.png new file mode 100644 index 0000000..24ace9e Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Resources.png differ diff --git a/Pixel_Crawler/Environment/Props/Static/Rocks.aseprite b/Pixel_Crawler/Environment/Props/Static/Rocks.aseprite new file mode 100644 index 0000000..b094fdc Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Rocks.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Static/Rocks.png b/Pixel_Crawler/Environment/Props/Static/Rocks.png new file mode 100644 index 0000000..60da09c Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Rocks.png differ diff --git a/Pixel_Crawler/Environment/Props/Static/Shadows.aseprite b/Pixel_Crawler/Environment/Props/Static/Shadows.aseprite new file mode 100644 index 0000000..cd566a2 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Shadows.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Static/Shadows.png b/Pixel_Crawler/Environment/Props/Static/Shadows.png new file mode 100644 index 0000000..1bfe57d Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Shadows.png differ diff --git a/Pixel_Crawler/Environment/Props/Static/Tools.aseprite b/Pixel_Crawler/Environment/Props/Static/Tools.aseprite new file mode 100644 index 0000000..2be90f0 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Tools.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Static/Tools.png b/Pixel_Crawler/Environment/Props/Static/Tools.png new file mode 100644 index 0000000..ef08c5d Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Tools.png differ diff --git a/Pixel_Crawler/Environment/Props/Static/Trees/Model_01/Size_02.aseprite b/Pixel_Crawler/Environment/Props/Static/Trees/Model_01/Size_02.aseprite new file mode 100644 index 0000000..4b6d8b0 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Trees/Model_01/Size_02.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Static/Trees/Model_01/Size_02.png b/Pixel_Crawler/Environment/Props/Static/Trees/Model_01/Size_02.png new file mode 100644 index 0000000..4cfed07 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Trees/Model_01/Size_02.png differ diff --git a/Pixel_Crawler/Environment/Props/Static/Trees/Model_01/Size_03.aseprite b/Pixel_Crawler/Environment/Props/Static/Trees/Model_01/Size_03.aseprite new file mode 100644 index 0000000..e65a405 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Trees/Model_01/Size_03.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Static/Trees/Model_01/Size_03.png b/Pixel_Crawler/Environment/Props/Static/Trees/Model_01/Size_03.png new file mode 100644 index 0000000..5a9cab3 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Trees/Model_01/Size_03.png differ diff --git a/Pixel_Crawler/Environment/Props/Static/Trees/Model_01/Size_04.aseprite b/Pixel_Crawler/Environment/Props/Static/Trees/Model_01/Size_04.aseprite new file mode 100644 index 0000000..9f7429b Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Trees/Model_01/Size_04.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Static/Trees/Model_01/Size_04.png b/Pixel_Crawler/Environment/Props/Static/Trees/Model_01/Size_04.png new file mode 100644 index 0000000..85863e8 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Trees/Model_01/Size_04.png differ diff --git a/Pixel_Crawler/Environment/Props/Static/Trees/Model_01/Size_05.aseprite b/Pixel_Crawler/Environment/Props/Static/Trees/Model_01/Size_05.aseprite new file mode 100644 index 0000000..f9df39f Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Trees/Model_01/Size_05.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Static/Trees/Model_01/Size_05.png b/Pixel_Crawler/Environment/Props/Static/Trees/Model_01/Size_05.png new file mode 100644 index 0000000..13ffbf4 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Trees/Model_01/Size_05.png differ diff --git a/Pixel_Crawler/Environment/Props/Static/Trees/Model_02/Size_02.aseprite b/Pixel_Crawler/Environment/Props/Static/Trees/Model_02/Size_02.aseprite new file mode 100644 index 0000000..626b2fa Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Trees/Model_02/Size_02.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Static/Trees/Model_02/Size_02.png b/Pixel_Crawler/Environment/Props/Static/Trees/Model_02/Size_02.png new file mode 100644 index 0000000..ea6b272 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Trees/Model_02/Size_02.png differ diff --git a/Pixel_Crawler/Environment/Props/Static/Trees/Model_02/Size_03.aseprite b/Pixel_Crawler/Environment/Props/Static/Trees/Model_02/Size_03.aseprite new file mode 100644 index 0000000..f0812f8 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Trees/Model_02/Size_03.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Static/Trees/Model_02/Size_03.png b/Pixel_Crawler/Environment/Props/Static/Trees/Model_02/Size_03.png new file mode 100644 index 0000000..9668e76 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Trees/Model_02/Size_03.png differ diff --git a/Pixel_Crawler/Environment/Props/Static/Trees/Model_02/Size_04.aseprite b/Pixel_Crawler/Environment/Props/Static/Trees/Model_02/Size_04.aseprite new file mode 100644 index 0000000..7efa0e0 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Trees/Model_02/Size_04.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Static/Trees/Model_02/Size_04.png b/Pixel_Crawler/Environment/Props/Static/Trees/Model_02/Size_04.png new file mode 100644 index 0000000..47c4810 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Trees/Model_02/Size_04.png differ diff --git a/Pixel_Crawler/Environment/Props/Static/Trees/Model_02/Size_05.aseprite b/Pixel_Crawler/Environment/Props/Static/Trees/Model_02/Size_05.aseprite new file mode 100644 index 0000000..3551471 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Trees/Model_02/Size_05.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Static/Trees/Model_02/Size_05.png b/Pixel_Crawler/Environment/Props/Static/Trees/Model_02/Size_05.png new file mode 100644 index 0000000..8a943c7 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Trees/Model_02/Size_05.png differ diff --git a/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_02.aseprite b/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_02.aseprite new file mode 100644 index 0000000..f9f1dbe Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_02.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_02.png b/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_02.png new file mode 100644 index 0000000..811df63 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_02.png differ diff --git a/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_03-export.png b/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_03-export.png new file mode 100644 index 0000000..27559a1 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_03-export.png differ diff --git a/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_03.aseprite b/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_03.aseprite new file mode 100644 index 0000000..5eb993e Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_03.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_03.png b/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_03.png new file mode 100644 index 0000000..27559a1 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_03.png differ diff --git a/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_04-export-export.png b/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_04-export-export.png new file mode 100644 index 0000000..d344f1f Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_04-export-export.png differ diff --git a/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_04-export.png b/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_04-export.png new file mode 100644 index 0000000..d344f1f Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_04-export.png differ diff --git a/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_04.aseprite b/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_04.aseprite new file mode 100644 index 0000000..bc04654 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_04.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_04.png b/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_04.png new file mode 100644 index 0000000..c17bec9 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_04.png differ diff --git a/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_05.aseprite b/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_05.aseprite new file mode 100644 index 0000000..ac166b6 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_05.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_05.png b/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_05.png new file mode 100644 index 0000000..d3daf5c Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Trees/Model_03/Size_05.png differ diff --git a/Pixel_Crawler/Environment/Props/Static/Vegetation.aseprite b/Pixel_Crawler/Environment/Props/Static/Vegetation.aseprite new file mode 100644 index 0000000..4b7cebb Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Vegetation.aseprite differ diff --git a/Pixel_Crawler/Environment/Props/Static/Vegetation.png b/Pixel_Crawler/Environment/Props/Static/Vegetation.png new file mode 100644 index 0000000..f806136 Binary files /dev/null and b/Pixel_Crawler/Environment/Props/Static/Vegetation.png differ diff --git a/Pixel_Crawler/Environment/Structures/Buildings/Floors.aseprite b/Pixel_Crawler/Environment/Structures/Buildings/Floors.aseprite new file mode 100644 index 0000000..d028990 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Buildings/Floors.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Buildings/Floors.png b/Pixel_Crawler/Environment/Structures/Buildings/Floors.png new file mode 100644 index 0000000..dba7bf6 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Buildings/Floors.png differ diff --git a/Pixel_Crawler/Environment/Structures/Buildings/Props.aseprite b/Pixel_Crawler/Environment/Structures/Buildings/Props.aseprite new file mode 100644 index 0000000..d69ccc4 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Buildings/Props.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Buildings/Props.png b/Pixel_Crawler/Environment/Structures/Buildings/Props.png new file mode 100644 index 0000000..cd07ab1 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Buildings/Props.png differ diff --git a/Pixel_Crawler/Environment/Structures/Buildings/Roofs.aseprite b/Pixel_Crawler/Environment/Structures/Buildings/Roofs.aseprite new file mode 100644 index 0000000..ff138dd Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Buildings/Roofs.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Buildings/Roofs.png b/Pixel_Crawler/Environment/Structures/Buildings/Roofs.png new file mode 100644 index 0000000..707ea23 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Buildings/Roofs.png differ diff --git a/Pixel_Crawler/Environment/Structures/Buildings/Shadows.aseprite b/Pixel_Crawler/Environment/Structures/Buildings/Shadows.aseprite new file mode 100644 index 0000000..51264f9 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Buildings/Shadows.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Buildings/Shadows.png b/Pixel_Crawler/Environment/Structures/Buildings/Shadows.png new file mode 100644 index 0000000..2f610eb Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Buildings/Shadows.png differ diff --git a/Pixel_Crawler/Environment/Structures/Buildings/Walls.aseprite b/Pixel_Crawler/Environment/Structures/Buildings/Walls.aseprite new file mode 100644 index 0000000..74820e2 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Buildings/Walls.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Buildings/Walls.png b/Pixel_Crawler/Environment/Structures/Buildings/Walls.png new file mode 100644 index 0000000..a7d250e Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Buildings/Walls.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Alchemy/Alchemy.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Alchemy/Alchemy.aseprite new file mode 100644 index 0000000..13777e5 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Alchemy/Alchemy.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Alchemy/Alchemy_Table_01-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Alchemy/Alchemy_Table_01-Sheet.png new file mode 100644 index 0000000..679ff61 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Alchemy/Alchemy_Table_01-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Alchemy/Alchemy_Table_01.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Alchemy/Alchemy_Table_01.aseprite new file mode 100644 index 0000000..3a7d755 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Alchemy/Alchemy_Table_01.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Alchemy/Alchemy_Table_02-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Alchemy/Alchemy_Table_02-Sheet.png new file mode 100644 index 0000000..ef6ca00 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Alchemy/Alchemy_Table_02-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Alchemy/Alchemy_Table_02.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Alchemy/Alchemy_Table_02.aseprite new file mode 100644 index 0000000..7b48490 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Alchemy/Alchemy_Table_02.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Alchemy/Alchemy_Table_03-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Alchemy/Alchemy_Table_03-Sheet.png new file mode 100644 index 0000000..aec19ed Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Alchemy/Alchemy_Table_03-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Alchemy/Alchemy_Table_03.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Alchemy/Alchemy_Table_03.aseprite new file mode 100644 index 0000000..a603ed0 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Alchemy/Alchemy_Table_03.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Anvil/Anvil.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Anvil/Anvil.aseprite new file mode 100644 index 0000000..87a3f17 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Anvil/Anvil.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Anvil/Anvil.png b/Pixel_Crawler/Environment/Structures/Stations/Anvil/Anvil.png new file mode 100644 index 0000000..fc9ecd2 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Anvil/Anvil.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Anvil/Anvil_01-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Anvil/Anvil_01-Sheet.png new file mode 100644 index 0000000..ab480b6 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Anvil/Anvil_01-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Anvil/Anvil_01.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Anvil/Anvil_01.aseprite new file mode 100644 index 0000000..c390228 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Anvil/Anvil_01.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Anvil/Anvil_02-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Anvil/Anvil_02-Sheet.png new file mode 100644 index 0000000..e89e3ff Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Anvil/Anvil_02-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Anvil/Anvil_02.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Anvil/Anvil_02.aseprite new file mode 100644 index 0000000..e8d664c Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Anvil/Anvil_02.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Anvil/Anvil_03-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Anvil/Anvil_03-Sheet.png new file mode 100644 index 0000000..920eda8 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Anvil/Anvil_03-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Anvil/Anvil_03.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Anvil/Anvil_03.aseprite new file mode 100644 index 0000000..f975d53 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Anvil/Anvil_03.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire.aseprite new file mode 100644 index 0000000..8d1f3e4 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire.png b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire.png new file mode 100644 index 0000000..b781b00 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_01-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_01-Sheet.png new file mode 100644 index 0000000..e79c35a Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_01-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_01.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_01.aseprite new file mode 100644 index 0000000..b0a5290 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_01.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_02-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_02-Sheet.png new file mode 100644 index 0000000..b3c98b1 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_02-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_02.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_02.aseprite new file mode 100644 index 0000000..b821a52 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_02.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_03-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_03-Sheet.png new file mode 100644 index 0000000..01f83cb Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_03-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_03.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_03.aseprite new file mode 100644 index 0000000..5a15cd8 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_03.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_04-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_04-Sheet.png new file mode 100644 index 0000000..7555a25 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_04-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_04.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_04.aseprite new file mode 100644 index 0000000..a2196eb Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_04.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_05-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_05-Sheet.png new file mode 100644 index 0000000..fee1b7d Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_05-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_05.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_05.aseprite new file mode 100644 index 0000000..c27f76f Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_05.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_06-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_06-Sheet.png new file mode 100644 index 0000000..4afa734 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_06-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_06.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_06.aseprite new file mode 100644 index 0000000..eef2dca Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_06.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_07-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_07-Sheet.png new file mode 100644 index 0000000..465a061 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_07-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_07.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_07.aseprite new file mode 100644 index 0000000..5e091d0 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_07.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_08-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_08-Sheet.png new file mode 100644 index 0000000..7895452 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_08-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_08.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_08.aseprite new file mode 100644 index 0000000..718f16c Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_08.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_09-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_09-Sheet.png new file mode 100644 index 0000000..2604102 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_09-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_09.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_09.aseprite new file mode 100644 index 0000000..7612b52 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_09.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_10-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_10-Sheet.png new file mode 100644 index 0000000..7f6146b Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_10-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_10.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_10.aseprite new file mode 100644 index 0000000..0609064 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Bonfire_10.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Fire_01-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Fire_01-Sheet.png new file mode 100644 index 0000000..45f1d71 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Fire_01-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Fire_01.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Fire_01.aseprite new file mode 100644 index 0000000..9c2f61f Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Fire_01.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Fire_02-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Fire_02-Sheet.png new file mode 100644 index 0000000..b201ebb Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Fire_02-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Fire_02.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Fire_02.aseprite new file mode 100644 index 0000000..bf045c1 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Fire_02.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Smoke-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Smoke-Sheet.png new file mode 100644 index 0000000..5536c0f Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Smoke-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Smoke.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Smoke.aseprite new file mode 100644 index 0000000..033017c Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Bonfire/Smoke.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Butchery/Butchery_01-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Butchery/Butchery_01-Sheet.png new file mode 100644 index 0000000..33cfd56 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Butchery/Butchery_01-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Butchery/Butchery_01.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Butchery/Butchery_01.aseprite new file mode 100644 index 0000000..673f8c3 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Butchery/Butchery_01.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Butchery/Butchery_02.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Butchery/Butchery_02.aseprite new file mode 100644 index 0000000..769b882 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Butchery/Butchery_02.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Butchery/Butchery_02.png b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Butchery/Butchery_02.png new file mode 100644 index 0000000..26e1803 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Butchery/Butchery_02.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Butchery/Butchery_03.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Butchery/Butchery_03.aseprite new file mode 100644 index 0000000..3daf9a2 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Butchery/Butchery_03.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Butchery/Butchery_03.png b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Butchery/Butchery_03.png new file mode 100644 index 0000000..26babf0 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Butchery/Butchery_03.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Butchery/Butchery_04.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Butchery/Butchery_04.aseprite new file mode 100644 index 0000000..c40de0e Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Butchery/Butchery_04.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Butchery/Butchery_04.png b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Butchery/Butchery_04.png new file mode 100644 index 0000000..c7665af Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Butchery/Butchery_04.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooker/Cooker_01.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooker/Cooker_01.aseprite new file mode 100644 index 0000000..184d1d0 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooker/Cooker_01.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooker/Cooker_01.png b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooker/Cooker_01.png new file mode 100644 index 0000000..57111a3 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooker/Cooker_01.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooker/Cooker_02.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooker/Cooker_02.aseprite new file mode 100644 index 0000000..dae1c7a Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooker/Cooker_02.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooker/Cooker_02.png b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooker/Cooker_02.png new file mode 100644 index 0000000..a765951 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooker/Cooker_02.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooker/Cooker_03-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooker/Cooker_03-Sheet.png new file mode 100644 index 0000000..20bd3b1 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooker/Cooker_03-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooker/Cooker_03.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooker/Cooker_03.aseprite new file mode 100644 index 0000000..d20f1d9 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooker/Cooker_03.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooker/Cooker_04-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooker/Cooker_04-Sheet.png new file mode 100644 index 0000000..75ef94c Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooker/Cooker_04-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooker/Cooker_04.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooker/Cooker_04.aseprite new file mode 100644 index 0000000..3b4d9d5 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooker/Cooker_04.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooking Station.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooking Station.aseprite new file mode 100644 index 0000000..a30c316 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooking Station.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooking Station.png b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooking Station.png new file mode 100644 index 0000000..23b94d9 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Cooking Station.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Estructure.png b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Estructure.png new file mode 100644 index 0000000..9c727f3 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Estructure.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Grill/Grill_01-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Grill/Grill_01-Sheet.png new file mode 100644 index 0000000..caa3b9f Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Grill/Grill_01-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Grill/Grill_01.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Grill/Grill_01.aseprite new file mode 100644 index 0000000..cbc63d8 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Grill/Grill_01.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Grill/Grill_02-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Grill/Grill_02-Sheet.png new file mode 100644 index 0000000..ae2ea4f Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Grill/Grill_02-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Grill/Grill_02.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Grill/Grill_02.aseprite new file mode 100644 index 0000000..0304592 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Grill/Grill_02.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Grill/Grill_03-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Grill/Grill_03-Sheet.png new file mode 100644 index 0000000..002bde1 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Grill/Grill_03-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Grill/Grill_03.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Grill/Grill_03.aseprite new file mode 100644 index 0000000..285a6d2 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Grill/Grill_03.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Grill/Grill_04-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Grill/Grill_04-Sheet.png new file mode 100644 index 0000000..ef9c966 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Grill/Grill_04-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Grill/Grill_04.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Grill/Grill_04.aseprite new file mode 100644 index 0000000..de06d3f Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Cooking Station/Grill/Grill_04.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Furnace/Bricks_01-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Bricks_01-Sheet.png new file mode 100644 index 0000000..26404d0 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Bricks_01-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Furnace/Bricks_01.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Bricks_01.aseprite new file mode 100644 index 0000000..762feb5 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Bricks_01.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Furnace/Bricks_02-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Bricks_02-Sheet.png new file mode 100644 index 0000000..6dcefec Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Bricks_02-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Furnace/Bricks_02.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Bricks_02.aseprite new file mode 100644 index 0000000..15fec0a Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Bricks_02.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Furnace/Bricks_03-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Bricks_03-Sheet.png new file mode 100644 index 0000000..c189b77 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Bricks_03-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Furnace/Bricks_03.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Bricks_03.aseprite new file mode 100644 index 0000000..99fa324 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Bricks_03.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Furnace/Furnace.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Furnace.aseprite new file mode 100644 index 0000000..2fbd449 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Furnace.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Furnace/Furnace.png b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Furnace.png new file mode 100644 index 0000000..6ceda34 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Furnace.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Furnace/Iron_01-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Iron_01-Sheet.png new file mode 100644 index 0000000..6c51ea1 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Iron_01-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Furnace/Iron_01.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Iron_01.aseprite new file mode 100644 index 0000000..e8ff1ea Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Iron_01.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Furnace/Iron_02-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Iron_02-Sheet.png new file mode 100644 index 0000000..b879666 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Iron_02-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Furnace/Iron_02.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Iron_02.aseprite new file mode 100644 index 0000000..4020c3f Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Iron_02.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Furnace/Iron_03-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Iron_03-Sheet.png new file mode 100644 index 0000000..e4679c1 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Iron_03-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Furnace/Iron_03.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Iron_03.aseprite new file mode 100644 index 0000000..39f86da Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Iron_03.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Furnace/Stone_01-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Stone_01-Sheet.png new file mode 100644 index 0000000..4fd5e6d Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Stone_01-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Furnace/Stone_01.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Stone_01.aseprite new file mode 100644 index 0000000..5a61789 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Stone_01.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Furnace/Stone_02-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Stone_02-Sheet.png new file mode 100644 index 0000000..11ae87f Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Stone_02-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Furnace/Stone_02.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Stone_02.aseprite new file mode 100644 index 0000000..29b57c3 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Stone_02.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Furnace/Stone_03-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Stone_03-Sheet.png new file mode 100644 index 0000000..ce7731b Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Stone_03-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Furnace/Stone_03.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Stone_03.aseprite new file mode 100644 index 0000000..7000b64 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Furnace/Stone_03.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Sawmill/Base.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Sawmill/Base.aseprite new file mode 100644 index 0000000..87d164e Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Sawmill/Base.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Sawmill/Base.png b/Pixel_Crawler/Environment/Structures/Stations/Sawmill/Base.png new file mode 100644 index 0000000..e55e2c6 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Sawmill/Base.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Sawmill/Level_1.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Sawmill/Level_1.aseprite new file mode 100644 index 0000000..8c047f6 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Sawmill/Level_1.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Sawmill/Level_1.png b/Pixel_Crawler/Environment/Structures/Stations/Sawmill/Level_1.png new file mode 100644 index 0000000..f57690a Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Sawmill/Level_1.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Sawmill/Level_2-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Sawmill/Level_2-Sheet.png new file mode 100644 index 0000000..b8f517e Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Sawmill/Level_2-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Sawmill/Level_2.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Sawmill/Level_2.aseprite new file mode 100644 index 0000000..ed96566 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Sawmill/Level_2.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Sawmill/Level_3-Sheet.png b/Pixel_Crawler/Environment/Structures/Stations/Sawmill/Level_3-Sheet.png new file mode 100644 index 0000000..a46ccfc Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Sawmill/Level_3-Sheet.png differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Sawmill/Level_3.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Sawmill/Level_3.aseprite new file mode 100644 index 0000000..15c025f Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Sawmill/Level_3.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Workbench/Workbench.aseprite b/Pixel_Crawler/Environment/Structures/Stations/Workbench/Workbench.aseprite new file mode 100644 index 0000000..5657bcb Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Workbench/Workbench.aseprite differ diff --git a/Pixel_Crawler/Environment/Structures/Stations/Workbench/Workbench.png b/Pixel_Crawler/Environment/Structures/Stations/Workbench/Workbench.png new file mode 100644 index 0000000..6a51828 Binary files /dev/null and b/Pixel_Crawler/Environment/Structures/Stations/Workbench/Workbench.png differ diff --git a/Pixel_Crawler/Environment/Tilesets/Dungeon_Tiles.aseprite b/Pixel_Crawler/Environment/Tilesets/Dungeon_Tiles.aseprite new file mode 100644 index 0000000..1e8f847 Binary files /dev/null and b/Pixel_Crawler/Environment/Tilesets/Dungeon_Tiles.aseprite differ diff --git a/Pixel_Crawler/Environment/Tilesets/Dungeon_Tiles.png b/Pixel_Crawler/Environment/Tilesets/Dungeon_Tiles.png new file mode 100644 index 0000000..8c12b53 Binary files /dev/null and b/Pixel_Crawler/Environment/Tilesets/Dungeon_Tiles.png differ diff --git a/Pixel_Crawler/Environment/Tilesets/Floors_Tiles.aseprite b/Pixel_Crawler/Environment/Tilesets/Floors_Tiles.aseprite new file mode 100644 index 0000000..89beffd Binary files /dev/null and b/Pixel_Crawler/Environment/Tilesets/Floors_Tiles.aseprite differ diff --git a/Pixel_Crawler/Environment/Tilesets/Floors_Tiles.png b/Pixel_Crawler/Environment/Tilesets/Floors_Tiles.png new file mode 100644 index 0000000..93e87ee Binary files /dev/null and b/Pixel_Crawler/Environment/Tilesets/Floors_Tiles.png differ diff --git a/Pixel_Crawler/Environment/Tilesets/Overlay_tiles.aseprite b/Pixel_Crawler/Environment/Tilesets/Overlay_tiles.aseprite new file mode 100644 index 0000000..0c923d5 Binary files /dev/null and b/Pixel_Crawler/Environment/Tilesets/Overlay_tiles.aseprite differ diff --git a/Pixel_Crawler/Environment/Tilesets/Overlay_tiles.png b/Pixel_Crawler/Environment/Tilesets/Overlay_tiles.png new file mode 100644 index 0000000..5e499e1 Binary files /dev/null and b/Pixel_Crawler/Environment/Tilesets/Overlay_tiles.png differ diff --git a/Pixel_Crawler/Environment/Tilesets/Wall_Tiles.aseprite b/Pixel_Crawler/Environment/Tilesets/Wall_Tiles.aseprite new file mode 100644 index 0000000..de4df98 Binary files /dev/null and b/Pixel_Crawler/Environment/Tilesets/Wall_Tiles.aseprite differ diff --git a/Pixel_Crawler/Environment/Tilesets/Wall_Tiles.png b/Pixel_Crawler/Environment/Tilesets/Wall_Tiles.png new file mode 100644 index 0000000..41bb3ec Binary files /dev/null and b/Pixel_Crawler/Environment/Tilesets/Wall_Tiles.png differ diff --git a/Pixel_Crawler/Environment/Tilesets/Wall_Variations.aseprite b/Pixel_Crawler/Environment/Tilesets/Wall_Variations.aseprite new file mode 100644 index 0000000..cebb8b4 Binary files /dev/null and b/Pixel_Crawler/Environment/Tilesets/Wall_Variations.aseprite differ diff --git a/Pixel_Crawler/Environment/Tilesets/Wall_Variations.png b/Pixel_Crawler/Environment/Tilesets/Wall_Variations.png new file mode 100644 index 0000000..d8f6058 Binary files /dev/null and b/Pixel_Crawler/Environment/Tilesets/Wall_Variations.png differ diff --git a/Pixel_Crawler/Environment/Tilesets/Water.aseprite b/Pixel_Crawler/Environment/Tilesets/Water.aseprite new file mode 100644 index 0000000..9d4d9e0 Binary files /dev/null and b/Pixel_Crawler/Environment/Tilesets/Water.aseprite differ diff --git a/Pixel_Crawler/Environment/Tilesets/Water_tiles.aseprite b/Pixel_Crawler/Environment/Tilesets/Water_tiles.aseprite new file mode 100644 index 0000000..3528b66 Binary files /dev/null and b/Pixel_Crawler/Environment/Tilesets/Water_tiles.aseprite differ diff --git a/Pixel_Crawler/Environment/Tilesets/Water_tiles.png b/Pixel_Crawler/Environment/Tilesets/Water_tiles.png new file mode 100644 index 0000000..0640d9a Binary files /dev/null and b/Pixel_Crawler/Environment/Tilesets/Water_tiles.png differ diff --git a/Pixel_Crawler/Icons/Icons.aseprite b/Pixel_Crawler/Icons/Icons.aseprite new file mode 100644 index 0000000..e3fce87 Binary files /dev/null and b/Pixel_Crawler/Icons/Icons.aseprite differ diff --git a/Pixel_Crawler/Icons/Icons.png b/Pixel_Crawler/Icons/Icons.png new file mode 100644 index 0000000..21047e4 Binary files /dev/null and b/Pixel_Crawler/Icons/Icons.png differ diff --git a/Pixel_Crawler/Icons/Resources.aseprite b/Pixel_Crawler/Icons/Resources.aseprite new file mode 100644 index 0000000..02143f3 Binary files /dev/null and b/Pixel_Crawler/Icons/Resources.aseprite differ diff --git a/Pixel_Crawler/Icons/original.Resources.aseprite b/Pixel_Crawler/Icons/original.Resources.aseprite new file mode 100644 index 0000000..88d6e1c Binary files /dev/null and b/Pixel_Crawler/Icons/original.Resources.aseprite differ diff --git a/Pixel_Crawler/Terms.txt b/Pixel_Crawler/Terms.txt new file mode 100644 index 0000000..61efa3a --- /dev/null +++ b/Pixel_Crawler/Terms.txt @@ -0,0 +1,19 @@ +This pack was created by the author - Anokolisa - and contains 2d pixel art sprites for creating projects that can benefit from this type of art and style + +Some of the important points to consider when using these assets: + +1. It is not necessary to credit the author for any use of the arts, but if it is done it is appreciated. + 1.1 When you want to give credits to the author, contact by email: AnomalyPixel@gmail.com + 1.2 The author of the assets has no direct relationship with the development of projects using these assets + +2. The arts present can be altered in any shape, color or pattern + 2.1 Even after changes, these assets cannot be sold without authorization from the original creator, nor can they be marketed as a final product + +3. These arts cannot be sold as a final product, only the author can sell the assets + 3.1 these assets are sold in several different online stores, and their price reflects the guidelines of each of these stores, when buying the assets in the store you chose not to give the right to the same product in other stores + +4. You can use these assets in creating commercial products, study or any other project where they are functional + + +Patreon: https://www.patreon.com/Anokolisa +Twitter: https://twitter.com/Anokolisa diff --git a/Pixel_Crawler/Weapons/Bone/Bone.aseprite b/Pixel_Crawler/Weapons/Bone/Bone.aseprite new file mode 100644 index 0000000..f7eef37 Binary files /dev/null and b/Pixel_Crawler/Weapons/Bone/Bone.aseprite differ diff --git a/Pixel_Crawler/Weapons/Bone/Bone.png b/Pixel_Crawler/Weapons/Bone/Bone.png new file mode 100644 index 0000000..b1e5587 Binary files /dev/null and b/Pixel_Crawler/Weapons/Bone/Bone.png differ diff --git a/Pixel_Crawler/Weapons/Hands/Hands.aseprite b/Pixel_Crawler/Weapons/Hands/Hands.aseprite new file mode 100644 index 0000000..16927ca Binary files /dev/null and b/Pixel_Crawler/Weapons/Hands/Hands.aseprite differ diff --git a/Pixel_Crawler/Weapons/Hands/Hands.png b/Pixel_Crawler/Weapons/Hands/Hands.png new file mode 100644 index 0000000..9c227c7 Binary files /dev/null and b/Pixel_Crawler/Weapons/Hands/Hands.png differ diff --git a/Pixel_Crawler/Weapons/Wood/Wood.aseprite b/Pixel_Crawler/Weapons/Wood/Wood.aseprite new file mode 100644 index 0000000..5f41eb5 Binary files /dev/null and b/Pixel_Crawler/Weapons/Wood/Wood.aseprite differ diff --git a/Pixel_Crawler/Weapons/Wood/Wood.png b/Pixel_Crawler/Weapons/Wood/Wood.png new file mode 100644 index 0000000..61ea975 Binary files /dev/null and b/Pixel_Crawler/Weapons/Wood/Wood.png differ diff --git a/Pixel_Crawler/images/Alchemy_Table_01-Sheet.png b/Pixel_Crawler/images/Alchemy_Table_01-Sheet.png new file mode 120000 index 0000000..a6d7248 --- /dev/null +++ b/Pixel_Crawler/images/Alchemy_Table_01-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Alchemy/Alchemy_Table_01-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Alchemy_Table_02-Sheet.png b/Pixel_Crawler/images/Alchemy_Table_02-Sheet.png new file mode 120000 index 0000000..dc08f11 --- /dev/null +++ b/Pixel_Crawler/images/Alchemy_Table_02-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Alchemy/Alchemy_Table_02-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Alchemy_Table_03-Sheet.png b/Pixel_Crawler/images/Alchemy_Table_03-Sheet.png new file mode 120000 index 0000000..4c68754 --- /dev/null +++ b/Pixel_Crawler/images/Alchemy_Table_03-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Alchemy/Alchemy_Table_03-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Anvil.png b/Pixel_Crawler/images/Anvil.png new file mode 120000 index 0000000..c4c8721 --- /dev/null +++ b/Pixel_Crawler/images/Anvil.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Anvil/Anvil.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Anvil_01-Sheet.png b/Pixel_Crawler/images/Anvil_01-Sheet.png new file mode 120000 index 0000000..323cc58 --- /dev/null +++ b/Pixel_Crawler/images/Anvil_01-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Anvil/Anvil_01-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Anvil_02-Sheet.png b/Pixel_Crawler/images/Anvil_02-Sheet.png new file mode 120000 index 0000000..2e45dd2 --- /dev/null +++ b/Pixel_Crawler/images/Anvil_02-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Anvil/Anvil_02-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Anvil_03-Sheet.png b/Pixel_Crawler/images/Anvil_03-Sheet.png new file mode 120000 index 0000000..aa53312 --- /dev/null +++ b/Pixel_Crawler/images/Anvil_03-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Anvil/Anvil_03-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Base.png b/Pixel_Crawler/images/Base.png new file mode 120000 index 0000000..e7cfd4d --- /dev/null +++ b/Pixel_Crawler/images/Base.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Sawmill/Base.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Bone.png b/Pixel_Crawler/images/Bone.png new file mode 120000 index 0000000..709f1f7 --- /dev/null +++ b/Pixel_Crawler/images/Bone.png @@ -0,0 +1 @@ +../Weapons/Bone/Bone.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Bonfire.png b/Pixel_Crawler/images/Bonfire.png new file mode 120000 index 0000000..2b7d527 --- /dev/null +++ b/Pixel_Crawler/images/Bonfire.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Bonfire/Bonfire.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Bonfire_01-Sheet.png b/Pixel_Crawler/images/Bonfire_01-Sheet.png new file mode 120000 index 0000000..c5903c6 --- /dev/null +++ b/Pixel_Crawler/images/Bonfire_01-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Bonfire/Bonfire_01-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Bonfire_02-Sheet.png b/Pixel_Crawler/images/Bonfire_02-Sheet.png new file mode 120000 index 0000000..597f635 --- /dev/null +++ b/Pixel_Crawler/images/Bonfire_02-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Bonfire/Bonfire_02-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Bonfire_03-Sheet.png b/Pixel_Crawler/images/Bonfire_03-Sheet.png new file mode 120000 index 0000000..c8ffe7a --- /dev/null +++ b/Pixel_Crawler/images/Bonfire_03-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Bonfire/Bonfire_03-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Bonfire_04-Sheet.png b/Pixel_Crawler/images/Bonfire_04-Sheet.png new file mode 120000 index 0000000..30cae65 --- /dev/null +++ b/Pixel_Crawler/images/Bonfire_04-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Bonfire/Bonfire_04-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Bonfire_05-Sheet.png b/Pixel_Crawler/images/Bonfire_05-Sheet.png new file mode 120000 index 0000000..7a1b0a3 --- /dev/null +++ b/Pixel_Crawler/images/Bonfire_05-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Bonfire/Bonfire_05-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Bonfire_06-Sheet.png b/Pixel_Crawler/images/Bonfire_06-Sheet.png new file mode 120000 index 0000000..c982df0 --- /dev/null +++ b/Pixel_Crawler/images/Bonfire_06-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Bonfire/Bonfire_06-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Bonfire_07-Sheet.png b/Pixel_Crawler/images/Bonfire_07-Sheet.png new file mode 120000 index 0000000..9d02f08 --- /dev/null +++ b/Pixel_Crawler/images/Bonfire_07-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Bonfire/Bonfire_07-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Bonfire_08-Sheet.png b/Pixel_Crawler/images/Bonfire_08-Sheet.png new file mode 120000 index 0000000..70be0da --- /dev/null +++ b/Pixel_Crawler/images/Bonfire_08-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Bonfire/Bonfire_08-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Bonfire_09-Sheet.png b/Pixel_Crawler/images/Bonfire_09-Sheet.png new file mode 120000 index 0000000..e716a40 --- /dev/null +++ b/Pixel_Crawler/images/Bonfire_09-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Bonfire/Bonfire_09-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Bonfire_10-Sheet.png b/Pixel_Crawler/images/Bonfire_10-Sheet.png new file mode 120000 index 0000000..9ddb0b2 --- /dev/null +++ b/Pixel_Crawler/images/Bonfire_10-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Bonfire/Bonfire_10-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Bricks_01-Sheet.png b/Pixel_Crawler/images/Bricks_01-Sheet.png new file mode 120000 index 0000000..05caefc --- /dev/null +++ b/Pixel_Crawler/images/Bricks_01-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Furnace/Bricks_01-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Bricks_02-Sheet.png b/Pixel_Crawler/images/Bricks_02-Sheet.png new file mode 120000 index 0000000..3df5715 --- /dev/null +++ b/Pixel_Crawler/images/Bricks_02-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Furnace/Bricks_02-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Bricks_03-Sheet.png b/Pixel_Crawler/images/Bricks_03-Sheet.png new file mode 120000 index 0000000..373faac --- /dev/null +++ b/Pixel_Crawler/images/Bricks_03-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Furnace/Bricks_03-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Butchery_01-Sheet.png b/Pixel_Crawler/images/Butchery_01-Sheet.png new file mode 120000 index 0000000..860a44e --- /dev/null +++ b/Pixel_Crawler/images/Butchery_01-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Cooking Station/Butchery/Butchery_01-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Butchery_02.png b/Pixel_Crawler/images/Butchery_02.png new file mode 120000 index 0000000..9818d57 --- /dev/null +++ b/Pixel_Crawler/images/Butchery_02.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Cooking Station/Butchery/Butchery_02.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Butchery_03.png b/Pixel_Crawler/images/Butchery_03.png new file mode 120000 index 0000000..5236472 --- /dev/null +++ b/Pixel_Crawler/images/Butchery_03.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Cooking Station/Butchery/Butchery_03.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Butchery_04.png b/Pixel_Crawler/images/Butchery_04.png new file mode 120000 index 0000000..e5a623c --- /dev/null +++ b/Pixel_Crawler/images/Butchery_04.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Cooking Station/Butchery/Butchery_04.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Carry_Idle_Down-Sheet.png b/Pixel_Crawler/images/Carry_Idle_Down-Sheet.png new file mode 120000 index 0000000..ca5a8f5 --- /dev/null +++ b/Pixel_Crawler/images/Carry_Idle_Down-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Carry_Idle/Carry_Idle_Down-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Carry_Idle_Side-Sheet.png b/Pixel_Crawler/images/Carry_Idle_Side-Sheet.png new file mode 120000 index 0000000..244a069 --- /dev/null +++ b/Pixel_Crawler/images/Carry_Idle_Side-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Carry_Idle/Carry_Idle_Side-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Carry_Idle_Up-Sheet.png b/Pixel_Crawler/images/Carry_Idle_Up-Sheet.png new file mode 120000 index 0000000..a7b05fe --- /dev/null +++ b/Pixel_Crawler/images/Carry_Idle_Up-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Carry_Idle/Carry_Idle_Up-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Carry_Run_Down-Sheet.png b/Pixel_Crawler/images/Carry_Run_Down-Sheet.png new file mode 120000 index 0000000..b3cbd34 --- /dev/null +++ b/Pixel_Crawler/images/Carry_Run_Down-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Carry_Run/Carry_Run_Down-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Carry_Run_Side-Sheet.png b/Pixel_Crawler/images/Carry_Run_Side-Sheet.png new file mode 120000 index 0000000..0819030 --- /dev/null +++ b/Pixel_Crawler/images/Carry_Run_Side-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Carry_Run/Carry_Run_Side-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Carry_Run_Up-Sheet.png b/Pixel_Crawler/images/Carry_Run_Up-Sheet.png new file mode 120000 index 0000000..3965e56 --- /dev/null +++ b/Pixel_Crawler/images/Carry_Run_Up-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Carry_Run/Carry_Run_Up-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Carry_Walk_Down-Sheet.png b/Pixel_Crawler/images/Carry_Walk_Down-Sheet.png new file mode 120000 index 0000000..0a12143 --- /dev/null +++ b/Pixel_Crawler/images/Carry_Walk_Down-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Carry_Walk/Carry_Walk_Down-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Carry_Walk_Side-Sheet.png b/Pixel_Crawler/images/Carry_Walk_Side-Sheet.png new file mode 120000 index 0000000..4994802 --- /dev/null +++ b/Pixel_Crawler/images/Carry_Walk_Side-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Carry_Walk/Carry_Walk_Side-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Carry_Walk_Up-Sheet.png b/Pixel_Crawler/images/Carry_Walk_Up-Sheet.png new file mode 120000 index 0000000..b920fdb --- /dev/null +++ b/Pixel_Crawler/images/Carry_Walk_Up-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Carry_Walk/Carry_Walk_Up-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Collect_Down-Sheet.png b/Pixel_Crawler/images/Collect_Down-Sheet.png new file mode 120000 index 0000000..70a58d2 --- /dev/null +++ b/Pixel_Crawler/images/Collect_Down-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Collect_Base/Collect_Down-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Collect_Side-Sheet.png b/Pixel_Crawler/images/Collect_Side-Sheet.png new file mode 120000 index 0000000..68b20ef --- /dev/null +++ b/Pixel_Crawler/images/Collect_Side-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Collect_Base/Collect_Side-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Collect_Up-Sheet.png b/Pixel_Crawler/images/Collect_Up-Sheet.png new file mode 120000 index 0000000..f6444f6 --- /dev/null +++ b/Pixel_Crawler/images/Collect_Up-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Collect_Base/Collect_Up-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Cooker_01.png b/Pixel_Crawler/images/Cooker_01.png new file mode 120000 index 0000000..effacf8 --- /dev/null +++ b/Pixel_Crawler/images/Cooker_01.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Cooking Station/Cooker/Cooker_01.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Cooker_02.png b/Pixel_Crawler/images/Cooker_02.png new file mode 120000 index 0000000..e234f93 --- /dev/null +++ b/Pixel_Crawler/images/Cooker_02.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Cooking Station/Cooker/Cooker_02.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Cooker_03-Sheet.png b/Pixel_Crawler/images/Cooker_03-Sheet.png new file mode 120000 index 0000000..0e564ad --- /dev/null +++ b/Pixel_Crawler/images/Cooker_03-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Cooking Station/Cooker/Cooker_03-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Cooker_04-Sheet.png b/Pixel_Crawler/images/Cooker_04-Sheet.png new file mode 120000 index 0000000..fdc1565 --- /dev/null +++ b/Pixel_Crawler/images/Cooker_04-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Cooking Station/Cooker/Cooker_04-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Cooking Station.png b/Pixel_Crawler/images/Cooking Station.png new file mode 120000 index 0000000..aab66e8 --- /dev/null +++ b/Pixel_Crawler/images/Cooking Station.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Cooking Station/Cooking Station.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Crush_Down-Sheet.png b/Pixel_Crawler/images/Crush_Down-Sheet.png new file mode 120000 index 0000000..58678ad --- /dev/null +++ b/Pixel_Crawler/images/Crush_Down-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Crush_Base/Crush_Down-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Crush_Side-Sheet.png b/Pixel_Crawler/images/Crush_Side-Sheet.png new file mode 120000 index 0000000..9a46d6f --- /dev/null +++ b/Pixel_Crawler/images/Crush_Side-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Crush_Base/Crush_Side-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Crush_Up-Sheet.png b/Pixel_Crawler/images/Crush_Up-Sheet.png new file mode 120000 index 0000000..deede24 --- /dev/null +++ b/Pixel_Crawler/images/Crush_Up-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Crush_Base/Crush_Up-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Death-Sheet.png b/Pixel_Crawler/images/Death-Sheet.png new file mode 120000 index 0000000..4264ff0 --- /dev/null +++ b/Pixel_Crawler/images/Death-Sheet.png @@ -0,0 +1 @@ +../Entities/Mobs/Orc Crew/Orc/Death/Death-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Death_Down-Sheet.png b/Pixel_Crawler/images/Death_Down-Sheet.png new file mode 120000 index 0000000..0106c75 --- /dev/null +++ b/Pixel_Crawler/images/Death_Down-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Death_Base/Death_Down-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Death_Side-Sheet.png b/Pixel_Crawler/images/Death_Side-Sheet.png new file mode 120000 index 0000000..7054f07 --- /dev/null +++ b/Pixel_Crawler/images/Death_Side-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Death_Base/Death_Side-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Death_Up-Sheet.png b/Pixel_Crawler/images/Death_Up-Sheet.png new file mode 120000 index 0000000..f840248 --- /dev/null +++ b/Pixel_Crawler/images/Death_Up-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Death_Base/Death_Up-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Dungeon_Props.png b/Pixel_Crawler/images/Dungeon_Props.png new file mode 120000 index 0000000..86eb587 --- /dev/null +++ b/Pixel_Crawler/images/Dungeon_Props.png @@ -0,0 +1 @@ +../Environment/Props/Static/Dungeon_Props.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Dungeon_Tiles.png b/Pixel_Crawler/images/Dungeon_Tiles.png new file mode 120000 index 0000000..c35181d --- /dev/null +++ b/Pixel_Crawler/images/Dungeon_Tiles.png @@ -0,0 +1 @@ +../Environment/Tilesets/Dungeon_Tiles.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Esoteric.png b/Pixel_Crawler/images/Esoteric.png new file mode 120000 index 0000000..8bcf82e --- /dev/null +++ b/Pixel_Crawler/images/Esoteric.png @@ -0,0 +1 @@ +../Environment/Props/Static/Esoteric.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Estructure.png b/Pixel_Crawler/images/Estructure.png new file mode 120000 index 0000000..6e3e75d --- /dev/null +++ b/Pixel_Crawler/images/Estructure.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Cooking Station/Estructure.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Farm.png b/Pixel_Crawler/images/Farm.png new file mode 120000 index 0000000..5f39700 --- /dev/null +++ b/Pixel_Crawler/images/Farm.png @@ -0,0 +1 @@ +../Environment/Props/Static/Farm.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Fire_01-Sheet.png b/Pixel_Crawler/images/Fire_01-Sheet.png new file mode 120000 index 0000000..4f54918 --- /dev/null +++ b/Pixel_Crawler/images/Fire_01-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Bonfire/Fire_01-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Fire_02-Sheet.png b/Pixel_Crawler/images/Fire_02-Sheet.png new file mode 120000 index 0000000..9fea4d6 --- /dev/null +++ b/Pixel_Crawler/images/Fire_02-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Bonfire/Fire_02-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Fishing_Down-Sheet.png b/Pixel_Crawler/images/Fishing_Down-Sheet.png new file mode 120000 index 0000000..78b6ea4 --- /dev/null +++ b/Pixel_Crawler/images/Fishing_Down-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Fishing_Base/Fishing_Down-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Fishing_Side-Sheet.png b/Pixel_Crawler/images/Fishing_Side-Sheet.png new file mode 120000 index 0000000..318f82d --- /dev/null +++ b/Pixel_Crawler/images/Fishing_Side-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Fishing_Base/Fishing_Side-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Fishing_Up-Sheet.png b/Pixel_Crawler/images/Fishing_Up-Sheet.png new file mode 120000 index 0000000..87e456b --- /dev/null +++ b/Pixel_Crawler/images/Fishing_Up-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Fishing_Base/Fishing_Up-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Floors.png b/Pixel_Crawler/images/Floors.png new file mode 120000 index 0000000..648acc5 --- /dev/null +++ b/Pixel_Crawler/images/Floors.png @@ -0,0 +1 @@ +../Environment/Structures/Buildings/Floors.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Floors_Tiles.png b/Pixel_Crawler/images/Floors_Tiles.png new file mode 120000 index 0000000..7a52fe4 --- /dev/null +++ b/Pixel_Crawler/images/Floors_Tiles.png @@ -0,0 +1 @@ +../Environment/Tilesets/Floors_Tiles.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Furnace.png b/Pixel_Crawler/images/Furnace.png new file mode 120000 index 0000000..da320cb --- /dev/null +++ b/Pixel_Crawler/images/Furnace.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Furnace/Furnace.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Furniture.png b/Pixel_Crawler/images/Furniture.png new file mode 120000 index 0000000..6f33b82 --- /dev/null +++ b/Pixel_Crawler/images/Furniture.png @@ -0,0 +1 @@ +../Environment/Props/Static/Furniture.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Grill_01-Sheet.png b/Pixel_Crawler/images/Grill_01-Sheet.png new file mode 120000 index 0000000..e356735 --- /dev/null +++ b/Pixel_Crawler/images/Grill_01-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Cooking Station/Grill/Grill_01-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Grill_02-Sheet.png b/Pixel_Crawler/images/Grill_02-Sheet.png new file mode 120000 index 0000000..5b8c3f3 --- /dev/null +++ b/Pixel_Crawler/images/Grill_02-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Cooking Station/Grill/Grill_02-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Grill_03-Sheet.png b/Pixel_Crawler/images/Grill_03-Sheet.png new file mode 120000 index 0000000..7ae9589 --- /dev/null +++ b/Pixel_Crawler/images/Grill_03-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Cooking Station/Grill/Grill_03-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Grill_04-Sheet.png b/Pixel_Crawler/images/Grill_04-Sheet.png new file mode 120000 index 0000000..1105542 --- /dev/null +++ b/Pixel_Crawler/images/Grill_04-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Cooking Station/Grill/Grill_04-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Hands.png b/Pixel_Crawler/images/Hands.png new file mode 120000 index 0000000..9da02b8 --- /dev/null +++ b/Pixel_Crawler/images/Hands.png @@ -0,0 +1 @@ +../Weapons/Hands/Hands.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Hit_Down-Sheet.png b/Pixel_Crawler/images/Hit_Down-Sheet.png new file mode 120000 index 0000000..ce3db93 --- /dev/null +++ b/Pixel_Crawler/images/Hit_Down-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Hit_Base/Hit_Down-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Hit_Side-Sheet.png b/Pixel_Crawler/images/Hit_Side-Sheet.png new file mode 120000 index 0000000..8831084 --- /dev/null +++ b/Pixel_Crawler/images/Hit_Side-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Hit_Base/Hit_Side-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Hit_Up-Sheet.png b/Pixel_Crawler/images/Hit_Up-Sheet.png new file mode 120000 index 0000000..a11738d --- /dev/null +++ b/Pixel_Crawler/images/Hit_Up-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Hit_Base/Hit_Up-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Idle-Sheet.png b/Pixel_Crawler/images/Idle-Sheet.png new file mode 120000 index 0000000..a7af6f5 --- /dev/null +++ b/Pixel_Crawler/images/Idle-Sheet.png @@ -0,0 +1 @@ +../Entities/Mobs/Orc Crew/Orc/Idle/Idle-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Idle_Down-Sheet.png b/Pixel_Crawler/images/Idle_Down-Sheet.png new file mode 120000 index 0000000..4233787 --- /dev/null +++ b/Pixel_Crawler/images/Idle_Down-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Idle_Base/Idle_Down-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Idle_Side-Sheet.png b/Pixel_Crawler/images/Idle_Side-Sheet.png new file mode 120000 index 0000000..e7688a9 --- /dev/null +++ b/Pixel_Crawler/images/Idle_Side-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Idle_Base/Idle_Side-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Idle_Up-Sheet.png b/Pixel_Crawler/images/Idle_Up-Sheet.png new file mode 120000 index 0000000..4a448ea --- /dev/null +++ b/Pixel_Crawler/images/Idle_Up-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Idle_Base/Idle_Up-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Iron_01-Sheet.png b/Pixel_Crawler/images/Iron_01-Sheet.png new file mode 120000 index 0000000..a0220a9 --- /dev/null +++ b/Pixel_Crawler/images/Iron_01-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Furnace/Iron_01-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Iron_02-Sheet.png b/Pixel_Crawler/images/Iron_02-Sheet.png new file mode 120000 index 0000000..7cd7097 --- /dev/null +++ b/Pixel_Crawler/images/Iron_02-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Furnace/Iron_02-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Iron_03-Sheet.png b/Pixel_Crawler/images/Iron_03-Sheet.png new file mode 120000 index 0000000..4d1845a --- /dev/null +++ b/Pixel_Crawler/images/Iron_03-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Furnace/Iron_03-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Level_1.png b/Pixel_Crawler/images/Level_1.png new file mode 120000 index 0000000..7c33856 --- /dev/null +++ b/Pixel_Crawler/images/Level_1.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Sawmill/Level_1.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Level_2-Sheet.png b/Pixel_Crawler/images/Level_2-Sheet.png new file mode 120000 index 0000000..f5da153 --- /dev/null +++ b/Pixel_Crawler/images/Level_2-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Sawmill/Level_2-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Level_3-Sheet.png b/Pixel_Crawler/images/Level_3-Sheet.png new file mode 120000 index 0000000..241cc57 --- /dev/null +++ b/Pixel_Crawler/images/Level_3-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Sawmill/Level_3-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Meat.png b/Pixel_Crawler/images/Meat.png new file mode 120000 index 0000000..d3e99cc --- /dev/null +++ b/Pixel_Crawler/images/Meat.png @@ -0,0 +1 @@ +../Environment/Props/Static/Meat.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Pan.png b/Pixel_Crawler/images/Pan.png new file mode 120000 index 0000000..3dc708e --- /dev/null +++ b/Pixel_Crawler/images/Pan.png @@ -0,0 +1 @@ +../Environment/Props/Static/Pan.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Pan_01-Sheet.png b/Pixel_Crawler/images/Pan_01-Sheet.png new file mode 120000 index 0000000..db323a2 --- /dev/null +++ b/Pixel_Crawler/images/Pan_01-Sheet.png @@ -0,0 +1 @@ +../Environment/Props/Animated/Pan_01-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Pan_02-Sheet.png b/Pixel_Crawler/images/Pan_02-Sheet.png new file mode 120000 index 0000000..362c934 --- /dev/null +++ b/Pixel_Crawler/images/Pan_02-Sheet.png @@ -0,0 +1 @@ +../Environment/Props/Animated/Pan_02-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Pan_03-Sheet.png b/Pixel_Crawler/images/Pan_03-Sheet.png new file mode 120000 index 0000000..d87073a --- /dev/null +++ b/Pixel_Crawler/images/Pan_03-Sheet.png @@ -0,0 +1 @@ +../Environment/Props/Animated/Pan_03-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Pan_04-Sheet.png b/Pixel_Crawler/images/Pan_04-Sheet.png new file mode 120000 index 0000000..0f63701 --- /dev/null +++ b/Pixel_Crawler/images/Pan_04-Sheet.png @@ -0,0 +1 @@ +../Environment/Props/Animated/Pan_04-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Pan_05-Sheet.png b/Pixel_Crawler/images/Pan_05-Sheet.png new file mode 120000 index 0000000..114075a --- /dev/null +++ b/Pixel_Crawler/images/Pan_05-Sheet.png @@ -0,0 +1 @@ +../Environment/Props/Animated/Pan_05-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Pierce_Down-Sheet.png b/Pixel_Crawler/images/Pierce_Down-Sheet.png new file mode 120000 index 0000000..4ab42b0 --- /dev/null +++ b/Pixel_Crawler/images/Pierce_Down-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Down-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Pierce_Side-Sheet.png b/Pixel_Crawler/images/Pierce_Side-Sheet.png new file mode 120000 index 0000000..10f7f4f --- /dev/null +++ b/Pixel_Crawler/images/Pierce_Side-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Side-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Pierce_Top-Sheet.png b/Pixel_Crawler/images/Pierce_Top-Sheet.png new file mode 120000 index 0000000..1c75acd --- /dev/null +++ b/Pixel_Crawler/images/Pierce_Top-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Top-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Props.png b/Pixel_Crawler/images/Props.png new file mode 120000 index 0000000..b40786c --- /dev/null +++ b/Pixel_Crawler/images/Props.png @@ -0,0 +1 @@ +../Environment/Structures/Buildings/Props.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Resources.png b/Pixel_Crawler/images/Resources.png new file mode 120000 index 0000000..a227799 --- /dev/null +++ b/Pixel_Crawler/images/Resources.png @@ -0,0 +1 @@ +../Environment/Props/Static/Resources.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Rocks.png b/Pixel_Crawler/images/Rocks.png new file mode 120000 index 0000000..0c94ed8 --- /dev/null +++ b/Pixel_Crawler/images/Rocks.png @@ -0,0 +1 @@ +../Environment/Props/Static/Rocks.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Roofs.png b/Pixel_Crawler/images/Roofs.png new file mode 120000 index 0000000..c739079 --- /dev/null +++ b/Pixel_Crawler/images/Roofs.png @@ -0,0 +1 @@ +../Environment/Structures/Buildings/Roofs.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Run-Sheet.png b/Pixel_Crawler/images/Run-Sheet.png new file mode 120000 index 0000000..80b6d12 --- /dev/null +++ b/Pixel_Crawler/images/Run-Sheet.png @@ -0,0 +1 @@ +../Entities/Mobs/Orc Crew/Orc/Run/Run-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Run_Down-Sheet.png b/Pixel_Crawler/images/Run_Down-Sheet.png new file mode 120000 index 0000000..ef0e6a9 --- /dev/null +++ b/Pixel_Crawler/images/Run_Down-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Run_Base/Run_Down-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Run_Side-Sheet.png b/Pixel_Crawler/images/Run_Side-Sheet.png new file mode 120000 index 0000000..08e9268 --- /dev/null +++ b/Pixel_Crawler/images/Run_Side-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Run_Base/Run_Side-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Run_Up-Sheet.png b/Pixel_Crawler/images/Run_Up-Sheet.png new file mode 120000 index 0000000..3bb7a9c --- /dev/null +++ b/Pixel_Crawler/images/Run_Up-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Run_Base/Run_Up-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Shadows.png b/Pixel_Crawler/images/Shadows.png new file mode 120000 index 0000000..7b0ab17 --- /dev/null +++ b/Pixel_Crawler/images/Shadows.png @@ -0,0 +1 @@ +../Environment/Props/Static/Shadows.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Size_02.png b/Pixel_Crawler/images/Size_02.png new file mode 120000 index 0000000..061d08a --- /dev/null +++ b/Pixel_Crawler/images/Size_02.png @@ -0,0 +1 @@ +../Environment/Props/Static/Trees/Model_01/Size_02.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Size_03-export.png b/Pixel_Crawler/images/Size_03-export.png new file mode 120000 index 0000000..fda348d --- /dev/null +++ b/Pixel_Crawler/images/Size_03-export.png @@ -0,0 +1 @@ +../Environment/Props/Static/Trees/Model_03/Size_03-export.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Size_03.png b/Pixel_Crawler/images/Size_03.png new file mode 120000 index 0000000..a36c4c4 --- /dev/null +++ b/Pixel_Crawler/images/Size_03.png @@ -0,0 +1 @@ +../Environment/Props/Static/Trees/Model_01/Size_03.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Size_04-export-export.png b/Pixel_Crawler/images/Size_04-export-export.png new file mode 120000 index 0000000..134bc26 --- /dev/null +++ b/Pixel_Crawler/images/Size_04-export-export.png @@ -0,0 +1 @@ +../Environment/Props/Static/Trees/Model_03/Size_04-export-export.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Size_04-export.png b/Pixel_Crawler/images/Size_04-export.png new file mode 120000 index 0000000..42e245e --- /dev/null +++ b/Pixel_Crawler/images/Size_04-export.png @@ -0,0 +1 @@ +../Environment/Props/Static/Trees/Model_03/Size_04-export.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Size_04.png b/Pixel_Crawler/images/Size_04.png new file mode 120000 index 0000000..fd8f7d0 --- /dev/null +++ b/Pixel_Crawler/images/Size_04.png @@ -0,0 +1 @@ +../Environment/Props/Static/Trees/Model_01/Size_04.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Size_05.png b/Pixel_Crawler/images/Size_05.png new file mode 120000 index 0000000..16241a1 --- /dev/null +++ b/Pixel_Crawler/images/Size_05.png @@ -0,0 +1 @@ +../Environment/Props/Static/Trees/Model_01/Size_05.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Slice_Down-Sheet.png b/Pixel_Crawler/images/Slice_Down-Sheet.png new file mode 120000 index 0000000..5b27380 --- /dev/null +++ b/Pixel_Crawler/images/Slice_Down-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Slice_Base/Slice_Down-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Slice_Side-Sheet.png b/Pixel_Crawler/images/Slice_Side-Sheet.png new file mode 120000 index 0000000..fc00a0e --- /dev/null +++ b/Pixel_Crawler/images/Slice_Side-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Slice_Base/Slice_Side-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Slice_Up-Sheet.png b/Pixel_Crawler/images/Slice_Up-Sheet.png new file mode 120000 index 0000000..015d5b5 --- /dev/null +++ b/Pixel_Crawler/images/Slice_Up-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Slice_Base/Slice_Up-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Smoke-Sheet.png b/Pixel_Crawler/images/Smoke-Sheet.png new file mode 120000 index 0000000..4946a79 --- /dev/null +++ b/Pixel_Crawler/images/Smoke-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Bonfire/Smoke-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Stone_01-Sheet.png b/Pixel_Crawler/images/Stone_01-Sheet.png new file mode 120000 index 0000000..28a1017 --- /dev/null +++ b/Pixel_Crawler/images/Stone_01-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Furnace/Stone_01-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Stone_02-Sheet.png b/Pixel_Crawler/images/Stone_02-Sheet.png new file mode 120000 index 0000000..b8a0b85 --- /dev/null +++ b/Pixel_Crawler/images/Stone_02-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Furnace/Stone_02-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Stone_03-Sheet.png b/Pixel_Crawler/images/Stone_03-Sheet.png new file mode 120000 index 0000000..5068e6c --- /dev/null +++ b/Pixel_Crawler/images/Stone_03-Sheet.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Furnace/Stone_03-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Tools.png b/Pixel_Crawler/images/Tools.png new file mode 120000 index 0000000..0cf0b1d --- /dev/null +++ b/Pixel_Crawler/images/Tools.png @@ -0,0 +1 @@ +../Environment/Props/Static/Tools.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Vegetation.png b/Pixel_Crawler/images/Vegetation.png new file mode 120000 index 0000000..02eafa7 --- /dev/null +++ b/Pixel_Crawler/images/Vegetation.png @@ -0,0 +1 @@ +../Environment/Props/Static/Vegetation.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Walk_Down-Sheet.png b/Pixel_Crawler/images/Walk_Down-Sheet.png new file mode 120000 index 0000000..37c89d5 --- /dev/null +++ b/Pixel_Crawler/images/Walk_Down-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Walk_Base/Walk_Down-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Walk_Side-Sheet.png b/Pixel_Crawler/images/Walk_Side-Sheet.png new file mode 120000 index 0000000..79d8dbb --- /dev/null +++ b/Pixel_Crawler/images/Walk_Side-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Walk_Base/Walk_Side-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Walk_Up-Sheet.png b/Pixel_Crawler/images/Walk_Up-Sheet.png new file mode 120000 index 0000000..6c1b7b9 --- /dev/null +++ b/Pixel_Crawler/images/Walk_Up-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Walk_Base/Walk_Up-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Wall_Tiles.png b/Pixel_Crawler/images/Wall_Tiles.png new file mode 120000 index 0000000..eba12cd --- /dev/null +++ b/Pixel_Crawler/images/Wall_Tiles.png @@ -0,0 +1 @@ +../Environment/Tilesets/Wall_Tiles.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Wall_Variations.png b/Pixel_Crawler/images/Wall_Variations.png new file mode 120000 index 0000000..ff823b5 --- /dev/null +++ b/Pixel_Crawler/images/Wall_Variations.png @@ -0,0 +1 @@ +../Environment/Tilesets/Wall_Variations.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Walls.png b/Pixel_Crawler/images/Walls.png new file mode 120000 index 0000000..7a26c29 --- /dev/null +++ b/Pixel_Crawler/images/Walls.png @@ -0,0 +1 @@ +../Environment/Structures/Buildings/Walls.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Water_tiles.png b/Pixel_Crawler/images/Water_tiles.png new file mode 120000 index 0000000..0e93fa9 --- /dev/null +++ b/Pixel_Crawler/images/Water_tiles.png @@ -0,0 +1 @@ +../Environment/Tilesets/Water_tiles.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Watering_Down-Sheet.png b/Pixel_Crawler/images/Watering_Down-Sheet.png new file mode 120000 index 0000000..2697b64 --- /dev/null +++ b/Pixel_Crawler/images/Watering_Down-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Watering_Base/Watering_Down-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Watering_Side-Sheet.png b/Pixel_Crawler/images/Watering_Side-Sheet.png new file mode 120000 index 0000000..e819a14 --- /dev/null +++ b/Pixel_Crawler/images/Watering_Side-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Watering_Base/Watering_Side-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Watering_Up-Sheet.png b/Pixel_Crawler/images/Watering_Up-Sheet.png new file mode 120000 index 0000000..54b3b63 --- /dev/null +++ b/Pixel_Crawler/images/Watering_Up-Sheet.png @@ -0,0 +1 @@ +../Entities/Characters/Body_A/Animations/Watering_Base/Watering_Up-Sheet.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Wood.png b/Pixel_Crawler/images/Wood.png new file mode 120000 index 0000000..5fb280c --- /dev/null +++ b/Pixel_Crawler/images/Wood.png @@ -0,0 +1 @@ +../Weapons/Wood/Wood.png \ No newline at end of file diff --git a/Pixel_Crawler/images/Workbench.png b/Pixel_Crawler/images/Workbench.png new file mode 120000 index 0000000..bd20b4c --- /dev/null +++ b/Pixel_Crawler/images/Workbench.png @@ -0,0 +1 @@ +../Environment/Structures/Stations/Workbench/Workbench.png \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..7de465f --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# Create a game with SDL + + +Thanks to "anokolisa" for the spritesheets! They can be found here: +[itchi.io][https://anokolisa.itch.io/free-pixel-art-asset-pack-topdown-tileset-rpg-16x16-sprites] + + +The "Game" can be watched here: [youtube.com](https://www.youtube.com/watch?v=JAe09nhJKLE) diff --git a/fonts/DejaVuSans-Bold.ttf b/fonts/DejaVuSans-Bold.ttf new file mode 100644 index 0000000..6d65fa7 Binary files /dev/null and b/fonts/DejaVuSans-Bold.ttf differ diff --git a/fonts/DejaVuSansMono-Bold.ttf b/fonts/DejaVuSansMono-Bold.ttf new file mode 100644 index 0000000..8184ced Binary files /dev/null and b/fonts/DejaVuSansMono-Bold.ttf differ diff --git a/fonts/DejaVuSansMono.ttf b/fonts/DejaVuSansMono.ttf new file mode 100644 index 0000000..f578602 Binary files /dev/null and b/fonts/DejaVuSansMono.ttf differ diff --git a/fonts/SymbolsNerdFontMono-Regular.ttf b/fonts/SymbolsNerdFontMono-Regular.ttf new file mode 100644 index 0000000..d898eea Binary files /dev/null and b/fonts/SymbolsNerdFontMono-Regular.ttf differ diff --git a/logo/Run_Side-Sheet.png b/logo/Run_Side-Sheet.png new file mode 100644 index 0000000..d6721fa Binary files /dev/null and b/logo/Run_Side-Sheet.png differ diff --git a/logo/logo.aseprite b/logo/logo.aseprite new file mode 100644 index 0000000..d08962f Binary files /dev/null and b/logo/logo.aseprite differ diff --git a/logo/logo.png b/logo/logo.png new file mode 100644 index 0000000..9602b06 Binary files /dev/null and b/logo/logo.png differ diff --git a/logo/props.aseprite b/logo/props.aseprite new file mode 100644 index 0000000..4819208 Binary files /dev/null and b/logo/props.aseprite differ diff --git a/logo/props.png b/logo/props.png new file mode 100644 index 0000000..3567ed8 Binary files /dev/null and b/logo/props.png differ diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..dc79f8f --- /dev/null +++ b/main.cpp @@ -0,0 +1,18 @@ +#include "src/defaults/input.hpp" +#include "src/defaults/defaults.hpp" +#include "src/game/game.hpp" + + +int main(int argc, char** argv) { + + + if (argc == 2 && std::string(argv[1]) == "--fullscreen") { + Default::is_fullscreen = true; + // window size is ignored in fullscreen-desktop mode + } + + + Game game; + game.Run(); + return 0; +} diff --git a/music/bird.sing.wav b/music/bird.sing.wav new file mode 100644 index 0000000..ae71b4a Binary files /dev/null and b/music/bird.sing.wav differ diff --git a/music/character.attack.wav b/music/character.attack.wav new file mode 100644 index 0000000..50a013d Binary files /dev/null and b/music/character.attack.wav differ diff --git a/music/character.build.wav b/music/character.build.wav new file mode 100644 index 0000000..a64a421 Binary files /dev/null and b/music/character.build.wav differ diff --git a/music/character.collect.wav b/music/character.collect.wav new file mode 100644 index 0000000..8dd8fd2 Binary files /dev/null and b/music/character.collect.wav differ diff --git a/music/character.craft.wav b/music/character.craft.wav new file mode 100644 index 0000000..0195019 Binary files /dev/null and b/music/character.craft.wav differ diff --git a/music/character.cultivate.wav b/music/character.cultivate.wav new file mode 100644 index 0000000..355c253 Binary files /dev/null and b/music/character.cultivate.wav differ diff --git a/music/character.dead.wav b/music/character.dead.wav new file mode 100644 index 0000000..907211c Binary files /dev/null and b/music/character.dead.wav differ diff --git a/music/character.die.wav b/music/character.die.wav new file mode 100644 index 0000000..339eab6 Binary files /dev/null and b/music/character.die.wav differ diff --git a/music/character.drink.wav b/music/character.drink.wav new file mode 100644 index 0000000..3926cf7 Binary files /dev/null and b/music/character.drink.wav differ diff --git a/music/character.eat.wav b/music/character.eat.wav new file mode 100644 index 0000000..09ae6bc Binary files /dev/null and b/music/character.eat.wav differ diff --git a/music/character.hae.wav b/music/character.hae.wav new file mode 100644 index 0000000..6515dbb Binary files /dev/null and b/music/character.hae.wav differ diff --git a/music/character.hit.wav b/music/character.hit.wav new file mode 100644 index 0000000..82d0120 Binary files /dev/null and b/music/character.hit.wav differ diff --git a/music/character.plant.wav b/music/character.plant.wav new file mode 100644 index 0000000..f093654 Binary files /dev/null and b/music/character.plant.wav differ diff --git a/music/character.walk.wav b/music/character.walk.wav new file mode 100644 index 0000000..1a22817 Binary files /dev/null and b/music/character.walk.wav differ diff --git a/music/enemy.attack.wav b/music/enemy.attack.wav new file mode 100644 index 0000000..4e18e66 Binary files /dev/null and b/music/enemy.attack.wav differ diff --git a/music/intro.wav b/music/intro.wav new file mode 100644 index 0000000..d1bf20c Binary files /dev/null and b/music/intro.wav differ diff --git a/music/menu.hover.wav b/music/menu.hover.wav new file mode 100644 index 0000000..5915dc3 Binary files /dev/null and b/music/menu.hover.wav differ diff --git a/quit/quit_text_be.aseprite b/quit/quit_text_be.aseprite new file mode 100644 index 0000000..cdefc4e Binary files /dev/null and b/quit/quit_text_be.aseprite differ diff --git a/quit/quit_text_be.png b/quit/quit_text_be.png new file mode 100644 index 0000000..5dee7a4 Binary files /dev/null and b/quit/quit_text_be.png differ diff --git a/quit/quit_text_continued.aseprite b/quit/quit_text_continued.aseprite new file mode 100644 index 0000000..9da6d84 Binary files /dev/null and b/quit/quit_text_continued.aseprite differ diff --git a/quit/quit_text_continued.png b/quit/quit_text_continued.png new file mode 100644 index 0000000..760528c Binary files /dev/null and b/quit/quit_text_continued.png differ diff --git a/quit/quit_text_nope.aseprite b/quit/quit_text_nope.aseprite new file mode 100644 index 0000000..2db5a98 Binary files /dev/null and b/quit/quit_text_nope.aseprite differ diff --git a/quit/quit_text_nope.png b/quit/quit_text_nope.png new file mode 100644 index 0000000..d7788a9 Binary files /dev/null and b/quit/quit_text_nope.png differ diff --git a/quit/quit_text_to.aseprite b/quit/quit_text_to.aseprite new file mode 100644 index 0000000..a620183 Binary files /dev/null and b/quit/quit_text_to.aseprite differ diff --git a/quit/quit_text_to.png b/quit/quit_text_to.png new file mode 100644 index 0000000..4c4cc34 Binary files /dev/null and b/quit/quit_text_to.png differ diff --git a/saves/save.collissions b/saves/save.collissions new file mode 100644 index 0000000..31f8067 Binary files /dev/null and b/saves/save.collissions differ diff --git a/saves/save.map b/saves/save.map new file mode 100644 index 0000000..b9f797a Binary files /dev/null and b/saves/save.map differ diff --git a/saves/save.tileset_collissions b/saves/save.tileset_collissions new file mode 100644 index 0000000..497a1a3 Binary files /dev/null and b/saves/save.tileset_collissions differ diff --git a/saves/save.tileset_floortype b/saves/save.tileset_floortype new file mode 100644 index 0000000..d373e63 Binary files /dev/null and b/saves/save.tileset_floortype differ diff --git a/saves/save.tileset_objects b/saves/save.tileset_objects new file mode 100644 index 0000000..e721d5f Binary files /dev/null and b/saves/save.tileset_objects differ diff --git a/saves/save.tileset_recources b/saves/save.tileset_recources new file mode 100644 index 0000000..36e427a Binary files /dev/null and b/saves/save.tileset_recources differ diff --git a/scripts/audio/audio_normalize.sh b/scripts/audio/audio_normalize.sh new file mode 100644 index 0000000..3e369e2 --- /dev/null +++ b/scripts/audio/audio_normalize.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +set -euo pipefail + +SRC_DIR="music" +DST_DIR="music_cleaned" + +mkdir -p "$DST_DIR" + +for f in "$SRC_DIR"/*.wav; do + [ -e "$f" ] || continue + name=$(basename "$f") + + ffmpeg -hide_banner -loglevel error \ + -i "$f" \ + -af " + highpass=f=120, + afftdn=nf=-20, + agate=threshold=-40dB:ratio=2:attack=5:release=50, + loudnorm=I=-18:TP=-1.5:LRA=7 + " \ + -ar 44100 \ + -ac 1 \ + -c:a pcm_s16le \ + "$DST_DIR/$name" + + echo "Processed: $name" +done + +echo "Done." diff --git a/scripts/audio/audio_to_44100hz.sh b/scripts/audio/audio_to_44100hz.sh new file mode 100644 index 0000000..aaac696 --- /dev/null +++ b/scripts/audio/audio_to_44100hz.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -euo pipefail + +SRC_DIR="ORIG_music" +DST_DIR="music" + +mkdir -p "$DST_DIR" + +for f in "$SRC_DIR"/*.wav; do + [ -e "$f" ] || continue + name=$(basename "$f") + ffmpeg -hide_banner -loglevel error -i "$f" -ar 44100 -ac 1 "$DST_DIR/$name" + echo "Resampled: $name" +done + +echo "All files processed into $DST_DIR" diff --git a/scripts/audio/intro.wav b/scripts/audio/intro.wav new file mode 100644 index 0000000..7ff5750 Binary files /dev/null and b/scripts/audio/intro.wav differ diff --git a/scripts/audio/record.sh b/scripts/audio/record.sh new file mode 100755 index 0000000..5be1348 --- /dev/null +++ b/scripts/audio/record.sh @@ -0,0 +1,68 @@ +#!/bin/bash +set -euo pipefail + +show_help() { + echo "Usage: $0 <output_name> <duration_seconds>" + echo + echo "Records audio from the default microphone, applies:" + echo " - high-pass filter (remove low-frequency rumble)" + echo " - mono conversion" + echo " - peak normalization" + echo " - trims first 50ms (remove mic crack)" + echo " - loudness normalization (LUFS)" + echo "Outputs WAV to <output_name>.wav and plays it back." +} + +stop_recording() { + echo + echo "Stopping recording..." + # 2. Process the recorded audio with sox + sox "$tmp0" "$tmp1" highpass 120 remix 1,2 gain -n + + # 2. Remove mic crack (first 50ms) + ffmpeg -hide_banner -loglevel error -i "$tmp1" -ss 0.05 -c copy "$tmp2" + + # 3. Loudness normalize (LUFS) and back to 44100 Hz + ffmpeg -hide_banner -loglevel error -i "$tmp2" \ + -af "loudnorm=I=-18:TP=-1.5:LRA=7, aresample=44100, pan=mono|c0=0.5*c0+0.5*c1" \ + "${name}.wav" + + # Cleanup temporary files + rm -f "$tmp0" "$tmp1" "$tmp2" + + # 4. Playback + echo "Done. Playing back..." + aplay "${name}.wav" + + echo "Recording saved as ${name}.wav" +} +trap stop_recording SIGINT + +if [[ $# -eq 0 || "$1" == "--help" || "$1" == "-h" ]]; then + show_help + exit 0 +fi + +if [[ $# -lt 2 ]]; then + echo "Error: Missing arguments." + show_help + exit 1 +fi + +name="$1" +duration="$2" + +# Temporary files +tmp0="${name}_raw.wav" +tmp1="${name}_ra1w.wav" +tmp2="${name}_trim.wav" + +echo "Recording $duration seconds into $name.wav..." + +# 1. Record → high-pass → mono → peak normalize +arecord --duration="$duration" --format=cd "$tmp0" + +# Remove trap +trap - SIGINT + +stop_recording diff --git a/scripts/sprites/image_fix_4x_32_to_64.sh b/scripts/sprites/image_fix_4x_32_to_64.sh new file mode 100644 index 0000000..f59e41a --- /dev/null +++ b/scripts/sprites/image_fix_4x_32_to_64.sh @@ -0,0 +1,22 @@ +#!/bin/sh +set -e + +input="../Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Death/Death-Sheet.png" +output="../Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Death/Death-Sheet_padded.png" + +# 1. Crop into 4 frames (32×32 each) +magick "$input" -crop 32x32 +repage frame_%d.png + +# 2. Pad each to 64×64 with transparent background +for f in frame_*.png; do + magick "$f" -background none -gravity center -extent 64x64 "padded_$f" +done + +# 3. Explicitly list padded frames to avoid shell glob issues +frames=$(printf 'padded_frame_%d.png ' 0 1 2 3) + +# 4. Recombine into a single horizontal strip (256×64) +magick convert +append $frames "$output" + +# 5. Cleanup +rm frame_*.png padded_frame_*.png diff --git a/scripts/sprites/image_fix_96x64_to_64x64.sh b/scripts/sprites/image_fix_96x64_to_64x64.sh new file mode 100644 index 0000000..452b20a --- /dev/null +++ b/scripts/sprites/image_fix_96x64_to_64x64.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +input="../Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Death/Death-Sheet_shifted.png" +tmpdir="frames_tmp" +output="../Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Death/Death-Sheet_processed.png" + +mkdir -p "$tmpdir" + +# 1. split into 8 × 96x64 frames +convert "$input" -crop 96x64 +repage "$tmpdir/frame_%02d.png" + +# 2. crop each from 96x64 to 64x64 +for f in "$tmpdir"/frame_*.png; do + convert "$f" -crop 64x64+16+0 +repage "$f" +done + +# 3. recombine horizontally +magick convert +append "$tmpdir"/frame_*.png "$output" + +rm -rf $tmpdir +echo "done: $output" diff --git a/scripts/sprites/image_fix_remove_16_from_top_add_to_bottom.sh b/scripts/sprites/image_fix_remove_16_from_top_add_to_bottom.sh new file mode 100644 index 0000000..438263d --- /dev/null +++ b/scripts/sprites/image_fix_remove_16_from_top_add_to_bottom.sh @@ -0,0 +1,4 @@ +magick "../Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Death/Death-Sheet.png" \ + -crop 768x48+0+16 +repage \ + -background none -gravity north -extent 768x64 \ + "../Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Death/Death-Sheet_shifted.png" diff --git a/scripts/sprites/image_fix_scale_down_and_add_transparent.sh b/scripts/sprites/image_fix_scale_down_and_add_transparent.sh new file mode 100644 index 0000000..29eef84 --- /dev/null +++ b/scripts/sprites/image_fix_scale_down_and_add_transparent.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +in="../Pixel_Crawler/Environment/Structures/Stations/Workbench/Workbench.png" +out="../Pixel_Crawler/Environment/Structures/Stations/Workbench/Workbench_scaled.png" + +convert "$in" \ + -resize 186x340 \ + -background none \ + -gravity center \ + -extent 192x352 \ + "$out" diff --git a/src/audio/audio.cpp b/src/audio/audio.cpp new file mode 100644 index 0000000..4d5bd20 --- /dev/null +++ b/src/audio/audio.cpp @@ -0,0 +1,93 @@ +#include "audio.hpp" +#include <SDL3/SDL.h> +#include <stdio.h> +#include <string.h> + +Audio::Audio() + : mixer(nullptr), sound_count(0) +{ + if (!MIX_Init()) { + printf("MIX_Init failed: %s\n", SDL_GetError()); + return; + } + + mixer = MIX_CreateMixerDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, nullptr); + if (!mixer) { + printf("MIX_CreateMixerDevice failed: %s\n", SDL_GetError()); + MIX_Quit(); + return; + } +} + +void Audio::Quit() { + MIX_Quit(); + mixer=nullptr; +} + +bool Audio::RegisterSound(const char* id, const char* filename) { + if (!mixer || sound_count >= AUDIO_MAX_SOUNDS) { + return false; + } + + if (Find(id)) { + return false; // duplicate ID + } + + AudioSound& s = sounds[sound_count]; + + strncpy(s.id, id, AUDIO_ID_LEN - 1); + s.id[AUDIO_ID_LEN - 1] = '\0'; + + s.audio = MIX_LoadAudio(mixer, filename, false); + if (!s.audio) { + printf("MIX_LoadAudio failed (%s): %s\n", filename, SDL_GetError()); + return false; + } + + s.track = MIX_CreateTrack(mixer); + if (!s.track) { + MIX_DestroyAudio(s.audio); + return false; + } + + MIX_SetTrackAudio(s.track, s.audio); + + sound_count++; + return true; +} + +bool Audio::Play(const char* id, SDL_PropertiesID options) { + AudioSound* s = Find(id); + if (!s) { + return false; + } + + return MIX_PlayTrack(s->track, options); +} + +bool Audio::Stop(const char* id, SDL_PropertiesID options) { + AudioSound* s = Find(id); + if (!s) { + return false; + } + + return MIX_StopTrack(s->track, options); +} + +bool Audio::is_Playing(const char* id) { + AudioSound* s = Find(id); + if (!s) { + return false; + } + + return MIX_TrackPlaying(s->track); +} + +AudioSound* Audio::Find(const char* id) { + for (int i = 0; i < sound_count; ++i) { + if (strcmp(sounds[i].id, id) == 0) { + return &sounds[i]; + } + } + return nullptr; +} diff --git a/src/audio/audio.hpp b/src/audio/audio.hpp new file mode 100644 index 0000000..ef7be75 --- /dev/null +++ b/src/audio/audio.hpp @@ -0,0 +1,34 @@ +#pragma once + +#include <SDL3_mixer/SDL_mixer.h> + +#define AUDIO_MAX_SOUNDS 64 +#define AUDIO_ID_LEN 64 + +struct AudioSound { + char id[AUDIO_ID_LEN]; + MIX_Audio* audio; + MIX_Track* track; +}; + +class Audio { +public: + Audio(); + + bool RegisterSound(const char* id, const char* filename); + bool Play(const char* id, SDL_PropertiesID options = 0); + bool Stop(const char* id, SDL_PropertiesID options = 0); + bool is_Playing(const char* id); + void Quit(); + +private: + MIX_Mixer* mixer; + AudioSound sounds[AUDIO_MAX_SOUNDS]; + int sound_count; + + AudioSound* Find(const char* id); + + Audio(const Audio&) = delete; + Audio& operator=(const Audio&) = delete; +}; + diff --git a/src/bird/bird.cpp b/src/bird/bird.cpp new file mode 100644 index 0000000..929fed9 --- /dev/null +++ b/src/bird/bird.cpp @@ -0,0 +1,471 @@ +#include "bird.hpp" + +#include <SDL3/SDL.h> +#include <SDL3_image/SDL_image.h> +#include <cstdint> +#include <iostream> +#include <algorithm> +#include <cmath> + +#include "defaults/defaults.hpp" +#include "map/map.hpp" + +/* +static constexpr float TAKEOFF_TIME = 1.8f; +static constexpr float LANDING_TIME = 1.8f; +*/ +static constexpr float FLIGHT_HEIGHT = 80.0f; // Consistent flying altitude + +SDL_Texture* Bird::texture; + +std::vector<Bird*> Bird::birds{}; +std::atomic<std::uint64_t> Bird::next_id{0}; + +Bird::Bird(float x, float y) + : drawn(false), + pos_x(x), + pos_y(y), + id(next_id.fetch_add(1, std::memory_order_relaxed)), + target_pos{x, y}, + decision_timer(0.0) { + birds.push_back(this); + set_State(BirdState::WALKING, 2.4); +} + +bool Bird::Init(SDL_Renderer* renderer) { + birds.clear(); + texture = IMG_LoadTexture(renderer, "Bird/Spritesheet/Bird Spritesheet.png"); + SDL_SetTextureScaleMode(texture, SDL_SCALEMODE_NEAREST); + return texture != nullptr; +} + +void Bird::init_Landing() { + //std::cout << "BIRD INIT LANDING!\n"; + is_landing = true; + landing_progress = 0.0f; + landing_start_x = pos_x; + landing_start_y = pos_y; + landing_direction = facing_left ? -1.0f : 1.0f; // Store current flight direction + landing_prev_x_offset = 0.0f; + landing_prev_y_offset = 0.0f; +} + + +void Bird::Update(double delta_s, const SDL_FPoint& player_pos) { + // std::cout << "ALT: " << altitude << std::endl; + // std::cout << (int)state << " ISTART " << is_starting_to_fly << " ILAND " << is_landing << " XY: " << pos_x << " " << pos_y << " DC " << decision_timer << " STT: " << state_timer << std::endl; + state_timer += delta_s; + decision_timer -= delta_s; + + + // Make decisions when idle on ground + //if (landing_cooldown <= 0.0 && state == BirdState::IDLE && on_ground && decision_timer >= 2.0) { + if ( decision_timer <= 0 && + state != BirdState::FLYING) { + Decide(player_pos); + } + + /* + // Handle eating state + if (state == BirdState::EATING) { + eating_timer += delta_s; + if (eating_timer >= 3.0) { + set_State(BirdState::START_TO_FLY, 0.0); + pick_FlyTarget(player_pos); + return; + } + } + */ + + // Determine movement speed + float speed = 0.0f; + if (state == BirdState::FLYING) + speed = FLY_SPEED; + else if (state == BirdState::WALKING) + speed = WALK_SPEED; + + // Calculate distance to target + float dx = target_pos.x - pos_x; + float dy = target_pos.y - pos_y; + float dist = sqrtf(dx * dx + dy * dy); + + if (state == BirdState::WALKING) { + if (dist > 0.4) { + float move = speed * delta_s; + if (move > dist) move = dist; + + float next_px = pos_x + (dx / dist) * move; + float next_py = pos_y + (dy / dist) * move; + bool can_walk = false; + if (Map::is_FreePosition({ + next_px - tile_size / 2, + pos_y - tile_size / 2, + tile_size, + tile_size + })) { + pos_x = next_px; + can_walk = true; + } + if (Map::is_FreePosition({ + pos_x - tile_size / 2, + next_py - tile_size / 2, + tile_size, + tile_size + })) { + pos_y += (dy / dist) * move; + can_walk = true; + } + if (!can_walk) + set_State(BirdState::IDLE, 0.4); + + if (fabsf(dx) > 0.01f) facing_left = (dx < 0.0f); + } else { + //std::cout << "BIRD WALK REACHED GOAL" << std::endl; + set_State(BirdState::IDLE, 0.4); + } + } + else + // Handle flying movement + if (state == BirdState::FLYING && !is_landing && !is_starting_to_fly) { + if (dist > 2.0f) { + pos_x += (dx / dist) * speed * delta_s; + pos_y += (dy / dist) * speed * delta_s; + + // Update facing direction + if (fabsf(dx) > 0.01f) { + facing_left = (dx < 0.0f); + } + } else { + // Reached target - begin landing + init_Landing(); + } + } + // Handle walking movement + else + if (is_starting_to_fly) { + + float overall_dx = target_pos.x - pos_x; + takeoff_direction = (overall_dx >= 0.0f) ? 1.0f : -1.0f; + + float TAKEOFF_SPEED = 35.0f; + + takeoff_progress += TAKEOFF_SPEED * delta_s; + + float t = takeoff_progress / FLIGHT_HEIGHT; + + // Bias circle to start opposite target + float circle_direction = -takeoff_direction; + + float angle, x_offset; + if (t < 0.5f) { + angle = (t / 0.5f) * (M_PI / 2.0f); + x_offset = sinf(angle) * 30.0f * circle_direction; + } else { + angle = ((t - 0.5f) / 0.5f) * (M_PI / 2.0f); + x_offset = (1.0f + sinf(angle)) * 30.0f * circle_direction; + } + + float full_angle = t * M_PI; + float y_offset = -sinf(full_angle) * 20.0f; + + // Delta + float x_offset_delta = x_offset - takeoff_prev_x_offset; + takeoff_prev_x_offset = x_offset; + float y_offset_delta = -((takeoff_progress + y_offset) - takeoff_prev_y_offset); + takeoff_prev_y_offset = takeoff_progress + y_offset; + + facing_left = ( pos_x+x_offset_delta - pos_x < 0.0f); + + pos_x += x_offset_delta; + pos_y += y_offset_delta; + altitude += y_offset_delta*-1; + + // If finished takeoff, align for straight flight + if (takeoff_progress >= FLIGHT_HEIGHT) { + is_starting_to_fly = false; + + // Reset offsets + takeoff_prev_x_offset = 0.0f; + takeoff_prev_y_offset = 0.0f; + + facing_left = (target_pos.x - pos_x < 0.0f); + } + + // std::cout << "DEL: " << x_offset_delta << " " << y_offset_delta << std::endl; + } + // Handle landing animation with circular arc (position-based) + else if (is_landing) { + + landing_progress += speed * delta_s; + + if (landing_progress >= FLIGHT_HEIGHT) { + // if (fabs(target_pos.y - landing_start_y) >= FLIGHT_HEIGHT+1) { + std::cout << "STOP FLYING! START LANDING" << std::endl; + altitude = 0.0f; + set_State(BirdState::STOP_FLYING, 0.0); + return; + } + + float t = landing_progress / FLIGHT_HEIGHT; + + float angle; + float x_offset; + if (t < 0.5f) { + angle = (t / 0.5f) * (M_PI / 2.0f); + x_offset = sinf(angle) * 30.0f * landing_direction; + } else { + angle = ((t - 0.5f) / 0.5f) * (M_PI / 2.0f); + x_offset = (1.0f - sinf(angle)) * 30.0f * landing_direction; + } + + float full_angle = t * M_PI; + float y_offset = -sinf(full_angle) * 20.0f; + + float x_offset_delta = x_offset - landing_prev_x_offset; + landing_prev_x_offset = x_offset; + float y_offset_delta = (landing_progress + y_offset) - landing_prev_y_offset; + landing_prev_y_offset = landing_progress + y_offset; + + float dx = pos_x + x_offset_delta - pos_x; + if (fabsf(dx) > 0.01f) { + facing_left = (dx < 0.0f); + } + altitude -= y_offset_delta; + pos_x += x_offset_delta; + pos_y += y_offset_delta; + } + + // Update animation frames + animation_timer += delta_s; + if (animation_timer >= frame_duration_seconds) { + animation_timer = 0.0; + current_frame += frame_step; + + if (reverse_animation) { + if (current_frame < 0) + current_frame = 0; + } else { + if (current_frame >= frame_count) + current_frame = 0; + } + + src_rect.x = current_frame * tile_size; + } + +} + +void Bird::Render(SDL_Renderer* renderer) { + SDL_FRect dst; + dst.x = Scale(pos_x + Map::offset.x); + dst.y = Scale(pos_y + Map::offset.y); + dst.w = Scale(tile_size); + dst.h = Scale(tile_size); + + SDL_FlipMode flip = facing_left ? SDL_FLIP_NONE : SDL_FLIP_HORIZONTAL; + SDL_RenderTextureRotated(renderer, texture, &src_rect, &dst, 0.0, nullptr, flip); +} + +void Bird::set_Position(SDL_FPoint point) { + pos_x = point.x; + pos_y = point.y; +} + +void Bird::set_State(BirdState new_state, double dec_timer) { + + //std::cout << "BIRD SET STATE " << (int)new_state << std::endl; + decision_timer = dec_timer; + + /* + if (state == new_state) + return; + */ + + state = new_state; + state_timer = 0.0f; + transition_timer = 0.0f; + animation_timer = 0.0; + reverse_animation = false; + frame_step = 1; + + + switch (state) { + case BirdState::IDLE: + current_frame = 0; + set_Animation(0, 2, 0.25); + break; + + case BirdState::FLYING: + current_frame = 0; + set_Animation(1, 8, 0.06); + break; + + case BirdState::WALKING: + current_frame = 0; + set_Animation(2, 3, 0.15); + break; + + case BirdState::EATING: + if (!Animation::audio->is_Playing("bird.sing")) + Animation::audio->Play("bird.sing"); + current_frame = 0; + set_Animation(3, 3, 0.15); + break; + + case BirdState::START_TO_FLY: { + current_frame = 0; + is_starting_to_fly = true; + altitude = 0.0f; + set_Animation(4, 8, 0.06); + decision_timer = 8*0.06; + takeoff_progress = 0.0f; + takeoff_prev_x_offset = 0.0f; + takeoff_prev_y_offset = 0.0f; + break; + } + case BirdState::STOP_FLYING: { + frame_step = -1; + reverse_animation = true; + set_Animation(4, 8, 0.06); + decision_timer = 8*0.06; + is_landing = false; + takeoff_direction = facing_left ? -1.0f : 1.0f; + break; + } + case BirdState::ATTACK: { + current_frame = 0; + set_Animation(1, 8, 0.06); + break; + } + } + + src_rect.x = current_frame * tile_size; +} + +BirdState Bird::get_State() const { + return state; +} + +void Bird::set_Animation(int row, int frames, double frame_time) { + frame_count = frames; + frame_duration_seconds = frame_time; + + src_rect.x = current_frame * tile_size; + src_rect.y = row * tile_size; + src_rect.w = tile_size; + src_rect.h = tile_size; +} + +void Bird::Decide(const SDL_FPoint& player_pos) { + + // Calculate distance to player + float dx = pos_x - player_pos.x; + float dy = pos_y - player_pos.y; + float dist_sq = dx * dx + dy * dy; + + //std::cout << "START DECIED\n"; + // If too far, fly closer + if ( dist_sq > MAX_RADIUS * MAX_RADIUS && + state != BirdState::FLYING && + state != BirdState::STOP_FLYING && + state != BirdState::START_TO_FLY) { + //std::cout << "BIRD TARGET TOO FAR\n"; + set_State(BirdState::START_TO_FLY, 0.0); + pick_FlyTarget(player_pos); + return; + } + if (state == BirdState::START_TO_FLY) { + set_State(BirdState::FLYING, 0.0); + return; + } + + // Random behavior when close to player + int choice = rand() % 100; + float duration = rand() % 70 * 0.1f + 1.1f; + + // std::cout << "COC " << choice << std::endl; + + if (state == BirdState::STOP_FLYING) { + set_State(BirdState::IDLE, duration); + return; + } + + if (choice < 25) { + set_State(BirdState::EATING, duration); + } + else if (choice < 50) { + set_State(BirdState::WALKING, duration+1); + pick_GroundTarget(player_pos); + } + else if (choice < 75) { + set_State(BirdState::IDLE, duration); + } + else { + set_State(BirdState::START_TO_FLY, 0.0); + std::cout << "PDECIDE PICK START\n"; + pick_FlyTarget(player_pos); + std::cout << "PDECIDE PICK END\n"; + } + //std::cout << "END\n"; +} + +void Bird::pick_FlyTarget(const SDL_FPoint& player_pos) { + const float MIN_DIST = MAX_RADIUS; // minimum distance from current position + + float angle, radius, dx, dy, dist_sq; + constexpr int max_attempts = 100; + + SDL_FPoint new_pos = target_pos; + for (int i = 0; i < max_attempts; ++i) { + angle = (rand() % 628) / 100.0f; // 0 to ~2*PI + radius = MIN_RADIUS + (rand() % static_cast<int>(MAX_RADIUS - MIN_RADIUS)); + + new_pos.x = player_pos.x + cosf(angle) * radius; + new_pos.y = player_pos.y - FLIGHT_HEIGHT + sinf(angle) * (radius * 0.3f); + + // Clamp within map bounds + new_pos.x = std::clamp(new_pos.x, 0.0f, static_cast<float>(Map::size.x * Tile::tile_size)); + new_pos.y = std::clamp(new_pos.y, 0.0f, static_cast<float>(Map::size.y * Tile::tile_size)); + + dx = new_pos.x - pos_x; + dy = new_pos.y - pos_y; + dist_sq = dx * dx + dy * dy; + + if (!Map::is_FreePosition({ + new_pos.x - tile_size / 2, + new_pos.y - tile_size / 2, + tile_size, + tile_size + })) + continue; + + //dist_sq = MIN_DIST*MIN_DIST+1; + + if (dist_sq >= MIN_DIST * MIN_DIST) { + target_pos = new_pos; + return; + } + }; + set_State(BirdState::IDLE, 0.8); +} + +void Bird::pick_GroundTarget(const SDL_FPoint& player_pos) { + constexpr int max_attempts = 100; + + SDL_FPoint new_pos = target_pos; + for (int i = 0; i < max_attempts; ++i) { + float offset_x= static_cast<float>((rand() % 64) - 32); // -32 to +32 + float offset_y= static_cast<float>((rand() % 64) - 32); // -32 to +32 + new_pos.x = player_pos.x + offset_x; + new_pos.y = player_pos.y + offset_y; + if (Map::is_FreePosition({ + new_pos.x - tile_size / 2, + new_pos.y - tile_size / 2, + tile_size, + tile_size + })) { + target_pos = new_pos; + return; + } + }; + set_State(BirdState::IDLE, 0.8); +} diff --git a/src/bird/bird.hpp b/src/bird/bird.hpp new file mode 100644 index 0000000..fbeb9b7 --- /dev/null +++ b/src/bird/bird.hpp @@ -0,0 +1,105 @@ +#pragma once + +#include <SDL3/SDL.h> +#include <cstdint> +#include <vector> +#include <atomic> + +static constexpr float MIN_RADIUS = 124.f; +static constexpr float MAX_RADIUS = 164.f; +static constexpr float FLY_SPEED = 42.f; +static constexpr float WALK_SPEED = 10.f; + + +enum class BirdState { + IDLE, // 0 + FLYING, // 1 + WALKING, // 2 + EATING, // 3 + START_TO_FLY, // 4 + STOP_FLYING, // 5 + ATTACK // 6 +}; + +class Bird { +public: + static std::vector<Bird*> birds; + bool drawn; + float altitude = 0.0f; + + float pos_x = 0; + float pos_y = 0; + + Bird(float x, float y); + + static bool Init(SDL_Renderer*); + + void Update(double delta_s, const SDL_FPoint& player_pos); + void Decide(const SDL_FPoint& player_pos); + void pick_FlyTarget(const SDL_FPoint& player_pos); + void pick_GroundTarget(const SDL_FPoint& player_pos); + + + void Render(SDL_Renderer* renderer); + + void init_Landing(); + void set_State(BirdState new_state, double decision_timer); + void set_Position(SDL_FPoint); + + BirdState get_State() const; + +private: + static std::atomic<std::uint64_t> next_id; + std::uint64_t id; + + + void set_Animation(int row, int frames, double frame_time); + + static SDL_Texture* texture; + + SDL_FPoint velocity{0.f, 0.f}; + SDL_FPoint target_pos{0.f, 0.f}; + + double state_timer = 0.0; + double decision_timer = 0.0; + + bool is_landing = false; + bool is_starting_to_fly = false; + float landing_progress = 0.0f; + float takeoff_progress = 0.0f; + bool facing_left = true; + float vertical_offset = 0.0f; + float transition_timer = 0.0f; + + // Bird class private members + float landing_start_y = 0.0f; // store Y when landing starts + + float landing_start_x = 0.0f; // Store X when landing starts + float landing_direction = 1.0f; // Store flight direction for landing arc + float landing_prev_x_offset = 0.0f; + float landing_prev_y_offset = 0.0f; + + + float takeoff_direction = 1.0f; // Store flight direction for takeoff arc + float takeoff_prev_x_offset = 0.0f; + float takeoff_prev_y_offset = 0.0f; + + + + + bool reached_target = false; + bool init_start_to_fly = false; + + static constexpr int tile_size = 16; + + BirdState state = BirdState::IDLE; + + SDL_FRect src_rect{}; + int current_frame = 0; + int frame_count = 1; + bool reverse_animation = false; + int frame_step = 1; + + double frame_duration_seconds = 200; + double animation_timer = 0; +}; diff --git a/src/building/building.cpp b/src/building/building.cpp new file mode 100644 index 0000000..0788e63 --- /dev/null +++ b/src/building/building.cpp @@ -0,0 +1,402 @@ +#include "building/building.hpp" + +#include "defaults/ui.hpp" +#include "map/map.hpp" +#include "building/research.hpp" + + + +BuildingStatus +Building::construction_mode = BuildingStatus::CONSTRUCTING; + +BuildingType +Building::selected_building_type = BuildingType::NONE; + +int Building::draw_menu_curser_grid = -1; +int Building::draw_menu_curser_grid_active = -1; + +void +Building::Draw(SDL_Renderer* renderer, SDL_FPoint position, bool is_transparent, int transparency) { + + BuildingData_s* data = BuildingData::get_BuildingDataByType(building_type); + if (!data) return; + + const bool is_deconstruct = (Building::construction_mode == BuildingStatus::DECONSTRUCT); + + if (!is_deconstruct && (building_time <= 0.0f || data->building_duration <= 0.0f)) { + Object::Draw(renderer, position, is_transparent); + return; + } + + float progress = 1.0f - (building_time / data->building_duration); + progress = std::clamp(progress, 0.0f, 1.0f); + + int fill_r = 0, fill_g = 200, fill_b = 0; + + if (is_deconstruct) { + progress = 1.0f - progress; + fill_r = 200; fill_g = 0; fill_b = 0; + } + + if (!is_deconstruct) + transparency = 100.0f + (progress * 100.0f); + else + transparency = 200.0f - (progress * 100.0f); + + const int tile = Tile::tile_size; + const float bar_w = (float)(dimension.x * tile) * 0.8f; + const float bar_h = (float)tile * 0.15f; + + float bx = position.x + ((float)dimension.x * tile * 0.5f) - (bar_w * 0.5f); + float by = position.y - bar_h - 2.0f; + + Object::Draw(renderer, position, true, transparency); + + SDL_FRect bg{ Scale(bx + Map::offset.x), Scale(by + Map::offset.y), Scale(bar_w), Scale(bar_h) }; + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 180); + SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); + SDL_RenderFillRect(renderer, &bg); + + float fill_w = bar_w * progress; + SDL_FRect fg{ Scale(bx + Map::offset.x), Scale(by + Map::offset.y), Scale(fill_w), Scale(bar_h) }; + SDL_SetRenderDrawColor(renderer, fill_r, fill_g, fill_b, 220); + SDL_RenderFillRect(renderer, &fg); + + // RESOURCE LIST + const float row_h = tile * 0.6f; + const float icon_sz = row_h; + const float pad = 2.0f; + const float gap_y = 2.0f; + + float list_x = bx; + float list_y = by - row_h - 4.0f; + + int rows = 0; + if (!is_deconstruct) { + for (const BuildingCost &rc : data->cost) { + int missing = rc.amount - cost_fulfilled[rc.type]; + if (missing > 0) rows++; + } + } else { + for (const BuildingCost &rc : data->cost) { + int remaining = cost_fulfilled[rc.type]; + if (remaining > 0) rows++; + } + } + + if (rows == 0) return; + + float total_h = rows * row_h + (rows - 1) * gap_y + 2; + + SDL_FRect bg_all{ + Scale(list_x + Map::offset.x), + Scale(list_y - (total_h - row_h) + Map::offset.y), + Scale(bar_w), + Scale(total_h) + }; + SDL_SetRenderDrawColor(renderer, 0,0,0,transparency); + SDL_RenderFillRect(renderer, &bg_all); + + float row_y = list_y; + + auto render_row = [&](int value, ResourceType type) { + if (value <= 0) return; + + auto it = Icon::resource_pos.find(type); + if (it == Icon::resource_pos.end()) return; + + Icon::TilePos pos = it->second; + const float src_ts = 16.f; + + SDL_FRect src{ pos.x * src_ts, pos.y * src_ts, src_ts, src_ts }; + SDL_FRect dst{ + Scale(list_x + pad + Map::offset.x), + Scale(row_y + pad - 4.0f + Map::offset.y), + Scale(icon_sz), + Scale(icon_sz) + }; + SDL_RenderTexture(renderer, Icon::icons_texture, &src, &dst); + + std::string t = std::to_string(value); + SDL_Surface* surf = TTF_RenderText_Blended(Ui::font_tiny, t.c_str(), t.length(), {255,255,255,255}); + if (surf) { + SDL_Texture* tex = SDL_CreateTextureFromSurface(renderer, surf); + if (tex) { + SDL_FRect r{ + Scale(list_x + pad + icon_sz + 4.0f + Map::offset.x), + Scale(row_y + (row_h - surf->h) * 0.5f + 2.0f + Map::offset.y), + (float)surf->w, + (float)surf->h + }; + SDL_RenderTexture(renderer, tex, nullptr, &r); + SDL_DestroyTexture(tex); + } + SDL_DestroySurface(surf); + } + + row_y -= (row_h + gap_y); + }; + + // CONSTRUCTION + if (!is_deconstruct) { + for (const BuildingCost &rc : data->cost) { + int missing = rc.amount - cost_fulfilled[rc.type]; + render_row(missing, rc.type); // rc.type is ResourceType + } + } + // DECONSTRUCTION + else { + std::vector<BuildingCost> cost_vec(data->cost.begin(), data->cost.end()); + for (auto it = cost_vec.rbegin(); it != cost_vec.rend(); ++it) { + int remaining = cost_fulfilled[it->type]; + render_row(remaining, it->type); + } + } +} + +Building* +Building::get_BuildingById(size_t id) { + Object* obj = Object::get_ObjectById(id); + if (!obj) return nullptr; + + return dynamic_cast<Building*>(obj); +} + +bool +Building::Build(Inventory* inventory) { + BuildingData_s* data = BuildingData::get_BuildingDataByType(building_type); + if (!data || building_time <= 0.0f ) return false; + + const float dt = Default::delta_time; + if (dt <= 0.0f) return false; + + // Initialize cost_fulfilled if empty + if (cost_fulfilled.empty()) { + for (const BuildingCost& rc : data->cost) + cost_fulfilled[rc.type] = 0; // integer + } + + // Compute remaining cost + std::unordered_map<ResourceType, float> remaining; + float total_required = 0.0f; + float total_remaining = 0.0f; + + for (const BuildingCost& rc : data->cost) { + float rem = (float)rc.amount - (float)cost_fulfilled[rc.type]; + if (rem < 0.0f) rem = 0.0f; + remaining[rc.type] = rem; + total_required += rc.amount; + total_remaining += rem; + } + + if (total_remaining <= 0.0f) { + building_time = 0.0f; + return true; + } + + // Compute per-second consumption rate + std::unordered_map<ResourceType, float> consumption_rate; + for (const BuildingCost& rc : data->cost) + consumption_rate[rc.type] = (float)rc.amount / data->building_duration; + + // Desired consumption this tick + std::unordered_map<ResourceType, float> desired; + float redistribution_pool = 0.0f; + + for (auto& kv : remaining) { + float want = consumption_rate[kv.first] * dt; + desired[kv.first] = std::min(want, kv.second); + } + + // First pass: consume what is available + for (auto& kv : desired) { + ResourceType t = kv.first; + float want = kv.second; + + float inv_have = (float)inventory->get_Resource(t); + float take = std::min(inv_have, want); + + // Add fractionally + fractional_buffer[t] += take; + + // Convert to integer only when possible + int consume_int = (int)fractional_buffer[t]; + if (consume_int > 0) { + inventory->resources[t] -= consume_int; + cost_fulfilled[t] += consume_int; + fractional_buffer[t] -= consume_int; + } + + // Anything not consumed goes to redistribution + if (take < want) { + redistribution_pool += want - take; + } + } + + // Redistribution: proportional over remaining + if (redistribution_pool > 0.0f) { + float total_remaining_for_redistribution = 0.0f; + for (auto& kv : remaining) + total_remaining_for_redistribution += kv.second - desired[kv.first]; + + if (total_remaining_for_redistribution > 0.0f) { + for (auto& kv : remaining) { + float left = kv.second - desired[kv.first]; + if (left <= 0.0f) continue; + + float share = (left / total_remaining_for_redistribution) * redistribution_pool; + float inv_have = (float)inventory->get_Resource(kv.first); + float take = std::min(share, inv_have); + + fractional_buffer[kv.first] += take; + + int take_int = (int)fractional_buffer[kv.first]; + if (take_int > 0) { + inventory->resources[kv.first] -= take_int; + cost_fulfilled[kv.first] += take_int; + fractional_buffer[kv.first] -= take_int; + } + } + } + } + + // Recompute remaining for progress + total_remaining = 0.0f; + for (const BuildingCost& rc : data->cost) { + float rem = (float)rc.amount - (float)cost_fulfilled[rc.type]; + if (rem < 0.0f) rem = 0.0f; + total_remaining += rem; + } + + float progress = 1.0f - (total_remaining / total_required); + progress = std::clamp(progress, 0.0f, 1.0f); + building_time = data->building_duration * (1.0f - progress); + + if (building_time <= 0.0f) { + building_time = 0.0f; + building_status = BuildingStatus::CONSTRUCTED; + return true; + } + + return true; +} + +bool +Building::Deconstruct(Inventory* inventory) { + BuildingData_s* data = BuildingData::get_BuildingDataByType(building_type); + if (!data) + return false; + if (building_time >= data->building_duration) { + std::cout << "DECONSTRUCTER!\n"; + return true; + } + + const float dt = Default::delta_time; + if (dt <= 0.0f) return false; + + // Initialize cost_fulfilled if empty (unlikely) + if (cost_fulfilled.empty()) { + for (const BuildingCost& rc : data->cost) + cost_fulfilled[rc.type] = 0; + } + + // Compute per-second deconstruction rate + std::unordered_map<ResourceType, float> deconstruct_rate; + for (const BuildingCost& rc : data->cost) + deconstruct_rate[rc.type] = (float)rc.amount / data->building_duration; + + float total_remaining = 0.0f; + float total_required = 0.0f; + + for (const BuildingCost& rc : data->cost) { + total_required += rc.amount; + total_remaining += rc.amount - cost_fulfilled[rc.type]; + } + + // Amount to return this tick + for (auto& kv : cost_fulfilled) { + ResourceType t = kv.first; + int used = kv.second; + if (used <= 0) continue; + + float want = deconstruct_rate[t] * dt; + + // Add fractionally + fractional_buffer[t] += want; + + // Convert to integer only when possible + int give_back = std::min((int)fractional_buffer[t], used); + if (give_back > 0) { + inventory->resources[t] += give_back; // return to inventory + cost_fulfilled[t] -= give_back; + fractional_buffer[t] -= give_back; + } + } + + // Recompute building progress + total_remaining = 0.0f; + for (const BuildingCost& rc : data->cost) { + total_remaining += rc.amount - cost_fulfilled[rc.type]; + } + + float progress = 1.0f - (total_remaining / total_required); + progress = std::clamp(progress, 0.0f, 1.0f); + building_time = data->building_duration * (1.0f - progress); + + if (building_time > data->building_duration) { + building_time = data->building_duration; + std::cout << "DECONSTRUCTER!\n"; + return true; + } + + return false; +} + + +bool +Building::has_Menu() { + if ( static_cast<int>(category) >= static_cast<int>(BuildingType::CRAFTING_STONE_1) && + static_cast<int>(category) <= static_cast<int>(BuildingType::RESEARCH_IRON_3)) + return true; + + return false; +} + +CharacterMenuType +Building::open_Menu(Character* player) { + if (building_status != BuildingStatus::CONSTRUCTED) + return CharacterMenuType::NONE; + + if (BuildingData::is_ResearchTable(building_type)) { + Research::research_buildings.clear(); + Research::research_items.clear(); + + + + for (BuildingData_s data : BuildingData::building_data) + if (data.research_by == building_type && data.required_level <= player->level) + Research::research_buildings.push_back(data.type); + for (ItemStats data : Item::stats) + if (data.research_station == building_type && data.research_level <= static_cast<size_t>(player->level)) + Research::research_items.push_back(data.type); + + std::cout << "Open Research menu\n"; + std::cout << "Build Items: " << Research::research_buildings.size() << std::endl; + std::cout << "Item Items: " << Research::research_items.size() << std::endl; + selected_building_type = building_type; + return CharacterMenuType::RESEARCH; + } + if (BuildingData::is_CraftingTable(building_type)) { + std::cout << "Open Crafting menu\n"; + selected_building_type = building_type; + return CharacterMenuType::WORKBENCH; + } + return CharacterMenuType::NONE; +} + +void +Building::close_Menu() { + std::cout << "Close Build menu\n"; + Research::research_items.clear(); + Research::research_buildings.clear(); +} diff --git a/src/building/building.hpp b/src/building/building.hpp new file mode 100644 index 0000000..08d4f95 --- /dev/null +++ b/src/building/building.hpp @@ -0,0 +1,77 @@ +#pragma once + +#include <SDL3/SDL.h> + +#include <map> +#include <variant> +#include <optional> + +#include "defaults/input.hpp" +#include "map/tile.hpp" +#include "objects/object.hpp" +#include "building/building_data.hpp" +#include "inventory/inventory.hpp" + + +enum class BuildingStatus : uint32_t { + CONSTRUCTING, + CONSTRUCTED, + DECONSTRUCT +}; + + +enum class CharacterMenuType; + +class Building : public Object { +public: + std::unordered_map<ResourceType, int> cost_fulfilled; + std::unordered_map<ResourceType, float> fractional_buffer; + + static BuildingType selected_building_type; + static int draw_menu_curser_grid; + static int draw_menu_curser_grid_active; + float building_time = 0; + BuildingStatus building_status = BuildingStatus::CONSTRUCTING; + BuildingType building_type; + BuildingData_s* data; + + + + Building( // OBJECT + ObjectType ot, + ObjectCategory oc, + TileType tt, + size_t ts_id, + size_t tso_id, + SDL_Point wtp, + SDL_Point d, + int zi, + // BUILDING + BuildingType bt + ) + : Object(ot, oc, tt, ts_id, tso_id, wtp, d, zi), building_type(bt) { + data = BuildingData::get_BuildingDataByType(bt); + building_time = data->building_duration; + } + + static BuildingStatus construction_mode; + + static Building* + get_BuildingById(size_t id); + + void + Draw(SDL_Renderer* renderer, SDL_FPoint position, bool is_transparent = false, int transparency = false) override; + + bool + Build(Inventory*); + bool + Deconstruct(Inventory*); + + + bool + has_Menu(); + CharacterMenuType + open_Menu(Character* player); + void + close_Menu(); +}; diff --git a/src/building/building_data.cpp b/src/building/building_data.cpp new file mode 100644 index 0000000..498a493 --- /dev/null +++ b/src/building/building_data.cpp @@ -0,0 +1,696 @@ +#include "building/building_data.hpp" + +#include <SDL3_image/SDL_image.h> + +#include "defaults/ui.hpp" +#include "map/map.hpp" + +const int MENU_PADDING = 16; +const int MENU_TOP_PADDING = 10 + Ui::top_bar_height; +const int MENU_ITEM_SPACING = 6; +const int MENU_BG_COLOR_R = 0; +const int MENU_BG_COLOR_G = 0; +const int MENU_BG_COLOR_B = 0; +const int MENU_BG_COLOR_A = 182; +const int WORKBENCH_ROW_HEIGHTS[6] = {4, 3, 4, 4, 3, 4}; + + + + +namespace BuildingData { + SDL_Texture* workbench_texture; + ActiveBuild active_build; + + + // Keep the order of BuildingType enum! + std::vector<BuildingData_s> building_data = { + { BuildingType::NONE, + "None", + 0, + 0, + 0, + BuildingType::NONE, + {}, + TileType::TILE_TYPE_LAST, + 0, + 0 + + }, + + // CRAFTING TABLE + { BuildingType::CRAFTING_STONE_1, + "Crafting table Stone", + 6.0, + 3, + 200, + BuildingType::RESEARCH_STONE_1, + {{ResourceType::STONE, 6}, {ResourceType::WOOD, 4}, {ResourceType::CLAY, 2}}, + TileType::TILE_BUILDING, + 5, + 0 + }, + { BuildingType::CRAFTING_STONE_2, + "Crafting table Stone", + 10.0, + 3, + 400, + BuildingType::RESEARCH_STONE_2, + {{ResourceType::STONE, 20}, {ResourceType::WOOD, 7}, {ResourceType::CLAY, 7}}, + TileType::TILE_BUILDING, + 5, + 1 + }, + { BuildingType::CRAFTING_STONE_3, + "Crafting table Stone", + 14.0, + 3, + 600, + BuildingType::RESEARCH_STONE_3, + {{ResourceType::STONE, 30}, {ResourceType::WOOD, 12}, {ResourceType::CLAY, 12}, {ResourceType::IRON, 4}}, + TileType::TILE_BUILDING, + 5, + 2 + }, + { BuildingType::CRAFTING_WOOD_1, + "Crafting table Wood", + 6.0, + 3, + 1, + BuildingType::RESEARCH_WOOD_1, + {{ResourceType::WOOD, 8}, {ResourceType::CLAY, 2}}, + TileType::TILE_BUILDING, + 5, + 4 + }, + { BuildingType::CRAFTING_WOOD_2, + "Crafting table Wood", + 10.0, + 3, + 300, + BuildingType::RESEARCH_WOOD_2, + {{ResourceType::WOOD, 20}, {ResourceType::CLAY, 10}, {ResourceType::STONE, 4}}, + TileType::TILE_BUILDING, + 5, + 13 + }, + { BuildingType::CRAFTING_WOOD_3, + "Crafting table Wood", + 14.0, + 3, + 500, + BuildingType::RESEARCH_WOOD_3, + {{ResourceType::WOOD, 20}, {ResourceType::CLAY, 10}, {ResourceType::STONE, 4}, {ResourceType::IRON, 4}}, + TileType::TILE_BUILDING, + 5, + 14 + }, + { BuildingType::CRAFTING_IRON_1, + "Crafting table Iron", + 6.0, + 3, + 400, + BuildingType::RESEARCH_IRON_1, + {{ResourceType::IRON, 10}, {ResourceType::WOOD, 4}}, + TileType::TILE_BUILDING, + 5, + 5 + }, + { BuildingType::CRAFTING_IRON_2, + "Crafting table Iron", + 10.0, + 3, + 600, + BuildingType::RESEARCH_IRON_2, + {{ResourceType::IRON, 20}, {ResourceType::WOOD, 10}, {ResourceType::STONE, 4}}, + TileType::TILE_BUILDING, + 5, + 12 + }, + { BuildingType::CRAFTING_IRON_3, + "Crafting table Iron", + 14.0, + 3, + 800, + BuildingType::RESEARCH_IRON_3, + {{ResourceType::IRON, 20}, {ResourceType::WOOD, 10}, {ResourceType::STONE, 4}, {ResourceType::CLAY, 4}}, + TileType::TILE_BUILDING, + 5, + 16 + }, + + + + // RESEARCH TABLE + { BuildingType::RESEARCH_STONE_1, + "Research table Stone", + 6.0, + 3, + 200, + BuildingType::RESEARCH_WOOD_1, + {{ResourceType::STONE, 8}}, + TileType::TILE_BUILDING, + 5, + 6 + }, + { BuildingType::RESEARCH_STONE_2, + "Research table Stone", + 10.0, + 3, + 400, + BuildingType::RESEARCH_STONE_1, + {{ResourceType::STONE, 14}, {ResourceType::WOOD, 4}, {ResourceType::CLAY, 4}}, + TileType::TILE_BUILDING, + 5, + 11 + }, + { BuildingType::RESEARCH_STONE_3, + "Research table Stone", + 14.0, + 3, + 600, + BuildingType::RESEARCH_STONE_2, + {{ResourceType::STONE, 20}, {ResourceType::WOOD, 6}, {ResourceType::CLAY, 4}, {ResourceType::IRON, 4}}, + TileType::TILE_BUILDING, + 5, + 3 + }, + { BuildingType::RESEARCH_WOOD_1, + "Research table Wood", + 6.0, + 3, + 1, + BuildingType::NONE, + {{ResourceType::WOOD, 8}, {ResourceType::CLAY, 4}}, + TileType::TILE_BUILDING, + 5, + 7 + }, + { BuildingType::RESEARCH_WOOD_2, + "Research table Wood", + 10.0, + 3, + 300, + BuildingType::RESEARCH_WOOD_2, + {{ResourceType::WOOD, 14}, {ResourceType::CLAY, 4}, {ResourceType::STONE, 4}}, + TileType::TILE_BUILDING, + 5, + 10 + }, + { BuildingType::RESEARCH_WOOD_3, + "Research table Wood", + 14.0, + 3, + 500, + BuildingType::RESEARCH_WOOD_3, + {{ResourceType::WOOD, 20}, {ResourceType::CLAY, 6}, {ResourceType::STONE, 4}, {ResourceType::IRON, 4}}, + TileType::TILE_BUILDING, + 5, + 15 + }, + { BuildingType::RESEARCH_IRON_1, + "Research table Iron", + 6.0, + 3, + 400, + BuildingType::RESEARCH_STONE_1, + {{ResourceType::IRON, 8}, {ResourceType::WOOD, 4}}, + TileType::TILE_BUILDING, + 5, + 8 + }, + { BuildingType::RESEARCH_IRON_2, + "Research table Iron", + 10.0, + 3, + 600, + BuildingType::RESEARCH_IRON_1, + {{ResourceType::IRON, 14}, {ResourceType::WOOD, 3}, {ResourceType::STONE, 4}}, + TileType::TILE_BUILDING, + 5, + 9 + }, + { BuildingType::RESEARCH_IRON_3, + "Research table Iron", + 14.0, + 3, + 800, + BuildingType::RESEARCH_IRON_2, + {{ResourceType::IRON, 20}, {ResourceType::WOOD, 6}, {ResourceType::STONE, 4}, {ResourceType::CLAY, 4}}, + TileType::TILE_BUILDING, + 5, + 17 + }, + }; + + bool Init(SDL_Renderer* renderer) { + workbench_texture = IMG_LoadTexture(renderer, "Pixel_Crawler/Environment/Structures/Stations/Workbench/Workbench.png"); + if (!workbench_texture) { + std::cerr << "Failed to load workbench_texture!\n"; + return false; + } + return true; + } + + int + get_WorkbenchLevel(BuildingType type) { + switch (type) { + case BuildingType::CRAFTING_STONE_1: + case BuildingType::RESEARCH_STONE_1: + case BuildingType::CRAFTING_WOOD_1: + case BuildingType::RESEARCH_WOOD_1: + case BuildingType::CRAFTING_IRON_1: + case BuildingType::RESEARCH_IRON_1: + return 1; + case BuildingType::CRAFTING_STONE_2: + case BuildingType::RESEARCH_STONE_2: + case BuildingType::CRAFTING_WOOD_2: + case BuildingType::RESEARCH_WOOD_2: + case BuildingType::CRAFTING_IRON_2: + case BuildingType::RESEARCH_IRON_2: + return 2; + case BuildingType::CRAFTING_STONE_3: + case BuildingType::RESEARCH_STONE_3: + case BuildingType::CRAFTING_WOOD_3: + case BuildingType::RESEARCH_WOOD_3: + case BuildingType::CRAFTING_IRON_3: + case BuildingType::RESEARCH_IRON_3: + return 3; + default: return -1; + } + } + + BuildingData_s* get_BuildingDataByType(BuildingType type) { + for (auto& b : building_data) + if (b.type == type) return &b; + + return nullptr; + } + + std::vector<BuildingData_s*> + get_CraftingTable() { + std::vector<BuildingData_s*> result; + + for (auto& b : building_data) + if (is_CraftingTable(b.type)) + result.push_back(&b); + + return result; + } + + std::vector<BuildingData_s*> + get_ResearchTable() { + std::vector<BuildingData_s*> result; + + for (auto& b : building_data) + if (is_ResearchTable(b.type)) + result.push_back(&b); + + return result; + } + + + void + draw_WorkbenchMenu(SDL_Renderer* renderer, SDL_Rect win_size, std::vector<bool>& enabled_buildings) { + const int tile = Tile::tile_size; + const int tile_scale = 2; + + std::vector<BuildingData_s*> research = BuildingData::get_ResearchTable(); + std::vector<BuildingData_s*> crafting = BuildingData::get_CraftingTable(); + + struct Cell { + bool enabled; + float w, h; + float sx, sy; + }; + + Cell cells[6][3]; + + size_t active_id = 100; + + // PRECOMPUTE EVERYTHING + for (size_t row = 0; row < 6; ++row) { + for (size_t col = 0; col < 3; ++col) { + + BuildingData_s* data = + (row < 3) + ? research[row * 3 + col] + : crafting[(row - 3) * 3 + col]; + + Cell& c = cells[row][col]; + c.enabled = enabled_buildings[static_cast<size_t>(data->type)]; + + if (!c.enabled) + continue; + + if (data->type == active_build.type) + active_id = row * 3 + col; + + TilesetObject obj = Tile::get_ObjectFromTileSet( + data->tileset_id, + data->tileset_object_id, + data->tileset_type + ); + + c.sx = static_cast<float>(obj.position.x * tile); + c.sy = static_cast<float>(obj.position.y * tile); + c.w = static_cast<float>(obj.position.w * tile); + c.h = static_cast<float>(obj.position.h * tile); + } + } + + // COMPUTE MENU WIDTH + size_t max_w = 0; + + for (size_t row = 0; row < 6; ++row) { + size_t row_w = 0; + + for (size_t col = 0; col < 3; ++col) { + const Cell& c = cells[row][col]; + if (!c.enabled) + continue; + + row_w += (size_t)(c.w * tile_scale); + if (col < 2) + row_w += MENU_ITEM_SPACING; + } + + if (row_w > max_w) + max_w = row_w; + } + + if (max_w == 0) + max_w = 2 * tile + MENU_ITEM_SPACING; + + const float MENU_W = MENU_PADDING * 2 + (float)max_w; + const float menu_x = (float)win_size.w - MENU_W; + const float MENU_H = (float)win_size.h; + + // BACKGROUND + SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); + SDL_SetRenderDrawColor(renderer, + MENU_BG_COLOR_R, MENU_BG_COLOR_G, + MENU_BG_COLOR_B, MENU_BG_COLOR_A + ); + + SDL_FRect bg = { menu_x, 0, MENU_W, MENU_H }; + SDL_RenderFillRect(renderer, &bg); + + // DRAW + float cy = MENU_PADDING + MENU_TOP_PADDING; + + for (size_t row = 0; row < 6; ++row) { + bool has_enabled = false; + float cx = menu_x + MENU_PADDING; + + for (size_t col = 0; col < 3; ++col) { + const Cell& c = cells[row][col]; + if (!c.enabled) + continue; + + has_enabled = true; + + SDL_FRect src = { c.sx, c.sy, c.w, c.h }; + SDL_FRect dst = { cx, cy, c.w * tile_scale, c.h * tile_scale }; + + // higlight cell + if (active_id == row * 3 + col) { + SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); + SDL_SetRenderDrawColor(renderer, 255, 255, 0, 100); + SDL_RenderRect(renderer, &dst); + SDL_SetRenderDrawColor(renderer, 255, 255, 0, 40); + SDL_RenderFillRect(renderer, &dst); + } + + SDL_RenderTexture(renderer, BuildingData::workbench_texture, &src, &dst); + + cx += c.w * tile_scale + MENU_ITEM_SPACING; + } + + if (has_enabled) { + cy += WORKBENCH_ROW_HEIGHTS[row] * tile * tile_scale + MENU_ITEM_SPACING; + + } + } + } + + + BuildingType + menu_DetectWorkbenchClick(const Input& input, SDL_Rect win_size, std::vector<bool>& enabled_buildings) { + const int tile = Tile::tile_size; + const int tile_scale = 2; + std::vector<BuildingData_s*> research = BuildingData::get_ResearchTable(); + std::vector<BuildingData_s*> crafting = BuildingData::get_CraftingTable(); + + struct Cell { + BuildingData_s* data; + float x, y, w, h; + }; + + Cell cells[6][3]; + size_t max_w = 0; + + // PRECOMPUTE CELLS + float cy = MENU_PADDING + MENU_TOP_PADDING; + for (size_t row = 0; row < 6; ++row) { + float cx = MENU_PADDING; + bool has_enabled = false; + + for (size_t col = 0; col < 3; ++col) { + BuildingData_s* data = (row < 3) + ? research[row * 3 + col] + : crafting[(row - 3) * 3 + col]; + bool is_enabled = enabled_buildings[static_cast<size_t>(data->type)]; + if (!is_enabled) { + cells[row][col] = {nullptr, 0, 0, 0, 0}; + continue; + } + + TilesetObject obj = Tile::get_ObjectFromTileSet( + data->tileset_id, + data->tileset_object_id, + data->tileset_type + ); + + float w = static_cast<float>(obj.position.w * tile * tile_scale); + float h = static_cast<float>(obj.position.h * tile * tile_scale); + + cells[row][col] = {data, cx, cy, w, h}; + + cx += w + MENU_ITEM_SPACING; + has_enabled = true; + } + + if (has_enabled) + cy += WORKBENCH_ROW_HEIGHTS[row] * tile * tile_scale + MENU_ITEM_SPACING; + + if (cx - MENU_ITEM_SPACING > max_w) + max_w = static_cast<size_t>(cx - MENU_ITEM_SPACING); + } + + if (max_w == 0) + max_w = 2 * tile *tile_scale + MENU_ITEM_SPACING; + + const float menu_w = MENU_PADDING * 2 + static_cast<float>(max_w); + const float menu_x = static_cast<float>(win_size.w) - menu_w; + const float menu_y = 0.0f; + + SDL_FPoint mouse = input.mouse_state_raw; + + // check if mouse is inside menu + if (mouse.x < menu_x || mouse.x > menu_x + menu_w || + mouse.y < menu_y || mouse.y > menu_y + win_size.h) + return BuildingType::NONE; + + // detect clicked cell + for (size_t row = 0; row < 6; ++row) { + for (size_t col = 0; col < 3; ++col) { + Cell& c = cells[row][col]; + if (!c.data) continue; + + float x0 = menu_x + c.x + MENU_PADDING; + float y0 = menu_y + c.y; + + if (mouse.x >= x0 && mouse.x <= x0 + c.w && + mouse.y >= y0 && mouse.y <= y0 + c.h) { + return c.data->type; + } + } + } + + return BuildingType::NONE; + } + + bool + menu_Hovering(const Input& input, SDL_Rect win_size, std::vector<bool>& enabled_buildings) { + const int tile = Tile::tile_size; + std::vector<BuildingData_s*> research = BuildingData::get_ResearchTable(); + std::vector<BuildingData_s*> crafting = BuildingData::get_CraftingTable(); + size_t max_w = 0; + + for (size_t row = 0; row < 6; ++row) { + float cx = MENU_PADDING; + + for (size_t col = 0; col < 3; ++col) { + BuildingData_s* data = (row < 3) + ? research[row * 3 + col] + : crafting[(row - 3) * 3 + col]; + + bool is_enabled = enabled_buildings[static_cast<size_t>(data->type)]; + if (!is_enabled) + continue; + + TilesetObject obj = Tile::get_ObjectFromTileSet( + data->tileset_id, + data->tileset_object_id, + data->tileset_type + ); + + float w = static_cast<float>(obj.position.w * tile); + cx += w + MENU_ITEM_SPACING; + } + + + if (cx - MENU_ITEM_SPACING > max_w) + max_w = static_cast<size_t>(cx - MENU_ITEM_SPACING); + } + + if (max_w == 0) + max_w = 2 * tile + MENU_ITEM_SPACING; + + const float menu_w = MENU_PADDING * 2 + static_cast<float>(max_w); + const float menu_x = static_cast<float>(win_size.w) - menu_w; + const float menu_y = 0.0f; + const float menu_h = (float)win_size.h; + + SDL_FPoint mouse = input.mouse_state_raw; + + return mouse.x >= menu_x && mouse.x <= menu_x + menu_w && + mouse.y >= menu_y && mouse.y <= menu_y + menu_h; + } + + bool + is_BuildingCollidingWithObject() { + SDL_Point position = active_build.tile_position; + TilesetObject building = active_build.object; + + std::vector<bool> + collision_map = Tile::get_ObjectCollisionsFromTileset(building.tileset_info.set_id, + building.tileset_info.object_id, + Tile::get_Type(building.tileset_info.set_category)); + + int start_cx = std::floor(position.x * Tile::tile_size / float(Tile::tile_collider_size)); + int end_cx = std::ceil(((position.x + building.position.w * Tile::tile_size) / float(Tile::tile_collider_size))); + int start_cy = std::floor(position.y * Tile::tile_size / float(Tile::tile_collider_size)); + int end_cy = std::ceil(((position.y + building.position.h * Tile::tile_size ) / float(Tile::tile_collider_size))); + + int map_width_in_colliders = Map::size.x * (Tile::tile_size / Tile::tile_collider_size); + + // For each map tile collider cell + size_t i = 0; + for (int cy = start_cy; cy < end_cy; ++cy) { + for (int cx = start_cx; cx < end_cx; ++cx, i++) { + size_t index = static_cast<size_t>(cy * map_width_in_colliders + cx); + if (index >= Map::tile_collission_map.size()) + continue; + + if (collision_map[i] && Map::tile_collission_map[index]) + return true; + } + } + + // for each object collider cell + for (int x = 0; x < building.position.w; x++) { + for (int y = 0; y < building.position.h; y++) { + SDL_Point p = {position.x+x, position.y+y}; + if ( Tile::get_FloorType(p) != TileTypeFloors::MEADOW && + Tile::get_FloorType(p) != TileTypeFloors::BRICKS ) + return true; + size_t map_id = static_cast<size_t>(p.y * Map::size.x + x); + if (Map::tile_map[map_id].overlays.size() > 0) + return true; + std::vector<TileObject> objects = Map::get_ObjectsFromMapTile(p); + std::vector<bool> c_b = Tile::get_CollissionsOfTileFromObject(building, {x, y}); + for (TileObject& o : objects) { + Object* oo = Object::get_ObjectById(o.object_id); + // oo->print_CollisionMap(); + std::vector<bool> c_o = oo->get_CollissionsOfTile(o.position); + for (size_t i = 0; i < c_o.size(); i++) + if (c_o[i] && c_b[i]) return true; + } + } + } + return false; + } + + bool + snap_BuildPosition(float in_x, float in_y) { + float tile = Tile::tile_size; + float w = active_build.object.position.w * tile; + float h = active_build.object.position.h * tile; + + float dst_x = in_x - w * 0.5f; + float dst_y = in_y - h; + + float snapped_x = std::round(dst_x / tile) * tile; + float snapped_y = std::floor(dst_y / tile) * tile; + + while (snapped_y + tile > in_y) { + snapped_y -= tile; + } + + active_build.tile_position = Map::get_TileFromXy({snapped_x, snapped_y}); + + if (active_build.tile_position.x >= Map::size.x || + active_build.tile_position.y >= Map::size.y) + return false; + + active_build.world_position = {snapped_x, snapped_y}; + return true; + } + + void + update_ActiveBuildData(float pos_x, float pos_y) { + if (!snap_BuildPosition(pos_x, pos_y)) + return; + + active_build.is_colliding = is_BuildingCollidingWithObject(); + } + + void + draw_SelectedWorkbenchAt(SDL_Renderer* renderer) { + BuildingType t = active_build.type; + if (t == BuildingType::NONE) + return; + + float snapped_x = active_build.world_position.x; + float snapped_y = active_build.world_position.y; + + SDL_FRect dst = { + Scale(snapped_x + Map::offset.x), + Scale(snapped_y + Map::offset.y), + Scale(active_build.object.position.w*static_cast<int>(Tile::tile_size)), + Scale(active_build.object.position.h*static_cast<int>(Tile::tile_size)) + }; + + // -------- RED BACKGROUND WHEN COLLIDING ---------- + if (active_build.is_colliding) { + SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); + SDL_SetRenderDrawColor(renderer, 255, 0, 0, 40); + SDL_RenderFillRect(renderer, &dst); + } + // -------------------------------------------------- + + // Draw the workbench sprite on top + SDL_FRect src = { + static_cast<float>(active_build.object.position.x*static_cast<int>(Tile::tile_size)), + static_cast<float>(active_build.object.position.y*static_cast<int>(Tile::tile_size)), + static_cast<float>(active_build.object.position.w*static_cast<int>(Tile::tile_size)), + static_cast<float>(active_build.object.position.h*static_cast<int>(Tile::tile_size)) + }; + + SDL_SetTextureAlphaMod(BuildingData::workbench_texture, active_build.is_colliding ? 80 : 160); + SDL_RenderTexture(renderer, BuildingData::workbench_texture, &src, &dst); + SDL_SetTextureAlphaMod(BuildingData::workbench_texture, 255); + } + +} diff --git a/src/building/building_data.hpp b/src/building/building_data.hpp new file mode 100644 index 0000000..e2ba577 --- /dev/null +++ b/src/building/building_data.hpp @@ -0,0 +1,122 @@ +#pragma once + +#include "objects/object.hpp" + +enum class ItemType : uint32_t ; + +enum class BuildingType { + NONE, + CRAFTING_STONE_1, + CRAFTING_STONE_2, + CRAFTING_STONE_3, + CRAFTING_WOOD_1, + CRAFTING_WOOD_2, + CRAFTING_WOOD_3, + CRAFTING_IRON_1, + CRAFTING_IRON_2, + CRAFTING_IRON_3, + RESEARCH_STONE_1, + RESEARCH_STONE_2, + RESEARCH_STONE_3, + RESEARCH_WOOD_1, + RESEARCH_WOOD_2, + RESEARCH_WOOD_3, + RESEARCH_IRON_1, + RESEARCH_IRON_2, + RESEARCH_IRON_3, + LAST, +}; + +enum class BuildObjectType { + NONE, + WORKBENCH, + // WALL, DOOR, etc. +}; + + +struct BuildingCost { + ResourceType type; + int amount; +}; + + +struct BuildingData_s { + BuildingType type; + std::string title; + float building_duration; + int level_max; + int required_level; + BuildingType research_by; + + std::initializer_list<BuildingCost> cost; + + TileType tileset_type; + size_t tileset_id; + size_t tileset_object_id; +}; + +struct ActiveBuild { + BuildingType type = BuildingType::NONE; + BuildingData_s* data = nullptr; + TilesetObject object; + SDL_FPoint world_position = {0, 0}; + SDL_Point tile_position; + bool is_colliding = true; + + // Later add other types + // WallTypes wall_type + // DoorTypes door_type +}; + + +namespace BuildingData { + extern std::vector<BuildingData_s> + building_data; + extern SDL_Texture* + workbench_texture; + extern ActiveBuild + active_build; + + bool Init(SDL_Renderer*); + + inline bool is_CraftingTable(BuildingType t) { + return t >= BuildingType::CRAFTING_STONE_1 && + t <= BuildingType::CRAFTING_IRON_3; + } + + inline bool is_ResearchTable(BuildingType t) { + return t >= BuildingType::RESEARCH_STONE_1 && + t <= BuildingType::RESEARCH_IRON_3; + } + + BuildingData_s* + get_BuildingDataByType(BuildingType); + + std::vector<BuildingData_s*> + get_CraftingTable(); + + std::vector<BuildingData_s*> + get_ResearchTable(); + + + void + draw_WorkbenchMenu(SDL_Renderer* r, SDL_Rect win_size, std::vector<bool>& enabled_buildings); // it sucks to pass buildings + + BuildingType + menu_DetectWorkbenchClick(const Input& input, SDL_Rect win_size, std::vector<bool>& enabled_buildings); + + int + get_WorkbenchLevel(BuildingType); + + void + update_ActiveBuildData(float pos_x, float pos_y); + bool + is_BuildingCollidingWithObject(); + bool + snap_BuildPosition(float in_x, float in_y); + void + draw_SelectedWorkbenchAt(SDL_Renderer* r); + + bool + menu_Hovering(const Input& input, SDL_Rect win_size, std::vector<bool>& enabled_buildings); +} diff --git a/src/building/craft.cpp b/src/building/craft.cpp new file mode 100644 index 0000000..dcac518 --- /dev/null +++ b/src/building/craft.cpp @@ -0,0 +1,424 @@ +#include "building/craft.hpp" + +#include "defaults/ui.hpp" +#include "defaults/icons.hpp" + +#include "game/game.hpp" + + +namespace Craft { + + + const int MENU_BG_COLOR_R = 0; + const int MENU_BG_COLOR_G = 0; + const int MENU_BG_COLOR_B = 0; + const int MENU_BG_COLOR_A = 182; + + const int MENU_PADDING = 16; + const float MENU_INNER_W = 800; + const float MENU_INNER_H = 600; + const float MENU_W = MENU_PADDING * 2 + MENU_INNER_W; + const float MENU_H = MENU_PADDING * 2 + MENU_INNER_H; + const int MENU_ITEM_SPACING = 6; + const float MENU_TILE_SIZE = 48.0f; + const float MENU_INFO_W = 300.0f; + + const float MENU_BORDER_OUTER = 4.0f; + const float MENU_BORDER_SEPARATOR = 4.0f; + const float MENU_TILE_BORDER = 2.0f; + const int MENU_COLS = 6; + const int MENU_ROWS = 8; + + SDL_FRect MENU_CRAFT_BUTTON = {0,0,0,0}; + SDL_FRect MENU_INFO_PANEL = {0,0,0,0}; + SDL_Color MENU_HOVER_BORDER_C = Default::menu_hovering_color; + + + ItemCrafting item; + + + + + + void + draw_ItemInfoPanel(SDL_Renderer* renderer, + TTF_Font* font, + const SDL_FRect& panel_rect, + ItemType t) { + const float border = 4.f; + + SDL_SetRenderDrawColor(renderer, 60, 60, 70, 255); + SDL_FRect panel_border{ + panel_rect.x - border, + panel_rect.y - border, + panel_rect.w + border * 2.f, + panel_rect.h + border * 2.f + }; + SDL_RenderFillRect(renderer, &panel_border); + + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); + SDL_RenderFillRect(renderer, &panel_rect); + + if (t == ItemType::NONE) return; + + const float line_h = 20.f; + const float spacing = 4.f; + + float y = panel_rect.y + 6.f; + float x = panel_rect.x + 6.f; + + auto draw_line = [&](const std::string& s) { + SDL_Color white{255,255,255,255}; + SDL_Surface* surf = TTF_RenderText_Solid(font, s.c_str(), s.length(), white); + if (!surf) return; + + SDL_Texture* tex = SDL_CreateTextureFromSurface(renderer, surf); + if (tex) { + SDL_FRect dst{ x, y, (float)surf->w, (float)surf->h }; + SDL_RenderTexture(renderer, tex, nullptr, &dst); + SDL_DestroyTexture(tex); + } + y += line_h + spacing; + SDL_DestroySurface(surf); + }; + + const ItemStats& s = Item::get(t); + + draw_line("ITEM:"); + draw_line(s.title); + y += spacing; + + draw_line("COST:"); + for (auto& c : s.cost) { + std::string n; + switch (c.type) { + case ResourceType::WOOD: n = "Wood"; break; + case ResourceType::STONE: n = "Stone"; break; + case ResourceType::CLAY: n = "Clay"; break; + case ResourceType::BONE: n = "Bone"; break; + default: n = "?"; break; + } + draw_line(n + ": " + std::to_string(c.amount)); + } + y += spacing; + + draw_line("STATS:"); + if (s.base_damage > 0) draw_line("Damage: " + std::to_string(s.base_damage)); + if (s.base_armor > 0) draw_line("Armor: " + std::to_string(s.base_armor)); + draw_line("Health: " + std::to_string(s.base_health)); + draw_line("Max Lvl: " + std::to_string(s.max_level)); + } + + + void + draw_CraftMenu(Game* game, BuildingType type, bool hovering_craft_button) { + SDL_Renderer* renderer = game->renderer; + SDL_Rect win_size = game->win_size; + BuildingData_s building_s = BuildingData::building_data[static_cast<size_t>(type)]; + const float menu_x = static_cast<float>(win_size.w/2) - MENU_W/2; + const float menu_y = static_cast<float>(win_size.h/2) - MENU_H/2; + + const float inner_x = menu_x + MENU_BORDER_OUTER; + const float inner_y = menu_y + MENU_BORDER_OUTER; + const float inner_w = MENU_W - MENU_BORDER_OUTER * 2; + const float inner_h = MENU_H - MENU_BORDER_OUTER * 2; + + const float info_x = inner_x + inner_w - MENU_INFO_W; + + const float sep_x = info_x - MENU_BORDER_SEPARATOR; + + const float grid_x = inner_x; + const float grid_y = inner_y; + const float grid_w = sep_x - inner_x; + const float grid_h = inner_h; + + // MENU BACKGROUND + SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); + SDL_SetRenderDrawColor(renderer, + MENU_BG_COLOR_R, MENU_BG_COLOR_G, + MENU_BG_COLOR_B, MENU_BG_COLOR_A + ); + + SDL_FRect bg = { menu_x, menu_y, MENU_W, MENU_H }; + SDL_RenderFillRect(renderer, &bg); + + // LEFT RIGHT SEPARATOR + SDL_FRect separator_bar = { sep_x, inner_y, MENU_BORDER_SEPARATOR, inner_h }; + + SDL_SetRenderDrawColor(renderer, 80, 80, 80, 255); + SDL_RenderFillRect(renderer, &separator_bar); + + // HEADER BAR + const float header_h = 40.0f; + SDL_FRect header_rect = { grid_x, grid_y, grid_w, header_h }; + + SDL_SetRenderDrawColor(renderer, 50, 50, 50, 255); + SDL_RenderFillRect(renderer, &header_rect); + + const std::string header_text = + building_s.title + + std::string(" | Level ") + + std::to_string(BuildingData::get_WorkbenchLevel(building_s.type)); + + int text_w = 0; + int text_h = 0; + TTF_GetStringSize(Ui::font_menu, header_text.c_str(), header_text.size(), &text_w, &text_h); + + float text_x = header_rect.x + (header_rect.w - text_w) * 0.5f; + float text_y = header_rect.y + (header_h - text_h) * 0.5f; + + SDL_FRect text_dest = { text_x, text_y, static_cast<float>(text_w), static_cast<float>(text_h) }; + + SDL_Color text_color = { 230, 230, 230, 255 }; + SDL_Surface* surface_text = TTF_RenderText_Blended(Ui::font_menu, header_text.c_str(), header_text.size(), text_color); + if (!surface_text) { + SDL_DestroySurface(surface_text); + return; + } + + SDL_Texture* texture_text = SDL_CreateTextureFromSurface(renderer, surface_text); + if (!texture_text) { + SDL_DestroySurface(surface_text); + return; + } + SDL_RenderTexture(renderer, texture_text, nullptr, &text_dest); + + SDL_DestroyTexture(texture_text); + + + // GRID + const float tile_total = MENU_TILE_SIZE + MENU_TILE_BORDER * 2; + + const float grid_required_w = MENU_COLS * tile_total + (MENU_COLS - 1) * MENU_ITEM_SPACING; + const float grid_required_h = MENU_ROWS * tile_total + (MENU_ROWS - 1) * MENU_ITEM_SPACING; + + const float grid_content_y = grid_y + header_h; + const float grid_start_x = grid_x + (grid_w - grid_required_w) * 0.5f; + const float grid_start_y = grid_content_y + (grid_h - header_h - grid_required_h) * 0.5f; + + + int active_i_el = -1; + + std::vector<ItemType> researched_items = + Item::get_ResearchedItems(game->state_playing->player->researched_items); + + size_t i_count = researched_items.size(); + + size_t index = 0; + for (int r = 0; r < MENU_ROWS; ++r) { + for (int c = 0; c < MENU_COLS; ++c) { + + if (Building::draw_menu_curser_grid_active == r*MENU_COLS+c) { + active_i_el = index; + } + + float x = grid_start_x + c * (tile_total + MENU_ITEM_SPACING); + float y = grid_start_y + r * (tile_total + MENU_ITEM_SPACING); + + SDL_FRect border_rect{ x, y, tile_total, tile_total }; + SDL_FRect tile_rect{ + x + MENU_TILE_BORDER, + y + MENU_TILE_BORDER, + MENU_TILE_SIZE, + MENU_TILE_SIZE + }; + + if (Building::draw_menu_curser_grid_active == static_cast<int>(index)) + SDL_SetRenderDrawColor(renderer, 20, 215, 0, 255); + else if (Building::draw_menu_curser_grid == static_cast<int>(index)) + SDL_SetRenderDrawColor(renderer, MENU_HOVER_BORDER_C.r, MENU_HOVER_BORDER_C.g, MENU_HOVER_BORDER_C.b, MENU_HOVER_BORDER_C.a); + else + SDL_SetRenderDrawColor(renderer, 20, 20, 20, 255); + SDL_RenderFillRect(renderer, &border_rect); + + SDL_SetRenderDrawColor(renderer, 60, 60, 60, 255); + SDL_RenderFillRect(renderer, &tile_rect); + + if (index < i_count) { + auto it2 = Icon::item_pos.find(researched_items[index]); + if (it2 != Icon::item_pos.end()) { + SDL_FRect src{ it2->second.x * 16.f, it2->second.y * 16.f, 16.f, 16.f }; + SDL_RenderTexture(renderer, Icon::icons_texture, &src, &tile_rect); + } + } + + index++; + } + } + + // INFO PANEL + SDL_FRect info_panel = { info_x, inner_y, MENU_INFO_W, inner_h }; + MENU_INFO_PANEL = info_panel; + + ItemType item_for_info = ItemType::NONE; + + if (active_i_el > -1 && active_i_el < (int)i_count) { + const auto& researched = Item::get_ResearchedItems(game->state_playing->player->researched_items); + item_for_info = researched[static_cast<size_t>(active_i_el)]; + } + + draw_ItemInfoPanel(renderer, Ui::font_menu, info_panel, item_for_info); + + + // CRAFT BUTTON + float btn_h = 36.0f; + float btn_w = MENU_INFO_W - MENU_BORDER_OUTER * 2; + float btn_x = info_x + MENU_BORDER_OUTER; + float btn_y = inner_y + inner_h - btn_h - MENU_BORDER_OUTER; + + SDL_FRect btn_rect = { btn_x, btn_y, btn_w, btn_h }; + SDL_FRect btn_rect_bg = { btn_x-2, btn_y-2, btn_w+4, btn_h+4 }; + MENU_CRAFT_BUTTON = btn_rect; + + if (hovering_craft_button) + SDL_SetRenderDrawColor(renderer, MENU_HOVER_BORDER_C.r, MENU_HOVER_BORDER_C.g, MENU_HOVER_BORDER_C.b, MENU_HOVER_BORDER_C.a); + else + SDL_SetRenderDrawColor(renderer, 0,0,0, 255); + SDL_RenderFillRect(renderer, &btn_rect_bg); + + SDL_SetRenderDrawColor(renderer, 50, 50, 50, 255); + SDL_RenderFillRect(renderer, &btn_rect); + + // Draw progress + if (Craft::item.is_crafting) { + float progress = Craft::item.duration / Craft::item.duration_max; + SDL_FRect progress_rect = { btn_x, btn_y, btn_w * progress, btn_h }; + SDL_SetRenderDrawColor(renderer, 100, 200, 100, 255); + SDL_RenderFillRect(renderer, &progress_rect); + } + + // Button label + const std::string btn_text = "Craft"; + + int r_w = 0; + int r_h = 0; + TTF_GetStringSize(Ui::font_menu, btn_text.c_str(), btn_text.size(), &r_w, &r_h); + + float r_x = btn_x + (btn_w - r_w) * 0.5f; + float r_y = btn_y + (btn_h - r_h) * 0.5f; + + SDL_FRect r_dest = { r_x, r_y, static_cast<float>(r_w), static_cast<float>(r_h) }; + + SDL_Color r_color = { 230, 230, 230, 255 }; + SDL_Surface* r_surface = TTF_RenderText_Blended(Ui::font_menu, btn_text.c_str(), btn_text.size(), r_color); + if (!r_surface) { + SDL_DestroySurface(r_surface); + return; + } + + SDL_Texture* r_texture = SDL_CreateTextureFromSurface(renderer, r_surface); + if (!r_texture) { + SDL_DestroySurface(r_surface); + return; + } + + SDL_RenderTexture(renderer, r_texture, nullptr, &r_dest); + + SDL_DestroyTexture(r_texture); + } + + bool + is_CursorOverMenuInfoPanel(const SDL_FPoint mouse_pos) { + std::cout << "IP " << MENU_INFO_PANEL.x << " " << MENU_INFO_PANEL.y << " " << MENU_INFO_PANEL.w << " " << MENU_INFO_PANEL.h << " MPP " << mouse_pos.x << " " << mouse_pos.y << std::endl; + return ( + mouse_pos.x >= MENU_INFO_PANEL.x && + mouse_pos.x <= MENU_INFO_PANEL.x + MENU_INFO_PANEL.w && + mouse_pos.y >= MENU_INFO_PANEL.y && + mouse_pos.y <= MENU_INFO_PANEL.y + MENU_INFO_PANEL.h + ); + } + + + bool + cursor_OverCraftButton(const SDL_FPoint mouse_pos) { + return ( + mouse_pos.x >= MENU_CRAFT_BUTTON.x && + mouse_pos.x <= MENU_CRAFT_BUTTON.x + MENU_CRAFT_BUTTON.w && + mouse_pos.y >= MENU_CRAFT_BUTTON.y && + mouse_pos.y <= MENU_CRAFT_BUTTON.y + MENU_CRAFT_BUTTON.h + ); + } + + int + cursor_CraftGridTileIndex(SDL_FPoint mouse, SDL_Rect win_size) { + const float MENU_W = MENU_PADDING * 2 + MENU_INNER_W; + const float MENU_H = MENU_PADDING * 2 + MENU_INNER_H; + const float menu_x = static_cast<float>(win_size.w / 2) - MENU_W / 2; + const float menu_y = static_cast<float>(win_size.h / 2) - MENU_H / 2; + + const float inner_x = menu_x + MENU_BORDER_OUTER; + const float inner_y = menu_y + MENU_BORDER_OUTER; + const float inner_w = MENU_W - MENU_BORDER_OUTER * 2; + const float inner_h = MENU_H - MENU_BORDER_OUTER * 2; + + const float info_x = inner_x + inner_w - MENU_INFO_W; + const float sep_x = info_x - MENU_BORDER_SEPARATOR; + + const float grid_x = inner_x; + const float grid_y = inner_y; + const float grid_w = sep_x - inner_x; + const float grid_h = inner_h; + + const float header_h = 40.0f; + + const float tile_total = MENU_TILE_SIZE + MENU_TILE_BORDER * 2; + const float grid_required_w = MENU_COLS * tile_total + (MENU_COLS - 1) * MENU_ITEM_SPACING; + const float grid_required_h = MENU_ROWS * tile_total + (MENU_ROWS - 1) * MENU_ITEM_SPACING; + + const float grid_content_y = grid_y + header_h; + const float grid_start_x = grid_x + (grid_w - grid_required_w) * 0.5f; + const float grid_start_y = grid_content_y + (grid_h - header_h - grid_required_h) * 0.5f; + + if (mouse.x < grid_start_x || + mouse.y < grid_start_y || + mouse.x > grid_start_x + grid_required_w || + mouse.y > grid_start_y + grid_required_h) { + return -1; + } + + float rel_x = mouse.x - grid_start_x; + float rel_y = mouse.y - grid_start_y; + + const float step = tile_total + MENU_ITEM_SPACING; + + int c = static_cast<int>(rel_x / step); + int r = static_cast<int>(rel_y / step); + + if (c < 0 || c >= MENU_COLS || r < 0 || r >= MENU_ROWS) { + return -1; + } + + float cx = rel_x - c * step; + float cy = rel_y - r * step; + + if (cx < MENU_TILE_BORDER || cx > MENU_TILE_BORDER + MENU_TILE_SIZE || + cy < MENU_TILE_BORDER || cy > MENU_TILE_BORDER + MENU_TILE_SIZE) { + return -1; + } + + return r * MENU_COLS + c; + } + + + + + bool + craft_Start(Inventory* inventory, ItemType type) { + std::cout << "CRAFTING START " << (int)type << std::endl; + + Item::craft_ItemStart(inventory, type, Craft::item); + + return true; + } + + void + craft_Stop() { + Item::craft_Stop(Craft::item); + } + + bool + craft_Continue(Inventory* inventory, Messages* messages) { + return Item::craft_Item(inventory, Craft::item, messages); + } + +} diff --git a/src/building/craft.hpp b/src/building/craft.hpp new file mode 100644 index 0000000..2b244b1 --- /dev/null +++ b/src/building/craft.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include "building/building_data.hpp" +#include "inventory/item.hpp" + + +class Game; + +namespace Craft { + extern ItemCrafting item; + + void + draw_CraftMenu(Game* game, BuildingType type, bool hovering_craft_button); + bool + is_CursorOverMenuInfoPanel(const SDL_FPoint mouse_pos); + bool + cursor_OverCraftButton(const SDL_FPoint mouse_pos); + int + cursor_CraftGridTileIndex(SDL_FPoint mouse, SDL_Rect win_size); + + bool + craft_Start(Inventory*, ItemType); + bool + craft_Continue(Inventory*, Messages*); + void + craft_Stop(); +} diff --git a/src/building/research.cpp b/src/building/research.cpp new file mode 100644 index 0000000..f331f30 --- /dev/null +++ b/src/building/research.cpp @@ -0,0 +1,434 @@ +#include "building/research.hpp" + +#include "defaults/ui.hpp" +#include "defaults/icons.hpp" +#include "building/building.hpp" + + +namespace Research { + const int MENU_BG_COLOR_R = 0; + const int MENU_BG_COLOR_G = 0; + const int MENU_BG_COLOR_B = 0; + const int MENU_BG_COLOR_A = 182; + + const int MENU_PADDING = 16; + const float MENU_INNER_W = 800; + const float MENU_INNER_H = 600; + const float MENU_W = MENU_PADDING * 2 + MENU_INNER_W; + const float MENU_H = MENU_PADDING * 2 + MENU_INNER_H; + const int MENU_ITEM_SPACING = 6; + const float MENU_TILE_SIZE = 48.0f; + const float MENU_INFO_W = 300.0f; + + const float MENU_BORDER_OUTER = 4.0f; + const float MENU_BORDER_SEPARATOR = 4.0f; + const float MENU_TILE_BORDER = 2.0f; + const int MENU_COLS = 6; + const int MENU_ROWS = 8; + + SDL_FRect MENU_RESEARCH_BUTTON = {0,0,0,0}; + SDL_FRect MENU_INFO_PANEL = {0,0,0,0}; + SDL_Color MENU_HOVER_BORDER_C = Default::menu_hovering_color; + + const float RESEARCH_DURATION_MAX = 2.2f; + + + + + bool is_researching = false; + Researching research_item; + + + std::vector<BuildingType> research_buildings; + std::vector<ItemType> research_items; + + void + draw_ReserachMenu(SDL_Renderer* renderer, SDL_Rect win_size, BuildingType type, std::vector<bool>& researched_buildings, std::vector<bool>& researched_items, bool hovering_research_button) { + BuildingData_s building_s = BuildingData::building_data[static_cast<size_t>(type)]; + const float menu_x = static_cast<float>(win_size.w/2) - MENU_W/2; + const float menu_y = static_cast<float>(win_size.h/2) - MENU_H/2; + + const float inner_x = menu_x + MENU_BORDER_OUTER; + const float inner_y = menu_y + MENU_BORDER_OUTER; + const float inner_w = MENU_W - MENU_BORDER_OUTER * 2; + const float inner_h = MENU_H - MENU_BORDER_OUTER * 2; + + const float info_x = inner_x + inner_w - MENU_INFO_W; + + const float sep_x = info_x - MENU_BORDER_SEPARATOR; + + const float grid_x = inner_x; + const float grid_y = inner_y; + const float grid_w = sep_x - inner_x; + const float grid_h = inner_h; + + // MENU BACKGROUND + SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); + SDL_SetRenderDrawColor(renderer, + MENU_BG_COLOR_R, MENU_BG_COLOR_G, + MENU_BG_COLOR_B, MENU_BG_COLOR_A + ); + + SDL_FRect bg = { menu_x, menu_y, MENU_W, MENU_H }; + SDL_RenderFillRect(renderer, &bg); + + // LEFT RIGHT SEPARATOR + SDL_FRect separator_bar = { sep_x, inner_y, MENU_BORDER_SEPARATOR, inner_h }; + + SDL_SetRenderDrawColor(renderer, 80, 80, 80, 255); + SDL_RenderFillRect(renderer, &separator_bar); + + // HEADER BAR + const float header_h = 40.0f; + SDL_FRect header_rect = { grid_x, grid_y, grid_w, header_h }; + + SDL_SetRenderDrawColor(renderer, 50, 50, 50, 255); + SDL_RenderFillRect(renderer, &header_rect); + + const std::string header_text = + building_s.title + + std::string(" | Level ") + + std::to_string(BuildingData::get_WorkbenchLevel(building_s.type)); + + int text_w = 0; + int text_h = 0; + TTF_GetStringSize(Ui::font_menu, header_text.c_str(), header_text.size(), &text_w, &text_h); + + float text_x = header_rect.x + (header_rect.w - text_w) * 0.5f; + float text_y = header_rect.y + (header_h - text_h) * 0.5f; + + SDL_FRect text_dest = { text_x, text_y, static_cast<float>(text_w), static_cast<float>(text_h) }; + + SDL_Color text_color = { 230, 230, 230, 255 }; + SDL_Surface* surface_text = TTF_RenderText_Blended(Ui::font_menu, header_text.c_str(), header_text.size(), text_color); + if (!surface_text) { + SDL_DestroySurface(surface_text); + return; + } + + SDL_Texture* texture_text = SDL_CreateTextureFromSurface(renderer, surface_text); + if (!texture_text) { + SDL_DestroySurface(surface_text); + return; + } + SDL_RenderTexture(renderer, texture_text, nullptr, &text_dest); + + SDL_DestroyTexture(texture_text); + + + // GRID + const float tile_total = MENU_TILE_SIZE + MENU_TILE_BORDER * 2; + + const float grid_required_w = MENU_COLS * tile_total + (MENU_COLS - 1) * MENU_ITEM_SPACING; + const float grid_required_h = MENU_ROWS * tile_total + (MENU_ROWS - 1) * MENU_ITEM_SPACING; + + const float grid_content_y = grid_y + header_h; + const float grid_start_x = grid_x + (grid_w - grid_required_w) * 0.5f; + const float grid_start_y = grid_content_y + (grid_h - header_h - grid_required_h) * 0.5f; + + size_t b_count = research_buildings.size(); + size_t i_count = research_items.size(); + size_t slot_index = 0; + //std::cout << "BC " << b_count << " IC " << i_count << std::endl; + + int active_b_el = -1; + int active_i_el = -1; + + auto draw_checkmark = [&](SDL_Renderer* renderer, const SDL_FRect& rect) { + auto it = Icon::icon_pos.find(IconType::CHECKMARK); + SDL_FRect src{ it->second.x * 16.f, it->second.y * 16.f, 16.f, 16.f }; + SDL_RenderTexture(renderer, Icon::icons_texture, &src, &rect); + }; + + for (int r = 0; r < MENU_ROWS; ++r) { + for (int c = 0; c < MENU_COLS; ++c) { + if (Building::draw_menu_curser_grid_active == r*MENU_COLS+c) { + if (slot_index < b_count) + active_b_el = slot_index; + else + active_i_el = slot_index - b_count; + } + + float x = grid_start_x + c * (tile_total + MENU_ITEM_SPACING); + float y = grid_start_y + r * (tile_total + MENU_ITEM_SPACING); + + SDL_FRect border_rect{ x, y, tile_total, tile_total }; + SDL_FRect tile_rect{ + x + MENU_TILE_BORDER, + y + MENU_TILE_BORDER, + MENU_TILE_SIZE, + MENU_TILE_SIZE + }; + + if (Building::draw_menu_curser_grid_active == static_cast<int>(slot_index)) + SDL_SetRenderDrawColor(renderer, 20, 215, 0, 255); + else if (Building::draw_menu_curser_grid == static_cast<int>(slot_index)) + SDL_SetRenderDrawColor(renderer, MENU_HOVER_BORDER_C.r, MENU_HOVER_BORDER_C.g, MENU_HOVER_BORDER_C.b, MENU_HOVER_BORDER_C.a); + else + SDL_SetRenderDrawColor(renderer, 20, 20, 20, 255); + SDL_RenderFillRect(renderer, &border_rect); + + SDL_SetRenderDrawColor(renderer, 60, 60, 60, 255); + SDL_RenderFillRect(renderer, &tile_rect); + + if (slot_index < b_count) { + BuildingType bt = research_buildings[slot_index]; + auto it = Icon::building_pos.find(bt); + if (it != Icon::building_pos.end()) { + SDL_FRect src{ it->second.x * 16.f, it->second.y * 16.f, 16.f, 16.f }; + SDL_RenderTexture(renderer, Icon::icons_texture, &src, &tile_rect); + } + if (researched_buildings[static_cast<size_t>(bt)]) { + draw_checkmark(renderer, tile_rect); + } + + } else if (slot_index < b_count + i_count) { + ItemType itype = research_items[slot_index - b_count]; + auto it2 = Icon::item_pos.find(itype); + if (it2 != Icon::item_pos.end()) { + SDL_FRect src{ it2->second.x * 16.f, it2->second.y * 16.f, 16.f, 16.f }; + SDL_RenderTexture(renderer, Icon::icons_texture, &src, &tile_rect); + } + if (researched_items[static_cast<size_t>(itype)]) { + draw_checkmark(renderer, tile_rect); + } + } + + slot_index++; + } + } + + // INFO PANEL + std::string info_title; + if (active_b_el > -1 && active_b_el < static_cast<int>(research_buildings.size())) { + info_title = BuildingData::building_data[static_cast<size_t>(research_buildings[static_cast<size_t>(active_b_el)])].title; + } else if (active_i_el > -1 && active_i_el < static_cast<int>(research_items.size())) { + info_title = Item::stats[static_cast<size_t>(research_items[static_cast<size_t>(active_i_el)])].title; + } + + + SDL_FRect info_panel = { info_x, inner_y, MENU_INFO_W, inner_h }; + MENU_INFO_PANEL = info_panel; + SDL_SetRenderDrawColor(renderer, 40, 40, 40, 255); + SDL_RenderFillRect(renderer, &info_panel); + + + + // INFO TEXT + int tw = 0; + int th = 0; + TTF_GetStringSize(Ui::font_menu, info_title.c_str(), info_title.size(), &tw, &th); + + const float t_x = info_panel.x + (info_panel.w - tw) * 0.5f; + const float t_y = info_panel.y + MENU_BORDER_OUTER; + + SDL_Color t_color = { 230, 230, 230, 255 }; + + SDL_Surface* s = TTF_RenderText_Blended(Ui::font_menu, info_title.c_str(), info_title.size(), t_color); + if (!s) return; + + SDL_Texture* tex = SDL_CreateTextureFromSurface(renderer, s); + if (!tex) { + SDL_DestroySurface(s); + return; + } + + SDL_FRect dst = { t_x, t_y, static_cast<float>(tw), static_cast<float>(th) }; + SDL_RenderTexture(renderer, tex, nullptr, &dst); + + SDL_DestroyTexture(tex); + + // RESEARCH BUTTON + float btn_h = 36.0f; + float btn_w = MENU_INFO_W - MENU_BORDER_OUTER * 2; + float btn_x = info_x + MENU_BORDER_OUTER; + float btn_y = inner_y + inner_h - btn_h - MENU_BORDER_OUTER; + + SDL_FRect btn_rect = { btn_x, btn_y, btn_w, btn_h }; + SDL_FRect btn_rect_bg = { btn_x-2, btn_y-2, btn_w+4, btn_h+4 }; + MENU_RESEARCH_BUTTON = btn_rect; + + if (hovering_research_button) + SDL_SetRenderDrawColor(renderer, MENU_HOVER_BORDER_C.r, MENU_HOVER_BORDER_C.g, MENU_HOVER_BORDER_C.b, MENU_HOVER_BORDER_C.a); + else + SDL_SetRenderDrawColor(renderer, 0,0,0, 255); + SDL_RenderFillRect(renderer, &btn_rect_bg); + + SDL_SetRenderDrawColor(renderer, 50, 50, 50, 255); + SDL_RenderFillRect(renderer, &btn_rect); + + // Draw progress + if (Research::research_item.is_researching) { + float progress = Research::research_item.duration / RESEARCH_DURATION_MAX; + SDL_FRect progress_rect = { btn_x, btn_y, btn_w * progress, btn_h }; + SDL_SetRenderDrawColor(renderer, 100, 200, 100, 255); + SDL_RenderFillRect(renderer, &progress_rect); + } + + // Button label + const std::string btn_text = "Research"; + + int r_w = 0; + int r_h = 0; + TTF_GetStringSize(Ui::font_menu, btn_text.c_str(), btn_text.size(), &r_w, &r_h); + + float r_x = btn_x + (btn_w - r_w) * 0.5f; + float r_y = btn_y + (btn_h - r_h) * 0.5f; + + SDL_FRect r_dest = { r_x, r_y, static_cast<float>(r_w), static_cast<float>(r_h) }; + + SDL_Color r_color = { 230, 230, 230, 255 }; + SDL_Surface* r_surface = TTF_RenderText_Blended(Ui::font_menu, btn_text.c_str(), btn_text.size(), r_color); + if (!r_surface) { + SDL_DestroySurface(r_surface); + return; + } + + SDL_Texture* r_texture = SDL_CreateTextureFromSurface(renderer, r_surface); + if (!r_texture) { + SDL_DestroySurface(r_surface); + return; + } + + SDL_RenderTexture(renderer, r_texture, nullptr, &r_dest); + + SDL_DestroyTexture(r_texture); + } + + bool + is_CursorOverMenuInfoPanel(const SDL_FPoint mouse_pos) { + return ( + mouse_pos.x >= MENU_INFO_PANEL.x && + mouse_pos.x <= MENU_INFO_PANEL.x + MENU_INFO_PANEL.w && + mouse_pos.y >= MENU_INFO_PANEL.y && + mouse_pos.y <= MENU_INFO_PANEL.y + MENU_INFO_PANEL.h + ); + } + + + bool + cursor_OverResearchButton(const SDL_FPoint mouse_pos) { + return ( + mouse_pos.x >= MENU_RESEARCH_BUTTON.x && + mouse_pos.x <= MENU_RESEARCH_BUTTON.x + MENU_RESEARCH_BUTTON.w && + mouse_pos.y >= MENU_RESEARCH_BUTTON.y && + mouse_pos.y <= MENU_RESEARCH_BUTTON.y + MENU_RESEARCH_BUTTON.h + ); + } + + int + cursor_ResearchGridTileIndex(SDL_FPoint mouse, SDL_Rect win_size) { + const float MENU_W = MENU_PADDING * 2 + MENU_INNER_W; + const float MENU_H = MENU_PADDING * 2 + MENU_INNER_H; + const float menu_x = static_cast<float>(win_size.w / 2) - MENU_W / 2; + const float menu_y = static_cast<float>(win_size.h / 2) - MENU_H / 2; + + const float inner_x = menu_x + MENU_BORDER_OUTER; + const float inner_y = menu_y + MENU_BORDER_OUTER; + const float inner_w = MENU_W - MENU_BORDER_OUTER * 2; + const float inner_h = MENU_H - MENU_BORDER_OUTER * 2; + + const float info_x = inner_x + inner_w - MENU_INFO_W; + const float sep_x = info_x - MENU_BORDER_SEPARATOR; + + const float grid_x = inner_x; + const float grid_y = inner_y; + const float grid_w = sep_x - inner_x; + const float grid_h = inner_h; + + const float header_h = 40.0f; + + const float tile_total = MENU_TILE_SIZE + MENU_TILE_BORDER * 2; + const float grid_required_w = MENU_COLS * tile_total + (MENU_COLS - 1) * MENU_ITEM_SPACING; + const float grid_required_h = MENU_ROWS * tile_total + (MENU_ROWS - 1) * MENU_ITEM_SPACING; + + const float grid_content_y = grid_y + header_h; + const float grid_start_x = grid_x + (grid_w - grid_required_w) * 0.5f; + const float grid_start_y = grid_content_y + (grid_h - header_h - grid_required_h) * 0.5f; + + if (mouse.x < grid_start_x || + mouse.y < grid_start_y || + mouse.x > grid_start_x + grid_required_w || + mouse.y > grid_start_y + grid_required_h) { + return -1; + } + + float rel_x = mouse.x - grid_start_x; + float rel_y = mouse.y - grid_start_y; + + const float step = tile_total + MENU_ITEM_SPACING; + + int c = static_cast<int>(rel_x / step); + int r = static_cast<int>(rel_y / step); + + if (c < 0 || c >= MENU_COLS || r < 0 || r >= MENU_ROWS) { + return -1; + } + + float cx = rel_x - c * step; + float cy = rel_y - r * step; + + if (cx < MENU_TILE_BORDER || cx > MENU_TILE_BORDER + MENU_TILE_SIZE || + cy < MENU_TILE_BORDER || cy > MENU_TILE_BORDER + MENU_TILE_SIZE) { + return -1; + } + + return r * MENU_COLS + c; + } + + + + + bool + research_Start() { + if (!is_researching) + return false; + Researching item; + + size_t active_index = static_cast<size_t>(Building::draw_menu_curser_grid_active); + + size_t b_count = research_buildings.size(); + + size_t index = active_index; + if (active_index >= b_count) { + // RESEACHING ITEM + index = active_index - b_count; + item.i_type = Research::research_items[index]; + item.i_stats = Item::stats[static_cast<size_t>(item.i_type)]; + } else { + item.b_type = Research::research_buildings[index]; + item.b_stats = BuildingData::building_data[static_cast<size_t>(item.b_type)]; + } + + item.is_researching = true; + + research_item = item; + return true; + } + + void + research_Stop() { + Researching item; + research_item = item; + is_researching = false; + } + + bool + research_Continue(std::vector<bool>& researched_buildings, std::vector<bool>& researched_items) { + research_item.duration += Default::delta_time; + if (research_item.duration < RESEARCH_DURATION_MAX) + return false; + + std::cout << "Researched something!\n"; + if (research_item.i_type != ItemType::NONE) { + researched_items[static_cast<size_t>(research_item.i_type)] = true; + } else + if (research_item.b_type != BuildingType::NONE) { + researched_buildings[static_cast<size_t>(research_item.b_type)] = true; + } + + research_Stop(); + return true; + } + +} diff --git a/src/building/research.hpp b/src/building/research.hpp new file mode 100644 index 0000000..9716d6b --- /dev/null +++ b/src/building/research.hpp @@ -0,0 +1,43 @@ +#pragma once + +#include "building/building_data.hpp" +#include "inventory/item.hpp" + + +struct Researching { + BuildingType b_type = BuildingType::NONE; + BuildingData_s b_stats = {}; + ItemType i_type = ItemType::NONE; + ItemStats i_stats = {}; + float duration = 0; + bool is_researching = false; +}; + + +namespace Research { + + extern bool is_researching; + extern Researching research_item; + + + extern std::vector<BuildingType> + research_buildings; + extern std::vector<ItemType> + research_items; + + void + draw_ReserachMenu(SDL_Renderer*, SDL_Rect win_size, BuildingType type, std::vector<bool>& researched_buildings, std::vector<bool>& researched_items, bool hovering_research_button); + bool + is_CursorOverMenuInfoPanel(const SDL_FPoint mouse_pos); + bool + cursor_OverResearchButton(const SDL_FPoint mouse_pos); + int + cursor_ResearchGridTileIndex(SDL_FPoint mouse, SDL_Rect win_size); + + bool + research_Start(); + bool + research_Continue(std::vector<bool>& researched_buildings, std::vector<bool>& researched_items); + void + research_Stop(); +} diff --git a/src/character/animation.cpp b/src/character/animation.cpp new file mode 100644 index 0000000..ccd7f88 --- /dev/null +++ b/src/character/animation.cpp @@ -0,0 +1,88 @@ +#include "character/animation.hpp" +#include "game/game.hpp" +#include "audio/audio.hpp" + + +namespace Animation { + + float animation_frame_time = 0.1f; + Audio* audio = nullptr; + + AnimationData + load(SDL_Renderer* renderer, + const std::string& path, + float frame_width, + float frame_height, + std::string audio_name_in, + bool re, bool rs) { + SDL_Surface* surf = IMG_Load(path.c_str()); + SDL_Texture* tex = SDL_CreateTextureFromSurface(renderer, surf); + SDL_SetTextureScaleMode(tex, SDL_SCALEMODE_NEAREST); + if (!tex) { + std::cerr << "Failed to load texture: " << path << '\n'; + return {}; + } + + float tex_w = 0.0f; + float tex_h = 0.0f; + if (!SDL_GetTextureSize(tex, &tex_w, &tex_h)) { + std::cerr << "Failed to get texture size: " << SDL_GetError() << '\n'; + SDL_DestroyTexture(tex); + return {}; + } + + const float frame_count = static_cast<int>(tex_w / frame_width); + + AnimationData anim; + anim.texture = tex; + anim.surface = surf; + anim.frames.reserve(frame_count); + + for (int i = 0; i < frame_count; ++i) { + anim.frames.push_back({ + SDL_FRect{ i * frame_width, 0, frame_width, frame_height } + }); + } + + // Audio + anim.audio_name = audio_name_in; + if (anim.audio_name != "None") { + anim.has_audio = true; + std::string p = "music/" + anim.audio_name + ".wav"; + audio->RegisterSound(anim.audio_name.c_str(), p.c_str()); + } + + anim.reverse = re; anim.restart = rs; + + return anim; + } + + + void + update(AnimationData& anim, float delta_time) { + anim.timer += delta_time; + if (anim.timer >= animation_frame_time) { + anim.timer = 0.0f; + + if (!anim.reverse) { + anim.current_frame = + (anim.current_frame + 1) % anim.frames.size(); + } else { + if (anim.current_frame == 0) { + anim.current_frame = anim.frames.size() - 1; + } else { + anim.current_frame--; + } + } + + if (anim.current_frame == 0 && anim.restart) { + audio->Stop(anim.audio_name.c_str()); + } + if (anim.has_audio) { + if (!audio->is_Playing(anim.audio_name.c_str())) { + audio->Play(anim.audio_name.c_str()); + } + } + } + } +} diff --git a/src/character/animation.hpp b/src/character/animation.hpp new file mode 100644 index 0000000..693b0a3 --- /dev/null +++ b/src/character/animation.hpp @@ -0,0 +1,59 @@ +#pragma once + + +#include <SDL3/SDL.h> +#include <SDL3_image/SDL_image.h> + +#include <vector> +#include <unordered_map> +#include <string> +#include <cmath> +#include <iostream> + +#include "defaults/defaults.hpp" +#include "audio/audio.hpp" + +class Game; + +struct AnimationData { + SDL_Texture* texture; + SDL_Texture* txt_back; + SDL_Surface* surface = nullptr; + std::vector<SDL_FRect> frames; + size_t current_frame = 0; + float frame_time = 0.1f; + float timer = 0.0f; + bool has_audio = false; + std::string audio_name; + bool reverse = false; + bool restart = false; +}; + +struct CharacterAnimation { + std::unordered_map<WalkDirection, AnimationData> idle; + std::unordered_map<WalkDirection, AnimationData> walk; + std::unordered_map<WalkDirection, AnimationData> run; + std::unordered_map<WalkDirection, AnimationData> collect; + std::unordered_map<WalkDirection, AnimationData> cultivating; + std::unordered_map<WalkDirection, AnimationData> planting; + std::unordered_map<WalkDirection, AnimationData> build; + std::unordered_map<WalkDirection, AnimationData> hit; + std::unordered_map<WalkDirection, AnimationData> attack_sword; + std::unordered_map<WalkDirection, AnimationData> hit_woodaxe_stone; + std::unordered_map<WalkDirection, AnimationData> death; + std::unordered_map<WalkDirection, AnimationData> craft; + std::unordered_map<WalkDirection, AnimationData> block; + std::unordered_map<WalkDirection, AnimationData> drinking_river; + std::unordered_map<WalkDirection, AnimationData> eating; +}; + +namespace Animation { + extern float animation_frame_time; + extern Audio* audio; + + AnimationData + load(SDL_Renderer* renderer, const std::string& path, float frame_width, float frame_height, std::string audio_name, bool reverse, bool restart); + + void + update(AnimationData& anim, float delta_time); +} diff --git a/src/character/character.cpp b/src/character/character.cpp new file mode 100644 index 0000000..7061187 --- /dev/null +++ b/src/character/character.cpp @@ -0,0 +1,2377 @@ +#include "character/character.hpp" + +#include <algorithm> +#include <vector> + +#include "map/map.hpp" +#include "building/building.hpp" +#include "defaults/ui.hpp" +#include "resource/resource_data.hpp" +#include "building/research.hpp" +#include "building/craft.hpp" +#include "farm/farm.hpp" +#include "character/message.hpp" +#include "cursor/animated_cursor.hpp" + + + +Character::Character() + : messages(std::make_unique<Messages>()), + inventory(std::make_unique<Inventory>()), + discovered_resources(static_cast<size_t>(ResourceType::LAST), false), + discovered_vegetables(static_cast<size_t>(VegetableData::Type::COUNT), false), + discovered_buildings(static_cast<size_t>(BuildingType::LAST), false), + researched_buildings(static_cast<size_t>(BuildingType::LAST), false), + researched_items (static_cast<size_t>(ItemType::LAST), false) { + std::cout << "CREATE CHARACTER\n"; + active_menu = CharacterMenuType::NONE; + researched_buildings[static_cast<size_t>(BuildingType::RESEARCH_WOOD_1)] = true; + researched_items[static_cast<size_t>(ItemType::BUILDING_TOOL)] = true; + std::cout << "[CTOR] " << this << " " << researched_items.size() << "\n"; +} + +Character::Character(Character&&) { + std::cout << "[Character] Move constructor called!" << std::endl; + std::cout << "[DTOR] " << this << " " << researched_items.size() << "\n"; +} + + +Character::~Character() { + delete bird; +} + + +void +Character::Init(SDL_Renderer* renderer) { + x = 10.0f; + y = 10.0f; + speed = 62.0f; // pixels per second + sprint_multiply = 1.6; + direction = WalkDirection::DOWN; + moving = false; + flip = false; + tile_size = 64; + height = 48; + width = 16; + collider.w = 3; + collider.h = 3; + collider.x = (tile_size/2 - collider.w/2); + collider.y = tile_size - collider.h - 15; + collider_world.x = x + collider.x + collider.w * 0.5f; + collider_world.y = y + collider.y + collider.h * 0.5f; + spawn_point = {collider_world.x, collider_world.y}; + arm_reach_radius = 6; + collecting_logic.is_collecting = false; + + stats = { 25, 0, 25, 0, 50, 100, 2}; + + attacking_logic = { 0.0f, nullptr, AttackingLogicStatus_e::NONE, false, nullptr }; + consuming_logic = { 0.0f, 3.0f, false, false, nullptr }; + cultivation_logic = { 0.0f, 3.0f, false, false, {0,0} }; + planting_logic = { 0.0f, 3.0f, false, {0,0}, VegetableData::Type::NONE, false}; + sprintstart_logic = {0, 0.8, false}; + + death_duration = 0; + death_duration_max = 0.8; + death_shuffler = nullptr; + + is_placing_build = false; + + selected_item = inventory->hotbar_hands; + + bird = new Bird(x, y); + //bird->Init(renderer); + bird->set_State(BirdState::WALKING, 1.4); + + + + + // load_MapTiles animations + animation.idle[WalkDirection::DOWN] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Idle_Base/Idle_Down-Sheet.png", tile_size, tile_size, "None", false, false); + animation.idle[WalkDirection::SIDE] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Idle_Base/Idle_Side-Sheet.png", tile_size, tile_size, "None", false, false); + animation.idle[WalkDirection::UP] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Idle_Base/Idle_Up-Sheet.png", tile_size, tile_size, "None", false, false); + + animation.walk[WalkDirection::DOWN] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Walk_Base/Walk_Down-Sheet.png", tile_size, tile_size, "character.walk", false, false); + animation.walk[WalkDirection::SIDE] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Walk_Base/Walk_Side-Sheet.png", tile_size, tile_size, "character.walk", false, false); + animation.walk[WalkDirection::UP] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Walk_Base/Walk_Up-Sheet.png", tile_size, tile_size, "character.walk", false, false); + + animation.run[WalkDirection::DOWN] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Run_Base/Run_Down-Sheet.png", tile_size, tile_size, "None", false, false); + animation.run[WalkDirection::SIDE] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Run_Base/Run_Side-Sheet.png", tile_size, tile_size, "None", false, false); + animation.run[WalkDirection::UP] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Run_Base/Run_Up-Sheet.png", tile_size, tile_size, "None", false, false); + + animation.collect[WalkDirection::DOWN] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Down-Sheet.png", tile_size, tile_size, "character.collect", false, false); + animation.collect[WalkDirection::SIDE] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Side-Sheet.png", tile_size, tile_size, "character.collect", false, false); + animation.collect[WalkDirection::UP] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Up-Sheet.png", tile_size, tile_size, "character.collect", false, false); + + animation.cultivating[WalkDirection::DOWN] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Down-Sheet.png", tile_size, tile_size, "character.cultivate", false, false); + animation.cultivating[WalkDirection::SIDE] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Side-Sheet.png", tile_size, tile_size, "character.cultivate", false, false); + animation.cultivating[WalkDirection::UP] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Up-Sheet.png", tile_size, tile_size, "character.cultivate", false, false); + + animation.planting[WalkDirection::DOWN] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Down-Sheet.png", tile_size, tile_size, "character.plant", false, false); + animation.planting[WalkDirection::SIDE] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Side-Sheet.png", tile_size, tile_size, "character.plant", false, false); + animation.planting[WalkDirection::UP] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Up-Sheet.png", tile_size, tile_size, "character.plant", false, false); + + animation.craft[WalkDirection::DOWN] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Down-Sheet.png", tile_size, tile_size, "character.craft", false, false); + animation.craft[WalkDirection::SIDE] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Side-Sheet.png", tile_size, tile_size, "character.craft", false, false); + animation.craft[WalkDirection::UP] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Up-Sheet.png", tile_size, tile_size, "character.craft", false, false); + + animation.build[WalkDirection::DOWN] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Down-Sheet.png", tile_size, tile_size, "character.build", false, false); + animation.build[WalkDirection::SIDE] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Side-Sheet.png", tile_size, tile_size, "character.build", false, false); + animation.build[WalkDirection::UP] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Up-Sheet.png", tile_size, tile_size, "character.build", false, false); + + animation.hit[WalkDirection::DOWN] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Hit_Base/Hit_Down-Sheet.png", tile_size, tile_size, "character.hit", false, false); + animation.hit[WalkDirection::SIDE] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Hit_Base/Hit_Side-Sheet.png", tile_size, tile_size, "character.hit", false, false); + animation.hit[WalkDirection::UP] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Hit_Base/Hit_Up-Sheet.png", tile_size, tile_size, "character.hit", false, false); + + animation.attack_sword[WalkDirection::DOWN] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Wood_Down.png", tile_size, tile_size, "character.attack", false, false); + animation.attack_sword[WalkDirection::SIDE] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Wood_Side.png", tile_size, tile_size, "character.attack", false, false); + animation.attack_sword[WalkDirection::UP] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Base/Pierce_Wood_Top.png", tile_size, tile_size, "character.attack", false, false); + + animation.hit_woodaxe_stone[WalkDirection::DOWN] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Slice_Base/Slice_Down.png", tile_size, tile_size, "None", false, false); + animation.hit_woodaxe_stone[WalkDirection::SIDE] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Slice_Base/Slice_Side.png", tile_size, tile_size, "None", false, false); + animation.hit_woodaxe_stone[WalkDirection::UP] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Slice_Base/Slice_Up.png", tile_size, tile_size, "None", false, false); + + animation.death[WalkDirection::DOWN] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Death_Base/Death_Down-Sheet.png", tile_size, tile_size, "character.die", false, false); + animation.death[WalkDirection::SIDE] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Death_Base/Death_Side-Sheet.png", tile_size, tile_size, "character.die", false, false); + animation.death[WalkDirection::UP] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Death_Base/Death_Up-Sheet.png", tile_size, tile_size, "character.die", false, false); + + animation.block[WalkDirection::DOWN] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Blocking/Down.png", tile_size, tile_size, "None", false, false); + animation.block[WalkDirection::SIDE] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Blocking/Side.png", tile_size, tile_size, "None", false, false); + animation.block[WalkDirection::UP] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Blocking/Up.png", tile_size, tile_size, "None", false, false); + + animation.drinking_river[WalkDirection::DOWN] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Down-Sheet.png", tile_size, tile_size, "character.drink", false, false); + animation.drinking_river[WalkDirection::SIDE] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Side-Sheet.png", tile_size, tile_size, "character.drink", false, false); + animation.drinking_river[WalkDirection::UP] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Up-Sheet.png", tile_size, tile_size, "character.drink", false, false); + + animation.eating[WalkDirection::DOWN] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Down-Sheet.png", tile_size, tile_size, "character.eat", false, false); + animation.eating[WalkDirection::SIDE] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Side-Sheet.png", tile_size, tile_size, "character.eat", false, false); + animation.eating[WalkDirection::UP] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Up-Sheet.png", tile_size, tile_size, "character.eat", false, false); + + Animation::audio->RegisterSound("character.dead", "music/character.dead.wav"); + + handle_Animation(); + + set_Status(CharacterStatus::IDLE); + + + // Init message + messages->Add(MessageKey::MOIN); +} + +void Character::set_Status(const CharacterStatus& s) { + if (status != s && status != CharacterStatus::DYING && active_anim && active_anim->has_audio) + Animation::audio->Stop(active_anim->audio_name.c_str()); + status = s; + active_anim->timer = 0; + if (s != CharacterStatus::DEAD) + active_anim->current_frame = 0; + Animation::animation_frame_time = active_anim->frame_time; +} + + +void +Character::draw_CircleProgress(SDL_Renderer* renderer, int cx, int cy, int radius, float progress, + Uint8 color_r, Uint8 color_g, Uint8 color_b, Uint8 color_a) { + if (progress < 0.0f) progress = 0.0f; + if (progress > 1.0f) progress = 1.0f; + + int segments = 200; + float angle_step = 2.0f * M_PI / segments; + int filled_segments = static_cast<int>(segments * progress); + + SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); + SDL_SetRenderDrawColor(renderer, color_r, color_g, color_b, color_a); + + float offset_x = Scale(Map::offset.x); + float offset_y = Scale(Map::offset.y); + + for (int i = 0; i < filled_segments; ++i) { + float angle1 = i * angle_step; + + int x1 = cx + static_cast<int>(radius * std::cos(angle1)); + int y1 = cy + static_cast<int>(radius * std::sin(angle1)); + + SDL_RenderLine(renderer, cx+offset_x, cy+offset_y, x1+offset_x, y1+offset_y); + } + + SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); + SDL_SetRenderDrawColor(renderer, 16,47,144, 210); + const int circle_segments = 100; + for (int i = 0; i < circle_segments; ++i) { + float angle1 = i * 2.0f * M_PI / circle_segments; + float angle2 = (i + 1) * 2.0f * M_PI / circle_segments; + int x1 = cx + static_cast<int>(radius * std::cos(angle1)); + int y1 = cy + static_cast<int>(radius * std::sin(angle1)); + int x2 = cx + static_cast<int>(radius * std::cos(angle2)); + int y2 = cy + static_cast<int>(radius * std::sin(angle2)); + SDL_RenderLine(renderer, x1+offset_x, y1+offset_y, x2+offset_x, y2+offset_y); + } +} + +void +Character::draw_HorizontalProgress(SDL_Renderer* renderer, float progress, + Uint8 fill_r, Uint8 fill_g, Uint8 fill_b, Uint8 fill_a, + Uint8 bg_r, Uint8 bg_g, Uint8 bg_b, Uint8 bg_a) { + float width = Scale(20); // horizontal bar width + float height = Scale(2); // bar thickness + float x = Scale(collider_world.x + Map::offset.x) - width/2; + float y = Scale(collider_world.y - collider.y*0.75 + Map::offset.y); // slightly above character + + if (progress < 0.0f) progress = 0.0f; + if (progress > 1.0f) progress = 1.0f; + + SDL_FRect bg_rect = { x, y, width, height }; + SDL_FRect fill_rect = { x, y, width * progress, height }; + + SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); + + // Draw background + SDL_SetRenderDrawColor(renderer, bg_r, bg_g, bg_b, bg_a); + SDL_RenderFillRect(renderer, &bg_rect); + + // Draw filled portion + SDL_SetRenderDrawColor(renderer, fill_r, fill_g, fill_b, fill_a); + SDL_RenderFillRect(renderer, &fill_rect); +} + +void +Character::Draw(SDL_Renderer* renderer) { +#ifdef DEBUG_BUILD + // DEBUG CHARACTER RECTANGLE + SDL_SetRenderDrawColor(renderer, 255, 255,255, 255); + SDL_FRect debug_rect_1 { + Scale(x+Map::offset.x), + Scale(y+Map::offset.y), + Scale(64), + Scale(64) + }; + SDL_RenderRect(renderer, &debug_rect_1); + + // DEBUG Arm Range + SDL_SetRenderDrawColor(renderer, 0, 255, 0, 100); + for (float angle = 0; angle < 2 * M_PI; angle += 0.1f) { + float px = collider_world.x + cosf(angle) * arm_reach_radius + Map::offset.x; + float py = collider_world.y + sinf(angle) * arm_reach_radius + Map::offset.y; + SDL_RenderPoint(renderer, (int)Scale(px), (int)Scale(py)); + } + + // DEBUG Tiles in reach + SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); + SDL_SetRenderDrawColor(renderer, 0, 255, 0, 80); + + for (const auto& t : tiles_in_reach) { + SDL_FRect tile_rect = { + Scale(t.x * Tile::tile_size + Map::offset.x), + Scale(t.y * Tile::tile_size + Map::offset.y), + Scale(Tile::tile_size), + Scale(Tile::tile_size) + }; + + SDL_RenderFillRect(renderer, &tile_rect); + } + + // DEBUG COLLIDER + SDL_FRect debug_rect { + Scale((x + collider.x) + Map::offset.x), + Scale((y + collider.y) + Map::offset.y), + Scale(collider.w), + Scale(collider.h) + }; + SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255); + SDL_RenderFillRect(renderer, &debug_rect); +#endif + + if ( is_placing_build ) { + BuildingData::draw_SelectedWorkbenchAt(renderer); + } + // Render Placinf Soil + + if (selected_item->object_type == InventoryObjectType::ITEM) { + InventoryItem *it = static_cast<InventoryItem*>(selected_item); + if (it->type == ItemType::CULTIVATOR) { + if (cultivation_logic.is_removing) + Farm::soil_RenderRemove(renderer, {static_cast<float>(tile_world.x*Tile::tile_size) + Map::offset.x, static_cast<float>(tile_world.y*Tile::tile_size) + Map::offset.y}); + else + Farm::soil_Render(renderer, {static_cast<float>(tile_world.x*Tile::tile_size) + Map::offset.x, static_cast<float>(tile_world.y*Tile::tile_size) + Map::offset.y}, {0,0}, 140); + } + } + + // Render Character + const SDL_FRect& src = active_anim->frames[active_anim->current_frame]; + + SDL_FRect dst { + Scale(x + Map::offset.x), + Scale(y + Map::offset.y), + Scale(src.w), + Scale(src.h) + }; + + SDL_Texture* txt = active_anim->texture; + + if (status == CharacterStatus::DEAD && death_shuffler) + txt = SDL_CreateTextureFromSurface(renderer, death_shuffler->getSurface()); + + SDL_RenderTextureRotated(renderer, txt, &src, &dst, + 0.0, nullptr, + flip ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE); + if (collecting_logic.is_collecting) { + float collecting_progress = collecting_logic.duration / collecting_logic.duration_max; + Character::draw_HorizontalProgress(renderer, collecting_progress); + } + + + // START DEBUG Weapon rect +#ifdef DEBUG_BUILD + SDL_FRect weaponrect; + + const float weapon_w = 30.0f; + const float weapon_h = 16.0f; + + float cx = collider_world.x; + float cy = collider_world.y; + + switch (direction) { + case WalkDirection::LEFT: + weaponrect = { Scale(cx - weapon_w + Map::offset.x), Scale(cy - weapon_w*0.5 + Map::offset.y), Scale(weapon_w), Scale(weapon_h) }; + break; + + case WalkDirection::RIGHT: + weaponrect = { Scale(cx + Map::offset.x), Scale(cy - weapon_w*0.5 + Map::offset.y), Scale(weapon_w), Scale(weapon_h)}; + break; + + case WalkDirection::UP: + weaponrect = { Scale(cx - weapon_h*0.5 + Map::offset.x), Scale(cy - weapon_w + Map::offset.y), Scale(weapon_h), Scale(weapon_w)}; + break; + + case WalkDirection::DOWN: + weaponrect = { Scale(cx - weapon_h*0.5 + Map::offset.x), Scale(cy + Map::offset.y), Scale(weapon_h), Scale(weapon_w) }; + break; + default: + break; + } + SDL_SetRenderDrawColor(renderer, 255, 0, 0, 140); + SDL_RenderFillRect(renderer, &weaponrect); + // END DEBUG Weapon rect +#endif + + + + // Draw character messages + const float row_h = 14.0f; + float center_x = x + (src.w * 0.5f); + float start_y = y - row_h - 2.0f; + messages->Render(renderer, center_x, start_y); +} + +/* +bool +Character::is_CollidingWithObjects(const SDL_FRect& rect) { + const size_t scale = Tile::tile_size / Tile::tile_collider_size; + + // convert rectangle to collider coordinates + int start_cx = static_cast<int>(std::floor(rect.x / float(Tile::tile_collider_size))); + int end_cx = static_cast<int>(std::ceil((rect.x + rect.w) / float(Tile::tile_collider_size))); + int start_cy = static_cast<int>(std::floor(rect.y / float(Tile::tile_collider_size))); + int end_cy = static_cast<int>(std::ceil((rect.y + rect.h) / float(Tile::tile_collider_size))); + + // loop over tiles overlapped by rectangle in tile units + size_t tile_start_x = static_cast<size_t>(rect.x / Tile::tile_size); + size_t tile_end_x = static_cast<size_t>((rect.x + rect.w) / Tile::tile_size); + size_t tile_start_y = static_cast<size_t>(rect.y / Tile::tile_size); + size_t tile_end_y = static_cast<size_t>((rect.y + rect.h) / Tile::tile_size); + + for (size_t ty = tile_start_y; ty <= tile_end_y && ty < Map::size.y; ++ty) { + for (size_t tx = tile_start_x; tx <= tile_end_x && tx < Map::size.x; ++tx) { + size_t map_index = ty * Map::size.x + tx; + TileMap& tilemap = Map::tile_map[map_index]; + + for (const TileObject& obj : tilemap.objects) { + Object* object = Object::get_ObjectById(obj.object_id); + std::vector<bool> collision_map = object->get_CollisionMap(); + int obj_abs_x = static_cast<int>(tx) - obj.position.x; + int obj_abs_y = static_cast<int>(ty) - obj.position.y; + + int obj_cx = obj_abs_x * static_cast<int>(scale); + int obj_cy = obj_abs_y * static_cast<int>(scale); + size_t obj_cw = static_cast<size_t>(object->dimension.x) * scale; + size_t obj_ch = static_cast<size_t>(object->dimension.y) * scale; + + for (int cy = start_cy; cy < end_cy; ++cy) { + for (int cx = start_cx; cx < end_cx; ++cx) { + int rel_x = cx - obj_cx; + int rel_y = cy - obj_cy; + + if (rel_x < 0 || rel_y < 0 || static_cast<size_t>(rel_x) >= obj_cw || static_cast<size_t>(rel_y) >= obj_ch) + continue; + + size_t obj_index = static_cast<size_t>(rel_y) * obj_cw + static_cast<size_t>(rel_x); + bool cell_value = obj_index < collision_map.size() ? collision_map[obj_index] : false; + + if (cell_value) + return true; + } + } + + } + } + } + return false; +} + +*/ + +/* +bool +Character::is_Colliding(const SDL_FRect& rect) { + const int max_cells_x = static_cast<int>(Map::size.x * (Tile::tile_size / Tile::tile_collider_size)); + const int max_cells_y = static_cast<int>(Map::size.y * (Tile::tile_size / Tile::tile_collider_size)); + + const float corners[4][2] = { + { rect.x, rect.y }, + { rect.x + rect.w, rect.y }, + { rect.x, rect.y + rect.h }, + { rect.x + rect.w, rect.y + rect.h } + }; + + for (int i = 0; i < 4; ++i) { + const int cell_x = static_cast<int>(corners[i][0] / Tile::tile_collider_size); + const int cell_y = static_cast<int>(corners[i][1] / Tile::tile_collider_size); + + if (cell_x < 0 || cell_y < 0 || cell_x >= max_cells_x || cell_y >= max_cells_y) + return true; + + const size_t index = static_cast<size_t>(cell_y) * static_cast<size_t>(max_cells_x) + + static_cast<size_t>(cell_x); + + if (Map::tile_collission_map[index]) + return true; + } + + return false; + //return is_CollidingWithObjects(rect); +} +*/ + + + +TileObject* +Character::find_ClosestObject(SDL_Point* tile_found, ObjectCategory category) { + for (const SDL_Point& tile_point : tiles_in_reach) { + auto& objects = Map::get_ObjectsFromMapTile(tile_point); + for (auto& object : objects) { + Object* o = Object::get_ObjectById(object.object_id); + collecting_logic.tile_point = tile_point; + // find collectable or building + InventoryItem *it = nullptr; + // Why should this happen? + // if (selected_item->object_type != InventoryObjectType::NONE) { + it = static_cast<InventoryItem*>(selected_item); + // } + if ( (category == ObjectCategory::NONE && o->category != ObjectCategory::STATIC)) { + // THATS MIXING SHT + if ( (o->category == ObjectCategory::RESOURCE && it && + (static_cast<Resource*>(o)->is_Collectable(it->type))) + || o->category == ObjectCategory::BUILDING) { + *tile_found = tile_point; + return &object; + } else + if (o->category == ObjectCategory::FARM_CROP) { + Vegetable* veg = static_cast<Vegetable*>(o); + if (veg->is_Collectable()) + return &object; + } else { + } + } else + if ( category == o->category ) { + if ( o->category == ObjectCategory::BUILDING ) { + *tile_found = tile_point; + return &object; + } + if ( o->category == ObjectCategory::RESOURCE && it && + static_cast<Resource*>(o)->is_Collectable(it->type)) { + *tile_found = tile_point; + return &object; + } + } + } + } + return nullptr; +} + +void +Character::collect_Start(TileObject* map_object_p) { + + if (!map_object_p) { + std::cout << "No item!\n"; + collecting_logic.is_collecting = false; + return; + } + //Tile::print_TileObject(*map_object_p); + Object* object = Object::get_ObjectById(map_object_p->object_id); + + set_Status(CharacterStatus::COLLECT); + std::cout << "stat: " << (int)status << std::endl; + + collecting_logic.duration = 0; + collecting_logic.object = map_object_p; + std::cout << "Item found!\n"; + if (!map_object_p || (object->category != ObjectCategory::RESOURCE && + object->category != ObjectCategory::FARM_CROP)) { + std::cout << "Invalid object: " << (int)object->category << std::endl; + collect_Stop(); + return; + } + + std::cout << "CH " << collider_world.x << " " << collider_world.y << std::endl; + std::cout << "OB " << (object->world_tile_position.x+object->dimension.x/2)*16 << " " << (object->world_tile_position.y+object->dimension.y)*16-8 << std::endl; + collecting_logic.duration_max = 3; + // COLLECT RESOURCE + if (object->object_type != ObjectType::VEGETABLE) { + collecting_logic.resource = Tile::get_ResourceFromTileSet(object->tileset_id, object->tileset_object_id); + collecting_logic.duration_max = collecting_logic.resource.collecting_duration; + } else { + // COLLECT VEGETABLE + collecting_logic.duration_max = static_cast<Vegetable*>(object)->collecting_duration_max; + } + collecting_logic.is_collecting = true; + + float obj_x = (object->world_tile_position.x + object->dimension.x * 0.5f) * 16.0f; + float obj_y = (object->world_tile_position.y + object->dimension.y) * 16.0f - 8.0f; + + float dx = obj_x - collider_world.x; + float dy = obj_y - collider_world.y; + + float angle = std::atan2(dy, dx); + + const float pi = 3.14159265358979323846f; + const float quarter = pi * 0.25f; + const float three_quarter = pi * 0.75f; + + if (angle >= -quarter && angle < quarter) { + direction = WalkDirection::RIGHT; + flip = false; + } + else if (angle >= quarter && angle < three_quarter) { + direction = WalkDirection::DOWN; + flip = false; + } + else if (angle >= -three_quarter && angle < -quarter) { + direction = WalkDirection::UP; + flip = false; + } + else { + direction = WalkDirection::LEFT; + flip = true; + } + + float cl = collecting_logic.duration_max/2; + if (collecting_logic.duration_max > 3) + cl /= 2; + Animation::animation_frame_time = cl / active_anim->frames.size(); + handle_Animation(); +} + +void +Character::collect_Object() { + collecting_logic.duration += Default::delta_time; + if (collecting_logic.duration >= collecting_logic.duration_max) { + std::cout << "Collected item!\n"; + // Remove object from MapTileObject s + + Object* object = Object::get_ObjectById(collecting_logic.object->object_id); + if (object->object_type == ObjectType::VEGETABLE) { + Vegetable* v = static_cast<Vegetable*>(object); + if (v->is_Rotten()) { + inventory->add_Seed(v->type, inventory->get_Seed(v->type) == 0 ? 1 : (rand() % 3 == 1 ? 1 : 0), messages.get()); + } else if (v->is_seed) + inventory->add_Seed(v->type, v->quantity, messages.get()); + else + inventory->add_Vegetable(v->type, v->quantity, messages.get()); + + set_VegetableDiscovery(v->type); + + } else { + inventory->add_Resource(collecting_logic.resource.resource, static_cast<int>(collecting_logic.resource.quantity), messages.get()); + set_ResourceDiscovery(collecting_logic.resource.resource); + } + /* + resources[collecting_logic.resource.resource] += collecting_logic.resource.quantity; + */ + + if (object->object_type == ObjectType::VEGETABLE) { + static_cast<Vegetable*>(object)->pick_Up(); + } else { + TileObject* to = collecting_logic.object; + Object::Remove(Object::get_ObjectById(to->object_id)); + } + collect_Stop(); + } +} + +void +Character::collect_Stop() { + collecting_logic.duration = 0.0; + collecting_logic.object = nullptr; + collecting_logic.is_collecting = false; + collecting_logic.resource = {}; + set_Status(CharacterStatus::IDLE); + std::cout << "Collecting stopped!\n"; +} + + +float +Character::get_SprintStartFactor() const { + if (!sprintstart_logic.is_starting) + return 1.0f; + + double now = Default::get_TimeSinceStartInSec(); + double elapsed = now - sprintstart_logic.started_gamesec; + + if (elapsed <= 0.0) + return 0.0f; + + double t = elapsed / sprintstart_logic.starting_duration; + + if (t >= 1.0) + return 1.0f; + + return static_cast<float>(t); +} + + + + +bool +Character::build_Start() { + SDL_Point tile_point; + TileObject* map_object_p = find_ClosestObject(&tile_point, ObjectCategory::BUILDING); + + if (!map_object_p) { + // std::cout << "No building found!\n"; + return false; + } + //Tile::print_TileObject(*map_object_p); + Building* building = Building::get_BuildingById(map_object_p->object_id); + + if (status != CharacterStatus::BUILD) { + set_Status(CharacterStatus::BUILD); + } + + if (Building::construction_mode == BuildingStatus::CONSTRUCTING) { + if (!building->Build(inventory.get())) return false; + } else + if (Building::construction_mode == BuildingStatus::DECONSTRUCT){ + building->building_status = BuildingStatus::DECONSTRUCT; + if (building->Deconstruct(inventory.get())) { + Object::Remove(building); + return false; + } + } + + // SET ANIMATION DIRECTION + float dx = (tile_point.x * Tile::tile_size + Tile::tile_size * 0.5f) + - (collider_world.x + collider.w * 0.5f); + + float dy = (tile_point.y * Tile::tile_size + Tile::tile_size * 0.5f) + - (collider_world.y + collider.h * 0.5f); + + // Horizontal dominates + if (std::fabs(dx) > std::fabs(dy)) { + if (dx < 0) + direction = WalkDirection::LEFT; + else + direction = WalkDirection::RIGHT; + flip = (dx < 0); + } + // Vertical dominates + else { + if (dy > 0) + direction = WalkDirection::DOWN; + else + direction = WalkDirection::UP; + flip = false; + } + return true; +} + + +inline void setActiveMenu(CharacterMenuType& active_menu, const CharacterMenuType& new_menu, AnimatedCursor* cursor) { + switch (active_menu) { + case CharacterMenuType::NONE: + active_menu = new_menu; + cursor->set_State(CursorState::ANIMATED); + break; + default: + active_menu = CharacterMenuType::NONE; + cursor->set_State(CursorState::HIDDEN); + break; + } +} + +void +Character::interact_WithBuilding(Building* building, Input& input) { + if (active_menu == CharacterMenuType::WORKBENCH) { + building->close_Menu(); + setActiveMenu(active_menu, CharacterMenuType::NONE, input.cursor); + } else + if (building->has_Menu()) { + std::cout << "INTERACT OPEN" << std::endl; + CharacterMenuType type = building->open_Menu(this); + if (type != CharacterMenuType::NONE) + setActiveMenu(active_menu, type, input.cursor); + } +} + + +bool +Character::is_StatsBonusAlready(InventoryObjectType object_type, uint32_t type) { + for (CharacterStatsBonus& b : stats_bonus) + if (b.object_type == object_type && b.type == type) + return true; + + return false; +} + +void +Character::add_ToStatsBonus(InventoryObjectType object_type, + uint32_t type, + ConsumingStatsBonus sb) { + for (auto& entry : stats_bonus) { + if (entry.object_type == object_type && + entry.type == type) + { + entry.stats = sb; + entry.duration = sb.duration; + health_Increase(sb.health); + stamina_Increase(sb.stamina); + std::cout << "ADD STATS " << (int)type << std::endl; + return; + } + } + + if (stats_bonus.size() >= 2) { + std::cout << "I am overfed\n"; + return; + } + + stats_bonus.push_back({object_type, type, sb.duration, sb}); +} + +void +Character::reduce_StatsBonus() { + for (auto it = stats_bonus.begin(); it != stats_bonus.end(); ) + { + float total_duration = it->stats.duration; + if (total_duration <= 0.0f) + { + it = stats_bonus.erase(it); + continue; + } + + float previous_ratio = it->duration / total_duration; + + it->duration -= Default::delta_time; + if (it->duration < 0.0f) + it->duration = 0.0f; + + float new_ratio = it->duration / total_duration; + + float scale = (previous_ratio > 0.0f) + ? (new_ratio / previous_ratio) + : 0.0f; + + float oh = it->stats.health; + float os = it->stats.stamina; + it->stats.health *= scale; + it->stats.stamina *= scale; + it->stats.thirst *= scale; + it->stats.demage *= scale; + + stats.health_reduced -= (oh - it->stats.health); + if (stats.health_reduced <= 0.0f) + stats.health_reduced = 0.0f; + + stats.stamina_reduced -= (os - it->stats.stamina); + if (stats.stamina_reduced <= 0.0f) + stats.stamina_reduced = 0.0f; + + if (it->duration <= 0.0f) + it = stats_bonus.erase(it); + else + ++it; + } +} + +void +Character::attack_Start() { + std::cout << "Attack Start\n"; + InventoryItem *it = nullptr; + if (selected_item->object_type == InventoryObjectType::ITEM) { + it = static_cast<InventoryItem*>(selected_item); + } + if (!it) return; + set_Status(CharacterStatus::ATTACK); + handle_Animation(); + attacking_logic.duration = 0.0; + attacking_logic.item = it; + attacking_logic.has_attacked = false; + attacking_logic.is_attacking = AttackingLogicStatus_e::ATTACKING; + + //Animation::animation_frame_time = attacking_logic.item->speed / static_cast<float>(active_anim->frames.size()); +} + +void +Character::attack_Enemy() { + attacking_logic.duration += Default::delta_time; + + // just hit at the end of the hit + if (attacking_logic.duration >= attacking_logic.item->speed) { + attack_Stop(); + return; + } + if ( attacking_logic.has_attacked || + attacking_logic.duration < attacking_logic.item->speed*0.5) + return; + + std::cout << "Attack Enemy!!\n"; + + // check if weapnon is in enemy range + SDL_FRect weaponrect; + + const float weapon_w = 30.0f; + const float weapon_h = 16.0f; + + float cx = collider_world.x; + float cy = collider_world.y; + + switch (direction) { + case WalkDirection::LEFT: + weaponrect = { cx - weapon_w, cy - weapon_w*0.5f, weapon_w, weapon_h }; + break; + + case WalkDirection::RIGHT: + weaponrect = { cx, cy - weapon_w*0.5f, weapon_w, weapon_h }; + break; + + case WalkDirection::UP: + weaponrect = { cx - weapon_h*0.5f, cy - weapon_w, weapon_h, weapon_w }; + break; + + case WalkDirection::DOWN: + weaponrect = { cx - weapon_h*0.5f, cy, weapon_h, weapon_w }; + break; + default: + break; + } + + Enemy* enemy = Enemy::is_InEnemyReach(weaponrect); + + if (enemy && enemy->stats.health > 0) + enemy->getting_Hit(damage_Get()); + + attacking_logic.has_attacked = true; +} +void +Character::attack_Stop() { + std::cout << "Attack stopped.\n"; + attacking_logic.duration = 0.0; + attacking_logic.is_attacking = AttackingLogicStatus_e::NONE; + attacking_logic.item = nullptr; + attacking_logic.enemy = nullptr; + attacking_logic.has_attacked = false; + set_Status(CharacterStatus::IDLE); +} + +void +Character::block_Start() { + std::cout << "Block Start\n"; + InventoryItem *it = nullptr; + if (selected_item->object_type == InventoryObjectType::ITEM) { + it = static_cast<InventoryItem*>(selected_item); + } + if (!it) return; + set_Status(CharacterStatus::BLOCK); + handle_Animation(); + + attacking_logic.duration = 0.0; + attacking_logic.item = it; + attacking_logic.is_attacking = AttackingLogicStatus_e::BLOCKING_RUNNING; + + Animation::animation_frame_time = attacking_logic.item->speed / static_cast<float>(active_anim->frames.size()); +} + +void +Character::block_Enemy() { + if (attacking_logic.duration <= attacking_logic.item->speed/2) + attacking_logic.duration += Default::delta_time; + else { + attacking_logic.is_attacking = AttackingLogicStatus_e::BLOCKING_RUNNING; + attacking_logic.duration = attacking_logic.item->speed/2; + active_anim->current_frame = active_anim->frames.size()/2-1; + } + + return; +} + +void +Character::block_Stop() { + if (attacking_logic.duration < attacking_logic.item->speed) { + attacking_logic.duration += Default::delta_time; + return; + } + attacking_logic.duration = 0.0; + attacking_logic.is_attacking = AttackingLogicStatus_e::NONE; + attacking_logic.enemy = nullptr; + set_Status(CharacterStatus::IDLE); + return; +} + +void +Character::building_Stop() { + BuildingData::active_build.type = BuildingType::NONE; + BuildingData::active_build.data = nullptr; + is_placing_build = false; +} + + +void +Character::eat_Start() { + std::cout << "Eating Start\n"; + if ( stats_bonus.size() >= 2 && + !is_StatsBonusAlready(selected_item->object_type, static_cast<uint32_t>(static_cast<InventoryVegetable*>(selected_item)->type))) + return; + + messages->Add(MessageKey::EAT_APPRECIATION); + set_Status(CharacterStatus::EATING); + handle_Animation(); + consuming_logic.duration = 0.0; + consuming_logic.duration_max = 3.0f; + consuming_logic.is_consuming = true; + consuming_logic.is_drinking = false; +} + +void +Character::eat_Something() { + // std::cout << "Eating ...\n"; + if (consuming_logic.duration < consuming_logic.duration_max) { + consuming_logic.duration += Default::delta_time; + float stamina_per_second = 0.01f / consuming_logic.duration_max; + stamina_Reduce(stamina_per_second); + if (stamina_Get() <= 0) { + stamina_StopReg(); + messages->Add(MessageKey::PLAYER_EXHAUSTED); + consume_Stop(); + } + return; + } + + std::cout << "EATING COMPLETE\n"; + //InventoryVegetable + if (selected_item->object_type == InventoryObjectType::VEGETABLE) { + InventoryVegetable* it = static_cast<InventoryVegetable*>(selected_item); + add_ToStatsBonus(InventoryObjectType::VEGETABLE, static_cast<uint32_t>(it->type), it->stats_bonus); + if (inventory->remove_Vegetable(it->type, 1) == 0) { + bool setted_hotbar = inventory->set_HotbarItem(Inventory::selected_hotbar, Inventory::hotbar_hands); + if (setted_hotbar) + inventory->Equip(Inventory::hotbar_hands); + selected_item = inventory->get_SelectedHotbarItem(); + } + } + + consume_Stop(); +} + +void +Character::drink_Start() { + std::cout << "Drinking Start\n"; + messages->Add(MessageKey::WATER_APPRECIATION); + if (stats.thirst >= stats.thirst_max) + return; + set_Status(CharacterStatus::DRINK_RIVER); + handle_Animation(); + consuming_logic.duration = 0.0; + consuming_logic.is_consuming = true; + consuming_logic.is_drinking = true; +} + +void +Character::drink_River() { + // std::cout << "Drinking ...\n"; + if (consuming_logic.duration < consuming_logic.duration_max) { + if (stamina_Get() <= 0 || stats.thirst >= stats.thirst_max) { + consume_Stop(); + return; + } + consuming_logic.duration += Default::delta_time; + float amount_per_second = 25.0f / consuming_logic.duration_max; + stats.thirst += amount_per_second * Default::delta_time; + float stamina_per_second = 0.01f / consuming_logic.duration_max; + stamina_Reduce(stamina_per_second); + if (stamina_Get() <= 0) { + stamina_StopReg(); + messages->Add(MessageKey::PLAYER_EXHAUSTED); + } + return; + } + + if (stats.thirst > stats.thirst_max) + stats.thirst = stats.thirst_max; + + health_Increase(2); + + consume_Stop(); +} +void +Character::consume_Stop() { + std::cout << "Consuming Stopped\n"; + consuming_logic.duration = 0.0; + consuming_logic.is_consuming = false; + set_Status(CharacterStatus::IDLE); +} + +void +Character::cultivate_Start() { + std::cout << "Cultivate Start\n"; + TileTypeFloors floor_type = Tile::get_FloorType(Map::tile_map[Map::get_IdFromTilePoint(tile_world)].background); + std::cout << "FT: " << floor_type << " " << Map::get_IdFromTilePoint(tile_world) << std::endl; + if (!Tile::floor_props[floor_type].can_buid_on) + return; + if (stamina_Get() <= 0) + return; + + if ( Farm::soil_IsMaptile(tile_world) && + !cultivation_logic.is_removing) + return; + cultivate_Stop(); + set_Status(CharacterStatus::CULTIVATING); + handle_Animation(); + cultivation_logic.is_cultivating = true; + + cultivation_logic.tile_world = tile_world; +} +void +Character::cultivate_Soil() { + if (stamina_Get() <= 0) { + cultivate_Stop(); + return; + } + cultivation_logic.duration += Default::delta_time; + + float stamina_per_second = 0.06f / cultivation_logic.duration_max; + stamina_Reduce(stamina_per_second); + if (stamina_Get() <= 0) { + stamina_StopReg(); + messages->Add(MessageKey::PLAYER_EXHAUSTED); + cultivate_Stop(); + } + + if (cultivation_logic.duration >= cultivation_logic.duration_max) { + if (!cultivation_logic.is_removing) + Farm::soil_Place(cultivation_logic.tile_world); + else + Farm::soil_Remove(cultivation_logic.tile_world); + cultivate_Stop(); + } +} +void +Character::cultivate_Stop() { + cultivation_logic.duration = 0.0; + cultivation_logic.is_cultivating = false; + cultivation_logic.tile_world = {0,0}; + set_Status(CharacterStatus::IDLE); +} + +bool +Character::plant_Start() { + std::cout << "Plant Start\n"; + if (stamina_Get() <= 0) + return false; + if (!Farm::soil_IsMaptile(tile_world)) + return false; + if (Map::tile_map[static_cast<size_t>(Map::get_IdFromTilePoint(tile_world))].objects.size() > 0) { + std::cout << "SIZE:: " << Map::tile_map[static_cast<size_t>(Map::get_IdFromTilePoint(tile_world))].objects.size() << std::endl; + return false; + } + + set_Status(CharacterStatus::PLANTING); + handle_Animation(); + + planting_logic.is_planting = true; + planting_logic.tile_world = tile_world; + planting_logic.type = static_cast<InventoryVegetable*>(selected_item)->type; + planting_logic.is_seed = !static_cast<InventoryVegetable*>(selected_item)->is_seed; + return true; +} + +void +Character::plant_Vegetable() { + if (stamina_Get() <= 0) { + plant_Stop(); + return; + } + planting_logic.duration += Default::delta_time; + + float stamina_per_second = 0.06f / planting_logic.duration_max; + stamina_Reduce(stamina_per_second); + if (stamina_Get() <= 0) { + stamina_StopReg(); + messages->Add(MessageKey::PLAYER_EXHAUSTED); + plant_Stop(); + } + + if (planting_logic.duration >= planting_logic.duration_max) { + Vegetable* v = new Vegetable(planting_logic.type, planting_logic.tile_world, planting_logic.is_seed); + TileObject to = {{0,0}, true, v->id}; + size_t id = Map::get_IdFromTilePoint(planting_logic.tile_world); + Map::tile_map[id].objects.push_back(to); + if (!planting_logic.is_seed) // YES thats reversed! + inventory->remove_Seed(planting_logic.type, 1); + else + inventory->remove_Vegetable(planting_logic.type, 1); + + selected_item = inventory->get_SelectedHotbarItem(); + + plant_Stop(); + } +} + +void +Character::plant_Stop() { + std::cout << "Plant Stop\n"; + + planting_logic.duration = 0.0; + planting_logic.is_planting = false; + planting_logic.tile_world = {0,0}; + set_Status(CharacterStatus::IDLE); +} + + +float +Character::health_Get() { + return health_Max() - stats.health_reduced; +} +float +Character::health_Max() { + return stats.health_max + health_MaxBonus(); +} +float +Character::health_MaxBonus() { + float h = 0.0f; + for (auto& e : stats_bonus) { + h += e.stats.health; + } + return h; +} +void +Character::health_Reduce(float amount) { + stats.health_reduced += amount; +} +void +Character::health_Increase(float amount) { + stats.health_reduced -= amount; + if (stats.health_reduced < 0.0f) + stats.health_reduced = 0.0; +} + +float +Character::stamina_Get() { + return stamina_Max() - stats.stamina_reduced; +} +float +Character::stamina_Max() { + return stats.stamina_max + stamina_MaxBonus(); +} +float +Character::stamina_MaxBonus() { + float s = 0.0f; + for (auto& e : stats_bonus) { + s += e.stats.stamina; + } + return s; +} +void +Character::stamina_Reduce(float amount) { + stats.stamina_reduced += amount; +} +void +Character::stamina_Increase(float amount) { + stats.stamina_reduced -= amount; + if (stats.stamina_reduced < 0.0f) + stats.stamina_reduced = 0.0; +} + +void +Character::stamina_StartReg() { + if (stamina_Get() >= stamina_Max()) + return; + + if (!stamina_regen_logic.is_regenerating) { + stamina_regen_logic.delay_is += Default::delta_time; + if (stamina_regen_logic.delay_is >= stamina_regen_logic.delay_max) + stamina_regen_logic.is_regenerating = true; + } else { + float amount_per_second = stamina_regen_logic.regen_speed / 1; + if (status == CharacterStatus::WALK) { + amount_per_second *= 0.5; + } + stamina_Increase(amount_per_second * Default::delta_time); + if (stamina_Get() >= stamina_Max()) + stamina_StopReg(); + + } +} + +void +Character::stamina_StopReg() { + stamina_regen_logic.is_regenerating = false; + stamina_regen_logic.delay_is = 0; +} + +float +Character::damage_Get() { + if (!using_Weapon()) + return 0.0f; + std::cout << "DAMA " << static_cast<InventoryItem*>(selected_item)->damage << std::endl; + return static_cast<InventoryItem*>(selected_item)->damage; +} + + +void +Character::thirst_Drain() { + if (consuming_logic.is_consuming) + return; + + if (stats.thirst <= 0) { + float amount_per_second = 1; + health_Reduce(amount_per_second * Default::delta_time); + return; + } else { + thirst_drain_logic.send_message_0 = false; + } + + if (!thirst_drain_logic.send_message_20 && stats.thirst <= 2*stats.thirst_max/10) { + thirst_drain_logic.send_message_20 = true; + messages->Add(MessageKey::THIRST_20); + } else if (stats.thirst > 2*stats.thirst_max/10) { + thirst_drain_logic.send_message_20 = false; + } + + float amount_per_second = thirst_drain_logic.drain_speed / 1; + stats.thirst -= amount_per_second * Default::delta_time; + if (stats.thirst <= 0) { + stats.thirst = 0; + if (!thirst_drain_logic.send_message_0) { + thirst_drain_logic.send_message_0 = true; + messages->Add(MessageKey::THIRST_0); + } + } + +} + + +void +Character::getting_Hit(float demage) { + float block_staming = 2; + if (attacking_logic.is_attacking == AttackingLogicStatus_e::NONE) + set_Status(CharacterStatus::HIT); + collecting_logic.is_collecting = false; + if ((attacking_logic.is_attacking == AttackingLogicStatus_e::BLOCKING_RUNNING && stamina_Get() >= block_staming)) + stamina_Reduce(block_staming); + else + health_Reduce(demage); + + std::cout << "Char: Getting hit! " << std::endl; +} + +void +Character::death() { + if (status == CharacterStatus::DEAD) { + if (death_shuffler) + Resurrect(); + return; + } + death_duration += Default::delta_time; + if (death_duration > death_duration_max) { + if (status != CharacterStatus::DEAD) { + set_Status(CharacterStatus::DEAD); + } + } else { + if (status != CharacterStatus::DYING) + set_Status(CharacterStatus::DYING); + } +} + + +void +Character::Resurrect() { + if (status != CharacterStatus::DEAD || !death_shuffler) { + return; + } + + shuffle_timer += Default::delta_time; + + constexpr float SHUFFLE_START_TIME = 1.6f; + constexpr float MOVE_START_TIME = 2.1f; + constexpr float UNSHUFFLE_TIME = 1.4f; + constexpr float FRAME_REDUCE_TIME = 0.8f; + constexpr float MAX_DST = 32.0f; + + auto distance = [](const SDL_FPoint& a, const SDL_FPoint& b) { + float dx = a.x - b.x; + float dy = a.y - b.y; + return SDL_sqrtf(dx * dx + dy * dy); + }; + + float TICK_INTERVAL = 0.04f; + if (resurrect_phase > 0 && distance(collider_world, spawn_point) < MAX_DST) { + TICK_INTERVAL = 0.02f; + } + + static float tick_accumulator = 0.0f; + tick_accumulator += Default::delta_time; + bool tick = false; + if (tick_accumulator >= TICK_INTERVAL) { + tick_accumulator -= TICK_INTERVAL; + tick = true; + } + + /* ---------------- PHASE 0: INITIAL DELAY ---------------- */ + if (resurrect_phase == 0) { + if (shuffle_timer >= SHUFFLE_START_TIME) { + resurrect_phase = 1; + } + return; + } + + /* ---------------- PHASE 1: SHUFFLE ---------------- */ + if (resurrect_phase == 1) { + if (tick) { + death_shuffler->shufflePixels(); + } + + if (shuffle_timer >= MOVE_START_TIME) { + move_logic.move_to_position = spawn_point; + move_logic.automove = true; + death_position = collider_world; + resurrect_phase = 2; + } + return; + } + + /* ---------------- PHASE 2: SHUFFLE + MOVE ---------------- */ + if (resurrect_phase == 2) { + if (tick) { + if (MAX_DST && distance(collider_world, spawn_point) > MAX_DST) + death_shuffler->shufflePixels(); + else + death_shuffler->unshuffleStep(); + } + + if (distance(collider_world, spawn_point) <= 2.0f) { + resurrect_phase = 3; + resurrection_timer = 0.0f; + move_logic.automove = false; + } + return; + } + + /* ---------------- PHASE 3: UNSHUFFLE (2.8s) ---------------- */ + if (resurrect_phase == 3) { + resurrection_timer += Default::delta_time; + + if (tick) { + death_shuffler->unshuffleStep(); + } + + if (resurrection_timer >= UNSHUFFLE_TIME) { + resurrection_timer = 0.0f; + resurrection_start_frame = active_anim->current_frame; + resurrect_phase = 4; + } + return; + } + + /* ---------------- PHASE 4: FRAME REDUCTION (0.8s) ---------------- */ + if (resurrect_phase == 4) { + resurrection_timer += Default::delta_time; + + float t = resurrection_timer / FRAME_REDUCE_TIME; + if (t > 1.0f) t = 1.0f; + + active_anim->current_frame = + resurrection_start_frame * (1.0f - t); + + if (resurrection_timer >= FRAME_REDUCE_TIME) { + resurrect_phase = 5; + } + return; + } + + /* ---------------- PHASE 5: REVIVE ---------------- */ + delete death_shuffler; + death_shuffler = nullptr; + + resurrect_phase = 0; + shuffle_timer = 0.0f; + resurrection_timer = 0.0f; + + Revive(); +} + + +void +Character::Revive() { + stats.health_reduced = 0.0f; + stats.thirst = stats.thirst_max; + move_logic.automove = false; + set_Status(CharacterStatus::IDLE); + if (death_shuffler) + delete death_shuffler; + + death_shuffler = nullptr; + resurrection_unshuffle_phase = false; + resurrection_unshuffle_timer = 0.0f; + shuffle_timer = 0.0f; + death_duration = 0.0f; + set_Status(CharacterStatus::IDLE); + std::cout << "REVIVED!!\n"; +} + + +void +set_AttackAnimation(AnimationData* &ad, WalkDirection& dir, Character* ch) { + switch (static_cast<InventoryItem*>(ch->selected_item)->type) { + case ItemType::SWORD_WOOD: + ad = &ch->animation.attack_sword[dir]; + break; + + case ItemType::WOODAXE_STONE: + ad = &ch->animation.hit_woodaxe_stone[dir]; + break; + + default: + ad = nullptr; + return; + } + + if (!ad || ad->frames.empty()) { + fprintf(stderr, + "ERROR: Empty ATTACK animation\n" + " item=%d dir=%d\n", + (int)static_cast<InventoryItem*>(ch->selected_item)->type, + (int)dir + ); + } +} + +void +Character::handle_Animation() { + + AnimationData* active_anim_ref = nullptr; + + WalkDirection dir = direction; + if ( direction == WalkDirection::LEFT || + direction == WalkDirection::RIGHT) + dir = WalkDirection::SIDE; + + switch (status) { + case CharacterStatus::COLLECT: + active_anim_ref = &animation.collect[dir]; + break; + case CharacterStatus::CULTIVATING: + active_anim_ref = &animation.cultivating[dir]; + break; + case CharacterStatus::PLANTING: + active_anim_ref = &animation.planting[dir]; + break; + case CharacterStatus::BUILD: + active_anim_ref = &animation.build[dir]; + break; + case CharacterStatus::WALK: + active_anim_ref = &animation.walk[dir]; + break; + case CharacterStatus::RUN: + active_anim_ref = &animation.run[dir]; + break; + + case CharacterStatus::ATTACK: + set_AttackAnimation(active_anim_ref, dir, this); + break; + + case CharacterStatus::HIT: + active_anim_ref = &animation.hit[dir]; + break; + + case CharacterStatus::DYING: + active_anim_ref = &animation.death[dir]; + break; + + case CharacterStatus::DEAD: + active_anim_ref = &animation.death[dir]; + break; + + case CharacterStatus::CRAFT: + active_anim_ref = &animation.craft[dir]; + break; + + case CharacterStatus::BLOCK: + active_anim_ref = &animation.block[dir]; + break; + + case CharacterStatus::DRINK_RIVER: + active_anim_ref = &animation.drinking_river[dir]; + break; + + case CharacterStatus::EATING: + active_anim_ref = &animation.eating[dir]; + break; + + default: + active_anim_ref = &animation.idle[dir]; + break; + } + + if (status == CharacterStatus::DEAD) { + if (active_anim_ref) { + /* THIS SHOULD NOT BE REQUIRED + if ( active_anim_ref->frames.size() == 0) + active_anim_ref = &animation.idle[dir]; + */ + AnimationData& ad = *active_anim_ref; + + // lock last frame + //if (!ad.frames.empty() && !ad.reverse) { + if (resurrect_start == 2) { + ad.current_frame = ad.frames.size() - 1; + } + + ad.timer = 0.0f; + } + + active_anim = active_anim_ref; + return; + } + + + if (active_anim_ref) { + Animation::update(*active_anim_ref, static_cast<float>(Default::delta_time)); + active_anim = active_anim_ref; + } + + if (active_anim->frames.size() == 0) { + std::cout << "STATUS: " << (int)status << " " << std::endl; + exit(1); + } +} + + +void +Character::handle_Input(Input& input, SDL_Rect win_size) { + const bool* keys = SDL_GetKeyboardState(nullptr); + + // --- Handle mouse click for auto movement --- + /* + if (input.clicked_on_map) { + move_logic.move_to_position = {input.mouse_state.x - Map::offset.x, input.mouse_state.y - Map::offset.y}; + move_logic.automove = true; + } + */ + + thirst_Drain(); + if (health_Get() <= 0.0f) { + death(); + return; + } + + InventoryItem *sel_item = nullptr; + if (selected_item->object_type == InventoryObjectType::ITEM) { + sel_item = static_cast<InventoryItem*>(selected_item); + } + + // BUILD MENU + if (active_menu == CharacterMenuType::BUILDING) { + if (BuildingData::menu_Hovering(input, win_size, discovered_buildings)) { + if (input.click_left_released) { + BuildingType t = BuildingData::menu_DetectWorkbenchClick(input, win_size, discovered_buildings); + if (t != BuildingType::NONE) { + BuildingData::active_build.type = t; + BuildingData_s* data = BuildingData::get_BuildingDataByType(t); + BuildingData::active_build.data = data; + is_placing_build = true; + BuildingData::update_ActiveBuildData(collider_world.x, collider_world.y-collider.h); + BuildingData::active_build.object = Tile::get_ObjectFromTileSet( + data->tileset_id, + data->tileset_object_id, + data->tileset_type + ); + } + return; + } + } + } else + // INVENTORY + if (active_menu == CharacterMenuType::INVENTORY) { + if (input.click_left || input.click_left_released) { + if (Inventory::cursor_OverBuildMenu(input.mouse_state_raw)) { + if (input.click_left_released) { + Inventory::selected_build_item = Inventory::hit_BuildMenu(input.mouse_state_raw, win_size, researched_items); + std::cout << "SLE IN " << (int)Inventory::selected_build_item << std::endl; + inventory->selected_inventory.is_valid = false; + Item::craft_Stop(); + set_Status(CharacterStatus::IDLE); + } + return; + } if (Inventory::cursor_OverInfoPanel(input.mouse_state_raw)){ + if (input.click_left_released) { + if ( Inventory::selected_build_item != ItemType::NONE && + Inventory::cursor_OverCraftButton(input.mouse_state_raw)) { + if (Item::crafting_item.is_crafting) { + Item::craft_Stop(); + return; + } + if (Item::craft_ItemStart(inventory.get(), Inventory::selected_build_item)) + set_Status(CharacterStatus::CRAFT); + } + } + return; + } if (Inventory::cursor_OverInventoryGrid(input.mouse_state_raw)){ + if (input.click_left_released) { + inventory->selected_inventory = inventory->hit_InventoryGrid(input.mouse_state_raw); + Inventory::selected_item = &inventory->selected_inventory; + Inventory::selected_build_item = ItemType::NONE; + } + return; + } + } + if (Item::crafting_item.is_crafting && status == CharacterStatus::CRAFT) { + if (!Item::craft_Item(inventory.get(), Item::crafting_item, messages.get())) { + set_Status(CharacterStatus::IDLE); + Item::craft_Stop(); + } else { + if (Item::crafting_item.type == ItemType::SWORD_WOOD) { + if (!is_attackable) { + std::cout << "IM ATTACKABLE NOW!\n"; + is_attackable = true; + } + } + } + return; + } + if (keys[SDL_SCANCODE_1] || + keys[SDL_SCANCODE_2] || + keys[SDL_SCANCODE_3] || + keys[SDL_SCANCODE_4] || + keys[SDL_SCANCODE_5] || + keys[SDL_SCANCODE_6]) { + if (inventory->selected_inventory.is_valid) { + building_Stop(); + bool setted_hotbar = false; + if (inventory->selected_inventory.vegetable != VegetableData::Type::NONE) { + InventoryVegetable& iv = inventory->vegetables.at(inventory->selected_inventory.vegetable); + setted_hotbar = inventory->set_HotbarItem(Inventory::selected_hotbar, &iv); + //inventory->Equip(it); + } else + if (inventory->selected_inventory.seed != VegetableData::Type::NONE) { + InventoryVegetable& iv = inventory->seeds.at(inventory->selected_inventory.seed); + setted_hotbar = inventory->set_HotbarItem(Inventory::selected_hotbar, &iv); + //inventory->Equip(it); + } else { + setted_hotbar = inventory->set_HotbarItem(Inventory::selected_hotbar, inventory->selected_inventory.item); + if (setted_hotbar) { + if (sel_item) inventory->Equip(sel_item); + } + + } + if (setted_hotbar) { + if (consuming_logic.is_consuming && !consuming_logic.is_drinking) + consume_Stop(); + + selected_item = inventory->get_SelectedHotbarItem(); + sel_item = nullptr; + if (selected_item->object_type == InventoryObjectType::ITEM) { + sel_item = static_cast<InventoryItem*>(selected_item); + } + } + } + return; + } + } else + // WORKBENCH + if (active_menu == CharacterMenuType::WORKBENCH) { + if (input.pressed_c_released ) + setActiveMenu(active_menu, CharacterMenuType::NONE, input.cursor); + + Building::draw_menu_curser_grid = Research::cursor_ResearchGridTileIndex(input.mouse_state_raw, win_size); + // CRAFT + if (input.click_left_released) { + Craft::craft_Stop(); + + if (Craft::is_CursorOverMenuInfoPanel(input.mouse_state_raw)) { + std::vector<ItemType> rs = Item::get_ResearchedItems(researched_items); + if ( Building::draw_menu_curser_grid_active >= 0 && + Building::draw_menu_curser_grid_active < static_cast<int>(rs.size())) { + if ( Craft::cursor_OverCraftButton(input.mouse_state_raw)) { + Craft::craft_Start(inventory.get(), rs[static_cast<size_t>(Building::draw_menu_curser_grid_active)]); + } + } + + } else { // SELECTING ? + Building::draw_menu_curser_grid_active = Building::draw_menu_curser_grid; + } + } else if (Craft::item.is_crafting) { + bool enable_attackable = Craft::item.type == ItemType::SWORD_WOOD; + if (!Craft::craft_Continue(inventory.get(), messages.get())) { + Craft::craft_Stop(); + std::cout << "Crafting stopped..\n"; + } else { + if (enable_attackable) { + if (!is_attackable) { + std::cout << "IM ATTACKABLE NOW!\n"; + is_attackable = true; + } + } + } + } + return; + } else + // RESEARCH + if (active_menu == CharacterMenuType::RESEARCH) { + if (input.pressed_c_released ) + setActiveMenu(active_menu, CharacterMenuType::NONE, input.cursor); + + Building::draw_menu_curser_grid = Research::cursor_ResearchGridTileIndex(input.mouse_state_raw, win_size); + if (input.click_left_released) { + Research::research_Stop(); + + if (Research::is_CursorOverMenuInfoPanel(input.mouse_state_raw)) { + if ( Research::cursor_OverResearchButton(input.mouse_state_raw) && + Building::draw_menu_curser_grid_active >= 0) { + Research::is_researching = true; + Research::research_Start(); + } + + } else { + Building::draw_menu_curser_grid_active = Building::draw_menu_curser_grid; + } + } else if (Research::research_item.is_researching) { + if (Research::research_Continue(researched_buildings, researched_items)) + set_BuildingDiscovery(); + } + } else { + if (active_menu != CharacterMenuType::NONE) + setActiveMenu(active_menu, CharacterMenuType::NONE, input.cursor); + + Inventory::selected_build_item = ItemType::NONE; + Item::crafting_item.is_crafting = false; + } + + if (keys[SDL_SCANCODE_1] || + keys[SDL_SCANCODE_2] || + keys[SDL_SCANCODE_3] || + keys[SDL_SCANCODE_4] || + keys[SDL_SCANCODE_5] || + keys[SDL_SCANCODE_6]) { + selected_item = inventory->get_SelectedHotbarItem(); + building_Stop(); + if (active_menu == CharacterMenuType::BUILDING) + setActiveMenu(active_menu, CharacterMenuType::NONE, input.cursor); + std::cout << "SWITCH " << selected_item->id << std::endl; + return; + } + + if ( Building::construction_mode == BuildingStatus::CONSTRUCTING && + is_placing_build && + input.click_left_released && + !BuildingData::active_build.is_colliding) { + Map::place_ConstructionSide(); + BuildingData::active_build.type = BuildingType::NONE; + BuildingData::active_build.data = nullptr;; + is_placing_build = false; + return; + } + + + // INTERACT OBJECT OR ITEM + if (input.pressed_c_released && status != CharacterStatus::COLLECT) { + SDL_Point tile_point; + TileObject* map_object_p = find_ClosestObject(&tile_point, ObjectCategory::NONE); + if (!map_object_p) { + // check for river + for (auto [x,y] : tiles_in_reach) { + size_t id = static_cast<size_t>(y * Map::size.x + x); + Tile_s ts = Map::tile_map[id].background; + if (ts.object_id == SIZE_MAX) { + continue; + } + if (Tile::get_FloorType(ts) == + TileTypeFloors::WATER) { + std::cout << "River found!\n"; + drink_Start(); + // character rotate to tile + return; + } + } + std::cout << "Nothing to interact with! " << tiles_in_reach.size() << std::endl; + if (!Animation::audio->is_Playing("character.hae")) + Animation::audio->Play("character.hae"); + messages->Add(MessageKey::NOTHING_TO_INTERACT); + return; + } + + Object* object = Object::get_ObjectById(map_object_p->object_id); + switch (object->category) { + case ObjectCategory::RESOURCE: + case ObjectCategory::FARM_CROP: + collect_Start(map_object_p); + std::cout << "STAT: " << (int)status << std::endl; + return; + case ObjectCategory::BUILDING: + interact_WithBuilding(static_cast<Building*>(object), input); + return; + default: break; + } + } + + // CLICK MAP + if (!input.pressed_ctrl) { + // LEFT CLICK + if (input.click_left) { + if (sel_item) { + // START CULTIVATE + if ( sel_item->type == ItemType::CULTIVATOR && + status != CharacterStatus::CULTIVATING) + cultivate_Start(); + else + // START BUILD + if (sel_item->type == ItemType::BUILDING_TOOL) { + build_Start(); + return; + } else + // START ATTACK + if (using_Weapon() && + ( attacking_logic.is_attacking == AttackingLogicStatus_e::NONE || + attacking_logic.is_attacking == AttackingLogicStatus_e::BLOCKING_RUNNING)) { + collecting_logic.is_collecting = false; + attack_Start(); + return; + } + } else { + if (!planting_logic.is_planting && + Farm::soil_IsMaptile(tile_world)) { + switch (selected_item->object_type) { + case InventoryObjectType::VEGETABLE: + case InventoryObjectType::SEED: + if (plant_Start()) + return; + default: break; + } + } + if (!planting_logic.is_planting && !consuming_logic.is_consuming && selected_item->object_type == InventoryObjectType::VEGETABLE) { + eat_Start(); + } + } + } else + // RIGHT CLICK + if (input.click_right) { + if (using_Weapon() && attacking_logic.is_attacking == AttackingLogicStatus_e::NONE) { + attacking_logic.is_attacking = AttackingLogicStatus_e::BLOCKING_START; + } + } else + if (input.click_right_released) { + if (attacking_logic.is_attacking == AttackingLogicStatus_e::BLOCKING_RUNNING) { + std::cout << "STOP\n"; + attacking_logic.is_attacking = AttackingLogicStatus_e::BLOCKING_STOP; + } + } + } + + + if (consuming_logic.is_consuming) { + if (consuming_logic.is_drinking) + drink_River(); + else + eat_Something(); + return; + } + + + if (status == CharacterStatus::BUILD) { + set_Status(CharacterStatus::IDLE); + } + if (status == CharacterStatus::COLLECT) { + collect_Object(); + } else if (collecting_logic.is_collecting) { + collect_Stop(); + } + + if (input.pressed_shift && stamina_Get() > 0 && + (status == CharacterStatus::WALK || status == CharacterStatus::RUN)) { + + // START SPRINT + double stamina_drain = 0.05; + + if (sprintstart_logic.is_starting) { + double elapsed = Default::get_TimeSinceStartInSec() - sprintstart_logic.started_gamesec; + + double t = elapsed / sprintstart_logic.starting_duration; + if (t > 1.0) + t = 1.0; + + stamina_drain *= (t * t); + + if (t >= 1.0) { + sprintstart_logic.has_started = true; + sprintstart_logic.is_starting = false; + std::cout << "SPRINTING..\n"; + } + } + + stamina_Reduce(stamina_drain); + if (stamina_Get() <= 0) { + stamina_StopReg(); + messages->Add(MessageKey::PLAYER_EXHAUSTED); + } + else { + is_sprinting = true; + if (!sprintstart_logic.is_starting && !sprintstart_logic.has_started) { + sprintstart_logic.started_gamesec = Default::get_TimeSinceStartInSec(); + sprintstart_logic.is_starting = true; + std::cout << "STARTING SPRINT\n"; + } + + if (sprintstart_logic.is_starting) { + double elapsed = Default::get_TimeSinceStartInSec() - sprintstart_logic.started_gamesec; + if (elapsed >= sprintstart_logic.starting_duration) { + sprintstart_logic.has_started = true; + sprintstart_logic.is_starting = false; + std::cout << "SPRINTING..\n"; + } + } + } + } else if (is_sprinting) { + // SPRINT END + is_sprinting = false; + sprintstart_logic.started_gamesec = 0; + sprintstart_logic.is_starting = false; + sprintstart_logic.has_started = false; + std::cout << "STOP SPRINTING\n"; + } + + + switch (attacking_logic.is_attacking) { + case AttackingLogicStatus_e::ATTACKING: + attack_Enemy(); + break; + case AttackingLogicStatus_e::BLOCKING_START: + block_Start(); + break; + case AttackingLogicStatus_e::BLOCKING_RUNNING: + block_Enemy(); + break; + case AttackingLogicStatus_e::BLOCKING_STOP: + block_Stop(); + break; + default: break; + + } + if (attacking_logic.is_attacking != AttackingLogicStatus_e::NONE) + return; + if ( status == CharacterStatus::PLANTING && planting_logic.is_planting) { + plant_Vegetable(); + } + else + if ( status == CharacterStatus::CULTIVATING) { + cultivate_Soil(); + } else { + if (cultivation_logic.is_cultivating) + cultivate_Stop(); + } + + if (stamina_regen_logic.is_regenerating && ( + status != CharacterStatus::IDLE && + status != CharacterStatus::WALK)) + stamina_StopReg(); + else if (status == CharacterStatus::IDLE || + status == CharacterStatus::WALK) + stamina_StartReg(); +} + +void Character::handle_Move() { + if (attacking_logic.is_attacking == AttackingLogicStatus_e::ATTACKING) + return; + const bool* keys = SDL_GetKeyboardState(nullptr); + + float dx = 0.0f; + float dy = 0.0f; + + // --- Manual movement input --- + if (keys[SDL_SCANCODE_W]) dy -= 1.0f; + if (keys[SDL_SCANCODE_S]) dy += 1.0f; + if (keys[SDL_SCANCODE_A]) dx -= 1.0f; + if (keys[SDL_SCANCODE_D]) dx += 1.0f; + + moving = (dx != 0.0f || dy != 0.0f); + + // --- Disable automove when manually moving --- + /* + if (manual_move) + move_logic.automove = false; + */ + + if (move_logic.automove) { + float target_x = move_logic.move_to_position.x; + float target_y = move_logic.move_to_position.y; + + float center_x = x + collider.x + collider.w * 0.5f; + float center_y = y + collider.y + collider.h * 0.5f; + + dx = target_x - center_x; + dy = target_y - center_y; + + float distance = std::sqrt(dx * dx + dy * dy); + if (distance < 2.0f) { // close enough + move_logic.automove = false; + status = CharacterStatus::IDLE; + return; + } + + dx /= distance; + dy /= distance; + y += dy; + x += dx; + // --- Update world positions --- + collider_world.x = x + collider.x + collider.w * 0.5f; + collider_world.y = y + collider.y + collider.h * 0.5f; + tile_world.x = collider_world.x / Tile::tile_size; + tile_world.y = collider_world.y / Tile::tile_size; + return; + } + + // --- Stop if neither auto nor manual movement active --- + if (!moving) { + switch (status) { + case CharacterStatus::WALK: + case CharacterStatus::RUN: + set_Status(CharacterStatus::IDLE); + break; + default: break; + } + return; + } + + + if (collecting_logic.is_collecting) + collect_Stop(); + if (consuming_logic.is_consuming) + consume_Stop(); + if (planting_logic.is_planting) + plant_Stop(); + + attacking_logic.is_attacking = AttackingLogicStatus_e::NONE; + + if (is_sprinting) { + if (status != CharacterStatus::RUN) { + set_Status(CharacterStatus::RUN); + } + } else + if (status != CharacterStatus::WALK) { + set_Status(CharacterStatus::WALK); + } + + // --- Normalize and move --- + float length = std::sqrt(dx * dx + dy * dy); + if (length != 0.0f) { + dx /= length; + dy /= length; + } + + float real_speed = speed; + if (sprintstart_logic.is_starting) { + float start_factor = get_SprintStartFactor(); + float current_mult = 1.0f + (sprint_multiply - 1.0f) * start_factor; + real_speed *= current_mult; + } else if (is_sprinting) { + real_speed *= sprint_multiply; + } + + + float next_x = x + dx * real_speed * Default::delta_time; + float next_y = y + dy * real_speed * Default::delta_time; + + SDL_FRect next_rect = collider; + + // Move horizontally + next_rect.x = next_x + collider.x; + next_rect.y = y + collider.y; + if (Map::is_FreePosition(next_rect)) + x = next_x; + + // Move vertically + next_rect.x = x + collider.x; + next_rect.y = next_y + collider.y; + if (Map::is_FreePosition(next_rect)) + y = next_y; + + // --- Direction / sprite flipping --- + if (dx != 0.0f && dy != 0.0f) { + if (dx < 0) + direction = WalkDirection::LEFT; + else + direction = WalkDirection::RIGHT; + flip = (dx < 0); + } else if (dy > 0.0f) { + direction = WalkDirection::DOWN; + flip = false; + } else if (dy < 0.0f) { + direction = WalkDirection::UP; + flip = false; + } else if (dx != 0.0f) { + if (dx < 0) + direction = WalkDirection::LEFT; + else + direction = WalkDirection::RIGHT; + flip = (dx < 0); + } + + // --- Update world positions --- + collider_world.x = x + collider.x + collider.w * 0.5f; + collider_world.y = y + collider.y + collider.h * 0.5f; + tile_world.x = collider_world.x / Tile::tile_size; + tile_world.y = collider_world.y / Tile::tile_size; + + set_TilesInReach(); +} + + +void Character::Update() { + //bird->set_Position({x,y}); + bird->Update(Default::delta_time, collider_world); + + // std::cout <<" COLOLOL " << collider_world.x << " " << collider_world.y << std::endl; + reduce_StatsBonus(); + + if (status == CharacterStatus::HIT && active_anim->current_frame == 3) { + set_Status(CharacterStatus::IDLE); + } + + if ( is_placing_build) + BuildingData::update_ActiveBuildData(collider_world.x, collider_world.y - collider.h); + + handle_Move(); + handle_Animation(); +} + + +bool Character::is_RectWithinReach( const SDL_FRect& target) { + // Player center + float px = x+collider.x+collider.w*0.5; + float py = y+collider.x+collider.w*0.5; + + // Target center + float tx = target.x + target.w * 0.5f; + float ty = target.y + target.h * 0.5f; + + float dx = tx - px; + float dy = ty - py; + float distance_sq = dx * dx + dy * dy; + + float reach_sq = arm_reach_radius * arm_reach_radius; + return distance_sq <= reach_sq; +} + + +void +Character::set_TilesInReach() { + tiles_in_reach.clear(); + + const float reach = arm_reach_radius; + const float reach_sq = reach * reach; + const float cx = collider_world.x; + const float cy = collider_world.y; + const int ts = Tile::tile_size; + + int min_tx = static_cast<int>((cx - reach) / ts); + int max_tx = static_cast<int>((cx + reach) / ts); + int min_ty = static_cast<int>((cy - reach) / ts); + int max_ty = static_cast<int>((cy + reach) / ts); + + if (min_tx < 0) min_tx = 0; + if (min_ty < 0) min_ty = 0; + if (max_tx >= Map::size.x) max_tx = Map::size.x - 1; + if (max_ty >= Map::size.y) max_ty = Map::size.y - 1; + + for (int ty = min_ty; ty <= max_ty; ++ty) { + float tile_top = ty * ts; + float tile_bottom = tile_top + ts; + + for (int tx = min_tx; tx <= max_tx; ++tx) { + float tile_left = tx * ts; + float tile_right = tile_left + ts; + + float closest_x = cx < tile_left ? tile_left : (cx > tile_right ? tile_right : cx); + float closest_y = cy < tile_top ? tile_top : (cy > tile_bottom ? tile_bottom : cy); + + float dx = closest_x - cx; + float dy = closest_y - cy; + + if (dx * dx + dy * dy <= reach_sq) + if (tx > 0 && ty > 0 && tx < Map::size.x && ty < Map::size.y) + tiles_in_reach.push_back({tx, ty}); + } + } + + std::sort( + tiles_in_reach.begin(), + tiles_in_reach.end(), + [cx, cy](const SDL_Point& a, const SDL_Point& b) { + float ax = a.x * ts + ts * 0.5f; + float ay = a.y * ts + ts * 0.5f; + float bx = b.x * ts + ts * 0.5f; + float by = b.y * ts + ts * 0.5f; + + float da = (ax - cx) * (ax - cx) + (ay - cy) * (ay - cy); + float db = (bx - cx) * (bx - cx) + (by - cy) * (by - cy); + + return da < db; + } + ); +} + +bool +Character::using_Weapon() { + Inventory_s* it = nullptr; + it = static_cast<Inventory_s*>(selected_item); + if (!it) return false; + if (it->object_type != InventoryObjectType::ITEM) + return false; + ItemType& type = static_cast<InventoryItem*>(it)->type; + return Item::is_Weapon(type); +} + + + + + + + + + + + + + +void +Character::set_ResourceDiscovery(ResourceType resource) { + size_t id = static_cast<size_t>(resource); + + if (discovered_resources[id]) + return; + + discovered_resources[id] = true; + messages->Add(MessageKey::DISCOVERED_RESOURCE); + set_BuildingDiscovery(); +} + + +void +Character::set_VegetableDiscovery(VegetableData::Type vegetable) { + size_t id = static_cast<size_t>(vegetable); + + if (discovered_vegetables[id]) + return; + + discovered_vegetables[id] = true; + messages->Add(MessageKey::DISCOVERED_VEGETABLE); +} + + +void +Character::set_BuildingDiscovery() { + for (BuildingData_s bs : BuildingData::building_data) { + if (discovered_buildings[static_cast<size_t>(bs.type)]) + continue; + bool discovered = true; + if (level < bs.required_level) + continue; + if (!researched_buildings[static_cast<size_t>(bs.type)]) + continue; + for (BuildingCost cost : bs.cost) { + if (!discovered_resources[static_cast<size_t>(cost.type)]) { + discovered = false; + break; + } + } + if (!discovered) + continue; + + discovered_buildings[static_cast<size_t>(bs.type)] = true; + messages->Add(MessageKey::DISCOVERED_BUILDING); + + } +} + + + +bool +Character::is_BuildingUnlocked(BuildingType type) { + for (BuildingType t : unclocked__buildings) + if (t == type) return true; + return false; +} + +void +Character::unlock_Building(BuildingType type) { + unclocked__buildings.push_back(type); +} + + + + +bool +Character::Save(const std::string &path) const { + std::cout << "Save Character\n"; + std::ofstream file(path + "/character", std::ios::binary | std::ios::trunc); + if (!file) { + std::cout << "No file found at: " << path << std::endl; + return false; + } + + file.write(reinterpret_cast<const char*>(&stats), sizeof(stats)); + file.write(reinterpret_cast<const char*>(&x), sizeof(x)); + file.write(reinterpret_cast<const char*>(&y), sizeof(y)); + file.write(reinterpret_cast<const char*>(&level), sizeof(level)); + + + inventory->Save(path); + return file.good(); +} + + +bool +Character::Load(const std::string &path) { + std::cout << "Load Character\n"; + std::ifstream file(path + "/character", std::ios::binary); + if (!file) { + std::cout << "No file found at: " << path << std::endl; + return false; + } + + file.read(reinterpret_cast<char*>(&stats), sizeof(stats)); + file.read(reinterpret_cast<char*>(&x), sizeof(x)); + file.read(reinterpret_cast<char*>(&y), sizeof(y)); + file.read(reinterpret_cast<char*>(&level), sizeof(level)); + + inventory->Load(path); + + selected_item = inventory->get_SelectedHotbarItem(); + + for (auto rs : inventory->resources) + set_ResourceDiscovery(rs.first); + for (auto vs : inventory->vegetables) + set_VegetableDiscovery(vs.first); + for (auto vs : inventory->seeds) + set_VegetableDiscovery(vs.first); + set_BuildingDiscovery(); + + return file.good(); +} diff --git a/src/character/character.hpp b/src/character/character.hpp new file mode 100644 index 0000000..f79d769 --- /dev/null +++ b/src/character/character.hpp @@ -0,0 +1,348 @@ +#pragma once + +#include <SDL3/SDL.h> +#include <SDL3_image/SDL_image.h> + +#include <vector> +#include <unordered_map> +#include <string> +#include <cmath> +#include <iostream> +#include <memory> + +#include "defaults/defaults.hpp" +#include "map/tile.hpp" +#include "objects/object.hpp" +#include "character/animation.hpp" +#include "character/enemy.hpp" +#include "inventory/inventory.hpp" +#include "building/building_data.hpp" +#include "building/building.hpp" +#include "vegetables/vegetables.hpp" +#include "bird/bird.hpp" +#include "defaults/shuffle_texture.hpp" + +// Character stuff + +enum class CharacterMenuType { + NONE, + BUILDING, + INVENTORY, + WORKBENCH, + RESEARCH, +}; + +enum class CharacterStatus { + IDLE, + WALK, + RUN, + COLLECT, + ATTACK, + HIT, + DYING, + DEAD, + BUILD, + CRAFT, + BLOCK, + DRINK_RIVER, + EATING, + CULTIVATING, + PLANTING, +}; + + +struct CharacterMoveLogic { + SDL_FPoint move_to_position; + bool automove = false; +}; + +struct CharacterCollectingLogic { + float duration; + float duration_max; + TileObject* object; + Resource_s resource; + bool is_collecting; + SDL_Point tile_point; +}; + + +enum class AttackingLogicStatus_e { + NONE, + ATTACKING, + BLOCKING_START, + BLOCKING_RUNNING, + BLOCKING_STOP +}; + +struct CharacterAttackingLogic { + float duration; + InventoryItem* item; + AttackingLogicStatus_e is_attacking; + bool has_attacked; + Enemy* enemy; +}; + +struct CharacterConsumingLogic { + float duration; + float duration_max; + bool is_consuming; + bool is_drinking; + Resource* resource; +}; + +struct CharacterCultivatingLogic { + float duration; + float duration_max; + bool is_cultivating; + bool is_removing; + SDL_Point tile_world; +}; + +struct CharacterPlantingLogic { + float duration; + float duration_max; + bool is_planting; + SDL_Point tile_world; + VegetableData::Type type; + bool is_seed; +}; + +struct CharacterStats { + float health_max; + float health_reduced; + float stamina_max; + float stamina_reduced; + float thirst; + float thirst_max; + + float demage; +}; + +struct CharacterStaminaRegeneration { + bool is_regenerating = false; + float delay_max = 2.8; + float delay_is = 0; + float regen_speed = 2.4; +}; + +struct CharacterThirstDrainLogic { + float drain_speed = 0.01f; + bool send_message_0 = false; + bool send_message_20 = false; +}; + +struct CharacterSprintStartLogic { + double started_gamesec = 0; + double starting_duration = 2.8; + bool is_starting = false; + bool has_started = false; +}; + +struct CharacterStatsBonus { + InventoryObjectType object_type; + uint32_t type; + float duration; + ConsumingStatsBonus stats; +}; + +class Character { + //////////////////////////////////////// + /// Character + + float speed; + float sprint_multiply; + bool is_sprinting = false; + bool flip = false; + float arm_reach_radius = 0; + bool is_placing_build = false; + + std::vector<BuildingType> + unclocked__buildings; + + public: + size_t tile_size; // this is the size of the texture + CharacterMenuType active_menu; + Inventory_s* selected_item; + AnimationData* active_anim = nullptr; + CharacterAnimation animation; + WalkDirection direction = WalkDirection::UP; + CharacterAttackingLogic attacking_logic; + CharacterConsumingLogic consuming_logic; + CharacterSprintStartLogic sprintstart_logic; + Bird* bird = nullptr; + + bool is_attackable = false; + + std::vector<CharacterStatsBonus> stats_bonus; + + PixelShuffler* death_shuffler; + float shuffle_timer = 0.0f; + float shuffle_interval = 8.0f; + + + int resurrect_start = 0; // 1 and 2 + int resurrection_start_frame = 0; + float resurrection_unshuffle_timer = 0.0f; + bool resurrection_unshuffle_phase = false; + float death_duration; + float death_duration_max; + int resurrect_phase = 0; // 0..5 + float resurrection_timer = 0.0f; + + int height; + int width; + SDL_FRect collider; + SDL_FPoint collider_world; + SDL_Point tile_world; + std::vector<SDL_Point> + tiles_in_reach; + + SDL_FPoint death_position; + + + CharacterMoveLogic move_logic; + + bool moving; + + CharacterCollectingLogic collecting_logic; + CharacterCultivatingLogic cultivation_logic; + CharacterPlantingLogic planting_logic; + + CharacterStatus status; + + + CharacterStats stats = {}; + CharacterStaminaRegeneration stamina_regen_logic; + CharacterThirstDrainLogic thirst_drain_logic; + float x, y; + SDL_FPoint spawn_point; + int level = 1; + + std::unique_ptr<Messages> messages; + std::unique_ptr<Inventory> inventory; + + std::vector<bool>discovered_resources; + std::vector<bool>discovered_vegetables; + std::vector<bool>discovered_buildings; + std::vector<bool>researched_buildings; + std::vector<bool>researched_items; + + Character(); + Character(Character&&); + ~Character(); + + void Init(SDL_Renderer* renderer); + + void set_Status(const CharacterStatus&); + + void + draw_CircleProgress(SDL_Renderer* renderer, int cx, int cy, int radius, float progress, + Uint8 color_r=16, Uint8 color_g=47, Uint8 color_b=74, Uint8 color_a=210); + void + draw_HorizontalProgress(SDL_Renderer* renderer, float progress, + Uint8 fill_r = 16, Uint8 fill_g = 47, Uint8 fill_b = 144, Uint8 fill_a = 210, + Uint8 bg_r = 50, Uint8 bg_g = 50, Uint8 bg_b = 50, Uint8 bg_a = 100); + + void update_Animation(AnimationData& anim, float delta_time); + void Draw(SDL_Renderer* renderer); + + + float health_Get(); + float health_Max(); + float health_MaxBonus(); + void health_Reduce(float amount); + void health_Increase(float amount); + + float stamina_Get(); + float stamina_Max(); + float stamina_MaxBonus(); + void stamina_Reduce(float amount); + void stamina_Increase(float amount); + void stamina_StartReg(); + void stamina_StopReg(); + + float damage_Get(); + + TileObject* find_ClosestObject(SDL_Point* tile_found, ObjectCategory category = ObjectCategory::NONE); + void collect_Start(TileObject* map_object_p); + void collect_Object(); + void collect_Stop(); + + float get_SprintStartFactor() const; + + bool build_Start(); + + void attack_Start(); + void attack_Enemy(); + void attack_Stop(); + + void block_Start(); + void block_Enemy(); + void block_Stop(); + + void building_Stop(); + + void drink_Start(); + void drink_River(); + + void eat_Start(); + void eat_Something(); + + void consume_Stop(); + + void cultivate_Start(); + void cultivate_Soil(); + void cultivate_Stop(); + + bool plant_Start(); + void plant_Vegetable(); + void plant_Stop(); + + void thirst_Drain(); + + void interact_WithBuilding(Building* building, Input& input); + + bool is_StatsBonusAlready(InventoryObjectType object_type, uint32_t type); + void add_ToStatsBonus(InventoryObjectType object_type, uint32_t type, ConsumingStatsBonus sb); + void reduce_StatsBonus(); + + void getting_Hit(float demage); + void death(); + void Resurrect(); + void Revive(); + + //bool is_CollidingWithObjects(const SDL_FRect& rect); + bool is_Colliding(const SDL_FRect& rect); + + void handle_Input(Input& input, SDL_Rect win_size); + void handle_Animation(); + void Update(); + void handle_Move(); + + void draw_PickupRadius(SDL_Renderer* renderer); + + bool is_RectWithinReach( const SDL_FRect& target); + + void set_TilesInReach(); + + bool using_Weapon(); + + + void + set_ResourceDiscovery(ResourceType resource); + void + set_VegetableDiscovery(VegetableData::Type vegetable); + void + set_BuildingDiscovery(); + + + void + unlock_Building(BuildingType type); + bool + is_BuildingUnlocked(BuildingType type); + + bool + Save(const std::string &path) const; + bool + Load(const std::string &path); +}; diff --git a/src/character/enemy.cpp b/src/character/enemy.cpp new file mode 100644 index 0000000..91e8709 --- /dev/null +++ b/src/character/enemy.cpp @@ -0,0 +1,1433 @@ +#include "character/enemy.hpp" + +#include <stdlib.h> +#include <set> + +#include "map/map.hpp" +#include "map/path_finding.hpp" + + +std::vector<Enemy*> Enemy::enemies; +std::vector<SpawnParams> Enemy::enemies_to_spawn; + +SDL_FPoint Enemy::colider_default = {7, 7}; +EnemyAnimation Enemy::animation_all; +size_t Enemy::tile_size = 64; + +// Persistent thread pool +std::vector<SDL_Thread*> Enemy::workers; +std::vector<WorkerData> Enemy::job_queue; +std::mutex Enemy::queue_mutex; +std::condition_variable Enemy::queue_cv; + +bool Enemy::stop_threads = false; + +int Enemy::jobs_remaining = 0; +std::condition_variable Enemy::jobs_done_cv; + +int Enemy::id_next = 1; + +Enemy::Enemy(WeaponType weapon_type, WeaponMaterial weapon_material, SDL_FPoint position, EnemyStats status) + : weapon(weapon_type, weapon_material) { + x = position.x; + y = position.y; + stats = status; + + id = id_next++; + + detection_radius = 150 + rand() % 51; + + speed = 40.0f; + run = 1.4f; + direction = WalkDirection::DOWN; + moving = false; + flip = false; + collider.w = colider_default.x; + collider.h = colider_default.y; + collider.x = (tile_size/2 - collider.w/2); + collider.y = tile_size - collider.h - 16; + collider_world.x = x + collider.x + collider.w * 0.5f; + collider_world.y = y + collider.y + collider.h * 0.5f; + arm_reach_radius = 6; + resources = {}; + point_in_reach = false; + + dist_min = weapon.dimension.x-8; + dist_max = weapon.dimension.x; + + max_death_time = 10.0; + + stats = status; + + death_duration = 0; + death_duration_max = 0.8; + direction_blocked[WalkDirection::DOWN] = false; + direction_blocked[WalkDirection::UP] = false; + direction_blocked[WalkDirection::LEFT] = false; + direction_blocked[WalkDirection::RIGHT] = false; + animation = animation_all; + } + +void +Enemy::init_All(SDL_Renderer* renderer) { + animation_all.run[WalkDirection::DOWN] = Animation::load(renderer, "Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run_up.png", tile_size, tile_size, "None", false, false); + animation_all.run[WalkDirection::SIDE] = Animation::load(renderer, "Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run.png", tile_size, tile_size, "None", false, false); + animation_all.run[WalkDirection::UP] = Animation::load(renderer, "Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Run/Run_up.png", tile_size, tile_size, "None", false, false); + + animation_all.idle[WalkDirection::DOWN] = Animation::load(renderer, "Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Idle/Idle-Sheet_padded.png", tile_size, tile_size, "None", false, false); + animation_all.idle[WalkDirection::SIDE] = Animation::load(renderer, "Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Idle/Idle-Sheet_padded.png", tile_size, tile_size, "None", false, false); + animation_all.idle[WalkDirection::UP] = Animation::load(renderer, "Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Idle/Idle-Sheet_padded.png", tile_size, tile_size, "None", false, false); + + animation_all.attack[WalkDirection::DOWN] = Animation::load(renderer, "Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Attack/Attack_Down.png", tile_size, tile_size, "enemy.attack", false, true); + animation_all.attack[WalkDirection::SIDE] = Animation::load(renderer, "Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Attack/Attack.png", tile_size, tile_size, "enemy.attack", false, true); + animation_all.attack[WalkDirection::UP] = Animation::load(renderer, "Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Attack/Attack_Up.png", tile_size, tile_size, "enemy.attack", false, true); + + animation_all.hit[WalkDirection::DOWN] = Animation::load(renderer, "Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Idle/Idle-Sheet_padded.png", tile_size, tile_size, "character.hit", false, false); + animation_all.hit[WalkDirection::SIDE] = Animation::load(renderer, "Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Idle/Idle-Sheet_padded.png", tile_size, tile_size, "character.hit", false, false); + animation_all.hit[WalkDirection::UP] = Animation::load(renderer, "Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Idle/Idle-Sheet_padded.png", tile_size, tile_size, "character.hit", false, false); + + animation_all.death[WalkDirection::DOWN] = Animation::load(renderer, "Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Death/Death-Sheet_processed.png", tile_size, tile_size, "None", false, false); + animation_all.death[WalkDirection::SIDE] = Animation::load(renderer, "Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Death/Death-Sheet_processed.png", tile_size, tile_size, "None", false, false); + animation_all.death[WalkDirection::UP] = Animation::load(renderer, "Pixel_Crawler/Entities/Mobs/Skeleton Crew/Skeleton - Base/Death/Death-Sheet_processed.png", tile_size, tile_size, "None", false, false); + + init_Workers(10); +} + + +void +Enemy::Init() { + handle_Animation(); + + set_Status(EnemyStatus::IDLE); + + // REINIT POSITION + SDL_FPoint new_position = Map::get_ClosestPointWithoutCollision( + {static_cast<float>(collider_world.x), static_cast<float>(collider_world.y), + collider.w, collider.h}); + + if (new_position.x == 0 && new_position.y == 0) { + std::cout << "No position found!\n"; + return; + } + x = new_position.x - collider.x - collider.w * 0.5; + y = new_position.y - collider.y - collider.h * 0.5; + +} + + +void Enemy::set_Status(const EnemyStatus& s) { + status = s; + active_anim->timer = 0; + active_anim->current_frame = 0; + Animation::animation_frame_time = active_anim->frame_time; +} + +void +Enemy::handle_Animation() { + AnimationData* active_anim_ref = nullptr; + WalkDirection dir = direction; + if ( direction == WalkDirection::LEFT || + direction == WalkDirection::RIGHT) + dir = WalkDirection::SIDE; + + + switch (status) { + case EnemyStatus::RUN: + active_anim_ref = &animation.run[dir]; + break; + + case EnemyStatus::ATTACK: + active_anim_ref = &animation.attack[dir]; + break; + + case EnemyStatus::DYING: + active_anim_ref = &animation.death[dir]; + break; + + case EnemyStatus::DEAD: + active_anim_ref = &animation.death[dir]; + break; + + case EnemyStatus::HIT: + active_anim_ref = &animation.hit[dir]; + break; + + default: + active_anim_ref = &animation.idle[dir]; + break; + } + + if (status == EnemyStatus::DEAD) { + if (active_anim_ref) { + AnimationData& ad = *active_anim_ref; + + // lock animation to last frame + if (!ad.frames.empty()) { + ad.current_frame = ad.frames.size() - 1; + } + + // also stop the timer so update() never progresses + ad.timer = 0.0f; + } + + active_anim = active_anim_ref; + return; // absolutely do NOT call update() when dead + } + + if (active_anim_ref) { + Animation::update(*active_anim_ref, static_cast<float>(Default::delta_time)); + active_anim = active_anim_ref; + } +} + +void +Enemy::Draw(SDL_Renderer* renderer) { +#ifdef DEBUG_BUILD + // DEBUG COLLIDER + SDL_FRect debug_rect { + Scale((x + collider.x) + Map::offset.x), + Scale((y + collider.y) + Map::offset.y), + Scale(collider.w), + Scale(collider.h) + }; + SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255); + SDL_RenderRect(renderer, &debug_rect); + // DEBUG CHARACTER RECTANGLE + SDL_SetRenderDrawColor(renderer, 255, 255,255, 255); + SDL_FRect debug_rect_1 { + Scale(x+Map::offset.x), + Scale(y+Map::offset.y), + Scale(tile_size), + Scale(tile_size) + }; + SDL_RenderRect(renderer, &debug_rect_1); + + // DEBUG Arm Range + SDL_SetRenderDrawColor(renderer, 0, 255, 0, 100); + for (float angle = 0; angle < 2 * M_PI; angle += 0.1f) { + float px = collider_world.x + cosf(angle) * arm_reach_radius + Map::offset.x; + float py = collider_world.y + sinf(angle) * arm_reach_radius + Map::offset.y; + SDL_RenderPoint(renderer, (int)Scale(px), (int)Scale(py)); + } + + // DEBUG Tiles in reach + SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); + SDL_SetRenderDrawColor(renderer, 0, 255, 0, 80); + + for (const auto& t : tiles_in_reach) { + SDL_FRect tile_rect = { + Scale(t.x * Tile::tile_size) + Map::offset.x, + Scale(t.y * Tile::tile_size) + Map::offset.y, + Scale(Tile::tile_size), + Scale(Tile::tile_size) + }; + + SDL_RenderFillRect(renderer, &tile_rect); + } +#endif + + // Render Enemy + const SDL_FRect& src = active_anim->frames[active_anim->current_frame]; + + SDL_FRect dst { + Scale(x + Map::offset.x), + Scale(y + Map::offset.y), + Scale(src.w), + Scale(src.h) + }; + + /* + if (stats.health > 0) + if (flip) weapon.Draw(renderer, x + Map::offset.x, y + Map::offset.y); + */ + SDL_RenderTextureRotated(renderer, active_anim->texture, &src, &dst, + 0.0, nullptr, + flip ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE); + /* + + if (stats.health > 0) + if (!flip) weapon.Draw(renderer, x + Map::offset.x, y + Map::offset.y); + */ + + // HEALTH BAR + if (stats.health <= 0) return; + + float bar_width = Scale(40.0f); + float bar_height = Scale(4.0f); + + // position above the enemy sprite + float bar_x = Scale(x + Map::offset.x + tile_size/2) - bar_width/2; + float bar_y = Scale(y + Map::offset.y) + bar_height*2 - Scale(4.0f); + + // background (empty bar) + SDL_SetRenderDrawColor(renderer, 50, 50, 50, 255); + SDL_FRect bar_bg { + bar_x-1, + bar_y-1, + bar_width+2, + bar_height+2 + }; + SDL_RenderFillRect(renderer, &bar_bg); + + // current health percentage + float ratio = 0.0f; + if (stats.health_max > 0.0f) { + ratio = stats.health / stats.health_max; + if (ratio < 0.0f) ratio = 0.0f; + if (ratio > 1.0f) ratio = 1.0f; + } + + // foreground (current health) + SDL_SetRenderDrawColor(renderer, 200, 0, 0, 255); + SDL_FRect bar_fg { + bar_x, + bar_y, + bar_width * ratio, + bar_height + }; + SDL_RenderFillRect(renderer, &bar_fg); +} + +Enemy* +Enemy::is_InEnemyReach(const SDL_FRect& rect) { + + for (Enemy* enemy : Enemy::enemies) { + if (enemy->stats.health <= 0) continue; + + SDL_FRect other = { + enemy->x + enemy->collider.x, + enemy->y + enemy->collider.y, + enemy->collider.w, + enemy->collider.h + }; + + bool overlap = + rect.x < other.x + other.w && + rect.x + rect.w > other.x && + rect.y < other.y + other.h && + rect.y + rect.h > other.y; + + if (overlap) + return enemy; + } + return nullptr; +} + +/* +static inline double ms_since(Uint64 start) { + static const double freq = static_cast<double>(SDL_GetPerformanceFrequency()); + return (SDL_GetPerformanceCounter() - start) * 1000.0 / freq; +} +*/ + +int EnemyWorkerThread(void*) { + while (true) { + std::unique_lock<std::mutex> lock(Enemy::queue_mutex); + Enemy::queue_cv.wait(lock, [] { + return Enemy::stop_threads || !Enemy::job_queue.empty(); + }); + + if (Enemy::stop_threads && Enemy::job_queue.empty()) + return 0; + + WorkerData job = Enemy::job_queue.back(); + Enemy::job_queue.pop_back(); + lock.unlock(); + + job.enemy->set_NextMoves(*job.grid); + + std::lock_guard<std::mutex> finish_lock(Enemy::queue_mutex); + if (--Enemy::jobs_remaining == 0) + Enemy::jobs_done_cv.notify_one(); + } +} + +void Enemy::init_Workers(int num_threads) { + stop_threads = false; + jobs_remaining = 0; + for (int i = 0; i < num_threads; ++i) { + SDL_Thread* th = SDL_CreateThread(EnemyWorkerThread, "EnemyWorker", nullptr); + workers.push_back(th); + } +} + +void Enemy::shutdown_Workers() { + { + std::lock_guard<std::mutex> lock(queue_mutex); + stop_threads = true; + } + queue_cv.notify_all(); + + for (SDL_Thread* th : workers) { + SDL_WaitThread(th, nullptr); + } + workers.clear(); +} + +void Enemy::run_GetMovesThreads() +{ + std::vector<bool> grid = Map::tile_collission_map; + + std::set<int> checks = {0,1,2,3,4,5,6,7,8,12,16,32,64,128,256}; + + // ---- First pass: mark grid exactly like old version ---- + for (Enemy* e : Enemy::enemies) { + if (e->status != EnemyStatus::RUN || + !checks.count(e->next_moves.size())) + continue; + + int tx = static_cast<int>(e->collider_world.x / Tile::tile_collider_size); + int ty = static_cast<int>(e->collider_world.y / Tile::tile_collider_size); + + if (tx < 0 || ty < 0 || + tx >= static_cast<int>(Map::size.x * Tile::tile_collider_size) || + ty >= static_cast<int>(Map::size.y * Tile::tile_collider_size)) + continue; + + size_t id = static_cast<size_t>( + ty * (Map::size.x * Tile::tile_collider_size) + tx); + + grid[id] = true; + } + + auto grid_ptr = std::make_shared<std::vector<bool>>(std::move(grid)); + + // ---- Wait for previous frame to finish ---- + { + std::unique_lock<std::mutex> lock(queue_mutex); + jobs_done_cv.wait(lock, [] { return jobs_remaining == 0; }); + } + + // ---- Push jobs ---- + { + std::lock_guard<std::mutex> lock(queue_mutex); + + for (Enemy* e : Enemy::enemies) { + if (e->status != EnemyStatus::RUN) + continue; + if (e->point_in_reach) + continue; + + if (e->next_position.x == 0 || e->next_position.y == 0 ) + continue; + + job_queue.push_back({ e, grid_ptr }); + ++jobs_remaining; + } + } + + queue_cv.notify_all(); + + // ---- Wait like old SDL_WaitThread loop ---- + { + std::unique_lock<std::mutex> lock(queue_mutex); + jobs_done_cv.wait(lock, [] { return jobs_remaining == 0; }); + } +} + + + +void Enemy::Decide(Character& player) { + //float d_x = player.collider_world.x - collider_world.x; + //float d_y = player.collider_world.y - collider_world.y; + //size_t dc_x = static_cast<size_t>(abs(d_x)); + //size_t dc_y = static_cast<size_t>(abs(d_y)); + EnemyMovingType r; + + if (is_character_in_range) { + r = EnemyMovingType::CHARACTER; + } else if (move_focus != EnemyMovingType::NONE) { + r = move_focus; + } else { + // pick random type excluding CHARACTER + do { + r = static_cast<EnemyMovingType>(1 + rand() % (static_cast<int>(EnemyMovingType::LAST) - 1)); + } while (r == EnemyMovingType::CHARACTER); + } + set_MoveLogic(r, player); +} + +inline bool same_corner(const SDL_FPoint& a, const SDL_FPoint& b, float epsilon = 1.0f) { + return std::fabs(a.x - b.x) <= epsilon && std::fabs(a.y - b.y) <= epsilon; +} + + + +inline bool Enemy::character_InRange(SDL_FPoint char_pos) const { + float dx = char_pos.x - collider_world.x; + float dy = char_pos.y - collider_world.y; + float distance_squared = dx * dx + dy * dy; + return distance_squared <= detection_radius * detection_radius; +} + + +bool +Enemy::set_CollisinnWithEnemy(const SDL_FRect& rect) { + + if (avoiding_object) + return false; + + for (Enemy* enemy : Enemy::enemies) { + if (enemy == this || enemy->stats.health <= 0) continue; + + SDL_FRect other = { + enemy->x + enemy->collider.x, + enemy->y + enemy->collider.y, + enemy->collider.w, + enemy->collider.h + }; + + bool overlap = + rect.x < other.x + other.w && + rect.x + rect.w > other.x && + rect.y < other.y + other.h && + rect.y + rect.h > other.y; + + if (overlap) { + last_object_collision.min_x = rect.x; + last_object_collision.max_x = rect.x+rect.w; + last_object_collision.min_y = rect.y; + last_object_collision.max_y = rect.y+rect.h; + last_object_collision.valid = true; + collidiing_with_enemy = enemy; + return true; + } + } + return false; +} + +bool +Enemy::is_CollidingWithEnemy(const SDL_FRect& rect) { + for (Enemy* enemy : Enemy::enemies) { + if (enemy->stats.health <= 0) + continue; + + SDL_FRect other = { + enemy->x + enemy->collider.x, + enemy->y + enemy->collider.y, + enemy->collider.w, + enemy->collider.h + }; + + bool overlap = + rect.x < other.x + other.w && + rect.x + rect.w > other.x && + rect.y < other.y + other.h && + rect.y + rect.h > other.y; + + if (overlap) { + return true; + } + } + return false; +} + +/* +bool +Enemy::is_CollidingWithObjects(const SDL_FRect& rect) { + const size_t scale = Tile::tile_size / Tile::tile_collider_size; + + // convert rectangle to collider coordinates + int start_cx = static_cast<int>(std::floor(rect.x / float(Tile::tile_collider_size))); + int end_cx = static_cast<int>(std::ceil((rect.x + rect.w) / float(Tile::tile_collider_size))); + int start_cy = static_cast<int>(std::floor(rect.y / float(Tile::tile_collider_size))); + int end_cy = static_cast<int>(std::ceil((rect.y + rect.h) / float(Tile::tile_collider_size))); + + // loop over tiles overlapped by rectangle in tile units + size_t tile_start_x = static_cast<size_t>(rect.x / Tile::tile_size); + size_t tile_end_x = static_cast<size_t>((rect.x + rect.w) / Tile::tile_size); + size_t tile_start_y = static_cast<size_t>(rect.y / Tile::tile_size); + size_t tile_end_y = static_cast<size_t>((rect.y + rect.h) / Tile::tile_size); + + bool collision_found = false; + + float min_x = std::numeric_limits<float>::max(); + float min_y = std::numeric_limits<float>::max(); + float max_x = std::numeric_limits<float>::lowest(); + float max_y = std::numeric_limits<float>::lowest(); + for (size_t ty = tile_start_y; ty <= tile_end_y && ty < Map::size.y; ++ty) { + for (size_t tx = tile_start_x; tx <= tile_end_x && tx < Map::size.x; ++tx) { + size_t map_index = ty * Map::size.x + tx; + TileMap& tilemap = Map::tile_map[map_index]; + + for (const TileObject& obj : tilemap.objects) { + Object* object = Object::get_ObjectById(obj.object_id); + std::vector<bool> collision_map = object->get_CollisionMap(); + int obj_abs_x = static_cast<int>(tx) - obj.position.x; + int obj_abs_y = static_cast<int>(ty) - obj.position.y; + + int obj_cx = obj_abs_x * static_cast<int>(scale); + int obj_cy = obj_abs_y * static_cast<int>(scale); + size_t obj_cw = static_cast<size_t>(object->dimension.x) * scale; + size_t obj_ch = static_cast<size_t>(object->dimension.y) * scale; + + for (int cy = obj_cy; cy < obj_cy+static_cast<int>(obj_ch); ++cy) { + for (int cx = obj_cx; cx < obj_cx+static_cast<int>(obj_cw); ++cx) { + int rel_x = cx - obj_cx; + int rel_y = cy - obj_cy; + + if (rel_x < 0 || rel_y < 0 || static_cast<size_t>(rel_x) >= obj_cw || static_cast<size_t>(rel_y) >= obj_ch) + continue; + + size_t obj_index = static_cast<size_t>(rel_y) * obj_cw + static_cast<size_t>(rel_x); + + if (collision_map[obj_index]) { + float cell_x = static_cast<float>(cx) * Tile::tile_collider_size; + float cell_y = static_cast<float>(cy) * Tile::tile_collider_size; + + min_x = std::min(min_x, cell_x); + min_y = std::min(min_y, cell_y); + max_x = std::max(max_x, cell_x + static_cast<float>(Tile::tile_collider_size)); + max_y = std::max(max_y, cell_y + static_cast<float>(Tile::tile_collider_size)); + + if (cx >= start_cx && cx < end_cx && cy >= start_cy && cy < end_cy) + collision_found = true; + } + if (cx >= end_cx && cy >= end_cy && !collision_found) + return false; + + } + } + + } + } + } + if (collision_found) { + last_object_collision.min_x = std::min(min_x, max_x); + last_object_collision.max_x = std::max(min_x, max_x); + last_object_collision.min_y = std::min(min_y, max_y); + last_object_collision.max_y = std::max(min_y, max_y); + last_object_collision.valid = true; + } + return collision_found; +} +*/ + +void Enemy::compute_MapCollisionInterval(size_t cx, size_t cy, size_t max_x, size_t max_y) { + last_map_collision.valid = false; + + const size_t start_index = cy * max_x + cx; + if (!Map::tile_collission_map[start_index]) + return; + + size_t min_x = cx; + while (min_x > 0 && + Map::tile_collission_map[cy * max_x + (min_x - 1)]) + min_x--; + + size_t max_xi = cx; + while (max_xi < max_x - 1 && + Map::tile_collission_map[cy * max_x + (max_xi + 1)]) + max_xi++; + + size_t min_y = cy; + while (min_y > 0 && + Map::tile_collission_map[(min_y - 1) * max_x + cx]) + min_y--; + + size_t max_yi = cy; + while (max_yi < max_y - 1 && + Map::tile_collission_map[(max_yi + 1) * max_x + cx]) + max_yi++; + + last_map_collision.min_x = min_x * Tile::tile_collider_size; + last_map_collision.max_x = (max_xi + 1) * Tile::tile_collider_size; + + last_map_collision.min_y = min_y * Tile::tile_collider_size; + last_map_collision.max_y = (max_yi + 1) * Tile::tile_collider_size; + + last_map_collision.valid = true; +} + +bool +Enemy::is_CollidingWithWorld(const SDL_FRect& rect) { + const size_t max_cells_x = static_cast<size_t>(Map::size.x * (Tile::tile_size / Tile::tile_collider_size)); + const size_t max_cells_y = static_cast<size_t>(Map::size.y * (Tile::tile_size / Tile::tile_collider_size)); + + const float corners[4][2] = { + { rect.x, rect.y }, + { rect.x + rect.w, rect.y }, + { rect.x, rect.y + rect.h }, + { rect.x + rect.w, rect.y + rect.h } + }; + + for (int i = 0; i < 4; ++i) { + const size_t cell_x = corners[i][0] / Tile::tile_collider_size; + const size_t cell_y = corners[i][1] / Tile::tile_collider_size; + + if (cell_x >= max_cells_x || cell_y >= max_cells_y) + return true; + + const size_t index = static_cast<size_t>(cell_y * max_cells_x + cell_x); + + if (Map::tile_collission_map[index]) { + const size_t index = cell_y * max_cells_x + + cell_x; + + if (Map::tile_collission_map[index]) { + compute_MapCollisionInterval(cell_x, cell_y, max_cells_x, max_cells_y); + //std::cout << "COL: " << last_map_collision.min_x << " " << last_map_collision.max_x << " " << last_map_collision.min_y << " " << last_map_collision.max_y << std::endl; + return true; + } + } + } + return false; +} + +bool +Enemy::is_Colliding(const SDL_FRect& rect) { + /* + const size_t max_cells_x = Map::size.x * (Tile::tile_size / Tile::tile_collider_size); + const size_t max_cells_y = Map::size.y * (Tile::tile_size / Tile::tile_collider_size); + + const float corners[4][2] = { + { rect.x, rect.y }, + { rect.x + rect.w, rect.y }, + { rect.x, rect.y + rect.h }, + { rect.x + rect.w, rect.y + rect.h } + }; + + for (int i = 0; i < 4; ++i) { + const size_t cell_x = corners[i][0] / Tile::tile_collider_size; + const size_t cell_y = corners[i][1] / Tile::tile_collider_size; + + if (cell_x < 0 || cell_y < 0 || cell_x >= max_cells_x || cell_y >= max_cells_y) + return true; + + const size_t index = static_cast<size_t>(cell_y) * static_cast<size_t>(max_cells_x) + + static_cast<size_t>(cell_x); + + if (Map::tile_collission_map[index]) { + const size_t index = static_cast<size_t>(cell_y) * static_cast<size_t>(max_cells_x) + + static_cast<size_t>(cell_x); + + if (Map::tile_collission_map[index]) { + compute_MapCollisionInterval(cell_x, cell_y, max_cells_x, max_cells_y); + //std::cout << "COL: " << last_map_collision.min_x << " " << last_map_collision.max_x << " " << last_map_collision.min_y << " " << last_map_collision.max_y << std::endl; + return true; + } + } + } + */ + + // if (is_CollidingWithObjects(rect)) return true; + + return set_CollisinnWithEnemy(rect); +} + + +void Enemy::move_Path() { + if (next_moves.empty()) return; + + SDL_FPoint move_to_position = next_moves.back(); + + float cx = x + collider.x + collider.w * 0.5f; + float cy = y + collider.y + collider.h * 0.5f; + + + float dx = move_to_position.x - cx; + float dy = move_to_position.y - cy; + float dist = std::sqrt(dx*dx + dy*dy); + + + const float max_dist = 2; + + if (dist <= max_dist) { + next_moves.pop_back(); + + if (next_moves.empty()) { + // rotate to target + float fx = next_position.x - cx; + float fy = next_position.y - cy; + flip = (fx < 0); + if (std::abs(fx) > std::abs(fy)) { + direction = (fx < 0 ? WalkDirection::LEFT : WalkDirection::RIGHT); + weapon.flip = flip; + } else { + direction = (fy < 0 ? WalkDirection::UP : WalkDirection::DOWN); + } + + return; + } + return; + } + + // normalize step + float step_len = speed * Default::delta_time; + if (dist < step_len) step_len = dist; + dx = dx / dist * step_len; + dy = dy / dist * step_len; + + //std::cout << "MOVE_TO_POS: " << move_to_position.x << " " << move_to_position.y << "DX AND DY: " << dx << " " << dy << std::endl; + + SDL_FRect test = collider; + + + bool is_actually_colliding = is_Colliding({collider.x + x, collider.y + y, collider.w, collider.h}); + + test.x = x + collider.x + dx; + test.y = y + collider.y + dy; + + if (!is_Colliding(test) || is_actually_colliding) { + x += dx; + moving_logic.moving_distance.x += std::abs(dx); + y += dy; + moving_logic.moving_distance.y += std::abs(dy); + moving_logic.path_blocked = 0.0; + } else { + float dx = test.x - collider_world.x; + float dy = test.y - collider_world.y; + float len = std::sqrt(dx * dx + dy * dy); + dx /= len; + dy /= len; + bool left = (std::rand() % 2) == 0; + float px = left ? -dy : dy; + float py = left ? dx : -dx; + + float distance = 40.0f + static_cast<float>(std::rand()) / + (static_cast<float>(RAND_MAX) / 40.0f); + SDL_FPoint result = { + collider_world.x + px * distance, + collider_world.y + py * distance + }; + std::cout << "GETING OUTTTTT\n"; + moving_logic.position = Map::get_ClosestPointWithoutCollision({result.x, result.y, collider.w, collider.h}); + next_position = moving_logic.position; + moving_logic.moving_distance.x = 0.0f; + moving_logic.moving_distance.y = 0.0f; + point_in_reach = false; + moving_logic.path_blocked = 0.0; + set_Status(EnemyStatus::RUN); + moving_logic.avoid_blockage = true; + moving_logic.move_type = EnemyMovingType::WALK; + handle_Animation(); + return; + } + + + // SET WALK DIRECTION + flip = (dx < 0); + if (fabs(dx) > 0.0f && fabs(dx) > fabs(dy)) { + direction = (dx < 0 ? WalkDirection::LEFT : WalkDirection::RIGHT); + } else if (dy > 0.0f) { + direction = WalkDirection::DOWN; + } else if (dy < .0f) { + direction = WalkDirection::UP; + } + + if (status != EnemyStatus::RUN) + set_Status(EnemyStatus::RUN); + + + + // update world positions + collider_world.x = x + collider.x + collider.w * 0.5f; + collider_world.y = y + collider.y + collider.h * 0.5f; + tile_world.x = collider_world.x / Tile::tile_size; + tile_world.y = collider_world.y / Tile::tile_size; + + //set_TilesInReach(); +} + +void +Enemy::remove_Dead() { + if (Enemy::enemies.size() == 0) + return; + + for (auto it = Enemy::enemies.begin(); it != Enemy::enemies.end(); ) { + Enemy* e = *it; + + if (e->status == EnemyStatus::DEAD && e->death_duration > e->max_death_time) { + delete e; + it = Enemy::enemies.erase(it); + } else { + ++it; + } + } +} + +void +Enemy::init_SpawnEnemy(double delay_to_spawn_in_sec, WeaponType weapon_type = WeaponType::SWORD, + WeaponMaterial weapon_material = WeaponMaterial::WOOD, + SDL_FPoint position = {100,100}, + EnemyStats status = {16,16,2,false,false,0,1.2}) { + + double spawn_date = delay_to_spawn_in_sec + Default::get_TimeSinceStartInSec(); + Enemy::enemies_to_spawn.push_back({spawn_date, + weapon_type, + weapon_material, + position, + status}); +} + +bool +Enemy::spawn_Enemy(SpawnParams& params) { + if (params.spawn_date > Default::get_TimeSinceStartInSec()) + return false; + + Enemy* enemy = new Enemy(params.type, params.material, params.pos, params.stats); + enemy->Init(); + Enemy::enemies.push_back(enemy); + return true; +} + +void +Enemy::set_NextMoves(const std::vector<bool>& grid) { + // std::cout << "PL: " << player_collider_world.x << " " << player_collider_world.y << std::endl; + // std::cout << "TG: " << target_pos.x << " " << target_pos.y << std::endl; + // std::cout << "DS: " << dist_max-dist_min << std::endl; + next_moves = find_Path({collider_world.x, collider_world.y, collider.w, collider.h}, next_position, dist_max-dist_min, 0, grid); + // std::cout << "NM " << next_moves.size() << " " << collider_world.x << " " << collider_world.y << " " << next_position.x << " " << next_position.y << std::endl; +} + + +void +Enemy::set_AlignPosition(const SDL_FPoint& pos) { + float dist = dist_min + (dist_max-dist_min)/2; + //std::cout << "DS: " << dist.x << " " << dist.y <<std::endl; + + const float px = pos.x; + const float py = pos.y; + + float nx = collider_world.x; + float ny = collider_world.y; + + float cand[4][2]; + cand[0][0] = px + dist; cand[0][1] = py; + cand[1][0] = px - dist; cand[1][1] = py; + cand[2][0] = px; cand[2][1] = py + dist; + cand[3][0] = px; cand[3][1] = py - dist; + + // Compute distances from enemy to each candidate + float dist2[4]; + for (int i = 0; i < 4; i++) { + const float dx2 = cand[i][0] - collider_world.x; + const float dy2 = cand[i][1] - collider_world.y; + dist2[i] = dx2*dx2 + dy2*dy2; + } + + // Find nearest candidate first + int order[4] = {0,1,2,3}; + for (int i = 0; i < 4; i++) { + int best = i; + for (int j = i+1; j < 4; j++) { + if (dist2[order[j]] < dist2[order[best]]) + best = j; + } + int tmp = order[i]; + order[i] = order[best]; + order[best] = tmp; + } + + for (int k = 0; k < 4; k++) { + const int idx = order[k]; + const float tx = cand[idx][0]; + const float ty = cand[idx][1]; + + if (Map::is_FreePosition({tx-2, ty+collider.h-2, collider.w+4, collider.h+4})) { + nx = tx; + ny = ty; + break; + } + } + + next_position.x = nx; + next_position.y = ny; +} + +void +Enemy::set_MoveLogic(EnemyMovingType& type, Character& player) { + moving_logic = EnemyMovingLogic(); + moving_logic.move_type = type; + + EnemyStatus sta = EnemyStatus::IDLE; + point_in_reach = true; + moving_logic.avoid_blockage = false; + stuck_moves = 0; + + // std::cout << "FUCK " << (int)type << std::endl; + switch (type) { + case EnemyMovingType::NONE: + break; + case EnemyMovingType::OBJECT: + moving_logic.move_type = EnemyMovingType::NONE; + break; + case EnemyMovingType::IDLE: + moving_logic.duration = (180 + (rand() % 200))/100.0f; + sta = EnemyStatus::IDLE; + break; + case EnemyMovingType::WALK: { + SDL_FRect test_pos = collider; + int chance_move_far = rand() % 10; + + if (chance_move_far < 3) { + moving_logic.min_distance = 100; + moving_logic.max_distance = 140; + } else { + moving_logic.min_distance = 50; + moving_logic.max_distance = 101; + } + + // Retry generating a test position until it's valid + SDL_FPoint test_pos_c = {0,0}; + // START CLAMP NEW POSITION TO BOUNDARIES WHICH SUUUUUUCKS!!! + int i = 0; + + const int map_max_x = Map::boundaries.x * Tile::tile_size; + const int map_max_y = Map::boundaries.y * Tile::tile_size; + + do { + if (i++ > 3) { + moving_logic.move_type = EnemyMovingType::NONE; + return; + } + + int dist_x = moving_logic.min_distance + + rand() % (moving_logic.max_distance - moving_logic.min_distance + 1); + + int dist_y = moving_logic.min_distance + + rand() % (moving_logic.max_distance - moving_logic.min_distance + 1); + + if (rand() % 2) dist_x = -dist_x; + if (rand() % 2) dist_y = -dist_y; + + int new_x = static_cast<int>(collider_world.x) + dist_x; + int new_y = static_cast<int>(collider_world.y) + dist_y; + + if (new_x < 0 || new_y < 0 || + new_x >= map_max_x || new_y >= map_max_y) + continue; + + test_pos.x = new_x; + test_pos.y = new_y; + + test_pos_c = Map::get_ClosestPointWithoutCollision(test_pos); + + if (player.is_attackable && test_pos_c.x <= 530 && test_pos_c.y <= 334) + continue; + + break; + + } while (true); + // END CLAMP NEW POSITION TO BOUNDARIES WHICH SUUUUUUCkS!!! + + moving_logic.moving_distance = {0, 0}; + // moving_logic.position = Map::get_ClosestPointWithoutCollision(test_pos); + next_position = test_pos_c; + //set_AlignPosition(moving_logic.position); + // std::cout << " MEEE1 " << player.is_attackable << " " << collider_world.x << " " << collider_world.y << std::endl; + // std::cout << " MEEE2 " << player.is_attackable << " " << next_position.x << " " << next_position.y << std::endl; + sta = EnemyStatus::RUN; + point_in_reach = false; + break; + } + case EnemyMovingType::CHARACTER: { + bool is_player_alive = player.health_Get() > 0; + if (!is_player_alive) { + moving_logic.move_type = EnemyMovingType::NONE; + break; + } + moving_logic.object = static_cast<void*>(&player); + moving_logic.position = player.collider_world; + moving_logic.duration = 0.8 + ((double)rand() / RAND_MAX) * (1.8 - 0.8); + set_AlignPosition(moving_logic.position); + sta = EnemyStatus::RUN; + point_in_reach = false; + move_focus = EnemyMovingType::CHARACTER; + break; + } + case EnemyMovingType::LAST: + moving_logic.move_type = EnemyMovingType::NONE; + break; + } + + if (status != sta) { + set_Status(sta); + handle_Animation(); + } +} + +void +Enemy::Update(Character& player) { + + point_in_reach = false; + + if (player.is_attackable) { + is_character_in_range = character_InRange(player.collider_world); + if (!is_character_in_range && moving_logic.move_type == EnemyMovingType::CHARACTER) { + next_moves.clear(); + move_focus = EnemyMovingType::NONE; + moving_logic.move_type = EnemyMovingType::NONE; + attack_Stop(); + } +} + + // IS DEAD + if (stats.health <= 0) { + if (status == EnemyStatus::DYING || + status == EnemyStatus::DEAD) { + death(); + } + handle_Animation(); + return; + } + + // std::cout << "MVTY " << (int)moving_logic.move_type << std::endl; + // DECIDE // REDECIDE + //std::cout << "WLK " << moving_logic.moving_distance.x << " >= " << moving_logic.max_distance << " || " << moving_logic.moving_distance.y << " >= " << moving_logic.max_distance << std::endl; + if ( moving_logic.move_type == EnemyMovingType::NONE || ( + moving_logic.move_type == EnemyMovingType::IDLE && + moving_logic.duration <= 0)) { + Decide(player); + handle_Animation(); + return; + } else + if (moving_logic.move_type == EnemyMovingType::IDLE) { + moving_logic.duration -= Default::delta_time; + handle_Animation(); + return; + } else + if (moving_logic.move_type == EnemyMovingType::WALK) { + if ( moving_logic.moving_distance.x >= moving_logic.max_distance || + moving_logic.moving_distance.y >= moving_logic.max_distance ) { + moving_logic.move_type = EnemyMovingType::NONE; + next_moves.clear(); + handle_Animation(); + return; + } + } + + float d_x = moving_logic.position.x - collider_world.x; + float d_y = moving_logic.position.y - collider_world.y; + /* + size_t dc_x = static_cast<size_t>(abs(d_x)); + size_t dc_y = static_cast<size_t>(abs(d_y)); + + bool dist_ok_x = (dc_x >= dist_min && dc_x <= weapon.dimension.x) && (dc_y <= weapon.dimension.y/2); + bool dist_ok_y = (dc_y >= dist_min && dc_y <= weapon.dimension.x) && (dc_x <= weapon.dimension.y/2); + */ + + + float dist_sq = d_x * d_x + d_y * d_y; + + float min_sq = dist_min * dist_min; + float max_sq = dist_max * dist_max; + + //std::cout << "DSTQ " << (int)moving_logic.move_type << " " << next_moves.size()<< " " << dist_sq << " " << min_sq << " " << max_sq << std::endl; + bool point_moved = false; + if ( player.collider_world.x != moving_logic.position.x || + player.collider_world.y != moving_logic.position.y ) { + point_moved = true; + } + if (dist_sq >= min_sq && dist_sq <= max_sq) { + point_in_reach = true; + moving_logic.avoid_blockage = false; + next_moves.clear(); + } + if (next_moves.empty()) { + if (moving_logic.move_type == EnemyMovingType::WALK || (move_focus == EnemyMovingType::CHARACTER && point_moved && moving_logic.duration >= 0)) { + float mld = moving_logic.duration; + set_Status(EnemyStatus::IDLE); + moving_logic.move_type = EnemyMovingType::IDLE; + if (moving_logic.move_type == EnemyMovingType::WALK) + moving_logic.duration = (moving_logic.moving_distance.x + moving_logic.moving_distance.y) / 100 + 0.5; + else + moving_logic.duration = mld; + std::cout << "Walk DONE !!!!\n"; + return; + } + } else if (next_moves.size() < 2) { + ++stuck_moves; + if (stuck_moves > 20) { + // std::cout << "IM STUCK!!\n"; + set_Status(EnemyStatus::IDLE); + moving_logic.move_type = EnemyMovingType::IDLE; + next_position = collider_world; + next_moves.clear(); + return; + } + } + + if (move_focus == EnemyMovingType::CHARACTER) { + moving_logic.duration -= Default::delta_time; + // std::cout << moving_logic.duration << std::endl; + //std::cout << "NEXT MOVES: " << next_moves.size() << std::endl; + if (!moving_logic.avoid_blockage && ((point_moved && moving_logic.duration <= 0) || moving_logic.move_type != EnemyMovingType::CHARACTER)) { + set_MoveLogic(moving_logic.move_type, player); + return; + } + } + + if (moving_logic.move_type == EnemyMovingType::CHARACTER) { + if (stats.is_attacking) { + Attack(point_in_reach); + handle_Animation(); + return; + } + } + + if ( !point_in_reach ) { + move_Path(); + handle_Animation(); + return; + } + + + next_moves.clear(); + + // SET WALK DIRECTION + flip = (d_x < 0); + if (fabs(d_x) > 0.0f && fabs(d_x) > fabs(d_y)) { + direction = (d_x < 0 ? WalkDirection::LEFT : WalkDirection::RIGHT); + } else if (d_y > 0.0f) { + direction = WalkDirection::DOWN; + } else if (d_y < .0f) { + direction = WalkDirection::UP; + } + + switch (moving_logic.move_type) { + case EnemyMovingType::CHARACTER: + attack_Start(); + break; + case EnemyMovingType::WALK: + moving_logic.move_type = EnemyMovingType::IDLE; + set_MoveLogic(moving_logic.move_type, player); + break; + default: break; + } + + handle_Animation(); +} + +void +Enemy::attack_Start() { + set_Status(EnemyStatus::ATTACK); + handle_Animation(); + + Animation::animation_frame_time = stats.attack_duration_max / active_anim->frames.size(); + + stats.attack_duration = 0; + stats.is_attacking = true; + stats.has_attacked = false; +} + +void +Enemy::Attack( bool in_reach) { + // i should fic the frame_time to attack_duration + // so the animation finishes with the attack end. + stats.attack_duration += Default::delta_time; + if (stats.attack_duration < stats.attack_duration_max/2) + return; + + if (in_reach && !stats.has_attacked) { +#ifdef DEBUG_BUILD + std::cout << "Enemy: Attack character!\n"; +#endif + stats.has_attacked = true; + if (moving_logic.move_type == EnemyMovingType::CHARACTER) + static_cast<Character*>(moving_logic.object)->getting_Hit(stats.demage); + //player.getting_Hit(stats.demage); + } + attack_Stop(); +} + +void +Enemy::attack_Stop() { + if (stats.attack_duration < stats.attack_duration_max) + return; + set_Status(EnemyStatus::IDLE); + stats.attack_duration = 0; + stats.is_attacking = false; + stats.has_attacked = false; + + if (moving_logic.move_type == EnemyMovingType::CHARACTER) { + if (static_cast<Character*>(moving_logic.object)->health_Get() <= 0) + moving_logic.move_type = EnemyMovingType::NONE; + + } +} + +void +Enemy::getting_Hit(float demage) { + // if (status != EnemyStatus::HIT) set_Status(EnemyStatus::HIT); + std::cout << "ENEM " << stats.health << " " << demage << std::endl; + stats.health -= demage; + +#ifdef DEBUG_BUILD + std::cout << "Enemy: Getting hit! " << stats.health << std::endl; +#endif + + if (stats.health <= 0) { + attack_Stop(); + stats.health = 0; + death(); + } +} + +void +Enemy::death() { + death_duration += Default::delta_time; + if (death_duration > death_duration_max) { + if (status != EnemyStatus::DEAD) + set_Status(EnemyStatus::DEAD); + } else { + if (status != EnemyStatus::DYING) + set_Status(EnemyStatus::DYING); + } +} + +void +Enemy::set_TilesInReach() { + tiles_in_reach.clear(); + + float reach = arm_reach_radius; + float reach_sq = reach * reach; + + // bounding box of tiles to check + int min_tx = static_cast<int>((collider_world.x - reach) / Tile::tile_size); + int max_tx = static_cast<int>((collider_world.x + reach) / Tile::tile_size); + int min_ty = static_cast<int>((collider_world.y - reach) / Tile::tile_size); + int max_ty = static_cast<int>((collider_world.y + reach) / Tile::tile_size); + + // clamp to map bounds + if (min_tx < 0) min_tx = 0; + if (min_ty < 0) min_ty = 0; + if (max_tx >= static_cast<int>(Map::size.x)) max_tx = Map::size.x - 1; + if (max_ty >= static_cast<int>(Map::size.y)) max_ty = Map::size.y - 1; + + for (int ty = min_ty; ty <= max_ty; ++ty) { + for (int tx = min_tx; tx <= max_tx; ++tx) { + // tile rectangle + float tile_left = tx * static_cast<int>(Tile::tile_size); + float tile_top = ty * static_cast<int>(Tile::tile_size); + float tile_right = tile_left + Tile::tile_size; + float tile_bottom = tile_top + Tile::tile_size; + + // closest point on tile to character center + float closest_x = std::max(tile_left, std::min(collider_world.x, tile_right)); + float closest_y = std::max(tile_top, std::min(collider_world.y, tile_bottom)); + + float dx = closest_x - collider_world.x; + float dy = closest_y - collider_world.y; + + if (dx*dx + dy*dy <= reach_sq) + tiles_in_reach.push_back({tx, ty}); + } + } + + std::sort(tiles_in_reach.begin(), tiles_in_reach.end(), + [this](const SDL_Point& a, const SDL_Point& b) { + float ax = a.x * Tile::tile_size + Tile::tile_size * 0.5f; + float ay = a.y * Tile::tile_size + Tile::tile_size * 0.5f; + float bx = b.x * Tile::tile_size + Tile::tile_size * 0.5f; + float by = b.y * Tile::tile_size + Tile::tile_size * 0.5f; + + float da = (ax - collider_world.x) * (ax - collider_world.x) + + (ay - collider_world.y) * (ay - collider_world.y); + float db = (bx - collider_world.x) * (bx - collider_world.x) + + (by - collider_world.y) * (by - collider_world.y); + return da < db; + }); + +} + + + + + + + + + + + + +static void WriteStats(std::ofstream &file, const EnemyStats &s) { + file.write(reinterpret_cast<const char*>(&s.health), sizeof(s.health)); + file.write(reinterpret_cast<const char*>(&s.health_max), sizeof(s.health_max)); + file.write(reinterpret_cast<const char*>(&s.demage), sizeof(s.demage)); + file.write(reinterpret_cast<const char*>(&s.is_attacking), sizeof(s.is_attacking)); + file.write(reinterpret_cast<const char*>(&s.has_attacked), sizeof(s.has_attacked)); + file.write(reinterpret_cast<const char*>(&s.attack_duration), sizeof(s.attack_duration)); + file.write(reinterpret_cast<const char*>(&s.attack_duration_max), sizeof(s.attack_duration_max)); +} + +static void ReadStats(std::ifstream &file, EnemyStats &s) { + file.read(reinterpret_cast<char*>(&s.health), sizeof(s.health)); + file.read(reinterpret_cast<char*>(&s.health_max), sizeof(s.health_max)); + file.read(reinterpret_cast<char*>(&s.demage), sizeof(s.demage)); + file.read(reinterpret_cast<char*>(&s.is_attacking), sizeof(s.is_attacking)); + file.read(reinterpret_cast<char*>(&s.has_attacked), sizeof(s.has_attacked)); + file.read(reinterpret_cast<char*>(&s.attack_duration), sizeof(s.attack_duration)); + file.read(reinterpret_cast<char*>(&s.attack_duration_max), sizeof(s.attack_duration_max)); +} + +bool +Enemy::save_All(const std::string &path) { + std::ofstream file(path, std::ios::binary | std::ios::trunc); + if (!file) + return false; + + uint32_t count_total = static_cast<uint32_t>(enemies.size() + enemies_to_spawn.size()); + file.write(reinterpret_cast<const char*>(&count_total), sizeof(count_total)); + + for (auto *e : enemies) { + SpawnParams sp; + sp.spawn_date = 0.0; + sp.type = e->weapon.type; + sp.material = e->weapon.material; + sp.pos = { e->x, e->y }; + sp.stats = e->stats; + + file.write(reinterpret_cast<const char*>(&sp.spawn_date), sizeof(sp.spawn_date)); + file.write(reinterpret_cast<const char*>(&sp.type), sizeof(sp.type)); + file.write(reinterpret_cast<const char*>(&sp.material), sizeof(sp.material)); + file.write(reinterpret_cast<const char*>(&sp.pos.x), sizeof(sp.pos.x)); + file.write(reinterpret_cast<const char*>(&sp.pos.y), sizeof(sp.pos.y)); + WriteStats(file, sp.stats); + } + + // save pending + double current_time = Default::get_TimeSinceStartInSec(); + for (const auto &sp : enemies_to_spawn) { + SpawnParams tmp = sp; + tmp.spawn_date -= current_time; + + file.write(reinterpret_cast<const char*>(&tmp.spawn_date), sizeof(tmp.spawn_date)); + file.write(reinterpret_cast<const char*>(&tmp.type), sizeof(tmp.type)); + file.write(reinterpret_cast<const char*>(&tmp.material), sizeof(tmp.material)); + file.write(reinterpret_cast<const char*>(&tmp.pos.x), sizeof(tmp.pos.x)); + file.write(reinterpret_cast<const char*>(&tmp.pos.y), sizeof(tmp.pos.y)); + WriteStats(file, tmp.stats); + } + + return file.good(); +} + +bool Enemy::load_All(const std::string &path) { + std::ifstream file(path, std::ios::binary); + if (!file) + return false; + + for (auto *e : enemies) delete e; + enemies.clear(); + enemies_to_spawn.clear(); + + uint32_t count_total = 0; + file.read(reinterpret_cast<char*>(&count_total), sizeof(count_total)); + + for (uint32_t i = 0; i < count_total; ++i) { + SpawnParams sp; + file.read(reinterpret_cast<char*>(&sp.spawn_date), sizeof(sp.spawn_date)); + file.read(reinterpret_cast<char*>(&sp.type), sizeof(sp.type)); + file.read(reinterpret_cast<char*>(&sp.material), sizeof(sp.material)); + file.read(reinterpret_cast<char*>(&sp.pos.x), sizeof(sp.pos.x)); + file.read(reinterpret_cast<char*>(&sp.pos.y), sizeof(sp.pos.y)); + ReadStats(file, sp.stats); + + double delay = sp.spawn_date; + init_SpawnEnemy(delay, sp.type, sp.material, sp.pos, sp.stats); + } + + return file.good(); +} diff --git a/src/character/enemy.hpp b/src/character/enemy.hpp new file mode 100644 index 0000000..678df3b --- /dev/null +++ b/src/character/enemy.hpp @@ -0,0 +1,270 @@ +#pragma once + +#include <algorithm> +#include <mutex> +#include <condition_variable> + +#include "animation.hpp" +#include "objects/object.hpp" +#include "inventory/weapon.hpp" + +class Character; +class Enemy; + +enum class EnemyStatus { + IDLE, + RUN, + ATTACK, + HIT, + DEAD, + DYING, +}; + +struct EnemyAnimation { + std::unordered_map<WalkDirection, AnimationData> idle; + std::unordered_map<WalkDirection, AnimationData> run; + std::unordered_map<WalkDirection, AnimationData> attack; + std::unordered_map<WalkDirection, AnimationData> hit; + std::unordered_map<WalkDirection, AnimationData> death; +}; + +struct EnemyStats { + float health; + float health_max; + + float demage; + bool is_attacking; + bool has_attacked; + float attack_duration; + float attack_duration_max; +}; + +struct CollisionInterval { + float min_x, max_x; + float min_y, max_y; + bool valid; +}; + +struct SpawnParams { + double spawn_date; + WeaponType type; + WeaponMaterial material; + SDL_FPoint pos; + EnemyStats stats; +}; + + +struct EnemyMoveThreadData { + Enemy* enemy; + SDL_FPoint player; + bool is_moving; +}; + +enum class EnemyMovingType : uint32_t { + NONE, + IDLE, + CHARACTER, + OBJECT, + WALK, + LAST +}; +struct EnemyMovingLogic { + EnemyMovingType move_type = EnemyMovingType::NONE; + void* object = nullptr; + SDL_FPoint position = {0,0}; + bool position_changed = true; + float duration = 0.0f; + int max_distance = 120; + int min_distance = 80; + double path_blocked = 0; // time when blocked? + bool avoid_blockage = false; + SDL_FPoint moving_distance = {0,0}; +}; + +struct WorkerData { + Enemy* enemy; + std::shared_ptr<std::vector<bool>> grid; // use shared_ptr for safety +}; + +class Enemy { + static int id_next; + int id; + float speed; + float run; // multiplier + bool flip; + static size_t tile_size; + float arm_reach_radius; + + float detection_radius; + + public: + static SDL_FPoint colider_default; + static std::vector<Enemy*> enemies; + static std::vector<SpawnParams> enemies_to_spawn; + + + EnemyMovingLogic moving_logic = {EnemyMovingType::NONE, nullptr}; + + bool moving; + EnemyMovingType move_focus = EnemyMovingType::NONE; + float x, y; + SDL_FPoint next_position = {0,0}; + SDL_FRect collider; + + CollisionInterval last_object_collision = {0,0,0,0,false}; + bool avoiding_object = false; + SDL_FPoint avoidance_target = {0,0}; + std::vector<SDL_FPoint> avoidance_targets; + + Enemy* collidiing_with_enemy = nullptr; + + CollisionInterval last_map_collision = {0,0,0,0,false}; + bool avoiding_map = false; + + float dist_min = 24; + float dist_max = 32; + + bool is_character_in_range = false; + int stuck_moves = 0; + + std::vector<SDL_FPoint> next_moves; + SDL_Point last_player_pos{}; + SDL_Point last_target_pos{}; + + + AnimationData* active_anim; + static EnemyAnimation animation_all; + EnemyAnimation animation; + WalkDirection direction; + std::unordered_map<WalkDirection, bool> direction_blocked; + bool direction_tested_up; + bool direction_tested_left; + + EnemyStatus status; + + Weapon weapon; + + EnemyStats stats; + float max_death_time; + + float death_duration; + float death_duration_max; + + bool point_in_reach; + + Enemy(WeaponType weapon_type, + WeaponMaterial weapon_material, SDL_FPoint position, EnemyStats status); + + std::unordered_map<ResourceType,size_t> resources; + + SDL_FPoint collider_world; + SDL_Point tile_world; + std::vector<SDL_Point> tiles_in_reach; + + // START THREAD + static std::vector<SDL_Thread*> workers; + static std::vector<WorkerData> job_queue; + static std::mutex queue_mutex; + static std::condition_variable queue_cv; + + static bool stop_threads; + + // Job completion tracking + static int jobs_remaining; + static std::condition_variable jobs_done_cv; + + static void init_Workers(int num_threads); + static void shutdown_Workers(); + static void run_GetMovesThreads(); + // END THREAD + + + void + Init(); + static void + init_All(SDL_Renderer*); + + void + set_Status(const EnemyStatus&); + void + handle_Animation(); + + void + Draw(SDL_Renderer* renderer); + + static void + init_SpawnEnemy(double delay_to_spawn_in_sec, WeaponType weapon_type, WeaponMaterial weapon_material, SDL_FPoint position, EnemyStats status); + static bool + spawn_Enemy(SpawnParams&); + + static Enemy* + is_InEnemyReach(const SDL_FRect& rect); + + void + Decide(Character& player); + + bool + set_CollisinnWithEnemy(const SDL_FRect& rect); + + static bool + is_CollidingWithEnemy(const SDL_FRect& rect); + + bool + is_CollidingWithObjects(const SDL_FRect& rect); + + bool + is_CollidingWithWorld(const SDL_FRect& rect); + + bool + is_Colliding(const SDL_FRect& rect); + + inline bool character_InRange(SDL_FPoint char_pos) const; + + void + compute_MapCollisionInterval(size_t cx, size_t cy, size_t max_x, size_t max_y); + + void death(); + + static void remove_Dead(); + + // void // OLD?? + // move_ToPosition(SDL_FPoint move_to_position); + + void + set_AlignPosition(const SDL_FPoint& player); + + void + set_NextMoves(const std::vector<bool>& map_tiles); + + void + move_Path(); + + void + set_MoveLogic(EnemyMovingType&, Character& player); + + void + Update(Character& player); + + void + attack_Start(); + + void + Attack(bool in_reach); + + void + attack_Stop(); + + void + getting_Hit(float demage); + + void + set_TilesInReach(); + + + + + static bool + save_All(const std::string &path); + static bool + load_All(const std::string &path); +}; diff --git a/src/character/message.cpp b/src/character/message.cpp new file mode 100644 index 0000000..3bcac07 --- /dev/null +++ b/src/character/message.cpp @@ -0,0 +1,424 @@ +#include "character/message.hpp" + +#include <iostream> + +#include "defaults/ui.hpp" +#include "map/map.hpp" +#include "game/game.hpp" +#include "inventory/inventory.hpp" + +#define TOP_RIGHT_ICON_BG 180, 180, 180 + +Messages::Messages() { + messages.clear(); + messages_data = { + {MessageKey::MOIN, {10, MessageType::CHARACTER, "I should collect some things.."}}, + {MessageKey::BUILDING_TOOL_REQUIRED, {5, MessageType::CHARACTER, "I need a building tool!"}}, + {MessageKey::PLAYER_EXHAUSTED, {5, MessageType::CHARACTER, "I am exhausted..."}}, + {MessageKey::DISCOVERED_RESOURCE, {5, MessageType::CHARACTER, "A new resource!"}}, + {MessageKey::DISCOVERED_VEGETABLE, {5, MessageType::CHARACTER, "A new vegetable!"}}, + {MessageKey::DISCOVERED_BUILDING, {5, MessageType::CHARACTER, "Maybe i can build something with it.."}}, + {MessageKey::THIRST_20, {10, MessageType::CHARACTER, "I should drink something.."}}, + {MessageKey::THIRST_0, {10, MessageType::CHARACTER, "No water no life.."}}, + {MessageKey::WATER_APPRECIATION, {5, MessageType::CHARACTER, "Hmmm water"}}, + {MessageKey::EAT_APPRECIATION, {5, MessageType::CHARACTER, "Omnjomnjom"}}, + {MessageKey::CRAFTED_ITEM, {10, MessageType::CHARACTER, "Whatever i can do with that.."}}, + {MessageKey::ADD_INVENTORY, {10, MessageType::INVENTORY, "Added item: "}}, + {MessageKey::ADD_RESOURCE, {10, MessageType::RESOURCE, "Resource "}}, + {MessageKey::ADD_VEGETABLE, {10, MessageType::VEGETABLE, "Vegetable "}}, + {MessageKey::ADD_VEGETABLE_SEED, {10, MessageType::VEGETABLE_SEED, "Seed "}}, + {MessageKey::NOTHING_TO_INTERACT, {4, MessageType::CHARACTER, "I cant find anything to interact with.."}}, + }; +} + +void Messages::Add(MessageKey key, void* type_data) { + auto base = messages_data.find(key); + if (base == messages_data.end()) + return; + + Message_s msg = base->second; + + msg.type_data = type_data; + + if (msg.message_type == MessageType::INVENTORY) { + size_t* id_ptr = static_cast<size_t*>(msg.type_data); + std::cout << "ADD ID: " << *id_ptr << std::endl; + messages.emplace(key, msg); + return; + } + + if (msg.message_type == MessageType::RESOURCE) { + ResourceType new_type = *static_cast<ResourceType*>(msg.type_data); + auto range = messages.equal_range(key); + for (auto it = range.first; it != range.second; ) { + if (it->second.message_type == MessageType::RESOURCE) { + ResourceType old_type = *static_cast<ResourceType*>(it->second.type_data); + if (old_type == new_type) { + it = messages.erase(it); + continue; + } + } + ++it; + } + + messages.emplace(key, msg); + return; + } + + if (msg.message_type == MessageType::VEGETABLE) { + ResourceType new_type = *static_cast<ResourceType*>(msg.type_data); + auto range = messages.equal_range(key); + for (auto it = range.first; it != range.second; ) { + if (it->second.message_type == MessageType::VEGETABLE) { + ResourceType old_type = *static_cast<ResourceType*>(it->second.type_data); + if (old_type == new_type) { + it = messages.erase(it); + continue; + } + } + ++it; + } + + messages.emplace(key, msg); + return; + } + + auto range = messages.equal_range(key); + for (auto it = range.first; it != range.second; ) { + it = messages.erase(it); + } + + messages.emplace(key, msg); +} + +void +Messages::Update() { + for (auto it = messages.begin(); it != messages.end(); ) { + Message_s &msg = it->second; + + msg.duration -= Default::delta_time; + + if (msg.duration <= 0.0f) { + /* + if (msg.message_type == MessageType::VEGETABLE) + delete static_cast<VegetableData::Type*>(msg.type_data); + else + */ + if (msg.message_type == MessageType::RESOURCE) + delete static_cast<ResourceType*>(msg.type_data); + else + if (msg.message_type == MessageType::INVENTORY) + delete static_cast<size_t*>(msg.type_data); + else + if (msg.message_type == MessageType::VEGETABLE) + delete static_cast<ResourceType*>(msg.type_data); + it = messages.erase(it); + continue; + } + ++it; + } +} + + +void +Messages::Render(SDL_Renderer* renderer, float center_x, float start_y) { + if (!messages.empty() && Ui::font_tiny) { + const float row_h = 14.0f; + + // Stable iteration order + std::vector<MessageKey> keys; + keys.reserve(messages.size()); + for (const auto &kv : messages) + keys.push_back(kv.first); + + + for (size_t i = 0; i < keys.size(); ) { + + MessageKey key = keys[i]; + auto it = messages.find(key); + if (it == messages.end()) { + ++i; + continue; + } + + Message_s &msg = it->second; + + if (msg.message_type == MessageType::INVENTORY || + msg.message_type == MessageType::RESOURCE || + msg.message_type == MessageType::VEGETABLE) { + ++i; + continue; + } + + + // Render message + SDL_Color col{255, 255, 255, 255}; + SDL_Surface* surf = + TTF_RenderText_Blended(Ui::font_message, msg.message.c_str(), msg.message.length(), col); + SDL_Surface* surf_bg = + TTF_RenderText_Blended(Ui::font_message, msg.message.c_str(), msg.message.length(), {126,126,126,164}); + + if (surf && surf_bg) { + SDL_Texture* tex = SDL_CreateTextureFromSurface(renderer, surf); + SDL_Texture* tex_bg = SDL_CreateTextureFromSurface(renderer, surf_bg); + if (tex && tex_bg) { + + + SDL_FRect dst{ + Scale(center_x + Map::offset.x) - (surf->w * 0.5f), + Scale(start_y + Map::offset.y + 22.0f), + (float)surf->w, + (float)surf->h + }; + + SDL_FRect dst_bg = dst; + dst_bg.x -= 1; + dst_bg.y -= 1; + + SDL_RenderTexture(renderer, tex, nullptr, &dst); + SDL_RenderTexture(renderer, tex_bg, nullptr, &dst_bg); + SDL_DestroyTexture(tex); + SDL_DestroyTexture(tex_bg); + } + SDL_DestroySurface(surf); + SDL_DestroySurface(surf_bg); + } + + start_y -= row_h; + ++i; + } + } +} + +void Messages::render_InventoryMessages(Game* game, Inventory* inventory) { + if (messages.empty() || !Ui::font_menu) + return; + + const float bar_padding = 6.0f; + const float bar_height_min = 48.0f; + const float icon_bg_size = 48.0f; + const float right_margin = 10.0f; + const float spacing = 6.0f; + + // Collect inventory messages + std::vector<const Message_s*> inv_msgs; + inv_msgs.reserve(messages.size()); + + for (auto &kv : messages) { + if ( kv.second.message_type == MessageType::INVENTORY || + kv.second.message_type == MessageType::RESOURCE || + kv.second.message_type == MessageType::VEGETABLE || + kv.second.message_type == MessageType::VEGETABLE_SEED) + inv_msgs.push_back(&kv.second); + } + if (inv_msgs.empty()) + return; + + // Sort by remaining duration + std::sort(inv_msgs.begin(), inv_msgs.end(), + [](const Message_s* a, const Message_s* b){ + return a->duration > b->duration; + }); + + // Measure max text width + float max_text_w = 0.0f; + for (const Message_s* msg : inv_msgs) { + std::string text ; + if (msg->message_type == MessageType::INVENTORY) { + size_t id = *static_cast<size_t*>(msg->type_data); + // std::cout << "IDDD: " << id << " " << inventory->items.size() << " " << inventory->items.front()->id << std::endl; + InventoryItem* item = inventory->get_ItemById(id); + + if (!item) continue; + + text = "Added item: " + Item::to_String(item->type); + } else + if (msg->message_type == MessageType::RESOURCE) { + ResourceType* rt = static_cast<ResourceType*>(msg->type_data); + ResourceType type = *rt; + int amount = inventory->resources[type]; + text = std::to_string(amount); + } + else + if (msg->message_type == MessageType::VEGETABLE) { + VegetableData::Type* vtype = static_cast<VegetableData::Type*>(msg->type_data); + auto it = inventory->vegetables.find(*vtype); + int amount = 0; + if (it != inventory->vegetables.end()) + amount = it->second.count; + text = std::to_string(amount); + } + else + if (msg->message_type == MessageType::VEGETABLE_SEED) { + VegetableData::Type* vtype = static_cast<VegetableData::Type*>(msg->type_data); + auto it = inventory->seeds.find(*vtype); + int amount = 0; + if (it != inventory->seeds.end()) + amount = it->second.count; + text = std::to_string(amount); + } + + SDL_Color col{255,255,255,255}; + SDL_Surface* surf = TTF_RenderText_Blended(Ui::font_menu, text.c_str(), text.length(), col); + if (surf) { + max_text_w = std::max(max_text_w, static_cast<float>(surf->w)); + SDL_DestroySurface(surf); + } + } + + float total_width = max_text_w + bar_padding * 2.0f + icon_bg_size + bar_padding; + float bar_x = (float)game->win_size.w - total_width - right_margin; + float y = 10.0f; + + // Render messages + for (const Message_s* msg : inv_msgs) { + InventoryItem* item = nullptr; + ResourceType* rtype = nullptr; + VegetableData::Type* vtype = nullptr; + bool is_seed = false; + + std::string text ; + if (msg->message_type == MessageType::INVENTORY) { + size_t id = *static_cast<size_t*>(msg->type_data); + item = inventory->get_ItemById(id); + if (!item) continue; + + text = "Added item: " + Item::to_String(item->type); + } else + if (msg->message_type == MessageType::RESOURCE) { + rtype = static_cast<ResourceType*>(msg->type_data); + int amount = inventory->resources[*rtype]; + text = std::to_string(amount); + } + else + if (msg->message_type == MessageType::VEGETABLE) { + vtype = static_cast<VegetableData::Type*>(msg->type_data); + auto it = inventory->vegetables.find(*vtype); + int amount = 0; + if (it != inventory->vegetables.end()) + amount = it->second.count; + text = std::to_string(amount); + } + else + if (msg->message_type == MessageType::VEGETABLE_SEED) { + is_seed = true; + vtype = static_cast<VegetableData::Type*>(msg->type_data); + auto it = inventory->seeds.find(*vtype); + int amount = 0; + if (it != inventory->seeds.end()) + amount = it->second.count; + text = std::to_string(amount); + } + + SDL_Color col{255,255,255,255}; + SDL_Surface* surf = TTF_RenderText_Blended(Ui::font_menu, text.c_str(), text.length(), col); + if (!surf) continue; + + SDL_Texture* tex = SDL_CreateTextureFromSurface(game->renderer, surf); + if (!tex) { + SDL_DestroySurface(surf); + continue; + } + + float text_w = surf->w; + float text_h = surf->h; + float bar_h = std::max(text_h + bar_padding * 2.0f, bar_height_min); + + SDL_FRect bar_rect{bar_x, y, total_width, bar_h}; + + // Bar background + SDL_SetRenderDrawBlendMode(game->renderer, SDL_BLENDMODE_BLEND); + SDL_SetRenderDrawColor(game->renderer, 30, 30, 30, 170); + SDL_RenderFillRect(game->renderer, &bar_rect); + SDL_SetRenderDrawColor(game->renderer, 90, 90, 90, 210); + SDL_RenderRect(game->renderer, &bar_rect); + + // Text + SDL_FRect dst_text{ + bar_x + bar_padding, + y + bar_padding + bar_height_min/2 - (text_h*0.75f), + text_w, + text_h + }; + SDL_RenderTexture(game->renderer, tex, nullptr, &dst_text); + + SDL_DestroyTexture(tex); + SDL_DestroySurface(surf); + + // Icon + // Determine which payload we have + + + // Now select the correct icon source + bool draw_icon = false; + SDL_FRect src; + + // ---- INVENTORY ITEM ---- + if (item && item->type != ItemType::NONE) { + auto it = Icon::item_pos.find(item->type); + if (it != Icon::item_pos.end()) { + src = SDL_FRect{ + it->second.x * 16.0f, + it->second.y * 16.0f, + 16.0f, + 16.0f + }; + draw_icon = true; + } + } + + // ---- RESOURCE ---- + if (rtype && *rtype != ResourceType::NONE) { + auto it = Icon::resource_pos.find(*rtype); + if (it != Icon::resource_pos.end()) { + src = SDL_FRect{ + it->second.x * 16.0f, + it->second.y * 16.0f, + 16.0f, + 16.0f + }; + draw_icon = true; + } + } + + // ---- VEGETABLE ---- + if (vtype && *vtype != VegetableData::Type::NONE) { + SDL_Point pos = VegetableData::get_IconTilePosByType(*vtype, is_seed); + src = SDL_FRect{ + pos.x * 16.0f, + pos.y * 16.0f, + 16.0f, + 16.0f + }; + draw_icon = true; + } + + // ---- DRAW IF AVAILABLE ---- + if (draw_icon) { + SDL_FRect icon_bg{ + bar_x + total_width - icon_bg_size - bar_padding, + y + (bar_h - icon_bg_size) * 0.5f, + icon_bg_size, + icon_bg_size + }; + + SDL_SetRenderDrawColor(game->renderer, TOP_RIGHT_ICON_BG, 180); + SDL_RenderFillRect(game->renderer, &icon_bg); + + SDL_SetRenderDrawColor(game->renderer, 0, 0, 0, 255); + SDL_RenderRect(game->renderer, &icon_bg); + + SDL_FRect dst{ + icon_bg.x, + icon_bg.y, + icon_bg_size, + icon_bg_size + }; + + SDL_RenderTexture(game->renderer, Icon::icons_texture, &src, &dst); + } + + + y += bar_h + spacing; + } +} diff --git a/src/character/message.hpp b/src/character/message.hpp new file mode 100644 index 0000000..f93752f --- /dev/null +++ b/src/character/message.hpp @@ -0,0 +1,56 @@ +#pragma once + +#include "defaults/defaults.hpp" +#include "resource/resource_data.hpp" +#include <string> +#include <unordered_map> + +class Game; +class Inventory; + +enum class MessageType { + CHARACTER, + DISCOVERY, + INVENTORY, + RESOURCE, + VEGETABLE, + VEGETABLE_SEED, +}; + +struct Message_s { + float duration = 0; + MessageType message_type = MessageType::CHARACTER; + std::string message = ""; + void* type_data = nullptr; +}; + +enum class MessageKey { + MOIN, + BUILDING_TOOL_REQUIRED, + PLAYER_EXHAUSTED, + DISCOVERED_RESOURCE, + DISCOVERED_VEGETABLE, + DISCOVERED_BUILDING, + THIRST_20, + THIRST_0, + WATER_APPRECIATION, + EAT_APPRECIATION, + CRAFTED_ITEM, + ADD_INVENTORY, + ADD_RESOURCE, + ADD_VEGETABLE, + ADD_VEGETABLE_SEED, + NOTHING_TO_INTERACT, +}; + +class Messages { + public: + std::unordered_multimap<MessageKey, Message_s> messages; + std::unordered_map<MessageKey, Message_s> messages_data; + + Messages(); + void Add(MessageKey, void* type_data = nullptr); + void Update(); + void Render(SDL_Renderer*, float center_x, float start_y); + void render_InventoryMessages(Game*, Inventory* inventory); +}; diff --git a/src/cursor/animated_cursor.cpp b/src/cursor/animated_cursor.cpp new file mode 100644 index 0000000..29b3467 --- /dev/null +++ b/src/cursor/animated_cursor.cpp @@ -0,0 +1,283 @@ +// g++ -std=c++23 -O2 -Wall -Wextra animated_cursor.hpp.cpp $(pkg-config --cflags --libs sdl3 sdl3-image) -o cursor_particles && ./cursor_particles + +#include <SDL3/SDL.h> +#include <SDL3_image/SDL_image.h> +#include <vector> +#include <algorithm> +#include <random> +#include <cmath> +#include <print> + +#include "cursor/animated_cursor.hpp" + + +AnimatedCursor::AnimatedCursor() : spriteTexture(nullptr), + spriteSurface(nullptr), isReversing(false), reverseProgress(0.0f), + time(0.0f), clickX(400.0f), clickY(300.0f), + currentFrame(0), isPlayingAnimation(false), mouseX(400.0f), mouseY(300.0f) {} + + AnimatedCursor::~AnimatedCursor() { + Cleanup(); + } + +bool AnimatedCursor::Init(SDL_Renderer* renderer, const char* filename) { + spriteSurface = IMG_Load(filename); + if (!spriteSurface) { + SDL_Log("IMG_Load failed: %s", SDL_GetError()); + return false; + } + + spriteTexture = SDL_CreateTextureFromSurface(renderer, spriteSurface); + if (!spriteTexture) { + SDL_Log("SDL_CreateTextureFromSurface failed: %s", SDL_GetError()); + return false; + } + + frame_ExtractFirst(); + return true; +} + +void AnimatedCursor::set_State(const CursorState& state_new) { + std::print("MOUSE STATE {0}\n", (int)state_new); + + bool is_visible = SDL_CursorVisible(); + if (state == CursorState::ANIMATED || state == CursorState::HIDDEN) { + if (is_visible && !isReversing) + SDL_HideCursor(); + } else if (state == CursorState::NORMAL){ + if (!is_visible) + SDL_ShowCursor(); + } + state = state_new; +} + +void AnimatedCursor::frame_ExtractFirst() { + pixels.clear(); + allFrames.clear(); + allFrames.resize(TOTAL_FRAMES); + + // Lock surface for pixel access + SDL_LockSurface(spriteSurface); + Uint32* surfacePixels = (Uint32*)spriteSurface->pixels; + int pitch = spriteSurface->pitch / 4; + + const SDL_PixelFormatDetails* details = + SDL_GetPixelFormatDetails(spriteSurface->format); + if (!details) { + SDL_UnlockSurface(spriteSurface); + return; + } + + // Extract non-transparent pixels from all 8 frames + for (size_t frame = 0; frame < TOTAL_FRAMES; frame++) { + int frameOffsetX = static_cast<int>(frame) * FRAME_WIDTH; + + for (int y = 0; y < FRAME_HEIGHT; y++) { + for (int x = 0; x < FRAME_WIDTH; x++) { + Uint32 pixel = surfacePixels[y * pitch + (frameOffsetX + x)]; + Uint8 r, g, b, a; + SDL_GetRGBA(pixel, details, NULL, &r, &g, &b, &a); + + if (a > 0) { // Non-transparent pixel + Pixel p; + p.srcX = x; + p.srcY = y; + p.originalColor = {r, g, b, a}; + allFrames[frame].push_back(p); + } + } + } + } + + SDL_UnlockSurface(spriteSurface); + + // Start with first frame + pixels = allFrames[0]; + currentFrame = 0; + + // Generate shuffled positions and colors + state_GenerateShuffle(); +} + +void AnimatedCursor::state_GenerateShuffle() { + std::random_device rd; + std::mt19937 gen(rd()); + std::uniform_real_distribution<float> angleDist(0.0f, 2.0f * M_PI); + std::uniform_real_distribution<float> radiusDist(0.0f, SPHERE_RADIUS); + std::uniform_real_distribution<float> speedDist(0.3f, 4.5f); + std::uniform_int_distribution<> colorDist(0, 255); + + // Initialize each pixel with random position and movement + for (auto& p : pixels) { + // Initial position in sphere + p.currentAngle = angleDist(gen); + p.currentRadius = radiusDist(gen); + + // Target for smooth movement + p.targetAngle = angleDist(gen); + p.targetRadius = radiusDist(gen); + + // Random movement speeds + p.angleSpeed = speedDist(gen); + p.radiusSpeed = speedDist(gen) * 0.5f; + + // Generate random shuffled color + p.shuffledColor = { + (Uint8)colorDist(gen), + (Uint8)colorDist(gen), + (Uint8)colorDist(gen), + p.originalColor.a + }; + } +} + +SDL_Color lerpColor(const SDL_Color& a, const SDL_Color& b, float t) { + return { + (Uint8)(a.r + (b.r - a.r) * t), + (Uint8)(a.g + (b.g - a.g) * t), + (Uint8)(a.b + (b.b - a.b) * t), + (Uint8)(a.a + (b.a - a.a) * t) + }; +} + +void AnimatedCursor::Render(SDL_Renderer* renderer) { + if (state != CursorState::ANIMATED && !isReversing) return; + SDL_SetRenderDrawColor(renderer, 20, 20, 30, 255); + + // Calculate current state based on reverse progress + float progress = isReversing ? reverseProgress : 0.0f; + + // Ease function for smooth animation + float eased = progress * progress * (3.0f - 2.0f * progress); // Smoothstep + + // Position where animation happens (click position or following mouse) + // float centerX = isReversing ? clickX : mouseX; + // float centerY = isReversing ? clickY : mouseY; + float centerX = mouseX; + float centerY = mouseY; + + for (const auto& p : pixels) { + // Calculate position in sphere + float sphereX = centerX + cos(p.currentAngle) * p.currentRadius; + float sphereY = centerY + sin(p.currentAngle) * p.currentRadius; + + // Interpolate position + int x, y; + if (isReversing) { + // During animation: sphere -> sprite at click position + x = (int)(sphereX + (centerX - FRAME_WIDTH/2 + p.srcX - sphereX) * eased); + y = (int)(sphereY + (centerY - FRAME_HEIGHT/2 + p.srcY - sphereY) * eased); + } else { + // Shuffled state (sphere following mouse) + x = (int)sphereX; + y = (int)sphereY; + } + + // Interpolate color + SDL_Color color; + if (isReversing) { + color = lerpColor(p.shuffledColor, p.originalColor, eased); + } else { + color = p.shuffledColor; + } + + SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, color.a); + SDL_RenderPoint(renderer, x, y); + } + +} + +void AnimatedCursor::Update(float deltaTime, float mx, float my) { + if (state != CursorState::ANIMATED && !isReversing) return; + mouseX = mx; mouseY = my; + time += deltaTime; + + // Update pixel positions (movement within sphere) + if (!isReversing) { + std::random_device rd; + std::mt19937 gen(rd()); + std::uniform_real_distribution<float> angleDist(0.0f, 2.0f * M_PI); + std::uniform_real_distribution<float> radiusDist(0.0f, SPHERE_RADIUS); + + for (auto& p : pixels) { + // Smoothly move toward target + float angleDiff = p.targetAngle - p.currentAngle; + // Normalize angle difference to [-PI, PI] + while (angleDiff > M_PI) angleDiff -= 2.0f * M_PI; + while (angleDiff < -M_PI) angleDiff += 2.0f * M_PI; + + p.currentAngle += angleDiff * p.angleSpeed * deltaTime; + p.currentRadius += (p.targetRadius - p.currentRadius) * p.radiusSpeed * deltaTime; + + // Check if close to target, if so pick new target + if (fabs(angleDiff) < 0.1f && fabs(p.targetRadius - p.currentRadius) < 1.0f) { + p.targetAngle = angleDist(gen); + p.targetRadius = radiusDist(gen); + } + } + } + + // Handle reverse animation and frame playback + if (isReversing) { + reverseProgress += deltaTime / ANIMATION_DURATION; + + if (reverseProgress >= 0.2f) { + // Unshuffle complete, now play through frames + if (!isPlayingAnimation) { + isPlayingAnimation = true; + currentFrame = 0; + reverseProgress = 0.0f; + } + } + + // Play through animation frames + if (isPlayingAnimation) { + // Play all 8 frames over remaining time + float frameTime = ANIMATION_DURATION / TOTAL_FRAMES; + currentFrame = (int)(reverseProgress / frameTime); + + if (currentFrame >= (int)TOTAL_FRAMES) { + // Animation complete, go back to frame 0 and reshuffle + currentFrame = 0; + pixels = allFrames[0]; + state_GenerateShuffle(); + isReversing = false; + isPlayingAnimation = false; + reverseProgress = 0.0f; + } else { + // Switch to current frame + if (currentFrame < (int)TOTAL_FRAMES && currentFrame >= 0) { + pixels = allFrames[(size_t)currentFrame]; + // Keep the shuffle state for smooth transition + for (size_t i = 0; i < pixels.size() && i < allFrames[0].size(); i++) { + pixels[i].currentAngle = allFrames[0][i].currentAngle; + pixels[i].currentRadius = allFrames[0][i].currentRadius; + pixels[i].targetAngle = allFrames[0][i].targetAngle; + pixels[i].targetRadius = allFrames[0][i].targetRadius; + pixels[i].angleSpeed = allFrames[0][i].angleSpeed; + pixels[i].radiusSpeed = allFrames[0][i].radiusSpeed; + pixels[i].shuffledColor = allFrames[0][i].shuffledColor; + } + } + } + + reverseProgress += deltaTime / ANIMATION_DURATION; + } + } +} + +void AnimatedCursor::mouse_OnClick() { + if (state != CursorState::ANIMATED) return; + if (isReversing) return; + + isReversing = true; + reverseProgress = 0.0f; + clickX = mouseX; + clickY = mouseY; +} + + +void AnimatedCursor::Cleanup() { + if (spriteTexture) SDL_DestroyTexture(spriteTexture); + if (spriteSurface) SDL_DestroySurface(spriteSurface); +} diff --git a/src/cursor/animated_cursor.hpp b/src/cursor/animated_cursor.hpp new file mode 100644 index 0000000..7d960d5 --- /dev/null +++ b/src/cursor/animated_cursor.hpp @@ -0,0 +1,75 @@ +// g++ -std=c++23 -O2 -Wall -Wextra animated_cursor.hpp.cpp $(pkg-config --cflags --libs sdl3 sdl3-image) -o cursor_particles && ./cursor_particles + +#pragma once + +#include <SDL3/SDL.h> +#include <SDL3_image/SDL_image.h> +#include <vector> +#include <algorithm> +#include <random> +#include <cmath> + + + +enum class CursorState : uint32_t { + NORMAL, + ANIMATED, + HIDDEN +}; + +struct Pixel { + int srcX, srcY; + float currentAngle; // Current angle in sphere + float currentRadius; // Current radius in sphere + float targetAngle; // Target angle for movement + float targetRadius; // Target radius for movement + float angleSpeed; // Speed of angle change + float radiusSpeed; // Speed of radius change + SDL_Color originalColor; + SDL_Color shuffledColor; +}; + +class AnimatedCursor { +private: + SDL_Texture* spriteTexture; + SDL_Surface* spriteSurface; + + std::vector<Pixel> pixels; + std::vector<std::vector<Pixel>> allFrames; // Store all 8 frames + bool isReversing; + float reverseProgress; + float time; // For continuous animation + float clickX, clickY; // Position where click happened + int currentFrame; // 0-7 for the 8 frames + bool isPlayingAnimation; // True when playing through frames + + const int FRAME_WIDTH = 64; // 512 / 8 frames + const int FRAME_HEIGHT = 64; + const int SPHERE_RADIUS = 16; // 32px diameter sphere + const size_t TOTAL_FRAMES = 8; + const float ANIMATION_DURATION = 1.2f; // Total time for unshuffle + frame play + +public: + CursorState state = CursorState::NORMAL; + float mouseX, mouseY; // Sphere follows cursor + AnimatedCursor(); + + ~AnimatedCursor(); + + bool Init(SDL_Renderer* renderer, const char* filename); + + void set_State(const CursorState& state_new); + + void frame_ExtractFirst(); + + void state_GenerateShuffle(); + + void Render(SDL_Renderer* renderer); + + void Update(float deltaTime, float mx, float my); + + void mouse_OnClick(); + + + void Cleanup(); +}; diff --git a/src/defaults/defaults.cpp b/src/defaults/defaults.cpp new file mode 100644 index 0000000..cbdfd92 --- /dev/null +++ b/src/defaults/defaults.cpp @@ -0,0 +1,55 @@ +#include "defaults/defaults.hpp" + +#include <iostream> + +namespace Default { + // States + ModifyState_s modify_state = MODIFY_TILES; + + // Time + double delta_time = 0.0; + Uint64 now; + Uint64 last; + + Uint64 game_time_start = 0; + Uint64 game_time_running = 0; + Uint64 game_time_paused = 0; + Uint64 game_time_pause_start = 0; + + + float fps_timer = 0.0f; + int fps = 0; + int fps_counter = 0; + + float game_scale; + + bool is_fullscreen = false; + + SDL_Color menu_hovering_color = {255, 255, 100, 160}; + + void set_DeltaTime() { + last = now; + now = SDL_GetPerformanceCounter(); + delta_time = static_cast<double>((now - last)) / SDL_GetPerformanceFrequency(); + } + + + double get_TimeSinceStartInSec() { + double elapsed = (SDL_GetTicksNS() - game_time_start) * 1e-9; + return elapsed - game_time_paused; + } + + + const char* get_ModifyStateName() { + switch (modify_state) { + case MODIFY_TILES: return "Tiles"; + case MODIFY_COLLISSION: return "Collision"; + case MODIFY_FLOOR_TYPE: return "Floor Type"; + case MODIFY_OBJECTS: return "Objects"; + case MODIFY_OBJECTS_PROPS: return "Objects Properties"; + case MODIFY_OBJECTS_PROPS_RESOURCE: return "Objects Properties Resource"; + default: return "Unknown"; + } + } +} + diff --git a/src/defaults/defaults.hpp b/src/defaults/defaults.hpp new file mode 100644 index 0000000..fd9b6b0 --- /dev/null +++ b/src/defaults/defaults.hpp @@ -0,0 +1,57 @@ +#pragma once +#include <SDL3/SDL.h> + +#include <vector> +#include <stddef.h> + +enum class WalkDirection { + UP, + LEFT, + RIGHT, + SIDE, + DOWN +}; + +// Game states +enum ModifyState_s { + MODIFY_FIRST, + MODIFY_TILES, + MODIFY_COLLISSION, + MODIFY_FLOOR_TYPE, + MODIFY_OBJECTS, + MODIFY_OBJECTS_PROPS, + MODIFY_OBJECTS_PROPS_RESOURCE, + MODIFY_LAST +}; + +namespace Default { + extern ModifyState_s modify_state; + extern double delta_time; + extern Uint64 now; + extern Uint64 last; + extern float game_scale; + extern float fps_timer; + extern int fps; + extern int fps_counter; + + extern bool is_fullscreen; + + extern Uint64 game_time_start; + extern Uint64 game_time_running; + extern Uint64 game_time_paused; + extern Uint64 game_time_pause_start; + + extern SDL_Color menu_hovering_color; + + void set_DeltaTime(); + + double get_TimeSinceStartInSec(); + + const char* get_ModifyStateName(); +} + + + +inline float Scale(float i) { + return i*Default::game_scale; +} diff --git a/src/defaults/icons.cpp b/src/defaults/icons.cpp new file mode 100644 index 0000000..ff078e9 --- /dev/null +++ b/src/defaults/icons.cpp @@ -0,0 +1,80 @@ +#include "defaults/icons.hpp" + +#include <SDL3_image/SDL_image.h> + +#include <iostream> + +SDL_Texture* Icon::icons_texture = nullptr; + +std::unordered_map<ResourceType, Icon::TilePos> Icon::resource_pos = { + { ResourceType::WOOD, {0, 0} }, + { ResourceType::STONE,{1, 0} }, + { ResourceType::CLAY, {2, 0} }, + { ResourceType::IRON, {3, 0} } + // the rest filled in init() +}; + +std::unordered_map<ItemType, Icon::TilePos> Icon::item_pos = { + { ItemType::SWORD_WOOD, {7, 0} }, + { ItemType::SWORD_STONE, {7, 0} }, + { ItemType::PICKAXE_STONE, {16,0} }, + { ItemType::WOODAXE_STONE, {16,1} }, + { ItemType::BUILDING_TOOL, {15,0} }, + { ItemType::CULTIVATOR, {15,1} } + // the rest filled in init() +}; + +std::unordered_map<BuildingType, Icon::TilePos> Icon::building_pos = { + { BuildingType::RESEARCH_WOOD_1, {11, 0} }, + { BuildingType::CRAFTING_WOOD_1, {12, 0} }, + { BuildingType::RESEARCH_STONE_1, {11, 1} }, + { BuildingType::CRAFTING_STONE_1, {12, 1} }, + { BuildingType::RESEARCH_IRON_1, {11, 2} }, + { BuildingType::CRAFTING_IRON_1, {12, 2} }, + // the rest filled in init() +}; + +std::unordered_map<IconType, Icon::TilePos> Icon::icon_pos = { + { IconType::CHECKMARK, {0, 24} }, +}; + +bool +Icon::Init(SDL_Renderer* renderer) { + const char* file = "Pixel_Crawler/Icons/Icons.png"; + if(!renderer || !file) { + std::cerr << "MISSING ICONS.png\n"; + return false; + } + + icons_texture = IMG_LoadTexture(renderer, file); + if(!icons_texture) { + std::cout << "Failed to create texture!\n"; + return false; + } + + // defaults for resources + for(int i = (int)ResourceType::NONE; i < (int)ResourceType::LAST; ++i) { + ResourceType t = (ResourceType)i; + if(resource_pos.find(t) == resource_pos.end()) { + resource_pos[t] = {0, 1}; + } + } + + // defaults for items + for(int i = (int)ItemType::SWORD_WOOD; i <= (int)ItemType::NONE; ++i) { + ItemType t = (ItemType)i; + if(item_pos.find(t) == item_pos.end()) { + item_pos[t] = {0, 1}; + } + } + + return true; +} + +void +Icon::Quit() { + if(icons_texture) { + SDL_DestroyTexture(icons_texture); + icons_texture = nullptr; + } +} diff --git a/src/defaults/icons.hpp b/src/defaults/icons.hpp new file mode 100644 index 0000000..92f048b --- /dev/null +++ b/src/defaults/icons.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include <SDL3/SDL.h> + +#include "inventory/item.hpp" + +#include <unordered_map> + +enum class IconType { + CHECKMARK +}; + +namespace Icon { + + struct TilePos { + int x; + int y; + }; + + extern SDL_Texture* icons_texture; + extern std::unordered_map<ResourceType, TilePos> resource_pos; + extern std::unordered_map<ItemType, TilePos> item_pos; + extern std::unordered_map<BuildingType, TilePos> building_pos; + extern std::unordered_map<IconType, TilePos> icon_pos; + + bool Init(SDL_Renderer* renderer); + void Quit(); + +} diff --git a/src/defaults/input.cpp b/src/defaults/input.cpp new file mode 100644 index 0000000..7c8ef68 --- /dev/null +++ b/src/defaults/input.cpp @@ -0,0 +1,20 @@ +#include "defaults/input.hpp" + +#include "map/tile.hpp" +#include "character/character.hpp" +#include "map/map.hpp" +#include "defaults/ui.hpp" +#include "building/building.hpp" +#include "character/character.hpp" +#include "building/research.hpp" + + +void +Input::update_Mousetileposition() { + // set mouse tile position after while loop as im calling an important function there (lateron..) + size_t selection_size = Tile::get_SelectionSize(Default::modify_state); + mouse_tile_position = { + static_cast<int>((Input::mouse_state.x - mouse_game_offset.x) / selection_size), + static_cast<int>((Input::mouse_state.y - mouse_game_offset.y) / selection_size) + }; +} diff --git a/src/defaults/input.hpp b/src/defaults/input.hpp new file mode 100644 index 0000000..f1a5636 --- /dev/null +++ b/src/defaults/input.hpp @@ -0,0 +1,40 @@ +#pragma once + +#include <SDL3/SDL.h> +#include <iostream> +#include "defaults/defaults.hpp" +#include "cursor/animated_cursor.hpp" + +class Character; + + +class Input { + public: + + bool game_running = true; + bool game_restart = true; + bool click_left = false; + bool click_left_released = false; + bool click_right = false; + bool click_right_released = false; + bool clicked_on_map = false; + bool pressed_shift = false; + bool pressed_ctrl = false; + bool pressed_c = false; + bool pressed_c_released = false; + bool pressed_return = false; + bool pressed_return_released = false; + bool pressed_arrowdown_released = false; + bool pressed_arrowup_released = false; + AnimatedCursor* cursor; + SDL_FPoint mouse_state; + SDL_FPoint mouse_state_raw; + SDL_Point mouse_game_offset; + SDL_Point mouse_tile_position; + bool cursor_over_tileset; + + void update_Mousetileposition(); + //void event_InputModify(SDL_Event& event); + //void event_InputPlay (SDL_Event& event, Character& player); + //void event_Input(SDL_Window* window, SDL_Rect& win_size); +}; diff --git a/src/defaults/shuffle_texture.hpp b/src/defaults/shuffle_texture.hpp new file mode 100644 index 0000000..3dab3af --- /dev/null +++ b/src/defaults/shuffle_texture.hpp @@ -0,0 +1,183 @@ +#pragma once +#include <SDL3/SDL.h> +#include <SDL3_image/SDL_image.h> +#include <iostream> +#include <vector> +#include <random> +#include <algorithm> + +class PixelShuffler { +private: + SDL_Renderer* renderer; + SDL_Surface* surface; + SDL_Texture* texture; + // Store each shuffle step as a list of swaps + struct Swap { + int x1, y1, x2, y2; + }; + std::vector<std::vector<Swap>> shuffleHistory; // Each shuffle creates a list of swaps + std::mt19937 rng; + + +public: + PixelShuffler(SDL_Renderer* r, SDL_Surface* surf) : renderer(r), surface(surf), rng(std::random_device{}()) { + } + + // Get pixel at position (x, y) + Uint32 getPixel(int x, int y) { + if (x < 0 || x >= surface->w || y < 0 || y >= surface->h) { + return 0; + } + + Uint8* pixels = (Uint8*)surface->pixels; + int bpp = SDL_BYTESPERPIXEL(surface->format); + Uint8* pixel = pixels + y * surface->pitch + x * bpp; + + switch (bpp) { + case 1: + return *pixel; + case 2: + return *(Uint16*)pixel; + case 3: + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) + return ((Uint32)pixel[0] << 16) + | ((Uint32)pixel[1] << 8) + | (Uint32)pixel[2]; + else + return (Uint32)pixel[0] + | ((Uint32)pixel[1] << 8) + | ((Uint32)pixel[2] << 16); + case 4: + return *(Uint32*)pixel; + default: + return 0; + } + } + + // Set pixel at position (x, y) + void setPixel(int x, int y, Uint32 color) { + if (x < 0 || x >= surface->w || y < 0 || y >= surface->h) { + return; + } + + Uint8* pixels = (Uint8*)surface->pixels; + int bpp = SDL_BYTESPERPIXEL(surface->format); + Uint8* pixel = pixels + y * surface->pitch + x * bpp; + + switch (bpp) { + case 1: + *pixel = color; + break; + case 2: + *(Uint16*)pixel = color; + break; + case 3: + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { + pixel[0] = (color >> 16) & 0xff; + pixel[1] = (color >> 8) & 0xff; + pixel[2] = color & 0xff; + } else { + pixel[0] = color & 0xff; + pixel[1] = (color >> 8) & 0xff; + pixel[2] = (color >> 16) & 0xff; + } + break; + case 4: + *(Uint32*)pixel = color; + break; + } + } + + // Shuffle pixels by swapping each pixel with a random neighbor + void shufflePixels() { + SDL_LockSurface(surface); + + int width = surface->w; + int height = surface->h; + + std::vector<Swap> currentShuffleSwaps; + + // For each pixel, swap with a random neighbor + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + // Get random neighbor direction (0=right, 1=down, 2=left, 3=up) + int direction = rng() % 4; + int nx = x, ny = y; + + switch (direction) { + case 0: nx = (x + 1) % width; break; + case 1: ny = (y + 1) % height; break; + case 2: nx = (x - 1 + width) % width; break; + case 3: ny = (y - 1 + height) % height; break; + } + + // Only swap if neighbor is valid + if (nx >= 0 && nx < width && ny >= 0 && ny < height) { + // Swap pixels + Uint32 pixel1 = getPixel(x, y); + Uint32 pixel2 = getPixel(nx, ny); + setPixel(x, y, pixel2); + setPixel(nx, ny, pixel1); + + // Record this swap + currentShuffleSwaps.push_back({x, y, nx, ny}); + } + } + } + + // Add this shuffle to history + shuffleHistory.push_back(currentShuffleSwaps); + + SDL_UnlockSurface(surface); + texture = SDL_CreateTextureFromSurface(renderer, getSurface()); + } + + // Unshuffle by reversing the last shuffle step + bool unshuffleStep() { + if (shuffleHistory.empty()) { + return false; // Nothing to unshuffle + } + + SDL_LockSurface(surface); + + // Get the last shuffle + std::vector<Swap>& lastShuffle = shuffleHistory.back(); + + // Reverse the swaps in reverse order + for (auto it = lastShuffle.rbegin(); it != lastShuffle.rend(); ++it) { + const Swap& swap = *it; + + // Swap back + Uint32 pixel1 = getPixel(swap.x1, swap.y1); + Uint32 pixel2 = getPixel(swap.x2, swap.y2); + setPixel(swap.x1, swap.y1, pixel2); + setPixel(swap.x2, swap.y2, pixel1); + } + + // Remove this shuffle from history + shuffleHistory.pop_back(); + + SDL_UnlockSurface(surface); + texture = SDL_CreateTextureFromSurface(renderer, getSurface()); + return true; + } + + // Check if there are shuffles to undo + bool canUnshuffle() const { + return !shuffleHistory.empty(); + } + + // Get number of shuffle steps in history + int getShuffleCount() const { + return shuffleHistory.size(); + } + + SDL_Surface* getSurface() { return surface; } + + + // Get the working texture to render + SDL_Texture* getTexture() { + return texture; + } +}; + diff --git a/src/defaults/ui.cpp b/src/defaults/ui.cpp new file mode 100644 index 0000000..078cbea --- /dev/null +++ b/src/defaults/ui.cpp @@ -0,0 +1,526 @@ +#include "defaults/ui.hpp" + +#include "inventory/inventory.hpp" + +#include "game/game.hpp" +#include "character/character.hpp" + +#include <iostream> + +// Key description pairs +std::vector<std::pair<std::string, std::string>> +keyboard_layout = { + { "9", "Game mode: play"}, + { "Scroll", "Zoom in or out"}, + { "ctrl+s", "Map save to file"}, + { "s", "Map scale"}, + { "r", "Map clear"}, + { "shift+k", "Map clear colliders"}, + { "ctrl+LeftClick", "Map move"}, + { "i", "Info toggle"}, + { "h", "Tileset toggle hide"}, + { "[ctrl,shift]m", "Tileset toggle"}, + { "k", "Toggle set collission"}, + { "o", "Toggle set object or floor"}, + { "ctrl+o", "Set properties object"}, + { "shift+o", "Set properites resource"}, + { "ctrl+k", "Collider transfer to map"}, + { "c+LeftClick", "Object clear"}, + { "shift+LeftClick", "Object select"}, + { "[ctrl,shift]+", "Selector increase"}, + { "[ctrl,shift]- ", "Selector decrease"}, + { "ctrl+q", "Exit game"} +}; + +std::vector<std::pair<std::string, std::string>> +keyboard_layout_playing = { + { "f10", "Game mode: modify"}, + { "Scroll", "Zoom in or out"}, + { "0", "Zoom reset"}, + { "[w,a,s,d]", "Move in direction"}, + { "c", "Collect item | interact | plant"}, + { "i", "Info toggle"}, + { "e", "Inventory toggle"}, + { "b", "Build menu toggle"}, + { "k", "Building set deconstruct"}, + { "[1-6]", "Equipement set or select"}, + { "Left-Click", "Attack | Build | Deconstruct"}, + { "ctrl+q", "Exit game"} +}; + +namespace Ui { + bool draw_key_info = false; + + // Font + TTF_Font* font_big = nullptr; + TTF_Font* font_small = nullptr; + TTF_Font* font_tiny = nullptr; + TTF_Font* font_menu = nullptr; + TTF_Font* font_top_bar = nullptr; + TTF_Font* font_menu_bold = nullptr; + TTF_Font* font_message = nullptr; + + float top_bar_height = 40; + + bool + init_Font() { + if (!TTF_Init()) { + std::cerr << "SDL_ttf initialization failed: " << SDL_GetError() << std::endl; + return false; + } + + font_big = TTF_OpenFont("fonts/DejaVuSans-Bold.ttf", 28); + font_small = TTF_OpenFont("fonts/DejaVuSansMono.ttf", 30); + font_tiny = TTF_OpenFont("fonts/DejaVuSansMono.ttf", 12); + font_menu = TTF_OpenFont("fonts/DejaVuSansMono.ttf", 18); + font_menu_bold = TTF_OpenFont("fonts/DejaVuSansMono-Bold.ttf", 18); + font_top_bar = TTF_OpenFont("fonts/DejaVuSansMono-Bold.ttf", 28); + font_message = TTF_OpenFont("fonts/DejaVuSansMono.ttf", 22); + + if (!font_big || !font_small) { + std::cerr << "Failed to load font: " << SDL_GetError() << std::endl; + return false; + } + return true; + } + + void + delete_Font() { + TTF_CloseFont(font_big); + TTF_CloseFont(font_small); + TTF_CloseFont(font_top_bar); + } + + void + draw_KeyInfo(Game* game) { + if (!game->renderer || !font_small || !font_big) return; + + SDL_FRect rect_background_window = {0, 0, static_cast<float>(game->win_size.w), static_cast<float>(game->win_size.h)}; + SDL_SetRenderDrawBlendMode(game->renderer, SDL_BLENDMODE_BLEND); + SDL_SetRenderDrawColor(game->renderer, 0, 0, 0, 200); + SDL_RenderFillRect(game->renderer, &rect_background_window); + + + + SDL_Color text_color = {255, 255, 255, 255}; + float line_spacing = 8.0f; + + float total_height = 0.0f; + float max_key_width = 0.0f; + float max_desc_width = 0.0f; + + std::vector<std::pair<std::string, std::string>>& layout = + (dynamic_cast<StatePlaying*>(game->state_current) != nullptr) + ? keyboard_layout_playing + : keyboard_layout; + + for (const auto& [key, desc] : layout) { + SDL_Surface* surface_key = TTF_RenderText_Blended(font_big, key.c_str(), key.length(), text_color); + SDL_Surface* surface_desc = TTF_RenderText_Blended(font_small, desc.c_str(), desc.length(), text_color); + if (!surface_key || !surface_desc) { + if (surface_key) SDL_DestroySurface(surface_key); + if (surface_desc) SDL_DestroySurface(surface_desc); + continue; + } + + max_key_width = std::max(max_key_width, static_cast<float>(surface_key->w)); + max_desc_width = std::max(max_desc_width, static_cast<float>(surface_desc->w)); + total_height += std::max(surface_key->h, surface_desc->h) + line_spacing; + + SDL_DestroySurface(surface_key); + SDL_DestroySurface(surface_desc); + } + + total_height -= line_spacing; + + // Center coordinates + float col_spacing = 50.0f; + float x_key = (game->win_size.w - (max_key_width + max_desc_width + col_spacing)) / 2.0f; + float x_desc = x_key + max_key_width + col_spacing; + float y = (game->win_size.h - total_height) / 2.0f; + + // background + SDL_FPoint padding = {120.0f, 30.0f}; + SDL_FRect rect_background = {x_key - padding.x, y - padding.y, + (max_key_width + max_desc_width + 20.0f) + 2*padding.x, + total_height + 2*padding.y}; + SDL_SetRenderDrawBlendMode(game->renderer, SDL_BLENDMODE_BLEND); + SDL_SetRenderDrawColor(game->renderer, 0, 0, 0, 182); + SDL_RenderFillRect(game->renderer, &rect_background); + + // Text + for (const auto& [key, desc] : layout) { + SDL_Surface* surface_key = TTF_RenderText_Blended(font_big, key.c_str(), key.length(), text_color); + if (!surface_key) continue; + SDL_Texture* texture_key = SDL_CreateTextureFromSurface(game->renderer, surface_key); + if (!texture_key) { + SDL_DestroySurface(surface_key); + continue; + } + float h = static_cast<float>(surface_key->h); + + // Right-align the key + SDL_FRect dst_key = {x_key + max_key_width - static_cast<float>(surface_key->w), y, + static_cast<float>(surface_key->w), h}; + SDL_RenderTexture(game->renderer, texture_key, nullptr, &dst_key); + SDL_DestroySurface(surface_key); + SDL_DestroyTexture(texture_key); + + SDL_Surface* surface_desc = TTF_RenderText_Blended(font_small, desc.c_str(), desc.length(), text_color); + if (!surface_desc) continue; + SDL_Texture* texture_desc = SDL_CreateTextureFromSurface(game->renderer, surface_desc); + if (!texture_desc) { + SDL_DestroySurface(surface_desc); + continue; + } + + SDL_FRect dst_desc = {x_desc, y, static_cast<float>(surface_desc->w), static_cast<float>(surface_desc->h)}; + SDL_RenderTexture(game->renderer, texture_desc, nullptr, &dst_desc); + SDL_DestroySurface(surface_desc); + SDL_DestroyTexture(texture_desc); + + y += h + line_spacing; + } + } + + + void draw_Frames(SDL_Renderer* renderer, SDL_Rect win_size) { + SDL_Color text_color = {255, 255, 255, 255}; + + // --- RIGHT SIDE: FRAMES --- + + std::string res_text = "FPS: " + std::to_string(Default::fps); + + SDL_Surface* surf = TTF_RenderText_Blended(font_top_bar, res_text.c_str(), res_text.length(), text_color); + if (!surf) return; + + SDL_Texture* tex = SDL_CreateTextureFromSurface(renderer, surf); + if (!tex) { + SDL_DestroySurface(surf); + return; + } + + float padding = 20.0f; + float x = static_cast<float>(win_size.w) - static_cast<float>(surf->w) - padding; + + SDL_FRect rect = { + x, + 6.0f, + static_cast<float>(surf->w), + static_cast<float>(surf->h) + }; + + SDL_RenderTexture(renderer, tex, nullptr, &rect); + + SDL_DestroyTexture(tex); + SDL_DestroySurface(surf); + } + + + + void draw_TopBarTileInfo(SDL_Renderer* renderer, SDL_Rect win_size) { + SDL_Color text_color = {255, 255, 255, 255}; + + std::string text; + text = std::string("Mode: ") + Default::get_ModifyStateName(); + + // background + SDL_FRect top_bar_rect = { + 0.0f, + 0.0f, + static_cast<float>(win_size.w), + static_cast<float>(top_bar_height) + }; + + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 120); + SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); + SDL_RenderFillRect(renderer, &top_bar_rect); + + // --- LEFT TEXT --- + + SDL_Surface* surface_text = TTF_RenderText_Blended(font_top_bar, text.c_str(), text.length(), text_color); + if (!surface_text) return; + + SDL_Texture* texture_text = SDL_CreateTextureFromSurface(renderer, surface_text); + if (!texture_text) { + SDL_DestroySurface(surface_text); + return; + } + + SDL_FRect dst_text = {20.0f, 6.0f, static_cast<float>(surface_text->w), static_cast<float>(surface_text->h)}; + SDL_RenderTexture(renderer, texture_text, nullptr, &dst_text); + + SDL_DestroyTexture(texture_text); + SDL_DestroySurface(surface_text); + } + + void + draw_BottomLeftBars(SDL_Renderer* renderer, SDL_Rect win_size, Character& player) { + const float health_w = 20.0f; + const float energy_w = health_w * 0.5f; + const float thirst_w = health_w * 0.4f; + const float bar_h = 120.0f; + const float spacing = 4.0f; + + float start_x = 20.0f; + float start_y = static_cast<float>(win_size.h) - bar_h - 20.0f; + + auto clamp01 = [](float v) { + return v < 0.0f ? 0.0f : (v > 1.0f ? 1.0f : v); + }; + + float thirst_max = player.stats.thirst_max; + if (thirst_max <= 0.0f) thirst_max = 1.0f; + + float thirst_ratio = clamp01(player.stats.thirst / thirst_max); + + // ---------------- HEALTH ---------------- + + float health_max = player.health_Max(); + float health_bonus = player.health_MaxBonus(); + float health_base_max = health_max - health_bonus; + if (health_base_max < 0.0f) health_base_max = 0.0f; + + float health_capacity_ratio = clamp01(health_max / thirst_max); + float health_bar_max_h = bar_h * health_capacity_ratio; + + float health_base_capacity_ratio = + health_max > 0.0f ? clamp01(health_base_max / health_max) : 0.0f; + + float health_base_cap_h = health_bar_max_h * health_base_capacity_ratio; + float health_bonus_cap_h = health_bar_max_h - health_base_cap_h; + + float health_val = player.health_Get(); + + float health_base_ratio = + health_base_max > 0.0f ? clamp01(health_val / health_base_max) : 0.0f; + + float health_bonus_ratio = + health_bonus > 0.0f + ? clamp01((health_val - health_base_max) / health_bonus) + : 0.0f; + + float health_bottom_y = start_y + (bar_h - health_bar_max_h); + + // ---------------- STAMINA ---------------- + + float stamina_max = player.stamina_Max(); + float stamina_bonus = player.stamina_MaxBonus(); + float stamina_base_max = stamina_max - stamina_bonus; + if (stamina_base_max < 0.0f) stamina_base_max = 0.0f; + + float stamina_capacity_ratio = clamp01(stamina_max / thirst_max); + float stamina_bar_max_h = bar_h * stamina_capacity_ratio; + + float stamina_base_capacity_ratio = + stamina_max > 0.0f ? clamp01(stamina_base_max / stamina_max) : 0.0f; + + float stamina_base_cap_h = stamina_bar_max_h * stamina_base_capacity_ratio; + float stamina_bonus_cap_h = stamina_bar_max_h - stamina_base_cap_h; + + float stamina_val = player.stamina_Get(); + + float stamina_base_ratio = + stamina_base_max > 0.0f ? clamp01(stamina_val / stamina_base_max) : 0.0f; + + float stamina_bonus_ratio = + stamina_bonus > 0.0f + ? clamp01((stamina_val - stamina_base_max) / stamina_bonus) + : 0.0f; + + float stamina_bottom_y = start_y + (bar_h - stamina_bar_max_h); + + // ---------------- RECTS ---------------- + + SDL_FRect thirst_bg = { start_x, start_y, thirst_w, bar_h }; + SDL_FRect energy_bg = { + thirst_bg.x + thirst_w + spacing, + stamina_bottom_y, + energy_w, + stamina_bar_max_h + }; + SDL_FRect health_bg = { + energy_bg.x + energy_w + spacing, + health_bottom_y, + health_w, + health_bar_max_h + }; + + // ---------------- BACKGROUND ---------------- + + // thirst background + SDL_SetRenderDrawColor(renderer, 30, 30, 30, 255); + SDL_RenderFillRect(renderer, &thirst_bg); + + // stamina background base + SDL_FRect stamina_bg_base = { + energy_bg.x, + stamina_bottom_y + stamina_bonus_cap_h, + energy_w, + stamina_base_cap_h + }; + SDL_SetRenderDrawColor(renderer, 30, 30, 30, 255); + SDL_RenderFillRect(renderer, &stamina_bg_base); + + // stamina background bonus (slightly lighter) + SDL_FRect stamina_bg_bonus = { + energy_bg.x, + stamina_bottom_y, + energy_w, + stamina_bonus_cap_h + }; + SDL_SetRenderDrawColor(renderer, 45, 45, 45, 255); + SDL_RenderFillRect(renderer, &stamina_bg_bonus); + + // health background base + SDL_FRect health_bg_base = { + health_bg.x, + health_bottom_y + health_bonus_cap_h, + health_w, + health_base_cap_h + }; + SDL_SetRenderDrawColor(renderer, 30, 30, 30, 255); + SDL_RenderFillRect(renderer, &health_bg_base); + + // health background bonus (slightly lighter) + SDL_FRect health_bg_bonus = { + health_bg.x, + health_bottom_y, + health_w, + health_bonus_cap_h + }; + SDL_SetRenderDrawColor(renderer, 45, 45, 45, 255); + SDL_RenderFillRect(renderer, &health_bg_bonus); + + // ---------------- FOREGROUND ---------------- + + // health base fill + SDL_FRect health_fill_base = { + health_bg.x, + health_bottom_y + health_bonus_cap_h + + health_base_cap_h * (1.0f - health_base_ratio), + health_w, + health_base_cap_h * health_base_ratio + }; + SDL_SetRenderDrawColor(renderer, 200, 40, 40, 255); + SDL_RenderFillRect(renderer, &health_fill_base); + + // health bonus fill (lighter red) + SDL_FRect health_fill_bonus = { + health_bg.x, + health_bottom_y + + health_bonus_cap_h * (1.0f - health_bonus_ratio), + health_w, + health_bonus_cap_h * health_bonus_ratio + }; + SDL_SetRenderDrawColor(renderer, 255, 100, 100, 255); + SDL_RenderFillRect(renderer, &health_fill_bonus); + + // stamina base fill + SDL_FRect stamina_fill_base = { + energy_bg.x, + stamina_bottom_y + stamina_bonus_cap_h + + stamina_base_cap_h * (1.0f - stamina_base_ratio), + energy_w, + stamina_base_cap_h * stamina_base_ratio + }; + SDL_SetRenderDrawColor(renderer, 200, 200, 40, 255); + SDL_RenderFillRect(renderer, &stamina_fill_base); + + // stamina bonus fill (lighter yellow) + SDL_FRect stamina_fill_bonus = { + energy_bg.x, + stamina_bottom_y + + stamina_bonus_cap_h * (1.0f - stamina_bonus_ratio), + energy_w, + stamina_bonus_cap_h * stamina_bonus_ratio + }; + SDL_SetRenderDrawColor(renderer, 255, 255, 120, 255); + SDL_RenderFillRect(renderer, &stamina_fill_bonus); + + // thirst fill + SDL_FRect thirst_fill = { + thirst_bg.x, + start_y + bar_h * (1.0f - thirst_ratio), + thirst_w, + bar_h * thirst_ratio + }; + SDL_SetRenderDrawColor(renderer, 40, 120, 200, 255); + SDL_RenderFillRect(renderer, &thirst_fill); + + // ---------------- BORDERS ---------------- + + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); + SDL_RenderRect(renderer, &thirst_bg); + SDL_RenderRect(renderer, &energy_bg); + SDL_RenderRect(renderer, &health_bg); + + + + + + + + + + + + + const float icon_size = 32.0f; + const float icon_spacing = 6.0f; + const float icons_y = start_y - icon_size - 8.0f; + + const float max_duration = 300.0f; + + for (size_t n = 0; n < player.stats_bonus.size(); ++n) { + + const CharacterStatsBonus& bonus = player.stats_bonus[n]; + + const VegetableData::CropDefinition* data = + VegetableData::get_DataByType( + static_cast<VegetableData::Type>(bonus.type) + ); + + if (!data) + continue; + + SDL_FRect dst = { + thirst_bg.x + n * (icon_size + icon_spacing), + icons_y, + icon_size, + icon_size + }; + + SDL_FRect src = { + static_cast<float>(data->icon_tile_x * 16), + static_cast<float>(data->icon_tile_y * 16), + 16.0f, + 16.0f + }; + + SDL_RenderTexture(renderer, Icon::icons_texture, &src, &dst); + + // -------- duration overlay -------- + + float ratio = bonus.duration / max_duration; + if (ratio < 0.0f) ratio = 0.0f; + if (ratio > 1.0f) ratio = 1.0f; + + float overlay_h = dst.h * ratio; + + SDL_FRect overlay = { + dst.x, + dst.y + (dst.h - overlay_h), + dst.w, + overlay_h + }; + + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 140); + SDL_RenderFillRect(renderer, &overlay); + + // border + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); + SDL_RenderRect(renderer, &dst); + } + } +} diff --git a/src/defaults/ui.hpp b/src/defaults/ui.hpp new file mode 100644 index 0000000..f9ef969 --- /dev/null +++ b/src/defaults/ui.hpp @@ -0,0 +1,36 @@ +#pragma once + +#include <SDL3/SDL.h> +#include <SDL3_ttf/SDL_ttf.h> + +#include <vector> +#include <string> + +class Character; +class Game; + +namespace Ui { + extern bool draw_key_info; + + // Font + extern TTF_Font* font_big; + extern TTF_Font* font_small; + extern TTF_Font* font_tiny; + extern TTF_Font* font_menu; + extern TTF_Font* font_menu_bold; + extern TTF_Font* font_message; + + extern float top_bar_height; + + + bool init_Font(); + void delete_Font(); + + void draw_KeyInfo(Game* game); + + void draw_Frames(SDL_Renderer* renderer, SDL_Rect win_size); + + void draw_TopBarTileInfo(SDL_Renderer* renderer, SDL_Rect win_size); + + void draw_BottomLeftBars(SDL_Renderer* renderer, SDL_Rect win_size, Character& player); +} diff --git a/src/end_screen/end_screen.cpp b/src/end_screen/end_screen.cpp new file mode 100644 index 0000000..bac4e30 --- /dev/null +++ b/src/end_screen/end_screen.cpp @@ -0,0 +1,245 @@ +#include "end_screen.hpp" + +// ───────────────────────────────────────────────────────────────────────────── +// Helpers +// ───────────────────────────────────────────────────────────────────────────── + +float EndScreen::Lerp(float a, float b, float t) { + return a + (b - a) * t; +} + +// All images are 460×460 and share the same centred offset. +SDL_FPoint EndScreen::LayerOffset() const { + if (!assets[0].surface) return {0.0f, 0.0f}; + float ox = (screen_w - assets[0].surface->w) / 2.0f; + float oy = (screen_h - assets[0].surface->h) / 2.0f; + return {ox, oy}; +} + +// ───────────────────────────────────────────────────────────────────────────── +// Construction / Destruction +// ───────────────────────────────────────────────────────────────────────────── + +EndScreen::EndScreen(SDL_Renderer* r) : renderer(r) { Init(); } + +EndScreen::~EndScreen() { + for (auto& a : assets) + if (a.surface) SDL_DestroySurface(a.surface); +} + +// ───────────────────────────────────────────────────────────────────────────── +// Init +// ───────────────────────────────────────────────────────────────────────────── + +void EndScreen::Init() { + SDL_GetRenderOutputSize(renderer, &screen_w, &screen_h); + + const char* paths[NUM_LAYERS] = { + "quit/quit_text_to.png", + "quit/quit_text_be.png", + "quit/quit_text_continued.png", + "quit/quit_text_nope.png", + }; + + for (int i = 0; i < NUM_LAYERS; ++i) { + assets[i].surface = IMG_Load(paths[i]); + layer_state[i] = LayerState::WAITING; + layer_start_tick[i]= 0; + layer_due[i] = 0; + } + + rng.seed(std::random_device{}()); + last_time = SDL_GetTicks(); + + // Extract particles for every layer before starting + for (int i = 0; i < NUM_LAYERS; ++i) + BuildParticles(i); + + // Fire layer 0 immediately + StartLayer(0); +} + +// ───────────────────────────────────────────────────────────────────────────── +// BuildParticles — extract visible pixels from a surface into EndParticles. +// current is initialised to screen-centre; origin is the final screen pos. +// ───────────────────────────────────────────────────────────────────────────── + +void EndScreen::BuildParticles(int idx) { + auto& surf = assets[idx].surface; + if (!surf) return; + + const SDL_PixelFormatDetails* details = + SDL_GetPixelFormatDetails(surf->format); + Uint32* pixels = static_cast<Uint32*>(surf->pixels); + int pitch = surf->pitch / (int)sizeof(Uint32); + int w = surf->w, h = surf->h; + + SDL_FPoint off = LayerOffset(); // same for every layer + + auto& parts = layer_particles[idx]; + parts.clear(); + parts.reserve(static_cast<size_t>(w * h / 4)); // rough upper bound + + for (int y = 0; y < h; ++y) { + for (int x = 0; x < w; ++x) { + Uint32 p = pixels[y * pitch + x]; + Uint8 r, g, b, a; + SDL_GetRGBA(p, details, nullptr, &r, &g, &b, &a); + if (a > 100) { + EndParticle ep; + ep.origin = { off.x + static_cast<float>(x), + off.y + static_cast<float>(y) }; + ep.current = { screen_w / 2.0f, screen_h / 2.0f }; + parts.push_back(ep); + } + } + } +} + +// ───────────────────────────────────────────────────────────────────────────── +// StartLayer — begin the spread-in animation for one layer +// ───────────────────────────────────────────────────────────────────────────── + +void EndScreen::StartLayer(int idx) { + if (idx < 0 || idx >= NUM_LAYERS) return; + + layer_state[idx] = LayerState::SPREADING_IN; + layer_start_tick[idx] = SDL_GetTicks(); + + // All particles burst from screen centre + for (auto& ep : layer_particles[idx]) + ep.current = { screen_w / 2.0f, screen_h / 2.0f }; +} + +// ───────────────────────────────────────────────────────────────────────────── +// UpdateScreen — call on window resize +// ───────────────────────────────────────────────────────────────────────────── + +void EndScreen::UpdateScreen() { + SDL_GetRenderOutputSize(renderer, &screen_w, &screen_h); + for (int i = 0; i < NUM_LAYERS; ++i) + BuildParticles(i); + // Re-centre any currently-spreading layer + for (int i = 0; i < NUM_LAYERS; ++i) { + if (layer_state[i] == LayerState::SPREADING_IN) { + for (auto& ep : layer_particles[i]) + ep.current = { screen_w / 2.0f, screen_h / 2.0f }; + } + } +} + +// ───────────────────────────────────────────────────────────────────────────── +// Update +// ───────────────────────────────────────────────────────────────────────────── + +void EndScreen::Update() { + Uint64 now = SDL_GetTicks(); + last_time = now; + + // ── Advance any spreading layer ────────────────────────────────────────── + for (int i = 0; i < NUM_LAYERS; ++i) { + if (layer_state[i] != LayerState::SPREADING_IN) continue; + + float t = static_cast<float>(now - layer_start_tick[i]) + / static_cast<float>(SPREAD_DURATION_MS); + + if (t >= 1.0f) { + // Snap to final positions + for (auto& ep : layer_particles[i]) + ep.current = ep.origin; + + layer_state[i] = LayerState::VISIBLE; + + // Schedule the next layer + if (i + 1 < NUM_LAYERS) { + Uint64 gap = 0; + if (i == 0) gap = GAP_AFTER_0_MS; + else if (i == 1) gap = GAP_AFTER_1_MS; + else if (i == 2) gap = GAP_AFTER_2_MS; + layer_due[i + 1] = now + gap; + } + } else { + float cx = screen_w / 2.0f; + float cy = screen_h / 2.0f; + for (auto& ep : layer_particles[i]) { + ep.current.x = Lerp(cx, ep.origin.x, t); + ep.current.y = Lerp(cy, ep.origin.y, t); + } + } + } + + // ── Trigger any WAITING layer whose due time has arrived ───────────────── + for (int i = 1; i < NUM_LAYERS; ++i) { + if (layer_state[i] == LayerState::WAITING + && layer_due[i] > 0 + && now >= layer_due[i]) + { + StartLayer(i); + } + } + + // ── End condition: last layer fully visible ─────────────────────────────── + if (layer_state[NUM_LAYERS - 1] == LayerState::VISIBLE) { + if (!end_timer_started) { + end_timer_started = true; + end_timer_start = now; + } else if (now - end_timer_start >= END_PAUSE_MS) { + running = false; + } + } +} + +// ───────────────────────────────────────────────────────────────────────────── +// Render +// Strategy: every non-WAITING layer is drawn as white 1×1 particle rects. +// VISIBLE layers have all particles snapped to their origins, so they look +// like a solid rendered image. No SDL_RenderTexture is used at all, which +// means there is zero risk of one layer's texture rect overwriting another. +// ───────────────────────────────────────────────────────────────────────────── + +void EndScreen::Render() { + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); + SDL_RenderClear(renderer); + + SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); + + for (int i = 0; i < NUM_LAYERS; ++i) { + if (layer_state[i] == LayerState::WAITING) continue; + + // Draw every particle — works for both SPREADING_IN and VISIBLE states. + for (const auto& ep : layer_particles[i]) { + SDL_FRect r { ep.current.x, ep.current.y, 1.0f, 1.0f }; + SDL_RenderFillRect(renderer, &r); + } + } + + SDL_RenderPresent(renderer); +} + +// ───────────────────────────────────────────────────────────────────────────── +// Event loop +// ───────────────────────────────────────────────────────────────────────────── + +namespace EndScreen_Event { + void event_Loop(SDL_Renderer* renderer) { + EndScreen* scene = new EndScreen(renderer); + + while (scene->running) { + SDL_Event e; + while (SDL_PollEvent(&e)) { + if (e.type == SDL_EVENT_QUIT) + scene->running = false; + if (e.type == SDL_EVENT_KEY_DOWN && e.key.key == SDLK_ESCAPE) + scene->running = false; + if (e.type == SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED || + e.type == SDL_EVENT_WINDOW_RESIZED) + scene->UpdateScreen(); + } + + scene->Update(); + scene->Render(); + } + + delete scene; + } +} diff --git a/src/end_screen/end_screen.hpp b/src/end_screen/end_screen.hpp new file mode 100644 index 0000000..3177c34 --- /dev/null +++ b/src/end_screen/end_screen.hpp @@ -0,0 +1,72 @@ +// end_screen.hpp +// Ending screen: 4 images revealed one by one as particle bursts from centre. +// All layers are ALWAYS rendered as particles — no texture overdraw possible. +// Clear color: black. Text is white. + +#pragma once + +#include <SDL3/SDL.h> +#include <SDL3_image/SDL_image.h> +#include <vector> +#include <array> +#include <random> +#include <cstdint> + +struct EndParticle { + SDL_FPoint origin; // final screen position (centred) + SDL_FPoint current; // animated position +}; + +class EndScreen { +public: + bool running = true; + + explicit EndScreen(SDL_Renderer* r); + ~EndScreen(); + + void Update(); + void Render(); + void UpdateScreen(); + +private: + enum class LayerState { WAITING, SPREADING_IN, VISIBLE }; + + // ── Timings (ms) ───────────────────────────────────────────────────────── + // Fast burst animation, long delays between words. + static constexpr Uint64 SPREAD_DURATION_MS = 420; // fast particle burst + static constexpr Uint64 GAP_AFTER_0_MS = 200; // "to" → "be" (quick follow-up) + static constexpr Uint64 GAP_AFTER_1_MS = 1000; // "be" → "continued" + static constexpr Uint64 GAP_AFTER_2_MS = 2000; // "continued" → "nope" + static constexpr Uint64 END_PAUSE_MS = 2000; // hold all visible before done + + void Init(); + void BuildParticles(int layer_idx); + void StartLayer(int idx); + SDL_FPoint LayerOffset() const; // same offset for all layers (same image size) + static float Lerp(float a, float b, float t); + + SDL_Renderer* renderer = nullptr; + int screen_w = 0, screen_h = 0; + + static constexpr int NUM_LAYERS = 4; + + struct LayerAsset { + SDL_Surface* surface = nullptr; + // No texture needed — we render entirely via particles + }; + std::array<LayerAsset, NUM_LAYERS> assets{}; + std::array<LayerState, NUM_LAYERS> layer_state{}; + std::array<Uint64, NUM_LAYERS> layer_start_tick{}; // when spreading began + std::array<Uint64, NUM_LAYERS> layer_due{}; // scheduled start tick + std::array<std::vector<EndParticle>, NUM_LAYERS> layer_particles{}; + + bool end_timer_started = false; + Uint64 end_timer_start = 0; + Uint64 last_time = 0; + + std::mt19937 rng; +}; + +namespace EndScreen_Event { + void event_Loop(SDL_Renderer* renderer); +} diff --git a/src/farm/farm.cpp b/src/farm/farm.cpp new file mode 100644 index 0000000..de95c8c --- /dev/null +++ b/src/farm/farm.cpp @@ -0,0 +1,194 @@ +#include "farm.hpp" + +#include "map/map.hpp" + + +namespace Farm { + void soil_Place(SDL_Point position) { + static const SDL_Point offsets[] = { + { 0, 0 }, + { -1, 0 }, + { 1, 0 }, + { 0,-1 }, + { 0, 1 } + }; + + for (const SDL_Point& off : offsets) { + SDL_Point p{ position.x + off.x, position.y + off.y }; + const size_t id = Map::get_IdFromTilePoint(p); + if (id == SIZE_MAX) + continue; + + auto& overlays = Map::tile_map[id].overlays; + + // --- RULE 1 --- + // If any existing overlay on this tile already has offset {0,0}, + // skip placing anything on this tile. + if (!overlays.empty()) { + for (const auto& o : overlays) { + if (o.set_category == TileCategory::TILE_OVERLAY_FARM && o.set_position.x == 0 && o.set_position.y == 0) + goto skip_this_offset; + } + } + + // --- RULE 2 --- + // If we are placing at offset {0,0} on a tile that + // has overlays with offsets != {0,0}, remove them first. + if (off.x == 0 && off.y == 0) { + bool requires_cleanup = false; + + // Detect whether removal is needed + for (const auto& o : overlays) { + if (o.set_category == TileCategory::TILE_OVERLAY_FARM && + (o.set_position.x != 0 || o.set_position.y != 0)) { + requires_cleanup = true; + break; + } + } + + // Remove only TILE_OVERLAY_FARM overlays (non-zero offsets) + if (requires_cleanup) { + overlays.erase( + std::remove_if( + overlays.begin(), + overlays.end(), + [](const Tile_s& o) { + return o.set_category == TileCategory::TILE_OVERLAY_FARM && + (o.set_position.x != 0 || o.set_position.y != 0); + } + ), + overlays.end() + ); + } + } + + // --- PLACE --- + overlays.emplace_back(Tile_s{ + 0, // set_id + 0, // object_id + TileCategory::TILE_OVERLAY_FARM, + off // set_position + }); + +skip_this_offset: + continue; + } + } + void OLDsoil_Remove(SDL_Point position) { + static const SDL_Point offsets[] = { + { 0, 0 }, + { -1, 0 }, + { 1, 0 }, + { 0,-1 }, + { 0, 1 } + }; + + for (const SDL_Point& off : offsets) { + SDL_Point p{ position.x + off.x, position.y + off.y }; + const size_t id = Map::get_IdFromTilePoint(p); + if (id == SIZE_MAX) + continue; + + auto& overlays = Map::tile_map[id].overlays; + + overlays.erase( + std::remove_if( + overlays.begin(), + overlays.end(), + [&](const Tile_s& o) { + return o.set_category == TileCategory::TILE_OVERLAY_FARM && + o.set_position.x == off.x && + o.set_position.y == off.y; + }), + overlays.end() + ); + } + } + + void soil_Remove(SDL_Point position) { + static const SDL_Point offsets[] = { + { 0, 0 }, + { -1, 0 }, + { 1, 0 }, + { 0,-1 }, + { 0, 1 } + }; + + struct ToPlace { SDL_Point target; }; + std::vector<SDL_Point> to_place; + + for (const SDL_Point& off : offsets) { + SDL_Point p{ position.x + off.x, position.y + off.y }; + const size_t id = Map::get_IdFromTilePoint(p); + if (id == SIZE_MAX) + continue; + + auto& overlays = Map::tile_map[id].overlays; + + // Remove and mark overlays to recreate + overlays.erase( + std::remove_if(overlays.begin(), overlays.end(), + [&](const Tile_s& o) { + if (o.set_category != TileCategory::TILE_OVERLAY_FARM) + return false; + + // Remove overlay matching offset + if (o.set_position.x == off.x && o.set_position.y == off.y) + return true; + else if (!(off.x == 0 && off.y == 0) && + o.set_position.x == 0 && o.set_position.y == 0) { + // Remove overlay at {0,0} and mark to recreate + to_place.push_back(p); + return true; + } + return false; + }), + overlays.end() + ); + } + + for (const SDL_Point& p : to_place) { + soil_Place(p); + } + } + + bool soil_IsMaptile(SDL_Point& tile_world) { + for (Tile_s o : Map::tile_map[Map::get_IdFromTilePoint(tile_world)].overlays) { + if ( o.set_category == TileCategory::TILE_OVERLAY_FARM && + o.set_position.x == 0 && o.set_position.y == 0) { + return true; + } + } + return false; + } + + void soil_Render(SDL_Renderer* renderer, + SDL_FPoint position, + SDL_Point position_offset, + Uint8 alpha) { + SDL_FRect src = {16.0f + position_offset.x * 16.0f, + 16.0f + position_offset.y * 16.0f, + 16.0f, 16.0f}; + + SDL_FRect dst = {Scale(position.x), + Scale(position.y), + Scale(16), + Scale(16)}; + + SDL_Texture* tex = Tile::tilesets[TILE_OVERLAY][0].texture; + + SDL_SetTextureAlphaMod(tex, alpha); + SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); + + SDL_RenderTexture(renderer, tex, &src, &dst); + + SDL_SetTextureAlphaMod(tex, 255); + } + + void soil_RenderRemove(SDL_Renderer* renderer, SDL_FPoint position) { + SDL_FRect dst = {Scale(position.x), Scale(position.y), Scale(16), Scale(16)}; + + SDL_SetRenderDrawColor(renderer, 255, 0, 0, 100); + SDL_RenderFillRect(renderer, &dst); + } +} diff --git a/src/farm/farm.hpp b/src/farm/farm.hpp new file mode 100644 index 0000000..eae2941 --- /dev/null +++ b/src/farm/farm.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include "defaults/defaults.hpp" + +namespace Farm { + void soil_Place(SDL_Point position); + void soil_Remove(SDL_Point position); + bool soil_IsMaptile(SDL_Point& tile_world); + + void soil_Render(SDL_Renderer* renderer, SDL_FPoint position, SDL_Point position_offset = {0,0}, Uint8 alpha = 255); + void soil_RenderRemove(SDL_Renderer* renderer, SDL_FPoint position); +} diff --git a/src/game/game.cpp b/src/game/game.cpp new file mode 100644 index 0000000..233a469 --- /dev/null +++ b/src/game/game.cpp @@ -0,0 +1,446 @@ +#include "game/game.hpp" + + +#include <iostream> +#include <cmath> +#include <vector> +#include <unordered_map> +#include <fstream> + +#include "game_state.hpp" +#include "state_modify.hpp" +#include "state_playing.hpp" + +#include "defaults/defaults.hpp" +#include "character/character.hpp" +#include "defaults/ui.hpp" +#include "map/tile.hpp" +#include "map/map.hpp" +#include "inventory/weapon.hpp" +#include "building/building.hpp" +#include "defaults/icons.hpp" +#include "inventory/inventory.hpp" +#include "resource/resource_data.hpp" +#include "building/research.hpp" +#include "defaults/input.hpp" +#include "start_screen/start_screen.hpp" +#include "cursor/animated_cursor.hpp" +#include "end_screen/end_screen.hpp" + + +// Game class encapsulating SDL initialization and loop +Game::Game() : running(true) { + if (!SDL_Init(SDL_INIT_VIDEO)) { + std::cerr << "SDL_Init Error: " << SDL_GetError() << "\n"; + running = false; + } + Uint32 window_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE; + if (Default::is_fullscreen) { + window_flags |= SDL_WINDOW_FULLSCREEN; + } + + window = SDL_CreateWindow("Map creator", + win_size.w, win_size.h, + window_flags + ); + if (!window) { + std::cout << "Fialed to create window\n"; + running = false; + return; + } + + + + SDL_SetHint(SDL_HINT_RENDER_VSYNC, "0"); + renderer = SDL_CreateRenderer( window, "opengl" ); + if (!renderer) { + std::cout << "Fialed to create Renderer\n"; + running = false; + return; + } + SDL_SetRenderVSync(renderer, 1); + //SDL_SetRenderVSync(renderer, SDL_RENDERER_VSYNC_DISABLED); + + std::cout << "INIT DONE sdl\n"; + + lastTicks = SDL_GetTicks(); + + // INIT Cursor + SDL_HideCursor(); + cursor = input.cursor = new AnimatedCursor(); + cursor->Init(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Slice_Base/Slice_Up.png"); + + + // Music + audio = new Audio(); + Animation::audio = audio; + + /* + audio->RegisterSound("character.walk", "music/character.walk.wav"); + audio->RegisterSound("character.hit", "music/character.hit.wav"); + */ + audio->RegisterSound("bird.sing", "music/bird.sing.wav"); + audio->RegisterSound("menu.hover", "music/menu.hover.wav"); + audio->RegisterSound("character.hae", "music/character.hae.wav"); + + // INIT Font + Ui::init_Font(); + + // INIT TileSets + Tile::Init(renderer); + + // Icons + Icon::Init(renderer); + + + + + Default::now = SDL_GetPerformanceCounter(); + Default::last = 0; + Default::delta_time = 0.0; + + set_State(GameState_e::STATE_PLAYING, NewGameState_e::LOAD); + + set_State(GameState_e::STATE_MENU_MAIN); +} + +Game::Game(Game&&) { + std::cout << "[Game] Move constructor called!" << std::endl; +} + +Game::~Game() { + audio->Quit(); + Ui::delete_Font(); + SDL_DestroyRenderer(renderer); + SDL_DestroyWindow(window); + SDL_Quit(); +} + +void Game::set_State(GameState_e new_state, NewGameState_e game_state_e) { + // STATE_PLAYING + + // START CURSOR + switch (new_state) { + case GameState_e::STATE_MODIFY: + cursor->set_State(CursorState::NORMAL); + break; + case GameState_e::STATE_MENU_MAIN: + cursor->set_State(CursorState::ANIMATED); + break; + case GameState_e::STATE_PLAYING: + cursor->set_State(CursorState::HIDDEN); + break; + } + // END CURSOR + + state_changed = true; + if (new_state == GameState_e::STATE_PLAYING) { + + if (Default::game_time_pause_start != 0) { + Default::game_time_paused += (SDL_GetTicksNS() - Default::game_time_pause_start) * 1e-9; + Default::game_time_pause_start = 0; + } + + state_temp.reset(); + + switch (game_state_e) { + case NewGameState_e::LOAD: + case NewGameState_e::NEW: + input.game_restart = false; + + state_playing = std::make_unique<StatePlaying>(); + state_playing->Init(this); + break; + default: break; + } + + switch (game_state_e) { + case NewGameState_e::LOAD: + Load(active_game_dir); + break; + case NewGameState_e::NEW: + Save(active_game_dir); + break; + default: break; + } + + state_current = state_playing.get(); + + state_current_e = new_state; + return; + } + + if (state_current_e == GameState_e::STATE_PLAYING && Default::game_time_pause_start == 0) + Default::game_time_pause_start = SDL_GetTicksNS(); + + // STATE MODIFY AND MENU + switch (new_state) { + case GameState_e::STATE_MODIFY: + SDL_ShowCursor(); + state_temp = std::make_unique<StateModify>(); + break; + case GameState_e::STATE_MENU_MAIN: + SDL_ShowCursor(); + state_temp = std::make_unique<StateMenuMain>(); + break; + default: break; + } + bool is_set = false; + switch (new_state) { + case GameState_e::STATE_MODIFY: + case GameState_e::STATE_MENU_MAIN: + state_current = state_temp.get(); + state_current->Init(this); + is_set = true; + break; + default: break; + } + if (is_set) + state_current_e = new_state; +} + +void Game::Run() { + if (Default::is_fullscreen) + StartScreen_Event::event_Loop(renderer); + + SDL_GetRenderOutputSize(renderer, &win_size.w, &win_size.h); + + while (running) { + Default::set_DeltaTime(); + handle_Events(); + if (state_changed) { + continue; + } + //std::cout << "IC " << (int)this->input.click_left << std::endl; + Update(); + Render(); + + // FPS calculation + Default::fps_counter++; + Default::fps_timer += Default::delta_time; + + if (Default::fps_timer >= 1.0f) { + Default::fps = Default::fps_counter; + + Default::fps_counter = 0; + Default::fps_timer -= 1.0f; + } + } + + Enemy::shutdown_Workers(); + EndScreen_Event::event_Loop(renderer); +} + +void Game::handle_Events() { + SDL_Event event; + + //SDL_GetWindowSize(window, &win_size.w, &win_size.h); + + + Uint32 mouse_buttons = SDL_GetMouseState(&input.mouse_state_raw.x, &input.mouse_state_raw.y); + + input.mouse_state.x = input.mouse_state_raw.x/Default::game_scale; + input.mouse_state.y = input.mouse_state_raw.y/Default::game_scale; + + input.click_left = (mouse_buttons & SDL_BUTTON_MASK(SDL_BUTTON_LEFT)) != 0; + input.click_right = (mouse_buttons & SDL_BUTTON_MASK(SDL_BUTTON_RIGHT)) != 0; + + input.click_left_released = false; + input.click_right_released = false; + input.pressed_return_released = false; + input.pressed_arrowdown_released = false; + input.pressed_arrowup_released = false; + input.pressed_c_released = false; + + state_changed = false; + + input.mouse_game_offset = {Map::offset.x, + Map::offset.y }; + + // START set input.mouse_tile_position + Tile::set_HoveringTileset(input.mouse_state); + input.cursor_over_tileset = Tile::hovering_set; + + // END set input.mouse_tile_position + if (input.cursor_over_tileset) { + input.mouse_game_offset = {(int)Tile::tileset_offset.x, + (int)Tile::tileset_offset.y }; + } + + + while (SDL_PollEvent(&event)) { + switch (event.type) { + case SDL_EVENT_QUIT: + running = false; + break; + case SDL_EVENT_WINDOW_RESIZED: + case SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED: { + int w, h; + SDL_GetWindowSize(window, &w, &h); + win_size.w = w; + win_size.h = h; + break; + } + case SDL_EVENT_MOUSE_BUTTON_DOWN: + cursor->mouse_OnClick(); + break; + case SDL_EVENT_MOUSE_BUTTON_UP: + input.click_left_released = true; + input.click_left = false; + input.click_right_released = true; + input.click_right = false; + break; + case SDL_EVENT_MOUSE_WHEEL: + if (event.wheel.y > 0) + Default::game_scale += 0.2f; + else if (event.wheel.y < 0) + Default::game_scale -= 0.2f; + + if (Default::game_scale < 0.5) + Default::game_scale = 0.5; + if (Default::game_scale > 4.2f) + Default::game_scale = 4.2f; + break; + + case SDL_EVENT_KEY_DOWN: + switch (event.key.scancode) { + case SDL_SCANCODE_ESCAPE: + if (state_current_e == GameState_e::STATE_MENU_MAIN) + set_State(GameState_e::STATE_PLAYING, NewGameState_e::NONE); + else + set_State(GameState_e::STATE_MENU_MAIN); + return; + case SDL_SCANCODE_F9: + set_State(GameState_e::STATE_PLAYING, NewGameState_e::NONE); + return; + case SDL_SCANCODE_F10: + set_State(GameState_e::STATE_MODIFY); + return; + case SDL_SCANCODE_F12: + draw_frames = !draw_frames; + return; + case SDL_SCANCODE_LSHIFT: + input.pressed_shift = true; + break; + case SDL_SCANCODE_LCTRL: + input.pressed_ctrl = true; + break; + case SDL_SCANCODE_RETURN: + input.pressed_return = true; + break; + case SDL_SCANCODE_I: + Ui::draw_key_info = !Ui::draw_key_info; + break; + case SDL_SCANCODE_C: + input.pressed_c = true; + break; + case SDL_SCANCODE_Q: + if (input.pressed_ctrl) + running = false; + break; + default: + break; + } + break; + + case SDL_EVENT_KEY_UP: + switch (event.key.scancode) { + case SDL_SCANCODE_LCTRL: + input.pressed_ctrl = false; + break; + case SDL_SCANCODE_LSHIFT: + input.pressed_shift = false; + break; + case SDL_SCANCODE_C: + input.pressed_c = false; + input.pressed_c_released = true; + break; + case SDL_SCANCODE_RETURN: + input.pressed_return = false; + input.pressed_return_released = true; + break; + case SDL_SCANCODE_DOWN: + input.pressed_arrowdown_released = true; + break; + case SDL_SCANCODE_UP: + input.pressed_arrowup_released = true; + break; + default: + break; + } + default: + break; + } + + state_current->handle_Events(event, this); + } + + if (!input.game_running) running = false; + + input.update_Mousetileposition(); +} + +void Game::Update() { + state_current->Update(this); + cursor->Update(Default::delta_time, input.mouse_state_raw.x, input.mouse_state_raw.y); +} + +void Game::Render() { + SDL_SetRenderDrawColor(renderer, 62, 146, 209, 255); + SDL_RenderClear(renderer); + + Map::draw_MapTiles(this); + + state_current->Render(this); + + if (draw_frames) + Ui::draw_Frames(renderer, win_size); + + if (Ui::draw_key_info) Ui::draw_KeyInfo(this); + + cursor->Render(renderer); + + SDL_RenderPresent(renderer); +} + + + + +bool Game::Save(const std::string &path) const { + std::ofstream file(path + "/game", std::ios::binary | std::ios::trunc); + std::cout << "Save Game\n"; + if (!file) { + std::cout << "No file found at: " << path+"/game" << std::endl; + return false; + } + + // Default namespace + file.write(reinterpret_cast<const char*>(&Default::game_scale), sizeof(Default::game_scale)); + + // Map namespace + file.write(reinterpret_cast<const char*>(&Map::offset.x), sizeof(Map::offset.x)); + file.write(reinterpret_cast<const char*>(&Map::offset.y), sizeof(Map::offset.y)); + + state_playing->Save(path); + return file.good(); +} + +bool Game::Load(const std::string &path) { + std::ifstream file(path + "/game", std::ios::binary); + std::cout << "Load Game\n"; + if (!file) { + std::cout << "No file found at: " << path+"/game" << std::endl; + return false; + } + + // Default namespace + file.read(reinterpret_cast<char*>(&Default::game_scale), sizeof(Default::game_scale)); + + // Map namespace + file.read(reinterpret_cast<char*>(&Map::offset.x), sizeof(Map::offset.x)); + file.read(reinterpret_cast<char*>(&Map::offset.y), sizeof(Map::offset.y)); + + state_playing->Load(renderer, path); + + return file.good(); +} diff --git a/src/game/game.hpp b/src/game/game.hpp new file mode 100644 index 0000000..09dfe3f --- /dev/null +++ b/src/game/game.hpp @@ -0,0 +1,75 @@ +#pragma once + +#include <SDL3/SDL.h> +#include <SDL3/SDL_mouse.h> + + +#include <memory> +#include <cassert> +#include <iostream> + +#include "game/state_modify.hpp" +#include "game/state_playing.hpp" +#include "game/state_menu_main.hpp" + +#include "audio/audio.hpp" + +class Input; +class AnimatedCursor; + + +enum class NewGameState_e { + NONE, + NEW, + LOAD +}; + +// Game class encapsulating SDL initialization and loop +class Game { +public: + Game(); + Game(Game&&); + ~Game(); + + SDL_Rect win_size = {0,0,800, 600}; + SDL_Window* window = nullptr; + SDL_Renderer* renderer = nullptr; + + Audio* audio = nullptr; + + AnimatedCursor* cursor = nullptr; + + bool is_cheating = false; + + std::unique_ptr<StatePlaying> state_playing; + GameState* state_current = nullptr; + GameState_e state_current_e = GameState_e::STATE_MENU_MAIN; + std::unique_ptr<GameState> state_temp; + + std::string active_game_dir = "game_saves"; + + bool draw_frames = false; + + + Uint64 lastTicks; + bool running; + + Input input; + + bool state_changed = false; + + void set_State(GameState_e state, NewGameState_e game_state_e = NewGameState_e::NONE); + + void Run(); + + bool Save(const std::string &path) const; + bool Load(const std::string &path); + +private: + void handle_Events(); + + void Update(); + + void Render(); +}; + diff --git a/src/game/game_state.cpp b/src/game/game_state.cpp new file mode 100644 index 0000000..e5009ac --- /dev/null +++ b/src/game/game_state.cpp @@ -0,0 +1,2 @@ +#include "game/game_state.hpp" + diff --git a/src/game/game_state.hpp b/src/game/game_state.hpp new file mode 100644 index 0000000..144424f --- /dev/null +++ b/src/game/game_state.hpp @@ -0,0 +1,30 @@ +#pragma once + +#include <SDL3/SDL.h> +#include <SDL3/SDL_mouse.h> + +#include "audio/audio.hpp" +#include "cursor/animated_cursor.hpp" + +class Game; +class Input; + +enum class GameState_e { + STATE_MODIFY, + STATE_PLAYING, + STATE_MENU_MAIN +}; + +class GameState { +public: + virtual ~GameState() = default; + virtual bool Init(Game*) = 0; + virtual void handle_Events(SDL_Event&, Game*) = 0; + virtual void Update(Game*) = 0; + virtual void Render(Game*) = 0; + bool is_Finished() const { return finished; } +protected: + Audio* audio = nullptr; + AnimatedCursor* cursor = nullptr; + bool finished = false; +}; diff --git a/src/game/state_menu_main.cpp b/src/game/state_menu_main.cpp new file mode 100644 index 0000000..b074fed --- /dev/null +++ b/src/game/state_menu_main.cpp @@ -0,0 +1,190 @@ +#include "state_menu_main.hpp" +#include "defaults/ui.hpp" +#include "game/game.hpp" + +#include <SDL3/SDL.h> +#include <SDL3_ttf/SDL_ttf.h> +#include <vector> +#include <string> + +StateMenuMain::StateMenuMain() {} +StateMenuMain::~StateMenuMain() {} +static SDL_FRect menu_rect{}; + +bool StateMenuMain::Init(Game* game) { + audio = game->audio; + game->running = game->running; + + // Set up buttons + buttons.push_back({ MenuState::CONTI, "Continue", {300, 200, 200, 50}, false}); + buttons.push_back({ MenuState::SAVE, "Save Game", {300, 260, 200, 50}, false}); + buttons.push_back({ MenuState::LOAD, "Load Game", {300, 260, 200, 50}, false}); + buttons.push_back({ MenuState::NEW, "New Game", {300, 200, 200, 50}, false}); + buttons.push_back({ MenuState::QUIT, "Quit", {300, 320, 200, 50}, false}); + buttons.push_back({ MenuState::NEW_CHEAT, "New Cheat", {300, 200, 200, 50}, false}); + cursor = game->cursor; + cursor->set_State(CursorState::ANIMATED); + return true; +} + +void runState(MenuState state, Game* game) { + switch(state) { + case MenuState::CONTI: game->set_State(GameState_e::STATE_PLAYING, NewGameState_e::NONE); break; + case MenuState::SAVE: game->Save(game->active_game_dir); break; + case MenuState::LOAD: game->set_State(GameState_e::STATE_PLAYING, NewGameState_e::LOAD); break; + case MenuState::NEW: game->is_cheating = false; game->set_State(GameState_e::STATE_PLAYING, NewGameState_e::NEW); break; + case MenuState::QUIT: game->running = false; break; + case MenuState::NEW_CHEAT: game->is_cheating = true; game->set_State(GameState_e::STATE_PLAYING, NewGameState_e::NEW); break; + } + +} + +void StateMenuMain::handle_Events(SDL_Event& event, Game* game) { + if(event.type == SDL_EVENT_MOUSE_MOTION) { + float mx = event.motion.x; + float my = event.motion.y; + for(auto& btn : buttons) { + SDL_FPoint p = {mx, my}; + btn.hovered = SDL_PointInRectFloat(&p, &btn.rect); + } + } + else if(event.type == SDL_EVENT_MOUSE_BUTTON_UP && event.button.button == SDL_BUTTON_LEFT) { + for(size_t i=0; i<buttons.size(); ++i) { + if(buttons[i].hovered) { + runState(buttons[i].state, game); + return; + } + } + } + else if(event.type == SDL_EVENT_KEY_DOWN) { + switch (event.key.scancode) { + case SDL_SCANCODE_DOWN: + selected_index = selected_index+1 % buttons.size(); + break; + case SDL_SCANCODE_UP: + selected_index = (selected_index-1 + buttons.size()) % buttons.size(); + break; + case SDL_SCANCODE_RETURN: + runState(buttons[selected_index].state, game); + break; + default: + break; + } + } +} + +void StateMenuMain::Update(Game* game) { + // Button layout configuration + size_t button_width = 260; + size_t button_height = 70; + size_t button_gap = 25; // space between buttons + size_t padding = 40; // top and bottom padding inside the menu panel + + size_t total_height = + buttons.size() * (button_height + button_gap) - button_gap + + padding * 2; + + size_t start_x = static_cast<size_t>(game->win_size.w) / 2 - button_width / 2; + size_t start_y = static_cast<size_t>(game->win_size.h) / 2 - total_height / 2 + padding; + + static int last_clicked = -1; + bool any_button_hovered = false; + for(size_t i = 0; i < buttons.size(); ++i) { + if(buttons[i].hovered) { + any_button_hovered = true; + if ( (int)i != last_clicked ) { + if (audio->is_Playing("menu.hover") ) + audio->Stop("menu.hover"); + audio->Play("menu.hover"); + last_clicked = i; + } + } + + buttons[i].rect.x = start_x; + buttons[i].rect.y = start_y + i * (button_height + button_gap); + buttons[i].rect.w = button_width; + buttons[i].rect.h = button_height; + } + + if (!any_button_hovered) { + last_clicked = -1; + if (audio->is_Playing("menu.hover") ) + audio->Stop("menu.hover"); + } + + + // Store menu_rect for rendering + menu_rect.x = start_x - 30; + menu_rect.y = start_y - padding; + menu_rect.w = button_width + 60; + menu_rect.h = total_height; + +} + +void StateMenuMain::Render(Game* game) { + SDL_Renderer* r = game->renderer; + + // Fullscreen dim background + SDL_SetRenderDrawBlendMode(r, SDL_BLENDMODE_BLEND); + SDL_SetRenderDrawColor(r, 20, 20, 35, 180); + SDL_FRect dim = {0, 0, (float)game->win_size.w, (float)game->win_size.h}; + SDL_RenderFillRect(r, &dim); + + // Menu background + SDL_SetRenderDrawColor(r, 40, 40, 70, 230); + SDL_RenderFillRect(r, &menu_rect); + + // Menu border + SDL_SetRenderDrawColor(r, 120, 120, 170, 255); + SDL_RenderRect(r, &menu_rect); + for(int i = 1; i < 6; ++i) { + SDL_FRect inner = { + menu_rect.x + i, + menu_rect.y + i, + menu_rect.w - 2*i, + menu_rect.h - 2*i + }; + SDL_RenderRect(r, &inner); + } + + // Render buttons + for(size_t i = 0; i < buttons.size(); ++i) { + auto& btn = buttons[i]; + + // Border + float bd_w = 3; + SDL_FRect bd = {btn.rect.x-bd_w, btn.rect.y-bd_w, btn.rect.w+bd_w*2, btn.rect.h+bd_w*2 }; + SDL_SetRenderDrawColor(r, 70, 70, 120, 255); + SDL_RenderFillRect(r, &bd); + + // Button background + if(btn.hovered) + SDL_SetRenderDrawColor(r, 90, 170, 220, 255); + else + if(i == static_cast<size_t>(selected_index)) + SDL_SetRenderDrawColor(r, 80, 120, 170, 255); + else + SDL_SetRenderDrawColor(r, 70, 70, 120, 255); + SDL_RenderFillRect(r, &btn.rect); + + // Button text + SDL_Color color = {255, 255, 255, 255}; + SDL_Surface* surf = TTF_RenderText_Blended(Ui::font_menu_bold, btn.text.c_str(), btn.text.length(), color); + SDL_Texture* tex = SDL_CreateTextureFromSurface(r, surf); + + float tw, th; + SDL_GetTextureSize(tex, &tw, &th); + + SDL_FRect dst = { + btn.rect.x + (btn.rect.w - tw) * 0.5f, + btn.rect.y + (btn.rect.h - th) * 0.5f, + tw, + th + }; + + SDL_RenderTexture(r, tex, nullptr, &dst); + + SDL_DestroyTexture(tex); + SDL_DestroySurface(surf); + } +} diff --git a/src/game/state_menu_main.hpp b/src/game/state_menu_main.hpp new file mode 100644 index 0000000..fe82513 --- /dev/null +++ b/src/game/state_menu_main.hpp @@ -0,0 +1,39 @@ +#pragma once + +#include <string> +#include <vector> + +#include "game/game_state.hpp" + + +enum class MenuState { + CONTI, + SAVE, + LOAD, + NEW, + QUIT, + NEW_CHEAT +}; + +struct MenuButton { + MenuState state; + std::string text; + SDL_FRect rect; + bool hovered; +}; + + +// Example state +class StateMenuMain : public GameState { +private: + std::vector<MenuButton> buttons; + size_t selected_index = 0; +public: + StateMenuMain(); + ~StateMenuMain() override; + + bool Init(Game*) override; + void handle_Events(SDL_Event&, Game*) override; + void Update(Game*) override; + void Render(Game*) override; +}; diff --git a/src/game/state_modify.cpp b/src/game/state_modify.cpp new file mode 100644 index 0000000..cd15e73 --- /dev/null +++ b/src/game/state_modify.cpp @@ -0,0 +1,193 @@ +#include "state_modify.hpp" + +#include "game/game.hpp" +#include "map/map.hpp" +#include "defaults/ui.hpp" + +StateModify::StateModify() {} +StateModify::~StateModify() {} + +bool StateModify::Init(Game* game) { + if (!game->renderer) { + std::cerr << "Something went wrong in StateModify::Init\n"; + } + + //Tile::tileset_offset.x = Map::offset.x; + //Tile::tileset_offset.y = Map::offset.y; + cursor = game->cursor; + cursor->state = CursorState::NORMAL; + + return true; +} + +void StateModify::handle_Events(SDL_Event& event, Game* game) { + if (game->input.cursor_over_tileset) { + game->input.mouse_game_offset = {static_cast<int>(Tile::tileset_offset.x), + static_cast<int>(Tile::tileset_offset.y) }; + } + + + switch (event.type) { + case SDL_EVENT_KEY_DOWN: + switch (event.key.scancode) { + case SDL_SCANCODE_H: + Tile::draw_tile_set = !Tile::draw_tile_set; + break; + case SDL_SCANCODE_O: + Tile::tile_selected = false; + Tile::object_selected = false; + Tile::draw_tile_set = true; + + ModifyState_s state; + if (Tile::active_tileset_type == TILE_BACKGROUND) { + state = MODIFY_FLOOR_TYPE; + } else { + if (game->input.pressed_ctrl) + state = MODIFY_OBJECTS_PROPS; + else if (game->input.pressed_shift) + state = MODIFY_OBJECTS_PROPS_RESOURCE; + else + state = MODIFY_OBJECTS; + } + + Default::modify_state = (Default::modify_state != state) + ? state + : MODIFY_TILES; + break; + case SDL_SCANCODE_M: + // if (Default::game_state != GAME_MODIFY || !Tile::draw_tile_set) break; + if (!Tile::draw_tile_set) { + Tile::draw_tile_set = true; + break; + } + + Tile::tile_selected = false; + Tile::object_selected = false; + Tile::draw_tile_set = true; + if (game->input.pressed_ctrl) { + Default::modify_state = MODIFY_TILES; + Tile::active_tileset_type = + static_cast<TileType>( + (Tile::active_tileset_type + 1) == TILE_TYPE_LAST + ? TILE_TYPE_FIRST+1 + : Tile::active_tileset_type+1 + ); + Tile::active_tileset_id = 0; + } else if (game->input.pressed_shift) + Tile::active_tileset_id = + Tile::active_tileset_id == 0 + ? Tile::tilesets[Tile::active_tileset_type].size() - 1 + : Tile::active_tileset_id -1; + else { + Tile::active_tileset_id = + (Tile::active_tileset_id + 1) % Tile::tilesets[Tile::active_tileset_type].size(); + } + + Tile::active_tileset = &Tile::tilesets[Tile::active_tileset_type][Tile::active_tileset_id]; + //Tile::fix_TilesetObjectInfo(); + break; + case SDL_SCANCODE_RIGHTBRACKET: + if (game->input.pressed_ctrl) { + Tile::selection_tile_dimension.x++; + Tile::selection_tile_dimension.y++; + } else if (game->input.pressed_shift) + Tile::selection_tile_dimension.y++; + else + Tile::selection_tile_dimension.x++; + break; + case SDL_SCANCODE_SLASH: // thats - MINUS + if (game->input.pressed_ctrl) { + Tile::selection_tile_dimension.x = Tile::selection_tile_dimension.x > 0 + ? Tile::selection_tile_dimension.x -1 : 0; + Tile::selection_tile_dimension.y = Tile::selection_tile_dimension.y > 1 + ? Tile::selection_tile_dimension.y -1 : 1; + } else if (game->input.pressed_shift) + Tile::selection_tile_dimension.y = Tile::selection_tile_dimension.y > 1 + ? Tile::selection_tile_dimension.y -1 : 1; + else + Tile::selection_tile_dimension.x = Tile::selection_tile_dimension.x > 1 + ? Tile::selection_tile_dimension.x -1 : 1; + break; + case SDL_SCANCODE_0: + if (game->input.pressed_ctrl) + Tile::selection_tile_dimension = {1,1}; + break; + case SDL_SCANCODE_S: + if (game->input.pressed_ctrl) { + Map::save_MapTiles(Map::tile_map, Map::save_path); + Map::save_TileCollision( Map::save_collission_path); + Tile::save_Collissions(); + Tile::save_Objects(); + } else { + Default::game_scale = (Default::game_scale == 1) ? 2 : 1; + } + break; + case SDL_SCANCODE_R: + if (game->input.pressed_ctrl) { + Map::Reset(); + } + break; + case SDL_SCANCODE_K: + if (game->input.pressed_shift) { + Map::init_Collider(); + } else if (game->input.pressed_ctrl + && Default::modify_state == MODIFY_COLLISSION) { + Map::set_CollissionFromTileset(); + } else + Default::modify_state = (Default::modify_state != MODIFY_COLLISSION) + ? MODIFY_COLLISSION + : MODIFY_TILES; + break; + default: break; + } + default: break; + } +} + +void StateModify::StateModify::Update(Game* game) { + // SET Map offset + if ((!game->input.cursor_over_tileset && !Tile::setting_tileset_offset) || Map::setting_offset) + Map::set_Offset(game->input); + + bool hovering_set = Tile::hovering_set; + + if (Default::modify_state == MODIFY_COLLISSION) { + if (game->input.click_left_released) { + if (hovering_set) + Tile::set_Collission(game->input); + else + Map::set_Collission(game->input); + } + } else if (Default::modify_state == MODIFY_OBJECTS) { + if (game->input.click_left_released) { + if (hovering_set) + Tile::set_Object(game->input); + } + } else if (Default::modify_state == MODIFY_OBJECTS_PROPS) { + Tile::set_ObjectProps(game->input); + } else if (Default::modify_state == MODIFY_OBJECTS_PROPS_RESOURCE) { + ResourceData::set_ObjectPropsResource(game->input); + } else if (Default::modify_state == MODIFY_FLOOR_TYPE) { + Tile::set_FloorType(game->input); + } else if (game->input.click_left_released && game->input.pressed_c) { + Tile::clear_Objects(game->input); + } else if ((game->input.click_left || game->input.click_left_released)&& !game->input.pressed_ctrl) { + Tile::transfer_ToMap(game->input); + } + if (!Map::setting_offset && (hovering_set || Tile::setting_tileset_offset)) + Tile::set_TilesetOffset(game->input); +} + +void StateModify::StateModify::Render(Game* game) { + if (Tile::draw_tile_set) { + Tile::draw_Tileset(game->renderer, game->input); + } + + if (Tile::object_selected) + Tile::draw_SelectedObject(game->renderer, game->input); + + Ui::draw_TopBarTileInfo(game->renderer, game->win_size); + + Map::draw_SelectionBorder(game->renderer, game->input); + +} diff --git a/src/game/state_modify.hpp b/src/game/state_modify.hpp new file mode 100644 index 0000000..a4e88e8 --- /dev/null +++ b/src/game/state_modify.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include "game/game_state.hpp" + +// Example state +class StateModify : public GameState { +public: + StateModify(); + ~StateModify() override; + + bool Init(Game*) override; + void handle_Events(SDL_Event&, Game*) override; + void Update(Game*) override; + void Render(Game*) override; +}; diff --git a/src/game/state_playing.cpp b/src/game/state_playing.cpp new file mode 100644 index 0000000..349c89d --- /dev/null +++ b/src/game/state_playing.cpp @@ -0,0 +1,335 @@ +#include "state_playing.hpp" + +#include "inventory/weapon.hpp" +#include "map/map.hpp" +#include "building/research.hpp" +#include "building/craft.hpp" +#include "game/game.hpp" +#include "defaults/ui.hpp" +#include "character/message.hpp" +#include "defaults/shuffle_texture.hpp" + +StatePlaying::StatePlaying() { + std::cout << "CREATE STATE_PLAYING " << this << std::endl; +} +StatePlaying::~StatePlaying() { + std::cout << "STATEPL DTOR " << this << std::endl; +} + +StatePlaying::StatePlaying(StatePlaying&&) { + std::cout << "[StatePlaying] Move constructor called!" << std::endl; +} + +bool StatePlaying::Init(Game* game) { + std::cout << "Call init state_game\n"; + Default::now = SDL_GetPerformanceCounter(); + Default::last = 0; + Default::delta_time = 0.0; + + cursor = game->cursor; + cursor->set_State(CursorState::HIDDEN); + + // INIT Bird + Bird::Init(game->renderer); + + player = std::make_unique<Character>(); + player->Init(game->renderer); + + std::cout << "PLAYER:: " << this << " " << player << std::endl; + + // INIT Weapons + Weapon::Init(game->renderer); + + // INIT Building + BuildingData::Init(game->renderer); + + // INIT Enemy + Enemy::init_All(game->renderer); + + Map::tile_map = Map::load_MapTiles(Map::save_path); + if (Map::tile_map.size() == 0) Map::Init(); + + Map::load_TileCollision(Map::save_collission_path); + if (Map::tile_collission_map.size() == 0) Map::init_Collider(); + + Map::offset = {0, 0}; + Default::game_scale = 4.0; + + + // START CHEAT + if (game->is_cheating) { + player->inventory->add_Resource(ResourceType::WOOD, 120, player->messages.get()); + player->inventory->add_Resource(ResourceType::STONE, 120, player->messages.get()); + player->inventory->add_Resource(ResourceType::CLAY, 120, player->messages.get()); + player->inventory->add_Resource(ResourceType::IRON, 120, player->messages.get()); + player->set_ResourceDiscovery(ResourceType::WOOD); + player->set_ResourceDiscovery(ResourceType::STONE); + player->set_ResourceDiscovery(ResourceType::CLAY); + player->set_ResourceDiscovery(ResourceType::IRON); + player->researched_items[static_cast<size_t>(ItemType::SWORD_WOOD)] = true; + player->researched_items[static_cast<size_t>(ItemType::WOODAXE_STONE)] = true; + player->researched_items[static_cast<size_t>(ItemType::CULTIVATOR)] = true; + player->researched_buildings[static_cast<size_t>(BuildingType::CRAFTING_WOOD_1)] = true; + player->set_BuildingDiscovery(); + player->inventory->add_Item(ItemType::SWORD_WOOD, player->messages.get()); + player->inventory->add_Item(ItemType::WOODAXE_STONE, player->messages.get()); + player->inventory->add_Item(ItemType::BUILDING_TOOL, player->messages.get()); + player->inventory->add_Item(ItemType::CULTIVATOR, player->messages.get()); + player->inventory->add_Vegetable(VegetableData::Type::CARROT, 4, player->messages.get()); + player->inventory->add_Vegetable(VegetableData::Type::CABBAGE, 4, player->messages.get()); + player->is_attackable = true; + } + // END CHEAT + + + // Enemy + Enemy::enemies.clear(); + Enemy::enemies_to_spawn.clear(); + /* + */ + Enemy::init_SpawnEnemy(0, WeaponType::SWORD, WeaponMaterial::WOOD, {850, 480}, {16,16,2,false,false,0,1.2}); + Enemy::init_SpawnEnemy(0, WeaponType::SWORD, WeaponMaterial::WOOD, {450, 480}, {16,16,2,false,false,0,1.2}); + Enemy::init_SpawnEnemy(0, WeaponType::SWORD, WeaponMaterial::WOOD, {150, 480}, {16,16,2,false,false,0,1.2}); + /* + Enemy::init_SpawnEnemy(1, WeaponType::SWORD, WeaponMaterial::WOOD, {140, 100}, {6,6,1,false,false,0,1.2}); + Enemy::init_SpawnEnemy(1, WeaponType::SWORD, WeaponMaterial::WOOD, {100, 10}, {6,6,1,false,false,0,1.2}); + Enemy::init_SpawnEnemy(1, WeaponType::SWORD, WeaponMaterial::WOOD, {100, 130}, {6,6,1,false,false,0,1.2}); + Enemy::init_SpawnEnemy(1, WeaponType::SWORD, WeaponMaterial::WOOD, {200, 100}, {6,6,1,false,false,0,1.2}); + Enemy::init_SpawnEnemy(1, WeaponType::SWORD, WeaponMaterial::WOOD, {600,100}, {6,6,1,false,false,0,1.2}); + Enemy::init_SpawnEnemy(1, WeaponType::SWORD, WeaponMaterial::WOOD, {600,100}, {6,6,1,false,false,0,1.2}); + */ + //Enemy::init_SpawnEnemy(1, WeaponType::SWORD, WeaponMaterial::WOOD, {150, 100}, {6,6,1,false,false,0,1.2}); + + //for (int i = 0; i < 12; i++) Enemy::init_SpawnEnemy(1, WeaponType::SWORD, WeaponMaterial::WOOD, {600,100}, {6,6,1,false,false,0,1.2}); + + return true; +} + +inline void setActiveMenu(CharacterMenuType& active_menu, const CharacterMenuType& new_menu, AnimatedCursor* cursor) { + switch (active_menu) { + case CharacterMenuType::NONE: + active_menu = new_menu; + cursor->set_State(CursorState::ANIMATED); + break; + default: + active_menu = CharacterMenuType::NONE; + cursor->set_State(CursorState::HIDDEN); + break; + } +} + +void StatePlaying::handle_Events(SDL_Event& event, Game* game) { + if (game->input.cursor_over_tileset) { + game->input.mouse_game_offset = {(int)Tile::tileset_offset.x, + (int)Tile::tileset_offset.y }; + } + + game->input.clicked_on_map = false; + //std::cout << "ET: " << (int)event.type << std::endl; + switch (event.type) { + case SDL_EVENT_KEY_DOWN: { + if (event.key.scancode >= SDL_SCANCODE_1 && event.key.scancode <= SDL_SCANCODE_6) { + player->inventory->selected_hotbar_last = player->inventory->selected_hotbar; + player->inventory->selected_hotbar = (int)(event.key.scancode - SDL_SCANCODE_1) + 1; + } if (event.key.scancode == SDL_SCANCODE_0) { + Default::game_scale = 4.0; + } + break; + } + + case SDL_EVENT_KEY_UP: + switch (event.key.scancode) { + case SDL_SCANCODE_B: { + InventoryItem *sel_item = nullptr; + if (player->selected_item->object_type == InventoryObjectType::ITEM) { + sel_item = static_cast<InventoryItem*>(player->selected_item); + if (sel_item->type == ItemType::BUILDING_TOOL) + setActiveMenu(player->active_menu, CharacterMenuType::BUILDING, cursor); + else + player->messages->Add(MessageKey::BUILDING_TOOL_REQUIRED); + } else + player->messages->Add(MessageKey::BUILDING_TOOL_REQUIRED); + break; + } + case SDL_SCANCODE_R: + Inventory::selected_hotbar = !Inventory::selected_hotbar ? Inventory::selected_hotbar_last : 0; + break; + case SDL_SCANCODE_E: + setActiveMenu(player->active_menu, CharacterMenuType::INVENTORY, cursor); + Inventory::draw_menu = !Inventory::draw_menu; + break; + case SDL_SCANCODE_K: { + Building::construction_mode = Building::construction_mode == BuildingStatus::DECONSTRUCT ? + BuildingStatus::CONSTRUCTING: + BuildingStatus::DECONSTRUCT; + InventoryItem *it = static_cast<InventoryItem*>(player->selected_item); + if (it && it->type == ItemType::CULTIVATOR) + player->cultivation_logic.is_removing = !player->cultivation_logic.is_removing; + break; + } + case SDL_SCANCODE_F5: + player->health_Reduce(100000000); + break; + case SDL_SCANCODE_F11: // FOR TESTING + Enemy::init_SpawnEnemy(0, WeaponType::SWORD, WeaponMaterial::WOOD, {150, 100}, {16,16,2,false,false,0,1.2}); + return; + default: + break; + } + break; + case SDL_EVENT_MOUSE_BUTTON_UP: + if (!game->input.pressed_ctrl && !game->input.pressed_shift) + game->input.clicked_on_map = true; + break; + default: + break; + } +} + +void update_CameraOffset( + const SDL_FPoint& player_world, + const SDL_Rect& win_size +) { + const float inv_scale = 1.0f / Default::game_scale; + + const float logical_w = win_size.w * inv_scale; + const float logical_h = win_size.h * inv_scale; + + const float margin_x = logical_w * 0.4f; + const float margin_y = logical_h * 0.4f; + + const float player_screen_x = player_world.x + Map::offset.x; + const float player_screen_y = player_world.y + Map::offset.y; + + float target_offset_x = Map::offset.x; + float target_offset_y = Map::offset.y; + + // Horizontal deadzone + if (player_screen_x < margin_x) { + target_offset_x = margin_x - player_world.x; + } + else if (player_screen_x > logical_w - margin_x) { + target_offset_x = (logical_w - margin_x) - player_world.x; + } + + // Vertical deadzone + if (player_screen_y < margin_y) { + target_offset_y = margin_y - player_world.y; + } + else if (player_screen_y > logical_h - margin_y) { + target_offset_y = (logical_h - margin_y) - player_world.y; + } + + // --- Smooth interpolation --- + const float follow_speed = 10.0f; // higher = snappier + const float t = 1.0f - std::exp(-follow_speed * Default::delta_time); + + Map::offset.x += (target_offset_x - Map::offset.x) * t; + Map::offset.y += (target_offset_y - Map::offset.y) * t; +} + +void StatePlaying::Update(Game* game) { + + // SET Map offset + Map::set_Offset(game->input); + + // VEGETABLES + for (Vegetable* veg : VegetableData::all_vegetables) { + veg->Grow(Default::get_TimeSinceStartInSec()); + } + + // CHARACTER + player->handle_Input(game->input, game->win_size); + player->Update(); + if (player->status == CharacterStatus::DEAD && player->death_shuffler == nullptr) { + player->death_shuffler = new PixelShuffler(game->renderer, player->active_anim->surface); + player->shuffle_timer = 0.0f; + Animation::audio->Play("character.dead"); + return; + } + + // MESSAGES + player->messages->Update(); + + // START ENEMY HANDLING + // spawn + for (size_t i = 0; i < Enemy::enemies_to_spawn.size(); ) { + SpawnParams &sp = Enemy::enemies_to_spawn[i]; + if (Enemy::spawn_Enemy(sp)) + Enemy::enemies_to_spawn.erase(Enemy::enemies_to_spawn.begin() + static_cast<long>(i)); + else + ++i; + } + + + // get moves + Enemy::run_GetMovesThreads(); + + // update moves + for (Enemy* enemy : Enemy::enemies) + enemy->Update(*player); + + // clear dead + Enemy::remove_Dead(); + // END ENEMY HANDLING + + + // CAMERA + update_CameraOffset({player->x+player->tile_size/2, player->y+player->tile_size/2}, game->win_size); +} + +void StatePlaying::Render(Game* game) { + if (!game->renderer) + std::cerr << "ERROR in StatePlayin::Render\n"; + + player->messages->render_InventoryMessages(game, player->inventory.get()); + + switch (player->active_menu) { + case CharacterMenuType::NONE: break; + case CharacterMenuType::BUILDING: + BuildingData::draw_WorkbenchMenu(game->renderer, game->win_size, player->discovered_buildings); + break; + case CharacterMenuType::INVENTORY: + player->inventory->draw_Menu( game->renderer, game->win_size, Ui::font_menu, player->researched_items, Inventory::cursor_OverCraftButton(game->input.mouse_state_raw)); + break; + case CharacterMenuType::RESEARCH: + Research::draw_ReserachMenu(game->renderer, game->win_size, Building::selected_building_type, player->researched_buildings, player->researched_items, Research::cursor_OverResearchButton(game->input.mouse_state_raw)); + break; + case CharacterMenuType::WORKBENCH: + Craft::draw_CraftMenu(game, Building::selected_building_type, Craft::cursor_OverCraftButton(game->input.mouse_state_raw)); + break; + } + + player->inventory->draw_Hotbar(game->renderer, Ui::font_menu); + + //player->messages->render_ResourceMessages(game, player->inventory->resources); + + Ui::draw_BottomLeftBars(game->renderer, game->win_size, *player); +} + +void StatePlaying::Load(SDL_Renderer* renderer, std::string path) { + Map::tile_map = Map::load_MapTiles(path + "/map"); + std::cout << "STATE LOAD\n"; + Map::load_TileCollision(path + "/collisions"); + if (!renderer) + std::cerr << "FUCK NO RENDERER..\n"; + + + Enemy::load_All(path+"/enemies"); + for (size_t i = 0; i < Enemy::enemies_to_spawn.size(); ) { + SpawnParams &sp = Enemy::enemies_to_spawn[i]; + if (Enemy::spawn_Enemy(sp)) + Enemy::enemies_to_spawn.erase(Enemy::enemies_to_spawn.begin() + static_cast<long>(i)); + else + ++i; + } + + player->Load(path); +} + +void StatePlaying::Save(std::string path) { + Map::save_MapTiles(Map::tile_map, path + "/map"); + Map::save_TileCollision(path + "/collisions"); + Enemy::save_All(path+"/enemies"); + player->Save(path); +} diff --git a/src/game/state_playing.hpp b/src/game/state_playing.hpp new file mode 100644 index 0000000..24358f2 --- /dev/null +++ b/src/game/state_playing.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include "game/game_state.hpp" +#include "character/character.hpp" + +class StatePlaying : public GameState { + +public: + std::unique_ptr<Character> player; + StatePlaying(); + StatePlaying(StatePlaying&&); + ~StatePlaying() override; + + bool Init(Game*) override; + + void handle_Events(SDL_Event&, Game*) override; + + void Update(Game*) override; + + void Render(Game*) override; + + void Load(SDL_Renderer* renderer, std::string path); + void Save(std::string path); +}; diff --git a/src/inventory/inventory.cpp b/src/inventory/inventory.cpp new file mode 100644 index 0000000..54160e3 --- /dev/null +++ b/src/inventory/inventory.cpp @@ -0,0 +1,1340 @@ +#include "inventory.hpp" + +#include <string> +#include <sstream> +#include <iomanip> + +#include "defaults/icons.hpp" +#include "map/tile.hpp" +#include "defaults/ui.hpp" +#include "character/message.hpp" + +static SDL_Color MENU_HOVER_BORDER_C = Default::menu_hovering_color; + +static constexpr float INFO_PANEL_WIDTH = 180; +static constexpr float MENU_BORDER = 4.f; +static SDL_FRect menu_inner = {0,0, 0, 0}; + +float inventory_grid_ts = 48.f; +float inventory_grid_tile_border = 2.f; +float inventory_grid_tile_gap = 4.f; +float inventory_grid_slot_size = inventory_grid_ts + inventory_grid_tile_border * 2 + inventory_grid_tile_gap; + +int inventory_grid_cols = 5; +int inventory_grid_rows = 5; + +float build_menu_width = 64.f; +int build_menu_rows = 5; + + + +bool Inventory::draw_menu = false; +bool Inventory::clicked_button_craft = false; +int Inventory::selected_hotbar = 0; +int Inventory::selected_hotbar_last = 0; + +Equipement Inventory::hotbar[HOTBAR_SLOTS]; +InventoryItem* Inventory::hotbar_hands = nullptr; + +ItemType Inventory::selected_build_item = ItemType::NONE; +InventorySelection* Inventory::selected_item = nullptr; + + + + +Inventory::Inventory() { + std::cout << "CREATE INVENTORY!\n"; + + selected_hotbar = 0; + selected_hotbar_last = 0; + draw_menu = false; + clicked_button_craft = false; + + selected_build_item = ItemType::NONE; + + hotbar_hands = new InventoryItem(0, ItemType::HAND); + next_item_id = 1; + Inventory::selected_item = nullptr; + + for (int i = 1; i < HOTBAR_SLOTS; i++) { + Inventory::hotbar[i].item_id = 0; + Inventory::hotbar[i].type = InventoryObjectType::ITEM; + } +} + + +Inventory::Inventory(Inventory&&) { + std::cout << "[Inventory] Move constructor called!" << std::endl; +} + + +// EQUIPEMENT + +void Inventory::Equip(InventoryItem* item) { + equipment[item->equipement_slot].item_id = item->id; + equipment[item->equipement_slot].type = InventoryObjectType::ITEM; +} + +void Inventory::Equip(InventoryVegetable* item) { + equipment[item->equipement_slot].item_id = item->id; + equipment[item->equipement_slot].type = InventoryObjectType::VEGETABLE; +} + +void Inventory::Unequip(EquipmentSlot slot) { + equipment.erase(slot); +} + +// VEGETABLE +void +Inventory::add_Vegetable(VegetableData::Type type, size_t amount, Messages* messages) { + auto [it, inserted] = vegetables.try_emplace(type, InventoryVegetable(next_item_id, type, false)); + if (inserted) + next_item_id++; + + it->second.count += amount; + + auto* t = new VegetableData::Type(type); + std::cout << "ADD VEGETABLE TYPE: " << static_cast<int>(*t) << std::endl; + if (messages) + messages->Add(MessageKey::ADD_VEGETABLE, static_cast<void*>(t)); +} + +int +Inventory::remove_Vegetable(VegetableData::Type type, size_t amount) { + auto it = vegetables.find(type); + int ret = -1; + if (it == vegetables.end() || it->second.count < amount) + return ret; + + it->second.count -= amount; + ret = it->second.count; + if (it->second.count == 0) { + vegetables.erase(it); + bool setted_hotbar = set_HotbarItem(Inventory::selected_hotbar, Inventory::hotbar_hands); + if (setted_hotbar) + Equip(Inventory::hotbar_hands); + } + return ret; +} + +int +Inventory::get_Vegetable(VegetableData::Type type) const { + auto it = vegetables.find(type); + return (it != vegetables.end()) ? it->second.count : 0; +} + +// SEED +void +Inventory::add_Seed(VegetableData::Type type, size_t amount, Messages* messages) { + auto [it, inserted] = seeds.try_emplace(type, InventoryVegetable(next_item_id, type, true)); + if (inserted) + next_item_id++; + + it->second.count += amount; + + auto* t = new VegetableData::Type(type); + std::cout << "ADD VEGETABLE TYPE: " << static_cast<int>(*t) << std::endl; + if (messages) + messages->Add(MessageKey::ADD_VEGETABLE_SEED, static_cast<void*>(t)); +} + +bool +Inventory::remove_Seed(VegetableData::Type type, size_t amount) { + std::cout << "TSCHÖÖ\n"; + auto it = seeds.find(type); + if (it == seeds.end() || it->second.count < amount) + return false; + + it->second.count -= amount; + if (it->second.count == 0) { + seeds.erase(it); + bool setted_hotbar = set_HotbarItem(Inventory::selected_hotbar, Inventory::hotbar_hands); + if (setted_hotbar) + Equip(Inventory::hotbar_hands); + } + return true; +} + +int +Inventory::get_Seed(VegetableData::Type type) const { + auto it = seeds.find(type); + return (it != seeds.end()) ? it->second.count : 0; +} + +// RESOURCE +void +Inventory::add_Resource(ResourceType type, int amount, Messages* messages) { + if (type == ResourceType::NONE || amount <= 0) + return; + + resources[type] += amount; + + ResourceType* t = new ResourceType(type); + std::cout << "ADD RESOURCE TYPE: "<< static_cast<int>(*t) << std::endl; + messages->Add(MessageKey::ADD_RESOURCE, static_cast<void*>(t)); +} +bool +Inventory::remove_Resource(ResourceType type, int amount) { + auto it = resources.find(type); + if (it == resources.end() || it->second < amount) + return false; + + it->second -= amount; + if (it->second == 0) + resources.erase(it); + return true; +} + +int +Inventory::get_Resource(ResourceType type) const { + auto it = resources.find(type); + return (it != resources.end()) ? it->second : 0; +} + + +// ITEM +InventoryItem* +Inventory::add_Item(ItemType item, Messages* messages) { + if (item == ItemType::NONE) return nullptr; + + size_t* id = new size_t(next_item_id++); + std::cout << "INV ID: " << *id << " " << next_item_id << std::endl; + items.emplace_back(std::make_unique<InventoryItem>(*id, item)); + if (messages) { + messages->Add(MessageKey::ADD_INVENTORY, static_cast<void*>(id)); + } + + + + std::cout << "ADD ITEM MESS\n"; + std::cout << items.size() << " type: " << Item::to_String(items.back()->type) << std::endl; + return items.back().get(); +} + +bool +Inventory::remove_Item(ItemType item) { + for (auto it = items.begin(); it != items.end(); ++it) { + if ((*it)->type == item) { + items.erase(it); + return true; + } + } + return false; +} + +bool +Inventory::has_Item(ItemType item) const { + for (auto& it : items) + if (it->type == item) + return true; + return false; +} + + +// DRAW +void +Inventory::draw_BuildMenu(SDL_Renderer* renderer, std::vector<bool> researched_items) { + const float ts = inventory_grid_ts; + const float gap = inventory_grid_tile_gap; + const float border = inventory_grid_tile_border; + + const float column_x = menu_inner.x + menu_inner.w - build_menu_width; + const float column_w = build_menu_width; + const float column_h = menu_inner.h; + + SDL_FRect bg{ column_x, menu_inner.y, column_w, column_h }; + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); + SDL_RenderFillRect(renderer, &bg); + + const float icon_x = column_x + (column_w - ts) * 0.5f; + + auto draw_slot = [&](float y, ItemType item) { + SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); + SDL_FRect slot_bg{ icon_x, y, ts, ts }; + SDL_RenderFillRect(renderer, &slot_bg); + + if (item != ItemType::NONE) { + auto it = Icon::item_pos.find(item); + if (it != Icon::item_pos.end()) { + SDL_FRect src{ it->second.x * 16.f, it->second.y * 16.f, 16.f, 16.f }; + SDL_FRect dst{ icon_x, y, ts, ts }; + SDL_RenderTexture(renderer, Icon::icons_texture, &src, &dst); + } + } + + if (item != ItemType::NONE && item == selected_build_item) + SDL_SetRenderDrawColor(renderer, 40, 140, 40, 255); + else + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); + + SDL_FRect border_rect{ + icon_x - border, y - border, + ts + border * 2, ts + border * 2 + }; + SDL_RenderRect(renderer, &border_rect); + }; + + // row 0 + draw_slot(menu_inner.y + 0 * (ts + gap), ItemType::BUILDING_TOOL); + if (researched_items[static_cast<int>(ItemType::SWORD_WOOD)]) + draw_slot(menu_inner.y + 1 * (ts + gap), ItemType::SWORD_WOOD); + else + draw_slot(menu_inner.y + 1 * (ts + gap), ItemType::NONE); + + // rows not set jet + for (int i = 2; i < build_menu_rows; i++) + draw_slot(menu_inner.y + i * (ts + gap), ItemType::NONE); +} + +ItemType +Inventory::hit_BuildMenu(const SDL_FPoint& mouse, SDL_Rect, std::vector<bool> researched_items) { + const float ts = inventory_grid_ts; + const float gap = inventory_grid_tile_gap; + + const float column_x = menu_inner.x + menu_inner.w - build_menu_width; + const float column_w = build_menu_width; + + const float icon_x = column_x + (column_w - ts) * 0.5f; + const float icon_x_end = icon_x + ts; + + if (mouse.x < icon_x || mouse.x > icon_x_end) + return ItemType::NONE; + + float rel_y = mouse.y - menu_inner.y; + if (rel_y < 0) + return ItemType::NONE; + + int row = (int)(rel_y / (ts + gap)); + if (row < 0 || row >= build_menu_rows) + return ItemType::NONE; + + switch (row) { + case 0: + return ItemType::BUILDING_TOOL; + case 1: + if (researched_items[static_cast<size_t>(ItemType::SWORD_WOOD)]) + return ItemType::SWORD_WOOD; + return ItemType::NONE; + default: + return ItemType::NONE; + } +} + +bool +Inventory::cursor_OverCraftButton(const SDL_FPoint& mouse) { + const float panel_w = INFO_PANEL_WIDTH; + const float panel_h = menu_inner.h; + const float panel_x = menu_inner.x + menu_inner.w + 10.f; + const float panel_y = menu_inner.y; + + const float btn_h = 24.f; + const float btn_w = panel_w - 12.f; + const float btn_x = panel_x + 6.f; + const float btn_y = panel_y + panel_h - btn_h - 6.f; + + // simple AABB check + return mouse.x >= btn_x && mouse.x <= btn_x + btn_w && + mouse.y >= btn_y && mouse.y <= btn_y + btn_h; +} + +void +Inventory::draw_InfoPanel(SDL_Renderer* renderer, + TTF_Font* font, + ItemType /*unused*/, + bool is_hovering_craftbutton) +{ + const float panel_w = INFO_PANEL_WIDTH; + const float panel_h = menu_inner.h; + const float panel_x = menu_inner.x + menu_inner.w + 10.f; + const float panel_y = menu_inner.y; + const float border = 4.f; + + SDL_SetRenderDrawColor(renderer, 60, 60, 70, 255); + SDL_FRect panel_border{ + panel_x - border, + panel_y - border, + panel_w + border * 2.f, + panel_h + border * 2.f + }; + SDL_RenderFillRect(renderer, &panel_border); + + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); + SDL_FRect panel_bg{ panel_x, panel_y, panel_w, panel_h }; + SDL_RenderFillRect(renderer, &panel_bg); + + const float line_h = 20.f; + const float spacing = 4.f; + float y = panel_y + 6.f; + + auto draw_line = [&](const std::string& text) + { + SDL_Color white{255,255,255,255}; + SDL_Surface* surf = TTF_RenderText_Solid(font, text.c_str(), text.length(), white); + if (!surf) return; + + SDL_Texture* tex = SDL_CreateTextureFromSurface(renderer, surf); + if (tex) + { + SDL_FRect dst{ + panel_x + 6.f, + y, + (float)surf->w, + (float)surf->h + }; + SDL_RenderTexture(renderer, tex, nullptr, &dst); + SDL_DestroyTexture(tex); + } + + y += line_h + spacing; + SDL_DestroySurface(surf); + }; + + auto resource_name = [](ResourceType type) -> const std::string& + { + size_t idx = static_cast<size_t>(type); + if (idx < ResourceData::names.size()) + return ResourceData::names[idx]; + return ResourceData::names.back(); + }; + + const ItemCrafting& ci = Item::crafting_item; + + // ================================================================ + // BUILD ITEM SELECTED + // ================================================================ + if (selected_build_item != ItemType::NONE) + { + const ItemStats& s = Item::get(selected_build_item); + + const bool craftable = + (s.crafting_duration > 0.f) && + (s.cost.size() != 0); + + draw_line("ITEM:"); + draw_line(s.title); + y += spacing; + + if (craftable) + { + draw_line("COST:"); + for (const auto& c : s.cost) + { + const std::string& name = resource_name(c.type); + draw_line(name + ": " + std::to_string(c.amount)); + } + y += spacing; + } + + draw_line("STATS:"); + + if (s.base_damage > 0) + draw_line("Damage: " + std::to_string(s.base_damage)); + + if (s.base_armor > 0) + draw_line("Armor: " + std::to_string(s.base_armor)); + + draw_line("Health: " + std::to_string(s.base_health)); + + if (s.base_speed > 0.f) { + std::ostringstream ss; + ss << std::fixed << std::setprecision(1) << s.base_speed; + draw_line("Speed: " + ss.str()); + } + + if (s.max_level > 0) + draw_line("Max Lvl: " + std::to_string(s.max_level)); + + if (!craftable) + return; + + const float btn_h = 24.f; + const float btn_w = panel_w - 12.f; + const float btn_x = panel_x + 6.f; + const float btn_y = panel_y + panel_h - btn_h - 6.f; + + SDL_SetRenderDrawColor(renderer, 40, 140, 40, 255); + SDL_FRect craft_btn{ btn_x - 1.f, btn_y - 1.f, btn_w + 2.f, btn_h + 2.f }; + SDL_RenderFillRect(renderer, &craft_btn); + + if (is_hovering_craftbutton) + SDL_SetRenderDrawColor(renderer, + MENU_HOVER_BORDER_C.r, + MENU_HOVER_BORDER_C.g, + MENU_HOVER_BORDER_C.b, + MENU_HOVER_BORDER_C.a); + else + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); + + SDL_RenderRect(renderer, &craft_btn); + + if (ci.is_crafting && ci.stats.type == s.type) + { + float p = ci.duration / s.crafting_duration; + if (p < 0.f) p = 0.f; + if (p > 1.f) p = 1.f; + + SDL_SetRenderDrawColor(renderer, 80, 200, 80, 255); + SDL_FRect fill{ btn_x, btn_y, btn_w * p, btn_h }; + SDL_RenderFillRect(renderer, &fill); + } + + SDL_Surface* surf = + TTF_RenderText_Solid(Ui::font_menu_bold, "Craft", 5, SDL_Color{255,255,255,255}); + + if (surf) + { + SDL_Texture* tex = SDL_CreateTextureFromSurface(renderer, surf); + if (tex) + { + SDL_FRect dst{ + btn_x + btn_w * 0.5f - surf->w * 0.5f, + btn_y + btn_h * 0.5f - surf->h * 0.5f, + (float)surf->w, + (float)surf->h + }; + SDL_RenderTexture(renderer, tex, nullptr, &dst); + SDL_DestroyTexture(tex); + } + SDL_DestroySurface(surf); + } + + return; + } + + // ================================================================ + // IF CRAFTING BUT NOTHING SELECTED -> SHOW CRAFTING ITEM + // ================================================================ + if (ci.is_crafting) + { + const ItemStats& s = ci.stats; + + draw_line("CRAFTING:"); + draw_line(s.title); + y += spacing; + + const float btn_h = 24.f; + const float btn_w = panel_w - 12.f; + const float btn_x = panel_x + 6.f; + const float btn_y = panel_y + panel_h - btn_h - 6.f; + + float p = 0.f; + if (s.crafting_duration > 0.f) + p = ci.duration / s.crafting_duration; + + if (p < 0.f) p = 0.f; + if (p > 1.f) p = 1.f; + + SDL_SetRenderDrawColor(renderer, 80, 200, 80, 255); + SDL_FRect fill{ btn_x, btn_y, btn_w * p, btn_h }; + SDL_RenderFillRect(renderer, &fill); + + return; + } + + // ================================================================ + // INVENTORY SELECTION + // ================================================================ + if (selected_item && selected_item->is_valid) + { + draw_line("ITEM:"); + + if (selected_item->resource != ResourceType::NONE) + { + draw_line(resource_name(selected_item->resource)); + return; + } + + if (selected_item->vegetable != VegetableData::Type::NONE) + { + const auto& def = + VegetableData::crop_defs[static_cast<uint32_t>(selected_item->vegetable)]; + draw_line(def.name); + return; + } + + if (selected_item->seed != VegetableData::Type::NONE) + { + const auto& def = + VegetableData::crop_defs[static_cast<uint32_t>(selected_item->seed)]; + std::string name = std::string(def.name) + " seed"; + draw_line(name); + return; + } + + if (selected_item->item) + { + auto* inv_item = + static_cast<InventoryItem*>(selected_item->item); + const ItemStats& s = Item::get(inv_item->type); + draw_line(s.title); + draw_line("STATS:"); + + if (s.base_damage > 0) + draw_line("Damage: " + std::to_string(s.base_damage)); + + if (s.base_armor > 0) + draw_line("Armor: " + std::to_string(s.base_armor)); + + draw_line("Health: " + std::to_string(s.base_health)); + + if (s.base_speed > 0.f) + draw_line("Speed: " + std::to_string(s.base_speed)); + + if (s.max_level > 0) + draw_line("Max Lvl: " + std::to_string(s.max_level)); + return; + } + } +} + +void +Inventory::draw_InventoryGrid(SDL_Renderer* renderer) { + auto draw_icon = [&](float x, float y, Icon::TilePos pos, int count, bool highlight) { + const float src_ts = 16.f; + + // border + if (highlight) + SDL_SetRenderDrawColor(renderer, MENU_HOVER_BORDER_C.r, MENU_HOVER_BORDER_C.g, MENU_HOVER_BORDER_C.b, MENU_HOVER_BORDER_C.a); + else + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); + SDL_FRect b{ + x - inventory_grid_tile_border, + y - inventory_grid_tile_border, + inventory_grid_ts + inventory_grid_tile_border * 2, + inventory_grid_ts + inventory_grid_tile_border * 2 + }; + SDL_RenderFillRect(renderer, &b); + + + // infill + SDL_SetRenderDrawColor(renderer, 60, 60, 70, 255); + SDL_FRect i{ + x, + y, + inventory_grid_ts, + inventory_grid_ts + }; + SDL_RenderFillRect(renderer, &i); + + // icon + SDL_FRect src{ pos.x * src_ts, pos.y * src_ts, src_ts, src_ts }; + SDL_FRect dst{ x, y, inventory_grid_ts, inventory_grid_ts }; + SDL_RenderTexture(renderer, Icon::icons_texture, &src, &dst); + + // text + if (count > 0) { + SDL_Color white{255,255,255,255}; + std::string t = std::to_string(count); + + SDL_Surface* surf = TTF_RenderText_Solid(Ui::font_tiny, t.c_str(), t.length(), white); + if (!surf) return; + + SDL_Texture* tex = SDL_CreateTextureFromSurface(renderer, surf); + if (tex) { + SDL_FRect r{ + x + inventory_grid_ts - surf->w, + y + inventory_grid_ts - surf->h, + (float)surf->w, + (float)surf->h + }; + SDL_RenderTexture(renderer, tex, nullptr, &r); + SDL_DestroyTexture(tex); + } + SDL_DestroySurface(surf); + } + }; + + float inv_left = menu_inner.x; + float inv_top = menu_inner.y; + + auto get_tile_position = [&](int idx) { + int col = idx % inventory_grid_cols; + int row = idx / inventory_grid_cols; + float x = inv_left + col * inventory_grid_slot_size + inventory_grid_tile_border; + float y = inv_top + row * inventory_grid_slot_size + inventory_grid_tile_border; + return std::pair<float,float>(x,y); + }; + + int index = 0; + + // RESOURCE + for (auto& pair : resources) { + if (pair.second <= 0) continue; + + //std::cout << "ITM: " << (int)pair.first << " " << pair.second << std::endl; + if (index >= inventory_grid_cols * inventory_grid_rows) break; + + auto it = Icon::resource_pos.find(pair.first); + if (it == Icon::resource_pos.end()) continue; + + auto pos = get_tile_position(index); + bool highlight = (selected_inventory.is_valid && + selected_inventory.resource == pair.first); + + draw_icon(pos.first, pos.second, it->second, pair.second, highlight); + index++; + } + + // VEGETABLE + for (auto& pair : vegetables) { + if (pair.second.count <= 0) continue; + + //std::cout << "ITM: " << (int)pair.first << " " << pair.second << std::endl; + if (index >= inventory_grid_cols * inventory_grid_rows) break; + + + VegetableData::Type type = pair.first; + const VegetableData::CropDefinition* data = VegetableData::get_DataByType(type); + + auto pos = get_tile_position(index); + bool highlight = (selected_inventory.is_valid && + selected_inventory.vegetable == pair.first); + + //std::cout << "DAT: " <<data.icon_tile_x << " " << data.icon_tile_y << std::endl; + draw_icon(pos.first, pos.second, {data->icon_tile_x, data->icon_tile_y}, pair.second.count, highlight); + index++; + } + + // SEEDS + for (auto& pair : seeds) { + if (pair.second.count <= 0) continue; + + //std::cout << "ITM: " << (int)pair.first << " " << pair.second << std::endl; + if (index >= inventory_grid_cols * inventory_grid_rows) break; + + + VegetableData::Type type = pair.first; + const VegetableData::CropDefinition* data = VegetableData::get_DataByType(type); + + auto pos = get_tile_position(index); + bool highlight = (selected_inventory.is_valid && + selected_inventory.seed == pair.first); + + //std::cout << "DAT: " <<data.icon_tile_x << " " << data.icon_tile_y << std::endl; + draw_icon(pos.first, pos.second, {data->icon_tile_x-1, data->icon_tile_y}, pair.second.count, highlight); + index++; + } + + // ITEM -> TOOL/WEAPON + for (auto& inv_item : items) { + if (index >= inventory_grid_cols * inventory_grid_rows) break; + + auto it = Icon::item_pos.find(inv_item->type); + if (it == Icon::item_pos.end()) continue; + + auto pos = get_tile_position(index); + bool highlight = (selected_inventory.item && + selected_inventory.is_valid && + selected_inventory.item->id == inv_item->id); + + draw_icon(pos.first, pos.second, it->second, 1, highlight); + index++; + } +} + +InventorySelection +Inventory::hit_InventoryGrid(const SDL_FPoint& mouse) { + InventorySelection sel; + + float inv_left = menu_inner.x; + float inv_top = menu_inner.y; + + int index = 0; + + auto rect_for_slot = [&](int idx) { + int col = idx % inventory_grid_cols; + int row = idx / inventory_grid_cols; + + float x = inv_left + col * inventory_grid_slot_size + inventory_grid_tile_border; + float y = inv_top + row * inventory_grid_slot_size + inventory_grid_tile_border; + + return SDL_FRect{ x, y, inventory_grid_ts, inventory_grid_ts }; + }; + + for (auto& pair : resources) { + if (pair.second <= 0) continue; + + if (index >= inventory_grid_cols * inventory_grid_rows) break; + + auto it = Icon::resource_pos.find(pair.first); + if (it == Icon::resource_pos.end()) continue; + + SDL_FRect r = rect_for_slot(index); + + if (mouse.x >= r.x && mouse.x <= r.x + r.w && + mouse.y >= r.y && mouse.y <= r.y + r.h) { + sel.is_valid = true; + sel.resource = pair.first; + sel.vegetable = VegetableData::Type::NONE; + sel.item = nullptr; + sel.tile = it->second; + return sel; + } + + index++; + } + for (auto& pair : vegetables) { + if (pair.second.count <= 0) continue; + + if (index >= inventory_grid_cols * inventory_grid_rows) break; + + + VegetableData::Type type = pair.first; + const VegetableData::CropDefinition* data = VegetableData::get_DataByType(type); + + SDL_FRect r = rect_for_slot(index); + + if (mouse.x >= r.x && mouse.x <= r.x + r.w && + mouse.y >= r.y && mouse.y <= r.y + r.h) { + sel.is_valid = true; + sel.vegetable = type; + sel.resource = ResourceType::NONE; + sel.item = nullptr; + sel.tile = {data->icon_tile_x, data->icon_tile_y}; + return sel; + } + + index++; + } + for (auto& pair : seeds) { + if (pair.second.count <= 0) continue; + + if (index >= inventory_grid_cols * inventory_grid_rows) break; + + + VegetableData::Type type = pair.first; + const VegetableData::CropDefinition* data = VegetableData::get_DataByType(type); + + SDL_FRect r = rect_for_slot(index); + + if (mouse.x >= r.x && mouse.x <= r.x + r.w && + mouse.y >= r.y && mouse.y <= r.y + r.h) { + sel.is_valid = true; + sel.seed = type; + sel.vegetable = VegetableData::Type::NONE; + sel.resource = ResourceType::NONE; + sel.item = nullptr; + sel.tile = {data->icon_tile_x, data->icon_tile_y}; + return sel; + } + + index++; + } + + + for (auto &inv_item : items) { + if (index >= inventory_grid_cols * inventory_grid_rows) break; + + auto it = Icon::item_pos.find(inv_item->type); + if (it == Icon::item_pos.end()) continue; + + SDL_FRect r = rect_for_slot(index); + + if (mouse.x >= r.x && mouse.x <= r.x + r.w && + mouse.y >= r.y && mouse.y <= r.y + r.h) { + sel.is_valid = true; + sel.item = inv_item.get(); + sel.resource = ResourceType::NONE; + sel.vegetable = VegetableData::Type::NONE; + sel.tile = it->second; + return sel; + } + + index++; + } + + return sel; +} + +bool +Inventory::cursor_OverInventoryGrid(const SDL_FPoint& mouse) { + const float grid_x = menu_inner.x; + const float grid_y = menu_inner.y; + + const float grid_w = inventory_grid_cols * inventory_grid_slot_size; + const float grid_h = inventory_grid_rows * inventory_grid_slot_size; + + return mouse.x >= grid_x && + mouse.x < grid_x + grid_w && + mouse.y >= grid_y && + mouse.y < grid_y + grid_h; +} + +bool +Inventory::cursor_OverBuildMenu(const SDL_FPoint& mouse) { + const float column_x = menu_inner.x + menu_inner.w - build_menu_width; + const float column_w = build_menu_width; + + return mouse.x >= column_x && + mouse.x <= column_x + column_w && + mouse.y >= menu_inner.y && + mouse.y <= menu_inner.y + menu_inner.h; +} + +bool +Inventory::cursor_OverInfoPanel(const SDL_FPoint& mouse) { + const float panel_x = menu_inner.x + menu_inner.w + 10.f; + const float panel_w = INFO_PANEL_WIDTH; + + return mouse.x >= panel_x && + mouse.x <= panel_x + panel_w && + mouse.y >= menu_inner.y && + mouse.y <= menu_inner.y + menu_inner.h; +} + +void +Inventory::draw_Menu(SDL_Renderer* renderer, SDL_Rect win_size, TTF_Font* font, std::vector<bool> researched_items, bool is_hovering_craftbutton) { + // real grid sizes + float grid_w = inventory_grid_cols * inventory_grid_slot_size; + float grid_h = inventory_grid_rows * inventory_grid_slot_size; + + // inner area: grid + build menu on the right + float inner_w = grid_w + build_menu_width; + float inner_h = grid_h + 40.f; + + float total_w = inner_w + MENU_BORDER * 2; + float total_h = inner_h + MENU_BORDER * 2; + + float start_x = win_size.w * 0.5f - total_w * 0.5f; + float start_y = win_size.h * 0.5f - total_h * 0.5f; + + SDL_FRect outer{ + start_x, + start_y, + total_w, + total_h + }; + + menu_inner = { + start_x + MENU_BORDER, + start_y + MENU_BORDER, + inner_w, + inner_h + }; + + SDL_SetRenderDrawColor(renderer, 60, 60, 70, 255); + SDL_RenderFillRect(renderer, &outer); + + SDL_SetRenderDrawColor(renderer, 120, 120, 140, 255); + SDL_RenderFillRect(renderer, &menu_inner); + + draw_InventoryGrid(renderer); + draw_BuildMenu(renderer, researched_items); + draw_InfoPanel(renderer, font, selected_build_item, is_hovering_craftbutton); +} + + +void +Inventory::draw_Hotbar(SDL_Renderer* renderer, TTF_Font* font) { + const float slot_size = 48.f; + const float spacing = 4.f; + const float start_x = 20.f; + const float start_y = 20.f; + + SDL_Color number_color = {255, 255, 255, 255}; // white numbers + + for (int i = 1; i < HOTBAR_SLOTS; ++i) { + float x = start_x + i * (slot_size + spacing); + float y = start_y; + + // Slot background + SDL_FRect bg{ x, y, slot_size, slot_size }; + SDL_SetRenderDrawColor(renderer, 50, 50, 60, 255); + SDL_RenderFillRect(renderer, &bg); + + // Border + if (i == selected_hotbar) + SDL_SetRenderDrawColor(renderer, 255, 255, 100, 255); + else + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); + SDL_RenderRect(renderer, &bg); + + // Draw item icon if exists + if (hotbar[i].item_id != 0) { + if (hotbar[i].type == InventoryObjectType::ITEM) { + ItemType item = get_ItemById(hotbar[i].item_id)->type; + if (item != ItemType::NONE) { + auto it = Icon::item_pos.find(item); + if (it != Icon::item_pos.end()) { + SDL_FRect src{ it->second.x * 16.f, it->second.y * 16.f, 16.f, 16.f }; + SDL_FRect dst{ x, y, slot_size, slot_size }; + SDL_RenderTexture(renderer, Icon::icons_texture, &src, &dst); + } + } + } else + if (hotbar[i].type == InventoryObjectType::VEGETABLE) { + InventoryVegetable& item = get_VegetableById(hotbar[i].item_id); + const VegetableData::CropDefinition* + data = get_DataByType(item.type); + SDL_FRect src{ data->icon_tile_x * 16.f, data->icon_tile_y * 16.f, 16.f, 16.f }; + SDL_FRect dst{ x, y, slot_size, slot_size }; + SDL_RenderTexture(renderer, Icon::icons_texture, &src, &dst); + } else + if (hotbar[i].type == InventoryObjectType::SEED) { + InventoryVegetable& item = get_SeedById(hotbar[i].item_id); + const VegetableData::CropDefinition* + data = get_DataByType(item.type); + SDL_FRect src{ (data->icon_tile_x-1) * 16.f, data->icon_tile_y * 16.f, 16.f, 16.f }; + SDL_FRect dst{ x, y, slot_size, slot_size }; + SDL_RenderTexture(renderer, Icon::icons_texture, &src, &dst); + } + } + + // Draw slot number in bottom-right corner + std::string number = std::to_string(i); + SDL_Surface* surf = TTF_RenderText_Solid(font, number.c_str(), number.length(), number_color); + if (surf) { + SDL_Texture* tex = SDL_CreateTextureFromSurface(renderer, surf); + if (tex) { + SDL_FRect dst{ + x + slot_size - surf->w - 2.f, + y + slot_size - surf->h - 2.f, + (float)surf->w, + (float)surf->h + }; + SDL_RenderTexture(renderer, tex, nullptr, &dst); + SDL_DestroyTexture(tex); + } + SDL_DestroySurface(surf); + } + } +} + +bool Inventory::set_HotbarItem(int slot, Inventory_s* item) { + if (slot < 0 || slot >= HOTBAR_SLOTS || !item) return false; + hotbar[slot].item_id = item->id; + selected_hotbar_last = selected_hotbar; + hotbar[slot].type = item->object_type; + return true; +} + +Inventory_s* Inventory::get_SelectedHotbarItem() { + Equipement eq = hotbar[selected_hotbar]; + Inventory_s* item = nullptr; + if (eq.type == InventoryObjectType::ITEM) + item = get_ItemById(hotbar[selected_hotbar].item_id); + else + if (eq.type == InventoryObjectType::VEGETABLE) + item = &get_VegetableById(hotbar[selected_hotbar].item_id); + else + if (eq.type == InventoryObjectType::SEED) + item = &get_SeedById(hotbar[selected_hotbar].item_id); + + if (selected_hotbar == 0 || !item) { + // std::cout << "Something is broken,... " << selected_hotbar << " " << hotbar[selected_hotbar].item_id << std::endl; + return hotbar_hands; + } + return item; +} + +InventoryItem* Inventory::get_ItemById(size_t id) { + for (auto &item : items) + if (item->id == id) + return item.get(); + return nullptr; +} + +InventoryVegetable& Inventory::get_VegetableById(size_t id) { + for (auto &item : vegetables) + if (item.second.id == id) + return item.second; + throw std::out_of_range("Vegetable not found"); +} + +InventoryVegetable& Inventory::get_SeedById(size_t id) { + for (auto &item : seeds) + if (item.second.id == id) + return item.second; + throw std::out_of_range("Vegetable not found"); +} + + + + + + + + + + +static void WriteItem(std::ofstream &file, const InventoryItem &it) { + file.write(reinterpret_cast<const char*>(&it.object_type), sizeof(it.object_type)); + file.write(reinterpret_cast<const char*>(&it.id), sizeof(it.id)); + file.write(reinterpret_cast<const char*>(&it.equipement_slot), sizeof(it.equipement_slot)); + + file.write(reinterpret_cast<const char*>(&it.type), sizeof(it.type)); + file.write(reinterpret_cast<const char*>(&it.health_current), sizeof(it.health_current)); + file.write(reinterpret_cast<const char*>(&it.health_max), sizeof(it.health_max)); + + file.write(reinterpret_cast<const char*>(&it.speed), sizeof(it.speed)); + file.write(reinterpret_cast<const char*>(&it.level), sizeof(it.level)); +} + +static void WriteVegetable(std::ofstream &file, const InventoryVegetable &veg) { + file.write(reinterpret_cast<const char*>(&veg.object_type), sizeof(veg.object_type)); + + file.write(reinterpret_cast<const char*>(&veg.id), sizeof(veg.id)); + file.write(reinterpret_cast<const char*>(&veg.equipement_slot), sizeof(veg.equipement_slot)); + file.write(reinterpret_cast<const char*>(&veg.type), sizeof(veg.type)); + file.write(reinterpret_cast<const char*>(&veg.count), sizeof(veg.count)); + +} + +static void WriteSeed(std::ofstream &file, const InventoryVegetable &veg) { + file.write(reinterpret_cast<const char*>(&veg.object_type), sizeof(veg.object_type)); + + file.write(reinterpret_cast<const char*>(&veg.id), sizeof(veg.id)); + file.write(reinterpret_cast<const char*>(&veg.equipement_slot), sizeof(veg.equipement_slot)); + file.write(reinterpret_cast<const char*>(&veg.type), sizeof(veg.type)); + file.write(reinterpret_cast<const char*>(&veg.count), sizeof(veg.count)); +} + +bool Inventory::Save(const std::string &path) const { + std::ofstream file(path + "/inventory", std::ios::binary | std::ios::trunc); + std::cout << "Save Inventory\n"; + if (!file) { + std::cout << "No file found at: " << path + "/inventory" << std::endl; + return false; + } + + // resources + { + uint32_t count = resources.size(); + file.write(reinterpret_cast<const char*>(&count), sizeof(count)); + + for (const auto &kv : resources) { + file.write(reinterpret_cast<const char*>(&kv.first), sizeof(kv.first)); + file.write(reinterpret_cast<const char*>(&kv.second), sizeof(kv.second)); + } + } + + // items + { + uint32_t count = items.size(); + std::cout << "ITEM COUNT WRITE: " << count << std::endl; + file.write(reinterpret_cast<const char*>(&count), sizeof(count)); + + for (const auto &item : items) + WriteItem(file, *item); + + // vegetable + count = vegetables.size(); + std::cout << "VEGETABLE COUNT WRITE: " << count << std::endl; + file.write(reinterpret_cast<const char*>(&count), sizeof(count)); + + for (const auto &pair : vegetables) + WriteVegetable(file, pair.second); + + // seed + count = seeds.size(); + std::cout << "Seeds COUNT WRITE: " << count << std::endl; + file.write(reinterpret_cast<const char*>(&count), sizeof(count)); + + for (const auto &pair : seeds) + WriteSeed(file, pair.second); + } + + // equipment slot item_id + { + uint32_t count = equipment.size(); + file.write(reinterpret_cast<const char*>(&count), sizeof(count)); + + for (const auto &kv : equipment) { + EquipmentSlot slot = kv.first; + size_t id = kv.second.item_id; + std::cout << "EQ " << id << std::endl; + + file.write(reinterpret_cast<const char*>(&slot), sizeof(slot)); + file.write(reinterpret_cast<const char*>(&id), sizeof(id)); + } + } + + // hotbar + for (int i = 0; i < HOTBAR_SLOTS; ++i) { + std::cout << "WRITE " << hotbar[i].item_id << std::endl; + file.write(reinterpret_cast<const char*>(&hotbar[i].item_id), sizeof(hotbar[i].item_id)); + file.write(reinterpret_cast<const char*>(&hotbar[i].type), sizeof(hotbar[i].type)); + } + + // selected hotbars + std::cout << "WRITE SEL HOTBAR " << selected_hotbar << std::endl; + file.write(reinterpret_cast<const char*>(&selected_hotbar), sizeof(selected_hotbar)); + file.write(reinterpret_cast<const char*>(&selected_hotbar_last), sizeof(selected_hotbar_last)); + + return file.good(); +} + + +static void ReadBase(std::ifstream &file, Inventory_s *obj) { + // file.read(reinterpret_cast<char*>(&obj->object_type), sizeof(obj->object_type)); // remove + file.read(reinterpret_cast<char*>(&obj->id), sizeof(obj->id)); + file.read(reinterpret_cast<char*>(&obj->equipement_slot), sizeof(obj->equipement_slot)); +} +static InventoryItem* ReadItem(std::ifstream &file) { + auto *it = new InventoryItem(0, ItemType::HAND); + ReadBase(file, it); + + file.read(reinterpret_cast<char*>(&it->type), sizeof(it->type)); + file.read(reinterpret_cast<char*>(&it->health_current), sizeof(it->health_current)); + file.read(reinterpret_cast<char*>(&it->health_max), sizeof(it->health_max)); + + file.read(reinterpret_cast<char*>(&it->speed), sizeof(it->speed)); + file.read(reinterpret_cast<char*>(&it->level), sizeof(it->level)); + + return it; +} +static InventoryVegetable* ReadVegetable(std::ifstream &file) { + auto *veg = new InventoryVegetable(0, VegetableData::Type::NONE, false); + ReadBase(file, veg); + + file.read(reinterpret_cast<char*>(&veg->type), sizeof(veg->type)); + file.read(reinterpret_cast<char*>(&veg->count), sizeof(veg->count)); + + return veg; +} +static InventoryVegetable* ReadSeed(std::ifstream &file) { + auto *veg = new InventoryVegetable(0, VegetableData::Type::NONE, true); + ReadBase(file, veg); + + file.read(reinterpret_cast<char*>(&veg->type), sizeof(veg->type)); + file.read(reinterpret_cast<char*>(&veg->count), sizeof(veg->count)); + + return veg; +} +static Inventory_s* ReadObject(std::ifstream &file) +{ + InventoryObjectType ot; + file.read(reinterpret_cast<char*>(&ot), sizeof(ot)); + + switch (ot) { + case InventoryObjectType::ITEM: { + auto* it = ReadItem(file); + it->object_type = ot; + return it; + } + case InventoryObjectType::VEGETABLE: { + auto* veg = ReadVegetable(file); + veg->object_type = ot; + return veg; + } + case InventoryObjectType::SEED: { + auto* veg = ReadSeed(file); + veg->object_type = ot; + return veg; + } + + default: + return nullptr; + } +} + +bool Inventory::Load(const std::string &path) { + std::cout << "Load Inventory\n"; + std::ifstream file(path + "/inventory", std::ios::binary); + if (!file) { + std::cout << "No file found at: " << path + "/inventory" << std::endl; + return false; + } + + resources.clear(); + items.clear(); + vegetables.clear(); + equipment.clear(); + + // resources + { + uint32_t count = 0; + file.read(reinterpret_cast<char*>(&count), sizeof(count)); + + for (uint32_t i = 0; i < count; ++i) + { + ResourceType key; + int value; + + file.read(reinterpret_cast<char*>(&key), sizeof(key)); + file.read(reinterpret_cast<char*>(&value), sizeof(value)); + + resources[key] = value; + std::cout << "RES SIZ " << resources.size() << std::endl; + } + } + + // items + { + uint32_t count = 0; + file.read(reinterpret_cast<char*>(&count), sizeof(count)); + next_item_id = 0; + for (uint32_t i = 0; i < count; ++i) { + Inventory_s *obj = ReadObject(file); + + if (obj->id > next_item_id) + next_item_id = obj->id; + items.push_back(std::unique_ptr<InventoryItem>( + static_cast<InventoryItem*>(obj) + )); + std::cout << "ITM SIZ " << items.size() << std::endl; + } + + count = 0; + file.read(reinterpret_cast<char*>(&count), sizeof(count)); + for (uint32_t i = 0; i < count; ++i) { + Inventory_s *obj = ReadObject(file); + InventoryVegetable* veg = static_cast<InventoryVegetable*>(obj); + + vegetables.try_emplace(veg->type, *veg); + if (veg->id > next_item_id) + next_item_id = veg->id; + + std::cout << "VEG SIZ " << vegetables.size() << std::endl; + // we no longer need the allocated pointer after copying + delete veg; + } + count = 0; + file.read(reinterpret_cast<char*>(&count), sizeof(count)); + for (uint32_t i = 0; i < count; ++i) { + Inventory_s *obj = ReadObject(file); + InventoryVegetable* veg = static_cast<InventoryVegetable*>(obj); + + seeds.try_emplace(veg->type, *veg); + if (veg->id > next_item_id) + next_item_id = veg->id; + + std::cout << "SEED SIZ " << seeds.size() << std::endl; + // we no longer need the allocated pointer after copying + delete veg; + } + next_item_id++; + } + + // rebuild equipment map using item IDs + { + uint32_t count = 0; + file.read(reinterpret_cast<char*>(&count), sizeof(count)); + + for (uint32_t i = 0; i < count; ++i) { + EquipmentSlot slot; + size_t id; + + file.read(reinterpret_cast<char*>(&slot), sizeof(slot)); + file.read(reinterpret_cast<char*>(&id), sizeof(id)); + std::cout << "EQ " << id << std::endl; + + equipment[slot].item_id = id; + } + } + + // hotbar + for (int i = 0; i < HOTBAR_SLOTS; ++i) { + file.read(reinterpret_cast<char*>(&hotbar[i].item_id), sizeof(hotbar[i].item_id)); + //std::cout << "READ " << hotbar[i].item_id << std::endl; + file.read(reinterpret_cast<char*>(&hotbar[i].type), sizeof(hotbar[i].type)); + } + + // selected hotbar + file.read(reinterpret_cast<char*>(&selected_hotbar), sizeof(selected_hotbar)); + std::cout << "READ SEL HOTBAR " << selected_hotbar << std::endl; + file.read(reinterpret_cast<char*>(&selected_hotbar_last), sizeof(selected_hotbar_last)); + + return file.good(); +} + diff --git a/src/inventory/inventory.hpp b/src/inventory/inventory.hpp new file mode 100644 index 0000000..707f771 --- /dev/null +++ b/src/inventory/inventory.hpp @@ -0,0 +1,174 @@ +#pragma once + +#include <SDL3_ttf/SDL_ttf.h> + +#include <unordered_map> +#include <deque> +#include <list> +#include <vector> +#include <memory> + +#include "inventory/item.hpp" +#include "defaults/icons.hpp" +#include "vegetables/vegetables.hpp" + + +enum class InventoryObjectType : uint8_t { + NONE, + ITEM, + VEGETABLE, + SEED +}; + +struct Inventory_s { + size_t id = 0; + EquipmentSlot equipement_slot = EquipmentSlot::NONE; + InventoryObjectType object_type; + + Inventory_s(size_t d, InventoryObjectType ot) + : id(d), object_type(ot) { + } +}; + +struct InventoryItem : Inventory_s { + ItemType type = ItemType::HAND; + int health_current = 0; + int health_max = 0; + float speed = 0; + int level = 0; + float damage = 0; + InventoryItem(size_t d, ItemType t) + : Inventory_s(d, InventoryObjectType::ITEM), + type(t) + { + const ItemStats& info = Item::get(t); + health_current = info.base_health; + health_max = info.base_health; + speed = info.base_speed; + damage = info.base_damage; + level = 1; + equipement_slot = info.equipement_slot; + } +}; + +struct InventoryVegetable : Inventory_s { + size_t count = 0; + bool is_seed = false; + VegetableData::Type type; + const ConsumingStatsBonus& stats_bonus; + InventoryVegetable(size_t d, VegetableData::Type t, bool s) + : Inventory_s(d, s ? InventoryObjectType::SEED : InventoryObjectType::VEGETABLE), count(0), + is_seed(s), type(t), + stats_bonus(VegetableData::crop_defs[static_cast<uint32_t>(t)].stats_bonus) + { } +}; + + +static constexpr int HOTBAR_SLOTS = 7; // 0 == HANDS + +struct Equipement { + size_t item_id; + InventoryObjectType type; +}; + +struct InventorySelection { + Inventory_s* item = nullptr; + ResourceType resource = ResourceType::NONE; + VegetableData::Type vegetable = VegetableData::Type::NONE; + VegetableData::Type seed = VegetableData::Type::NONE; + Icon::TilePos tile; + bool is_valid = false; +}; + + +class Inventory { + size_t next_item_id; +public: + static bool draw_menu; + + static ItemType selected_build_item; + static InventorySelection* selected_item; + static bool clicked_button_craft; + + static Equipement + hotbar[HOTBAR_SLOTS]; + static int selected_hotbar; + static int selected_hotbar_last; + static InventoryItem* hotbar_hands; + + + // stackable items + std::unordered_map<ResourceType, int> resources; + std::unordered_map<VegetableData::Type, InventoryVegetable> + vegetables; + std::unordered_map<VegetableData::Type, InventoryVegetable> + seeds; + + std::list<std::unique_ptr<InventoryItem>> items; + + std::unordered_map<EquipmentSlot, Equipement> equipment; + + InventorySelection selected_inventory; + + Inventory(); + Inventory(Inventory&& other); + + void add_Vegetable(VegetableData::Type, size_t amount, Messages*); + int remove_Vegetable(VegetableData::Type type, size_t amount); + int get_Vegetable(VegetableData::Type type) const; + + void add_Seed(VegetableData::Type, size_t amount, Messages*); + bool remove_Seed(VegetableData::Type type, size_t amount); + int get_Seed(VegetableData::Type type) const; + + void add_Resource(ResourceType type, int amount, Messages* messages); + bool remove_Resource(ResourceType type, int amount); + int get_Resource(ResourceType type) const; + + InventoryItem* + add_Item(ItemType item, Messages*); + bool remove_Item(ItemType item); + bool has_Item(ItemType item) const; + InventoryItem* + get_ItemById(size_t id); + InventoryVegetable& + get_VegetableById(size_t id); + InventoryVegetable& + get_SeedById(size_t id); + + // EQUIPEMENT + void Unequip(EquipmentSlot); + void Equip(InventoryItem*); + void Equip(InventoryVegetable*); + + // DRAW + void draw_InventoryGrid(SDL_Renderer*); + void draw_BuildMenu(SDL_Renderer*, std::vector<bool> researched_items); + void draw_InfoPanel(SDL_Renderer*, TTF_Font*, ItemType, bool is_hovering_craftbutton); + void draw_Menu(SDL_Renderer* renderer, SDL_Rect win_size, TTF_Font* font, std::vector<bool> researched_items, bool is_hovering_craftbutton); + + static bool + cursor_OverInfoPanel(const SDL_FPoint& mouse); + static bool + cursor_OverBuildMenu(const SDL_FPoint& mouse); + static bool + cursor_OverInventoryGrid(const SDL_FPoint& mouse); + + static ItemType + hit_BuildMenu(const SDL_FPoint& mouse, SDL_Rect win_size, std::vector<bool> researched_items); + + static bool + cursor_OverCraftButton(const SDL_FPoint& mouse); + + void + draw_Hotbar(SDL_Renderer* renderer, TTF_Font* font); + + bool set_HotbarItem(int slot, Inventory_s* item); + Inventory_s* get_SelectedHotbarItem(); + + InventorySelection + hit_InventoryGrid(const SDL_FPoint& mouse); + + bool Save(const std::string &path) const; + bool Load(const std::string &path); +}; diff --git a/src/inventory/item.cpp b/src/inventory/item.cpp new file mode 100644 index 0000000..6d2c46c --- /dev/null +++ b/src/inventory/item.cpp @@ -0,0 +1,301 @@ +#include "inventory/item.hpp" + +#include <iostream> + +#include "inventory/inventory.hpp" +#include "character/message.hpp" + + +namespace Item { + ItemCrafting crafting_item; + + std::vector<ItemStats> stats = { + // NONE + { + ItemType::NONE, + "None", + {}, // empty cost + 0, 0, 0, 0, + 0, 0, 0, + 0, 0, + EquipmentSlot::NONE, + 0, + BuildingType::NONE + }, + // HAND + { + ItemType::HAND, + "Hands", + {}, // empty cost + 0, 0, 0, 0, + 0, 0, 0, + 0, 0, + EquipmentSlot::HAND_RIGHT, + 0, + BuildingType::NONE + }, + + // BUILDING_TOOL + { + ItemType::BUILDING_TOOL, + "Building tool", + { {ResourceType::WOOD, 2}, {ResourceType::STONE, 1} }, + 0, // base_damage + 0, // base_armor + 20, // base_health + 1.2, // base_speed + 0, // dmg_per_level + 0, // armor_per_level + 5, // health_per_level + 3, + 4.0, + EquipmentSlot::HAND_RIGHT, + 0, + BuildingType::NONE + }, + // SWORD_WOOD + { + ItemType::SWORD_WOOD, + "Sword wood", + { {ResourceType::WOOD, 6} }, + 2, // base_damage + 0, // base_armor + 20, // base_health + 0.8, // base_speed + 1, // dmg_per_level + 0, // armor_per_level + 5, // health_per_level + 3, // max_level + 6.0, + EquipmentSlot::HAND_RIGHT, + 1, + BuildingType::RESEARCH_WOOD_1 + }, + // SWORD_STONE + { + ItemType::SWORD_STONE, + "Sword stone", + { {ResourceType::WOOD, 2}, {ResourceType::STONE, 4} }, + 4, // base_damage + 0, // base_armor + 30, // base_health + 1.6, // base_speed + 1, // dmg_per_level + 0, // armor_per_level + 5, // health_per_level + 3, // max_level + 6.0, + EquipmentSlot::HAND_RIGHT, + 3, + BuildingType::RESEARCH_WOOD_1 + }, + // AXE_STONE + { + ItemType::WOODAXE_STONE, + "Wood Axe made of stone", + { {ResourceType::WOOD, 3}, {ResourceType::STONE, 5} }, + 2, // base_damage + 0, // base_armor + 30, // base_health + 1.5, // base_speed + 1, // dmg_per_level + 0, // armor_per_level + 5, // health_per_level + 3, // max_level + 6.0, + EquipmentSlot::HAND_RIGHT, + 1, + BuildingType::RESEARCH_WOOD_1 + }, + + // BONE_BREASTPLATE + { + ItemType::BONE_BREASTPLATE, + "Bone breasplate", + { {ResourceType::BONE, 10}, {ResourceType::WOOD, 2} }, + 0, // base_damage + 5, // base_armor + 30, // base_health + 0, // base_speed + 0, // dmg_per_level + 2, // armor_per_level + 5, // health_per_level + 3, + 7.0, + EquipmentSlot::CHEST, + 3, + BuildingType::RESEARCH_WOOD_2 + }, + + // PICKAXE_STONE + { + ItemType::PICKAXE_STONE, + "Pickaxe Stone", + { {ResourceType::WOOD, 3}, {ResourceType::STONE, 5} }, + 0, // base_damage + 0, // base_armor + 30, // base_health + 0, // base_speed + 0, // dmg_per_level + 2, // armor_per_level + 5, // health_per_level + 3, + 8.0, + EquipmentSlot::HAND_RIGHT, + 0, + BuildingType::RESEARCH_WOOD_1 + }, + + // CULTIVATOR + { + ItemType::CULTIVATOR, + "Cultivator", + { {ResourceType::WOOD, 4} }, + 0, // base_damage + 0, // base_armor + 30, // base_health + 0, // base_speed + 0, // dmg_per_level + 2, // armor_per_level + 5, // health_per_level + 3, + 4.0, + EquipmentSlot::HAND_RIGHT, + 0, + BuildingType::RESEARCH_WOOD_1 + }, + + // LAST + { + ItemType::LAST, + "None", + {}, // empty cost + 0, 0, 0, 0, + 0, 0, 0, + 0, 0, + EquipmentSlot::NONE, + 0, + BuildingType::NONE + } + }; + + + + bool is_Weapon(ItemType& item) { + switch (item) { + case ItemType::SWORD_WOOD: + case ItemType::SWORD_STONE: + case ItemType::WOODAXE_STONE: + return true; + default: + return false; + } + } + + const ItemStats& get(ItemType t) { + return stats[static_cast<size_t>(t)]; + } + + + int get_Damage(ItemType t, int lvl) { + const ItemStats& s = get(t); + if (lvl > s.max_level) lvl = s.max_level; + + return s.base_damage + s.dmg_per_level * (lvl - 1); + } + + int get_Health(ItemType t, int lvl) { + const ItemStats& s = get(t); + return s.base_health + s.health_per_level * (lvl - 1); + } + + bool craft_ItemStart(Inventory* inv, ItemType type, ItemCrafting& crafting_it) { + if (type == ItemType::NONE) return false; + + const ItemStats& stats = Item::get(type); + + crafting_it = { + type, + {}, + 0, + stats.crafting_duration, + false, + }; + + // check resources + for (auto& cost : stats.cost) + if (inv->get_Resource(cost.type) < cost.amount) + return false; + + crafting_it.stats = stats; + crafting_it.is_crafting = true; + std::cout << "CRAFTING STARTED!\n"; + return true; + } + + void craft_Stop(ItemCrafting& crafting_it) { + std::cout << "Crafting stopped!\n"; + ItemCrafting reset; + crafting_it = reset; + } + + bool craft_Item(Inventory* inv, ItemCrafting& crafting_it, Messages* messages) { + + // check resources + for (auto& cost : crafting_it.stats.cost) + if (inv->get_Resource(cost.type) < cost.amount) + return false; + + crafting_it.duration += Default::delta_time; + if (crafting_it.duration >= crafting_it.stats.crafting_duration) { + // remove resources + for (auto& cost : crafting_it.stats.cost) + inv->remove_Resource(cost.type, cost.amount); + + // add item instance + InventoryItem* item = inv->add_Item(crafting_it.type, messages); + if (!item) { + std::cout << "Someting failed while adding crafted item!\n"; + return false; + } + std::cout << "Item crafted!\n"; + return false; + } + + return true; + } + + std::vector<ItemType> + get_ResearchedItems(const std::vector<bool>& researched) { + std::vector<ItemType> result; + result.reserve(static_cast<size_t>(ItemType::LAST)); + + for (size_t i = 0; i < researched.size(); i++) { + if (researched[i]) { + result.push_back(static_cast<ItemType>(i)); + } + } + return result; + } + + + + + + std::string + to_String(ItemType type) { + switch (type) { + case ItemType::NONE: return "None"; + case ItemType::HAND: return "Hand"; + case ItemType::BUILDING_TOOL: return "Construction tool"; + case ItemType::SWORD_WOOD: return "Sword wood"; + case ItemType::SWORD_STONE: return "Sword stone"; + case ItemType::WOODAXE_STONE: return "Woodaxe stone"; + case ItemType::BONE_BREASTPLATE: return "Bone Breastplate"; + case ItemType::PICKAXE_STONE: return "Pickaxe stone"; + case ItemType::CULTIVATOR: return "Cultivator"; + case ItemType::LAST: return "Last"; + } + return ""; + } +} diff --git a/src/inventory/item.hpp b/src/inventory/item.hpp new file mode 100644 index 0000000..6075d01 --- /dev/null +++ b/src/inventory/item.hpp @@ -0,0 +1,92 @@ +#pragma once + +#include "objects/object.hpp" +#include "building/building_data.hpp" +#include "resource/resource.hpp" + +class Inventory; +class Messages; + + +enum class EquipmentSlot { + HEAD, + CAPE, + CHEST, + HAND_LEFT, + HAND_RIGHT, + LEGS, + NONE, + LAST +}; + + +// also add Item::stats if adding to ItemType! +enum class ItemType : uint32_t { + NONE, + HAND, + BUILDING_TOOL, + SWORD_WOOD, + SWORD_STONE, + WOODAXE_STONE, + BONE_BREASTPLATE, + PICKAXE_STONE, + CULTIVATOR, + LAST +}; + +struct ItemStats { + ItemType type; + std::string title; + std::initializer_list<BuildingCost> cost; + + int base_damage; + int base_armor; + int base_health; + + float base_speed; + + int dmg_per_level; + int armor_per_level; + int health_per_level; + + int max_level; + + float crafting_duration; + + EquipmentSlot equipement_slot; + + size_t research_level; + BuildingType research_station; +}; + +struct ItemCrafting { + ItemType type = ItemType::NONE; + ItemStats stats = {}; + float duration = 0; + float duration_max = 0; + bool is_crafting = false; +}; + + + +namespace Item { + extern ItemCrafting crafting_item; + + extern std::vector<ItemStats> stats; + + const ItemStats& get(ItemType t); + + bool is_Weapon(ItemType&); + + int get_Damage(ItemType t, int lvl); + + int get_Health(ItemType t, int lvl); + + std::vector<ItemType> + get_ResearchedItems(const std::vector<bool>& researched); + + bool craft_ItemStart(Inventory*, ItemType item, ItemCrafting& = Item::crafting_item); + bool craft_Item(Inventory*, ItemCrafting&, Messages*); + void craft_Stop(ItemCrafting& = Item::crafting_item); + std::string to_String(ItemType); +} diff --git a/src/inventory/weapon.cpp b/src/inventory/weapon.cpp new file mode 100644 index 0000000..3aff6a8 --- /dev/null +++ b/src/inventory/weapon.cpp @@ -0,0 +1,71 @@ +#include "inventory/weapon.hpp" + +#include <iostream> + +std::vector<WeaponTileSet> weapon_sets; +std::vector<WeaponSet> weapons; + + +Weapon::Weapon(WeaponType wtype, WeaponMaterial wmaterial) : type(wtype), material(wmaterial) { + for (size_t i = 0; i < weapons.size(); i++) { + const auto& w = weapons[i]; + const auto& tileset = weapon_sets[w.weapon_tileset_id]; + + if (w.type == wtype && tileset.material == wmaterial) { + weapon_index = i; + return; + } + } + weapon_index = (size_t)-1; // not found +} + +void +Weapon::AddWeaponFromTileset(size_t tileset_id, WeaponType type, + float demage, float speed, float x, float y, float w, float h) { + weapons.push_back({ + tileset_id, + SDL_FRect{x, y, w, h}, + type, + demage, + speed, + }); +} + + +void +Weapon::Init(SDL_Renderer* renderer) { + // Add the wood tileset + weapon_sets.push_back({ + IMG_LoadTexture(renderer, "Pixel_Crawler/Weapons/Wood/Wood.png"), + {12, 7}, // size in tiles + WeaponMaterial::WOOD + }); + + // Generate weapons from the tileset grid + AddWeaponFromTileset(0, WeaponType::LONGSWORD, 10, 1, 0, 0, 16, 48); + AddWeaponFromTileset(0, WeaponType::HAMMER, 10, 1, 16, 16, 16, 32); + AddWeaponFromTileset(0, WeaponType::SWORD, 10, 1, 32, 16, 16, 32); + AddWeaponFromTileset(0, WeaponType::SPEER, 10, 1, 48, 0, 16, 48); +} + + +void +Weapon::Draw(SDL_Renderer* renderer, float x, float y) { + if (weapon_index >= weapons.size()) return; + + const WeaponSet& weaponset = weapons[weapon_index]; + const WeaponTileSet& tileset = weapon_sets[weaponset.weapon_tileset_id]; + + SDL_FRect dest; + float offset = 20; + if (!flip) + offset = 19; + dest.x = Scale(x + offset); + dest.y = Scale(y + 15); + dest.w = Scale(static_cast<int>(weaponset.tileset_position.w)); + dest.h = Scale(static_cast<int>(weaponset.tileset_position.h)); + + SDL_RenderTextureRotated(renderer, tileset.texture, &weaponset.tileset_position, &dest, + 0.0, nullptr, + flip ? SDL_FLIP_NONE : SDL_FLIP_HORIZONTAL); +} diff --git a/src/inventory/weapon.hpp b/src/inventory/weapon.hpp new file mode 100644 index 0000000..aebaae3 --- /dev/null +++ b/src/inventory/weapon.hpp @@ -0,0 +1,57 @@ +#pragma once + +#include "defaults/defaults.hpp" + +#include <string> +#include <vector> +#include <unordered_map> +#include <SDL3_image/SDL_image.h> + +enum class WeaponType { + KNIFE, + LONGSWORD, + SWORD, + SPEER, + HAMMER, + BOW, + SHIELD, +}; + +enum class WeaponMaterial { + WOOD, + BONE +}; +struct WeaponTileSet { + SDL_Texture* texture; + SDL_Point size; + WeaponMaterial material; +}; + +struct WeaponSet { + size_t weapon_tileset_id; + SDL_FRect tileset_position; + WeaponType type; + float demage; + float speed; +}; + +extern std::vector<WeaponTileSet> weapon_sets; +extern std::vector<WeaponSet> weapons; + +class Weapon { + size_t weapon_index = (size_t)-1; + + static void AddWeaponFromTileset(size_t tileset_id, WeaponType type, + float demage, float speed, float x, float y, float w, float h); +public: + WeaponType type = WeaponType::SWORD; + WeaponMaterial material = WeaponMaterial::WOOD; + SDL_FPoint dimension = {30.0f, 16.0f}; + bool flip = false; + + Weapon(WeaponType type, WeaponMaterial material); + + static void Init(SDL_Renderer* renderer); + + void Draw(SDL_Renderer* renderer, float x, float y); +}; diff --git a/src/map/map.cpp b/src/map/map.cpp new file mode 100644 index 0000000..af4dc5e --- /dev/null +++ b/src/map/map.cpp @@ -0,0 +1,1178 @@ +#include "map/map.hpp" + +#include <cstddef> +#include <iostream> +#include <queue> +#include <set> + +#include "building/building_data.hpp" +#include "resource/resource.hpp" +#include "building/building.hpp" +#include "game/game.hpp" +#include "farm/farm.hpp" +#include "bird/bird.hpp" + +namespace Map { + + // save_MapTiles + std::string save_path = "saves/save.map"; + std::string save_collission_path = "saves/save.collissions"; + + bool setting_offset = false; + + SDL_Point offset_to_set = {0, 0}; + + SDL_Point offset = {0, 0}; + + SDL_Point size = {160, 100}; // map size in tiles... + SDL_Point boundaries = {63, 39}; // JEee fucked up the size, + // to much work to resize (i have an outer cage which fucks the path finding) + + std::vector<TileMap> tile_map; + + std::vector<bool> tile_collission_map; + + int frame_water = 0; + float global_frame_time = 0.0f; + float global_frame_time_max = 0.6f; + + int frame_meadow = 0; + float frame_meadow_time = 0.0f; + float frame_meadow_time_max = 0.6f; + + void + Init() { + tile_map.resize(static_cast<size_t>(Map::size.x * Map::size.y)); + + for (int y = 0; y < Map::size.y; ++y) { + for (int x = 0; x < Map::size.x; ++x) { + + bool is_border = + (x == 0) || (y == 0) || + (x == Map::size.x - 1) || + (y == Map::size.y - 1); + + size_t index = static_cast<size_t>(y * Map::size.x + x); + + tile_map[index].background = { 0, SIZE_MAX, TILE_GROUND, {is_border ? 17 : 0, 0} }; + //tile_map[index].overlay = { SIZE_MAX, SIZE_MAX, TILE_OVERLAY_CHARACTER, {0, 0} }; + } + } + + } + + void + init_Collider() { + tile_collission_map.clear(); + // init map_colliders + const size_t cells_per_tile_map = (Tile::tile_size / Tile::tile_collider_size)*(Tile::tile_size / Tile::tile_collider_size); + for (size_t i = 0; i < tile_map.size(); i++) { + for (size_t j = 0; j < cells_per_tile_map; j++) + tile_collission_map.push_back(false); + } + } + + void + Reset() { + tile_map.clear(); + Init(); + init_Collider(); + } + + + void + set_CollisionForTile(const TileMap &tile_map_item, + size_t map_tile_x, + size_t map_tile_y) { + + const size_t cells_per_tile = Tile::tile_size / Tile::tile_collider_size; + const size_t map_width_cells = static_cast<size_t>(Map::size.x) * cells_per_tile; + const Tile_s &tile = tile_map_item.background; + + const SDL_Point position = tile.set_position; + const TileSet &tileset = Tile::get_TilesetFromMapTile(tile); + + const size_t ts_width = static_cast<size_t>(tileset.size.x) * cells_per_tile; + + size_t map_cell_origin_x = map_tile_x * cells_per_tile; + size_t map_cell_origin_y = map_tile_y * cells_per_tile; + + for (size_t y = 0; y < cells_per_tile; ++y) { + for (size_t x = 0; x < cells_per_tile; ++x) { + size_t ts_index = + (static_cast<size_t>(position.y) * cells_per_tile + y) * ts_width + + (static_cast<size_t>(position.x) * cells_per_tile + x); + + if (ts_index >= tileset.collission_map.size()) + continue; + + size_t map_x = map_cell_origin_x + x; + size_t map_y = map_cell_origin_y + y; + size_t map_index = map_y * map_width_cells + map_x; + + if (map_index < tile_collission_map.size()) + tile_collission_map[map_index] = tileset.collission_map[ts_index]; + } + } + } + + void + set_CollissionFromTileset() { + for (int tile_index = 0; tile_index < static_cast<int>(tile_map.size()); ++tile_index) { + int map_tile_x = tile_index % Map::size.x; + int map_tile_y = tile_index / Map::size.x; + + + set_TileCollissionForObjects({map_tile_x, map_tile_y}); + } + } + + + void + set_ObjectCollisionOnTilemap(size_t object_id, SDL_Point map_tile) { + Object* object = Object::get_ObjectById(object_id); + + object->print_CollisionMap(); + const std::vector<bool>& collision_map = object->get_CollisionMap(); + + const size_t scale = Tile::tile_size / Tile::tile_collider_size; + + const size_t obj_cols = static_cast<size_t>(object->dimension.x) * scale; + const size_t obj_rows = static_cast<size_t>(object->dimension.y) * scale; + + std::cout << "DIM: " << object->dimension.x << " " << object->dimension.y << std::endl; + std::cout << "COL: " << obj_cols << " " << obj_rows << std::endl; + + + const size_t base_x = static_cast<size_t>(map_tile.x) * scale; + const size_t base_y = static_cast<size_t>(map_tile.y) * scale; + std::cout << "BAS: " << base_x << " " << base_y << std::endl; + + const size_t map_cols = static_cast<size_t>(Map::size.x) * scale; + + for (size_t oy = 0; oy < obj_rows; ++oy) { + for (size_t ox = 0; ox < obj_cols; ++ox) { + + const size_t obj_idx = oy * obj_cols + ox; + + if (collision_map[obj_idx]) { + const size_t mx = base_x + ox; + const size_t my = base_y + oy; + + const size_t map_idx = my * map_cols + mx; + std::cout << "COL: " << mx << " " << my << " " << map_idx << std::endl; + Map::tile_collission_map[map_idx] = true; + } + } + } + } + + + void + set_TileCollissionForObjects(SDL_Point map_tile) { + const size_t tile_index = static_cast<size_t>(map_tile.y * Map::size.x + map_tile.x); + + const size_t scale = Tile::tile_size / Tile::tile_collider_size; + + const size_t start_y = static_cast<size_t>(map_tile.y)* scale; + const size_t start_x = static_cast<size_t>(map_tile.x)* scale; + + const size_t map_cols = static_cast<size_t>(Map::size.x) * scale; + + const TileMap &tile_map_item = tile_map[tile_index]; + + // reset collisions for this tile + set_CollisionForTile(tile_map_item, static_cast<size_t>(map_tile.x), static_cast<size_t>(map_tile.y)); + + // merge collisions from all objects on the tile + for (const TileObject& to : tile_map[tile_index].objects) { + + Object* object = Object::get_ObjectById(to.object_id); + + const std::vector<bool> collision_map = + object->get_CollissionsOfTile(to.position); + + for (size_t oy = 0; oy < scale; ++oy) { + for (size_t ox = 0; ox < scale; ++ox) { + + const size_t tile_cell = oy * scale + ox; + + if (collision_map[tile_cell]) { + const size_t map_idx = + (start_y + oy) * map_cols + (start_x + ox); + Map::tile_collission_map[map_idx] = true; + } + } + } + } + } + + + void + save_TileCollision(const std::string &path) { + std::ofstream out(path, std::ios::binary); + if (!out) { + std::cerr << "Failed to open file for writing: " << path << '\n'; + return; + } + + out.write(reinterpret_cast<const char*>(&Map::size.x), sizeof(Map::size.x)); + out.write(reinterpret_cast<const char*>(&Map::size.y), sizeof(Map::size.y)); + // Write the size first + size_t size = tile_collission_map.size(); + out.write(reinterpret_cast<const char*>(&size), sizeof(size)); + + // Write each bool as a byte + for (bool value : tile_collission_map) { + uint8_t byte = value ? 1 : 0; + out.write(reinterpret_cast<const char*>(&byte), sizeof(byte)); + } + + std::cout << "Saved " << size << " collision cells to " << path << '\n'; + } + + void + load_TileCollision(const std::string &path) { + std::ifstream in(path, std::ios::binary); + if (!in) { + std::cerr << "Failed to open file for reading: " << path << '\n'; + return; + } + + + int map_tilesize_x; + int map_tilesize_y; + in.read(reinterpret_cast<char*>(&map_tilesize_x), sizeof(map_tilesize_x)); + in.read(reinterpret_cast<char*>(&map_tilesize_y), sizeof(map_tilesize_y)); + + std::cout << "WUU " << map_tilesize_x << " " << map_tilesize_y<< std::endl; + + // Read the size + size_t size = 0; + in.read(reinterpret_cast<char*>(&size), sizeof(size)); + + if (!in) { + std::cerr << "Failed to read size from file: " << path << '\n'; + return; + } + + // Resize and read data + std::vector<bool> temp(size); + const size_t w = static_cast<size_t>(Map::size.x); + const size_t h = static_cast<size_t>(Map::size.y); + const size_t m = Tile::tile_size/Tile::tile_collider_size; + + Map::tile_collission_map.assign(w * h * m * m, false); + for (size_t i = 0; i < size; ++i) { + uint8_t byte = 0; + in.read(reinterpret_cast<char*>(&byte), sizeof(byte)); + temp[i] = (byte != 0); + size_t x = i% static_cast<size_t>(map_tilesize_x); + size_t y = i/ static_cast<size_t>(map_tilesize_x); + Map::tile_collission_map[y*static_cast<size_t>(Map::size.x)+x] = temp[i]; + } + + + if (!in) { + std::cerr << "File corrupted or incomplete: " << path << '\n'; + return; + } + + //Map::tile_collission_map = std::move(temp); + std::cout << "Loaded " << size << " collision cells from " << path << '\n'; + } + + void + save_MapTiles(const std::vector<TileMap>& tile_map, const std::string& path) { + std::ofstream file(path, std::ios::binary); + if (!file.is_open()) return; + + size_t map_count = tile_map.size(); + file.write(reinterpret_cast<const char*>(&map_count), sizeof(map_count)); + + size_t id = 0; + for (const auto& map : tile_map) { + // --- background --- + + size_t map_tile_x = id % static_cast<size_t>(Map::size.x); + size_t map_tile_y = id / static_cast<size_t>(Map::size.x); + file.write(reinterpret_cast<const char*>(&map_tile_x), sizeof(map_tile_x)); + file.write(reinterpret_cast<const char*>(&map_tile_y), sizeof(map_tile_y)); + file.write(reinterpret_cast<const char*>(&map.background.set_id), sizeof(map.background.set_id)); + file.write(reinterpret_cast<const char*>(&map.background.object_id), sizeof(map.background.object_id)); + file.write(reinterpret_cast<const char*>(&map.background.set_category), sizeof(map.background.set_category)); + file.write(reinterpret_cast<const char*>(&map.background.set_position), sizeof(map.background.set_position)); + // --- overlays --- + const std::size_t overlay_count = map.overlays.size(); + file.write(reinterpret_cast<const char*>(&overlay_count), sizeof(overlay_count)); + + for (const Tile_s& ov : map.overlays) { + file.write(reinterpret_cast<const char*>(&ov.set_id), sizeof(ov.set_id)); + file.write(reinterpret_cast<const char*>(&ov.object_id), sizeof(ov.object_id)); + file.write(reinterpret_cast<const char*>(&ov.set_category), sizeof(ov.set_category)); + file.write(reinterpret_cast<const char*>(&ov.set_position), sizeof(ov.set_position)); + } + + // --- objects --- + size_t obj_count = map.objects.size(); + file.write(reinterpret_cast<const char*>(&obj_count), sizeof(obj_count)); + + for (const auto& obj : map.objects) { + Object* o = Object::get_ObjectById(obj.object_id); + + // TilesetObject + file.write(reinterpret_cast<const char*>(&obj.position.x), sizeof(obj.position.x)); + file.write(reinterpret_cast<const char*>(&obj.position.y), sizeof(obj.position.y)); + file.write(reinterpret_cast<const char*>(&o->dimension.x), sizeof(o->dimension.x)); + file.write(reinterpret_cast<const char*>(&o->dimension.y), sizeof(o->dimension.y)); + file.write(reinterpret_cast<const char*>(&obj.draw_from_this_tile), sizeof(obj.draw_from_this_tile)); + + auto object_type = static_cast<int>(o->object_type); + auto category = static_cast<int>(o->category); + file.write(reinterpret_cast<const char*>(&object_type), sizeof(object_type)); + file.write(reinterpret_cast<const char*>(&category), sizeof(category)); + // im getting tile_type on load + + int tileset_type = static_cast<int>(o->tileset_type); + file.write(reinterpret_cast<const char*>(&tileset_type), sizeof(tileset_type)); + file.write(reinterpret_cast<const char*>(&o->tileset_id), sizeof(o->tileset_id)); + file.write(reinterpret_cast<const char*>(&o->tileset_object_id), sizeof(o->tileset_object_id)); + + file.write(reinterpret_cast<const char*>(&o->z_index), sizeof(o->z_index)); + + if (o->category == ObjectCategory::BUILDING) { + Building* b = static_cast<Building*>(o); + + auto type = static_cast<int>(b->building_type); + auto status = static_cast<int>(b->building_status); + + file.write(reinterpret_cast<const char*>(&type), sizeof(type)); + file.write(reinterpret_cast<const char*>(&status), sizeof(status)); + file.write(reinterpret_cast<const char*>(&b->building_time), + sizeof(b->building_time)); + + size_t cost_count = b->cost_fulfilled.size(); + file.write(reinterpret_cast<const char*>(&cost_count), sizeof(cost_count)); + for (auto& p : b->cost_fulfilled) { + auto r = static_cast<int>(p.first); + file.write(reinterpret_cast<const char*>(&r), sizeof(r)); + file.write(reinterpret_cast<const char*>(&p.second), + sizeof(p.second)); + } + + size_t frac_count = b->fractional_buffer.size(); + file.write(reinterpret_cast<const char*>(&frac_count), sizeof(frac_count)); + for (auto& p : b->fractional_buffer) { + auto r = static_cast<int>(p.first); + file.write(reinterpret_cast<const char*>(&r), sizeof(r)); + file.write(reinterpret_cast<const char*>(&p.second), + sizeof(p.second)); + } + } + else if (o->category == ObjectCategory::FARM_CROP) { + Vegetable* v = static_cast<Vegetable*>(o); + + auto type = static_cast<int>(v->type); + file.write(reinterpret_cast<const char*>(&type), sizeof(type)); + file.write(reinterpret_cast<const char*>(&v->is_seed), + sizeof(v->is_seed)); + + file.write(reinterpret_cast<const char*>(&v->quantity), + sizeof(v->quantity)); + file.write(reinterpret_cast<const char*>(&v->growth_stage), + sizeof(v->growth_stage)); + file.write(reinterpret_cast<const char*>(&v->next_update_sec), + sizeof(v->next_update_sec)); + file.write(reinterpret_cast<const char*>(&v->collecting_duration_max), + sizeof(v->collecting_duration_max)); + + file.write(reinterpret_cast<const char*>(&v->tileset_object_x), + sizeof(v->tileset_object_x)); + file.write(reinterpret_cast<const char*>(&v->tileset_object_y), + sizeof(v->tileset_object_y)); + + auto slot = static_cast<int>(v->equipement_slot); + file.write(reinterpret_cast<const char*>(&slot), sizeof(slot)); + } + } + id++; + } + } + + + std::vector<TileMap> + load_MapTiles(const std::string& path) { + std::vector<TileMap> tile_map; + std::ifstream file(path, std::ios::binary); + if (!file.is_open()) return tile_map; + + size_t map_count = 0; + file.read(reinterpret_cast<char*>(&map_count), sizeof(map_count)); + tile_map.resize(static_cast<size_t>(Map::size.y*Map::size.x)); + + for (size_t id = 0; id < map_count; id++) { + //int x = i % static_cast<size_t>(Map::size.x); + //int y = i / static_cast<size_t>(Map::size.x); + size_t x; + size_t y; + + file.read(reinterpret_cast<char*>(&x), sizeof(x)); + file.read(reinterpret_cast<char*>(&y), sizeof(y)); + auto& map = tile_map[y*static_cast<size_t>(Map::size.x)+x]; + // --- background --- + file.read(reinterpret_cast<char*>(&map.background.set_id), sizeof(map.background.set_id)); + file.read(reinterpret_cast<char*>(&map.background.object_id), sizeof(map.background.object_id)); + file.read(reinterpret_cast<char*>(&map.background.set_category), sizeof(map.background.set_category)); + file.read(reinterpret_cast<char*>(&map.background.set_position), sizeof(map.background.set_position)); + + // --- overlays --- + std::size_t overlay_count = 0; + file.read(reinterpret_cast<char*>(&overlay_count), sizeof(overlay_count)); + + map.overlays.clear(); + map.overlays.resize(overlay_count); + + for (std::size_t i = 0; i < overlay_count; ++i) { + Tile_s& ov = map.overlays[i]; + + file.read(reinterpret_cast<char*>(&ov.set_id), sizeof(ov.set_id)); + file.read(reinterpret_cast<char*>(&ov.object_id), sizeof(ov.object_id)); + file.read(reinterpret_cast<char*>(&ov.set_category), sizeof(ov.set_category)); + file.read(reinterpret_cast<char*>(&ov.set_position), sizeof(ov.set_position)); + } + + TileSet& tileset = Tile::get_TilesetFromMapTile(map.background); + map.background.object_id = static_cast<size_t>(map.background.set_position.y*tileset.size.x + map.background.set_position.x); + map.background.set_category = Tile::tilesets[TILE_BACKGROUND][map.background.set_id].category; + // std::cout << "SCM: " << map.background.set_id << " " << map.background.object_id<< std::endl; + + // --- objects --- + size_t obj_count = 0; + file.read(reinterpret_cast<char*>(&obj_count), sizeof(obj_count)); + map.objects.resize(obj_count); + + for (auto& map_object : map.objects) { + TilesetObject obj; + + // TilesetObject + file.read(reinterpret_cast<char*>(&obj.position.x), sizeof(obj.position.x)); + file.read(reinterpret_cast<char*>(&obj.position.y), sizeof(obj.position.y)); + file.read(reinterpret_cast<char*>(&obj.position.w), sizeof(obj.position.w)); + file.read(reinterpret_cast<char*>(&obj.position.h), sizeof(obj.position.h)); + + file.read(reinterpret_cast<char*>(&obj.draw_from_this_tile), + sizeof(obj.draw_from_this_tile)); + + int object_type; + file.read(reinterpret_cast<char*>(&object_type), sizeof(object_type)); + + int cat_i; + file.read(reinterpret_cast<char*>(&cat_i), sizeof(cat_i)); + ObjectCategory category = static_cast<ObjectCategory>(cat_i); + + int tt; + file.read(reinterpret_cast<char*>(&tt), sizeof(tt)); + TileType tileset_type = static_cast<TileType>(tt); + + file.read(reinterpret_cast<char*>(&obj.tileset_info.set_id), + sizeof(obj.tileset_info.set_id)); + file.read(reinterpret_cast<char*>(&obj.tileset_info.object_id), + sizeof(obj.tileset_info.object_id)); + + file.read(reinterpret_cast<char*>(&obj.z_index), sizeof(obj.z_index)); + + + + // SET DATA TO REAL OBJECT AND MAP OBJECT + SDL_Point wp = {static_cast<int>(x)-obj.position.x, static_cast<int>(y)-obj.position.y}; + Object* o = Object::get_ObjectByWorldPositionAndTilesetObjectID(wp, obj.tileset_info.object_id); + Object* on = nullptr; + + SDL_Point dim = {obj.position.w, obj.position.h}; + + + switch (category) { + + case ObjectCategory::STATIC: { + on = new Static( + static_cast<ObjectType>(object_type), + ObjectCategory::STATIC, + tileset_type, + obj.tileset_info.set_id, + obj.tileset_info.object_id, + wp, + dim, + obj.z_index); + break; + } + + case ObjectCategory::RESOURCE: { + Resource_s r = Tile::get_ResourceFromTileSet( + obj.tileset_info.set_id, + obj.tileset_info.object_id); + + on = new Resource( + static_cast<ObjectType>(object_type), + ObjectCategory::RESOURCE, + tileset_type, + obj.tileset_info.set_id, + obj.tileset_info.object_id, + wp, + dim, + obj.z_index, + r.resource, + r.quantity, + r.collecting_methode, + r.collecting_duration); + break; + } + + case ObjectCategory::BUILDING: { + int bt_i; + file.read(reinterpret_cast<char*>(&bt_i), sizeof(bt_i)); + BuildingType bt = static_cast<BuildingType>(bt_i); + + int status_i; + file.read(reinterpret_cast<char*>(&status_i), sizeof(status_i)); + BuildingStatus status = static_cast<BuildingStatus>(status_i); + + float time; + file.read(reinterpret_cast<char*>(&time), sizeof(time)); + + size_t cost_count; + file.read(reinterpret_cast<char*>(&cost_count), sizeof(cost_count)); + + std::unordered_map<ResourceType, int> cost_f; + for (size_t i = 0; i < cost_count; ++i) { + int r, v; + file.read(reinterpret_cast<char*>(&r), sizeof(r)); + file.read(reinterpret_cast<char*>(&v), sizeof(v)); + cost_f[static_cast<ResourceType>(r)] = v; + } + + size_t frac_count; + file.read(reinterpret_cast<char*>(&frac_count), sizeof(frac_count)); + + std::unordered_map<ResourceType, float> frac_b; + for (size_t i = 0; i < frac_count; ++i) { + int r; + float v; + file.read(reinterpret_cast<char*>(&r), sizeof(r)); + file.read(reinterpret_cast<char*>(&v), sizeof(v)); + frac_b[static_cast<ResourceType>(r)] = v; + } + + on = new Building( + static_cast<ObjectType>(object_type), + ObjectCategory::BUILDING, + tileset_type, + obj.tileset_info.set_id, + obj.tileset_info.object_id, + wp, + dim, + obj.z_index, + bt); + + Building* b = static_cast<Building*>(on); + b->building_status = status; + b->building_time = time; + b->cost_fulfilled = std::move(cost_f); + b->fractional_buffer = std::move(frac_b); + break; + } + + case ObjectCategory::FARM_CROP: { + int type_i; + bool is_seed; + file.read(reinterpret_cast<char*>(&type_i), sizeof(type_i)); + file.read(reinterpret_cast<char*>(&is_seed), sizeof(is_seed)); + + Vegetable* v = new Vegetable(static_cast<VegetableData::Type>(type_i), wp, is_seed); + + file.read(reinterpret_cast<char*>(&v->quantity), sizeof(v->quantity)); + file.read(reinterpret_cast<char*>(&v->growth_stage), + sizeof(v->growth_stage)); + file.read(reinterpret_cast<char*>(&v->next_update_sec), + sizeof(v->next_update_sec)); + file.read(reinterpret_cast<char*>(&v->collecting_duration_max), + sizeof(v->collecting_duration_max)); + + file.read(reinterpret_cast<char*>(&v->tileset_object_x), + sizeof(v->tileset_object_x)); + file.read(reinterpret_cast<char*>(&v->tileset_object_y), + sizeof(v->tileset_object_y)); + + int slot; + file.read(reinterpret_cast<char*>(&slot), sizeof(slot)); + v->equipement_slot = static_cast<EquipmentSlot>(slot); + + on = v; + break; + } + + default: + break; + } + + + if (!o && on) { + Object::objects.push_back(on); + o = on; + } + + /* + std::cout << "OP: " << obj.position.x << " " << obj.position.y << " ID " << o->id << std::endl; + std::cout << "WP " << wp.x << " " << wp.y << std::endl; + std::cout << "DM: " << obj.position.w << " " << obj.position.h << " ID " << obj.tileset_info.object_id << std::endl; + */ + map_object = {{obj.position.x, obj.position.y}, obj.draw_from_this_tile, o ? o->id : 0}; + } + } + + return tile_map; + } + + inline bool + isInView(float x, float y, float w, float h, const SDL_Rect &win) { + return !(x + w < 0 || + y + h < 0 || + x > win.w || + y > win.h); + } + + inline int + waveFrame( float t, int x_i, int y_i, int frame_count, float speed = 1.8f) { + float wave = + sinf(t * speed + x_i * 0.4f + y_i * 0.6f) + + sinf(t * speed * 0.66f - x_i * 0.7f + y_i * 0.3f) * 0.5f; + + wave *= (1.0f / 1.5f); + + float scaled = (wave + 1.0f) * (frame_count * 0.5f); + int frame = (int)scaled; + + if (frame < 0) frame = 0; + if (frame >= frame_count) frame = frame_count - 1; + + return frame; + } + + void + draw_MapTiles(Game* game) { + // std::cout << "FL " << Map::offset.x << " " << Map::offset.y << " " << Default::game_scale << std::endl; + SDL_Renderer* renderer = game->renderer; + Character& player = *game->state_playing->player; + SDL_Rect win_size = game->win_size; + + float view_x0 = -Map::offset.x; + float view_y0 = -Map::offset.y; + float view_x1 = view_x0 + win_size.w / Scale(1.f); + float view_y1 = view_y0 + win_size.h / Scale(1.f); + + int size = Tile::get_Size(); + + global_frame_time += Default::delta_time; + /* + if (global_frame_time >= global_frame_time_max) { + frame_water = frame_water > 0 ? frame_water-1 : 3; + global_frame_time = 0.0f; + if (frame_water == 0) + global_frame_time_max = 0.3f + ((float)rand() / (float)RAND_MAX) * 1.2f; + //std::cout << "global_frame_time_max: " << global_frame_time_max << std::endl; + } + */ + frame_meadow_time += Default::delta_time; + if (frame_meadow_time >= frame_meadow_time_max) { + frame_meadow++; + frame_meadow %= 3; + frame_meadow_time = 0.0f; + if (frame_meadow == 0) + frame_meadow_time_max = 1.4f + ((float)rand() / (float)RAND_MAX) * 2.3f; + //std::cout << "frame_meadow_time_max: " << frame_meadow_time_max << std::endl; + } + for (size_t i = 0; i < Map::tile_map.size(); ++i) { + // START draw background tiles + Tile_s& tile = Map::tile_map[i].background; + + int x_i = i % static_cast<size_t>(Map::size.x); + int y_i = i / static_cast<size_t>(Map::size.x); + + float world_x = x_i * size; + float world_y = y_i * size; + + float world_x2 = world_x + size; + float world_y2 = world_y + size; + + // CULL TILE IF OUTSIDE CAMERA + if (world_x2 < view_x0 || world_x > view_x1 || + world_y2 < view_y0 || world_y > view_y1) + continue; + + float xf = world_x + Map::offset.x; + float yf = world_y + Map::offset.y; + + SDL_FRect dst { + Scale(xf), + Scale(yf), + Scale(size), + Scale(size) + }; + + SDL_Point set_position = tile.set_position; + + + if (tile.set_category == TileCategory::TILE_WATER && set_position.y < 5) { + float local_speed = 1.8f * (0.8f + 0.4f * sinf(x_i*0.3f + y_i*0.5f)); + int frame = waveFrame(global_frame_time, x_i, y_i, 4, local_speed); + set_position.x += frame * 6; + } + else if (tile.set_category == TileCategory::TILE_GROUND && set_position.y == 10) { + float local_speed = 1.5f * (0.85f + 0.3f * sinf(x_i*0.25f + y_i*0.35f)); + int frame = waveFrame(global_frame_time, x_i, y_i, 3, local_speed); + set_position.x += frame; + } + SDL_FRect src { + static_cast<float>(set_position.x) * Tile::tile_size, + static_cast<float>(set_position.y) * Tile::tile_size, + (float)Tile::tile_size, + (float)Tile::tile_size + }; + + SDL_RenderTexture(renderer, + Tile::tilesets[TILE_BACKGROUND][tile.set_id].texture, + &src, + &dst); + + for (Tile_s& overlay : Map::tile_map[i].overlays) { + if (overlay.set_category == TileCategory::TILE_OVERLAY_FARM) { + Farm::soil_Render(renderer, {xf, yf}, overlay.set_position); + } + } + // END draw background tiles + + + } + + draw_ObjectTiles(renderer, player, win_size); + + // if (Default::game_state == GAME_PLAY) return; + + if (Default::modify_state == MODIFY_COLLISSION) { + size_t selection_size = Tile::get_SelectionSize(Default::modify_state); + const float cell_size = static_cast<float>(selection_size); + size_t map_width = static_cast<size_t>(Map::size.x)*(Tile::tile_size/Tile::tile_collider_size); + size_t map_height = static_cast<size_t>(Map::size.y)*(Tile::tile_size/Tile::tile_collider_size); + + SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); + SDL_SetRenderDrawColor(renderer, 255, 0, 0, 100); + + for (size_t y = 0; y < map_height; ++y) { + for (size_t x = 0; x < map_width; ++x) { + size_t index = y * map_width + x; + if (!Map::tile_collission_map[index]) + continue; + + SDL_FRect cell_rect = { + Scale(x * cell_size + Map::offset.x), + Scale(y * cell_size + Map::offset.y), + Scale(cell_size), + Scale(cell_size) + }; + + // draw cell outline + SDL_RenderRect(renderer, &cell_rect); + + // draw cross + SDL_RenderLine(renderer, + cell_rect.x, cell_rect.y, + cell_rect.x + cell_rect.w, cell_rect.y + cell_rect.h); + SDL_RenderLine(renderer, + cell_rect.x + cell_rect.w, cell_rect.y, + cell_rect.x, cell_rect.y + cell_rect.h); + } + } + } + } + + + void draw_SelectionBorder(SDL_Renderer* renderer, Input& input) { + // START render selecting border + bool cursor_over_tile = Tile::hovering_set; + if (cursor_over_tile) return; + + int selection_size = Tile::get_SelectionSize(Default::modify_state); + SDL_FRect tile_rect { + Scale(input.mouse_tile_position.x * selection_size + Map::offset.x), + Scale(input.mouse_tile_position.y * selection_size + Map::offset.y), + Scale(selection_size) * Tile::selection_tile_dimension.x, + Scale(selection_size) * Tile::selection_tile_dimension.y + }; + + SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255); + SDL_RenderRect(renderer, &tile_rect); + // END render selecting border + } + + void + draw_ObjectTiles(SDL_Renderer* renderer, Character& player, SDL_Rect win_size) { + int size = Tile::get_Size(); + + std::vector<bool> enemies_drawn(Enemy::enemies.size(), false); + + // draw objects and character + bool character_drawn = false; + bool player_behind = false; + + float character_collider_x = player.collider_world.x; // - player.collider.w*0.5; + float character_collider_y = player.collider_world.y; // - player.collider.h*0.5; + + for (Bird* bird : Bird::birds) + bird->drawn = false; + + for (size_t i = 0; i < Map::tile_map.size(); ++i) { + TileMap& tilemap = Map::tile_map[i]; + + int x_i = i % static_cast<size_t>(Map::size.x); + int y_i = i / static_cast<size_t>(Map::size.x); + + float xf = (x_i * size); + float yf = (y_i * size); + + SDL_FPoint xy_point = {xf+size, yf+size}; + + // Render Character if no object is hiding it + player_behind = false; + + for (TileObject& o : tilemap.objects) { + Object* object = Object::get_ObjectById(o.object_id); + // o = relative position, + // so can be 0 0, 0 1, 1 0, 1 1 if object size is 2 2 +#ifdef DEBUG_BUILD + // START DEBUG RECT + SDL_FRect dbg = { + Scale(xf + Map::offset.x), + Scale(yf + Map::offset.y), + Scale(size), + Scale(size)}; + SDL_FRect dbg_rect = dbg; + SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); + SDL_RenderRect(renderer, &dbg_rect); + // START DEBUG RECT +#endif + //if (o.position.x != 0 || o.position.y != o.position.h-1) continue; + // real object 0,0 start in map pixel + float m_xf = xf - o.position.x*size; + float m_yf = yf - o.position.y*size; + + float width = static_cast<int>(object->dimension.x) * size; + float height = static_cast<int>(object->dimension.y) * size; + + SDL_FPoint m_point = {m_xf+width, m_yf+height}; + + SDL_FRect obj_bb { + Scale(m_xf + Map::offset.x), + Scale(m_yf + Map::offset.y), + Scale(width), + Scale(height) + }; + + if (!isInView(obj_bb.x, obj_bb.y, obj_bb.w, obj_bb.h, win_size)) + continue; + //if (!o.draw_from_this_tile) continue; + + size_t j = 0; + //std::cout << "PS "<< o.position.x<< " " <<o.position.y <<std::endl; + for (Enemy* enemy : Enemy::enemies) { + SDL_FPoint enemy_bb { + static_cast<float>(enemy->collider_world.x), + static_cast<float>(enemy->collider_world.y), + }; + if (!isInView(enemy_bb.x, enemy_bb.y, enemy->collider.w, enemy->collider.h, win_size)) { + j++; + continue; + } + if ( !enemies_drawn[j] && + (enemy->stats.health <= 0 || + (enemy_bb.x >= m_xf && + enemy_bb.y >= m_yf && + enemy_bb.x + enemy->collider.w <= m_point.x && + enemy_bb.y <= m_point.y && + object->z_index > 0 ))) { + if ( enemy->stats.health <= 0 || + object->is_InFrontOf({m_xf, m_yf}, + {enemy_bb.x, + enemy_bb.y, + enemy->collider.w, + enemy->collider.h})) { + enemy->Draw(renderer); + enemies_drawn[j] = true; + } + } + j++; + } + + + + player_behind = false; + int am_i_behind_an_object = object->is_InFrontOf({m_xf, m_yf}, + {character_collider_x, + character_collider_y, + player.collider.w, + player.collider.h}); + if (am_i_behind_an_object) { + if ( am_i_behind_an_object == 1 && + character_collider_y-player.height/3 > m_yf && + ( player.collider_world.x > m_xf || + player.collider_world.x < m_xf+object->dimension.x ) ) + player_behind = true; + if (!character_drawn) { + //std::cout << "DRAW BEHIND\n"; + player.Draw(renderer); + character_drawn = true; + } + } + for (Bird* bird : Bird::birds) { + if (bird->drawn) + continue; + if ( static_cast<int>(bird->pos_x/Tile::tile_size) != x_i || + static_cast<int>((bird->pos_y-bird->altitude)/Tile::tile_size) != y_i) + continue; + + bird->Render(renderer); + // std::cout << "I AM GETTING CALLED BIRD AMP " << bird->pos_y << " " << bird->altitude << std::endl; + bird->drawn = true; + } + //std::cout << player_behind << std::endl; + //std::cout << "CHA: " << character_collider_x << " " << character_collider_y << " " << player.collider.w << " " << player.collider.h << std::endl; + //std::cout << "OJJ: " << m_xf << " " << m_yf << " " << m_point.x << " " << m_point.y << std::endl; + + + + // START OBJECT DRAW + if (o.draw_from_this_tile) + object->Draw(renderer, {m_xf, m_yf}, player_behind); + // END OBJECT DRAW + + } + size_t j = 0; + if ( !character_drawn && + player.collider_world.x >= xf && + player.collider_world.x <= xy_point.x && + player.collider_world.y >= yf && + player.collider_world.y <= xy_point.y) { + player.Draw(renderer); + character_drawn = true; + } + for (Enemy* enemy : Enemy::enemies) { + if ( !enemies_drawn[j] && + enemy->stats.health > 0 && + enemy->collider_world.x >= xf && + enemy->collider_world.x <= xy_point.x && + enemy->collider_world.y >= yf && + enemy->collider_world.y <= xy_point.y) { + enemy->Draw(renderer); + enemies_drawn[j] = true; + } + j++; + } + } + for (Bird* bird : Bird::birds) + if (!bird->drawn) { + //std::cout << "BIRD AMP " << bird->pos_y << " " << bird->altitude << std::endl; + bird->Render(renderer); + } + } + + + void + set_Offset(Input& input) { + // Set map map offset set + if (!input.click_left && Map::offset_to_set.x != 0 && Map::offset_to_set.y != 0) { + Map::offset_to_set.x = 0; + Map::offset_to_set.y = 0; + Map::setting_offset = false; + } + // Set map offset + else if (Map::offset_to_set.x != 0 && Map::offset_to_set.y != 0) { + Map::offset.x = input.mouse_state.x - Map::offset_to_set.x; + Map::offset.y = input.mouse_state.y - Map::offset_to_set.y; + } + // Update map offset set + if (input.click_left && input.pressed_ctrl && + (Map::offset_to_set.x == 0 && Map::offset_to_set.y == 0)) { + Map::offset_to_set.x = input.mouse_state.x - Map::offset.x; + Map::offset_to_set.y = input.mouse_state.y - Map::offset.y; + Map::setting_offset = true; + } + } + + void + set_Collission(Input& input) { + size_t cells_per_tile = Tile::tile_size/Tile::tile_collider_size; + const size_t map_width = static_cast<size_t>(Map::size.x)*cells_per_tile; + + for (size_t y = 0; y < static_cast<size_t>(Tile::selection_tile_dimension.y); ++y) { + for (size_t x = 0; x < static_cast<size_t>(Tile::selection_tile_dimension.x); ++x) { + + size_t cell_x = static_cast<size_t>(input.mouse_tile_position.x) + x; + size_t cell_y = static_cast<size_t>(input.mouse_tile_position.y) + y; + size_t id = cell_y * map_width + cell_x; + + if (id >= Map::tile_collission_map.size()) + continue; + + Map::tile_collission_map[id] = !Map::tile_collission_map[id]; + } + } + } + + std::vector<TileObject>& + get_ObjectsFromMapTile(SDL_Point tile_point) { + int index = static_cast<int>(tile_point.y * Map::size.x + tile_point.x); + return Map::tile_map[static_cast<size_t>(index)].objects; + } + + + void + place_ConstructionSide() { + TilesetObject object = BuildingData::active_build.object; + // object.building_status = TileBuildingStatus::CONSTRUCT; + + TileType type = Tile::get_Type(object.tileset_info.set_category); + + std::vector<bool> collision_map = + Tile::get_ObjectCollisionsFromTileset(object.tileset_info.set_id, object.tileset_info.object_id, type); + + // std::cout << "I " << object.tileset_info.set_id << " " << object.tileset_info.object_id << " " << (int)type << " " << (int)BuildingData::active_build.type <<std::endl; + + // set draw tile + SDL_Point draw_tile = {0,0}; + int s = Tile::tile_size / Tile::tile_collider_size; + int width_c = object.position.w * s; + for (int y = 0; y < object.position.w; y++) { + for (int x = 0; x < object.position.w; x++) { + for (int yc = y * s; yc < y + 1 * s; yc++) { + for (int xc = x * s; xc < x + 1 * s; xc++) { + size_t i = static_cast<size_t>(yc * width_c + xc); + if (i >= collision_map.size()) break; + if (collision_map[i] && y > draw_tile.y) { + if (x <= draw_tile.x) draw_tile = {x, y}; + } + } + } + } + } + + + // place in map array + Building* building = new Building(object.object_type, + ObjectCategory::BUILDING, + type, + object.tileset_info.set_id, + object.tileset_info.object_id, + {static_cast<int>(BuildingData::active_build.tile_position.x), static_cast<int>(BuildingData::active_build.tile_position.y)}, + {object.position.w, object.position.h}, + object.z_index, + BuildingData::active_build.type); + Object::objects.push_back(building); + + for (int y = 0; y < object.position.h; y++) { + for (int x = 0; x < object.position.w; x++) { + SDL_Point world_position = {BuildingData::active_build.tile_position.x+x, BuildingData::active_build.tile_position.y+y}; + object.position.x = x; + object.position.y = y; + object.draw_from_this_tile = false; + size_t index = static_cast<size_t>(world_position.y*Map::size.x + world_position.x); + + if (x == draw_tile.x && y == draw_tile.y) + object.draw_from_this_tile = true; + Map::tile_map[index].objects.push_back({{x, y}, object.draw_from_this_tile, building->id}); + // Sort map objects + std::sort(Map::tile_map[index].objects.begin(), + Map::tile_map[index].objects.end(), + [](const TileObject& a, const TileObject& b) { + Object* oa = Object::get_ObjectById(a.object_id); + Object* ob = Object::get_ObjectById(b.object_id); + return oa->z_index < ob->z_index; + }); + set_TileCollissionForObjects({world_position.x, world_position.y}); + + } + } + std::cout << "PLACING!\n"; + } + + bool + is_FreePosition(SDL_FRect candidate_rect) { + int left_tile = static_cast<int>(candidate_rect.x / Tile::tile_collider_size); + int top_tile = static_cast<int>(candidate_rect.y / Tile::tile_collider_size); + int right_tile = static_cast<int>((candidate_rect.x + candidate_rect.w) / Tile::tile_collider_size); + int bottom_tile = static_cast<int>((candidate_rect.y + candidate_rect.h) / Tile::tile_collider_size); + + for (int ty = top_tile; ty <= bottom_tile; ++ty) { + for (int tx = left_tile; tx <= right_tile; ++tx) { + if (tx < 0 || ty < 0 || tx >= (Map::size.x*Tile::tile_collider_size) || ty >= (Map::size.y*Tile::tile_collider_size)) { + return false; + } + + size_t idx = static_cast<size_t>(ty * Map::size.x*Tile::tile_collider_size + tx); + if (Map::tile_collission_map[idx]) { + return false; + } + } + } + + // CHECK ENEMY COLLISION + if (Enemy::is_CollidingWithEnemy(candidate_rect)) + return false; + + return true; + } + + + SDL_FPoint + get_ClosestPointWithoutCollision(const SDL_FRect &rect) { + int cx_tile = static_cast<int>(rect.x / Tile::tile_size); + int cy_tile = static_cast<int>(rect.y / Tile::tile_size); + + if (is_FreePosition({rect.x - rect.w*0.5f, rect.y - rect.h*0.5f, rect.w, rect.h})) + return { rect.x, rect.y }; + + struct TilePos { int x, y; }; + std::queue<TilePos> q; + std::set<std::pair<int,int>> visited; + + q.push({ cx_tile, cy_tile }); + visited.insert({ cx_tile, cy_tile }); + + const int dirs[4][2] = { {1,0}, {-1,0}, {0,1}, {0,-1} }; + + while (!q.empty()) { + TilePos t = q.front(); + q.pop(); + + float px = static_cast<size_t>(t.x) * Tile::tile_size; + float py = static_cast<size_t>(t.y) * Tile::tile_size; + + SDL_FRect test_rect = { px - rect.w*0.5f, py - rect.h*0.5f, rect.w, rect.h }; + if (is_FreePosition(test_rect)) + return { px, py }; + + for (int i = 0; i < 4; ++i) + { + int nx = t.x + dirs[i][0]; + int ny = t.y + dirs[i][1]; + + if (nx < 0 || ny < 0 || nx >= static_cast<int>(Map::size.x) || ny >= static_cast<int>(Map::size.y) ) + continue; + + if (visited.insert({ nx, ny }).second) + q.push({ nx, ny }); + } + } + + std::cout << "No point found!\n"; + return { 0,0 }; + } + +}; diff --git a/src/map/map.hpp b/src/map/map.hpp new file mode 100644 index 0000000..d186b86 --- /dev/null +++ b/src/map/map.hpp @@ -0,0 +1,100 @@ +#pragma once + +#include <SDL3/SDL.h> + +#include <unordered_map> +#include <vector> +#include <string> +#include <fstream> +#include <iostream> + +#include "defaults/defaults.hpp" +#include "map/tile.hpp" +#include "defaults/input.hpp" +#include "character/character.hpp" +#include "character/enemy.hpp" + +class Game; + + +typedef struct { + Tile_s background; + std::vector<Tile_s> overlays; + std::vector<TileObject> objects; + SDL_Point position; +} TileMap; + +namespace Map { + extern std::string save_path; + extern std::string save_collission_path; + + extern bool setting_offset; + extern SDL_Point offset_to_set; + extern SDL_Point offset; + extern SDL_Point size; + extern SDL_Point boundaries; // JEee fucked up the size, + // to much work to resize (i have an outer cage which fucks the path finding) + + extern int frame_water; + extern float frame_water_time; + extern float frame_water_time_max; + extern int frame_meadow; + extern float frame_meadow_time; + extern float frame_meadow_time_max; + + extern std::vector<TileMap> tile_map; + extern std::vector<bool> tile_collission_map; + + void Init(); + void init_Collider(); + void set_CollissionFromTileset(); + + void save_MapTiles(const std::vector<TileMap>& tile_map, const std::string& path); + std::vector<TileMap> load_MapTiles(const std::string& path); + + void draw_MapTiles(Game*); + void draw_SelectionBorder(SDL_Renderer* renderer, Input& input); + void draw_ObjectTiles(SDL_Renderer* renderer, Character& player, SDL_Rect win_size); + + void Reset(); // <- thats not doing what it should.. + + void save_TileCollision(const std::string& path); + void load_TileCollision(const std::string& path); + + + + void set_Offset(Input& input); + void set_Collission(Input& input); + void set_CollissionForTile(SDL_Point tile); + void set_ObjectCollisionOnTilemap(size_t object_id, SDL_Point map_tile); + void set_TileCollissionForObjects(SDL_Point map_tile); + + std::vector<TileObject>& + get_ObjectsFromMapTile(SDL_Point tile_point); + + inline SDL_Point + get_TileFromXy(SDL_FPoint point) { + return { + static_cast<int>((point.x) / Tile::tile_size), + static_cast<int>((point.y) / Tile::tile_size) + }; + } + inline size_t + get_IdFromTilePoint(SDL_Point point) { + if (point.x < 0) point.x = 0; + if (point.y < 0) point.y = 0; + if (point.x >= Map::size.x) point.x = Map::size.x-1; + if (point.y >= Map::size.y) point.y = Map::size.y-1; + size_t id = static_cast<size_t>(point.y * static_cast<int>(Map::size.x) + point.x); + return id > static_cast<size_t>(Map::size.x*Map::size.y-1) ? SIZE_MAX : id; + } + + void + place_ConstructionSide(); + + bool + is_FreePosition(SDL_FRect candidate_rect); + + SDL_FPoint + get_ClosestPointWithoutCollision(const SDL_FRect &rect); +}; diff --git a/src/map/path_finding.hpp b/src/map/path_finding.hpp new file mode 100644 index 0000000..febbafb --- /dev/null +++ b/src/map/path_finding.hpp @@ -0,0 +1,247 @@ +#pragma once + +#include <vector> +#include <cmath> + +#include "defaults/defaults.hpp" +#include "map/map.hpp" + + + +#include <vector> +#include <queue> +#include <cmath> +#include <map> +#include <algorithm> +#include <limits> + +// --- Helper Structs for A* --- + +// Node represents a single tile/cell in the grid. +struct Node { + int x; + int y; + float g_cost = std::numeric_limits<float>::infinity(); // Cost from start + float h_cost = 0.0f; // Estimated cost to goal (Heuristic) + Node* parent = nullptr; + + float f_cost() const { + return g_cost + h_cost; + } +}; + +// Custom comparison for the priority queue (min-heap). +// A* prioritizes the node with the LOWEST F-cost. +struct CompareNode { + bool operator()(const Node* a, const Node* b) const { + return a->f_cost() > b->f_cost(); // '>' for min-heap + } +}; + +// --- Heuristic Function --- + +// Use Euclidean distance for a grid with diagonal movement (optimal) +float get_Heuristic(int x1, int y1, int x2, int y2) { + float dx = static_cast<float>(x1 - x2); + float dy = static_cast<float>(y1 - y2); + return std::sqrt(dx * dx + dy * dy); +} + +// Map key to uniquely identify a grid cell +long long get_Map_Key(int x, int y, int grid_w) { + return static_cast<long long>(y) * grid_w + x; +} + +bool is_Path_Blocked( + const std::vector<bool>& grid, + int grid_w, int grid_h, + int current_x, int current_y, + int obj_w_tiles, int obj_h_tiles) +{ + // The path is blocked if any tile within the object's bounding box + // at the current (current_x, current_y) position collides. + for (int dy = 0; dy < obj_h_tiles; ++dy) { + for (int dx = 0; dx < obj_w_tiles; ++dx) { + int check_x = current_x + dx; + int check_y = current_y + dy; + + // Check if coordinates are within the grid bounds + if (check_x < 0 || check_x >= grid_w || check_y < 0 || check_y >= grid_h) { + // Technically outside the map is a collision/unwalkable boundary + return true; + } + + // Calculate 1D index: grid[y * grid_w + x] + // Collision is true if the value is 'true' + if (grid[static_cast<size_t>(check_y * grid_w + check_x)]) { + return true; + } + } + } + return false; +} + +std::vector<SDL_FPoint> find_Path(const SDL_FRect& object_rect, const SDL_FPoint& dest_px, const int max_dist, const int min_dist, std::vector<bool> grid) { + int collider_size = Tile::tile_collider_size; + int tx = static_cast<int>(object_rect.x / Tile::tile_collider_size); + int ty = static_cast<int>(object_rect.y / Tile::tile_collider_size); + + if ( ! (tx < 0 || ty < 0 || + tx >= static_cast<int>(Map::size.x * Tile::tile_collider_size) || + ty >= static_cast<int>(Map::size.y * Tile::tile_collider_size)) ) { + size_t id = static_cast<size_t>(ty * (Map::size.x * Tile::tile_collider_size) + tx); + grid[id] = false; + } + + int grid_w = static_cast<size_t>(Map::size.x * (Tile::tile_size / collider_size)); + int grid_h = static_cast<size_t>(Map::size.y * (Tile::tile_size / collider_size)); + + int obj_w_tiles = static_cast<int>(std::ceil(object_rect.w / collider_size)); + int obj_h_tiles = static_cast<int>(std::ceil(object_rect.h / collider_size)); + + // Start/Goal cells (top-left tile corner of the object's occupied space) + int start_x = static_cast<int>(object_rect.x) / collider_size; + int start_y = static_cast<int>(object_rect.y) / collider_size; + + // Original goal tile is still used for the heuristic calculation (H-cost) + // as it guides the search *toward* the general destination area. + int goal_x = dest_px.x / collider_size; + int goal_y = dest_px.y / collider_size; + + // Check if goal tile is reachable/valid (initial check remains useful) + /* + if (is_Path_Blocked(grid, grid_w, grid_h, goal_x, goal_y, obj_w_tiles, obj_h_tiles)) { + // Only return if the target TILE is blocked, but even then the range might be reachable. + // For a ranged search, it's safer to only return empty if start is blocked. + // For now, let's keep the existing logic. + // return {}; + } + */ + + // --- A* Initialization --- + std::priority_queue<Node*, std::vector<Node*>, CompareNode> open_set; + std::map<long long, Node> all_nodes; + + // Start Node Setup + long long start_key = get_Map_Key(start_x, start_y, grid_w); + Node& start_node = all_nodes[start_key]; + start_node.x = start_x; + start_node.y = start_y; + start_node.g_cost = 0.0f; + start_node.h_cost = get_Heuristic(start_x, start_y, goal_x, goal_y); + + open_set.push(&start_node); + + // Variables for Ranged Goal Check (in pixels) + float min_dist_sq = static_cast<float>(min_dist) * min_dist; + float max_dist_sq = static_cast<float>(max_dist) * max_dist; + + + int iii = 0; + + // --- A* Main Loop --- + while (!open_set.empty()) { + iii++; + Node* current_node = open_set.top(); + open_set.pop(); + + // 1. Check for Ranged Goal Condition + // Calculate the center pixel coordinates of the current tile + float current_center_x = (current_node->x + 0.5f) * collider_size; + float current_center_y = (current_node->y + 0.5f) * collider_size; + + // Calculate squared Euclidean distance to the *exact* destination pixel + float dx = current_center_x - dest_px.x; + float dy = current_center_y - dest_px.y; + float dist_sq = dx * dx + dy * dy; + + // Check if distance is within [min_dist, max_dist] (using squared distance for performance) + if (dist_sq <= max_dist_sq && dist_sq >= min_dist_sq) { + // Path found! This node is a valid stopping point within the range. + std::vector<SDL_FPoint> path; + path.push_back({dest_px.x, dest_px.y}); + Node* runner = current_node; + + // Reconstruct path from the current valid node back to start + while (runner) { + iii++; + // Convert tile coordinates back to the center of the tile in pixel coordinates + SDL_FPoint point; + point.x = (runner->x + 0.5f) * collider_size; + point.y = (runner->y + 0.5f) * collider_size; + path.push_back(point); + runner = runner->parent; + if (iii > 3500) { + path.clear(); + break; + } + } + + // Path is currently: [Goal Tile Center, ..., Start Tile Center] + std::reverse(path.begin(), path.end()); + + // As requested: Remove the starting point, as the path should contain the next move(s) + if (path.size() > 1) { + path.erase(path.begin()); + } + + // As requested: The returned vector should be [goal, ..., first move] + std::reverse(path.begin(), path.end()); + + // The last point in the current path (the final node/tile center) is the stopping point. + // You may want to replace this with the exact target *pixel* if the goal is to stop + // at the closest point on the boundary of the allowed range, but since this + // node is just a *tile* within the range, we'll leave it as the tile center + // to follow the existing logic structure. + + return path; + } + + // The rest of the A* logic (neighbor exploration) remains the same + // ------------------------------------------------------------------- + // 2. Explore Neighbors (8 directions for diagonal movement) + for (int dx = -1; dx <= 1; ++dx) { + for (int dy = -1; dy <= 1; ++dy) { + iii++; + if (dx == 0 && dy == 0) continue; + + int neighbor_x = current_node->x + dx; + int neighbor_y = current_node->y + dy; + + // Check bounds and collision + if (neighbor_x < 0 || neighbor_x >= grid_w || neighbor_y < 0 || neighbor_y >= grid_h) { + continue; + } + if (is_Path_Blocked(grid, grid_w, grid_h, neighbor_x, neighbor_y, obj_w_tiles, obj_h_tiles)) { + continue; + } + + float move_cost = (dx != 0 && dy != 0) ? 1.41421356f : 1.0f; + float tentative_g_cost = current_node->g_cost + move_cost; + + long long neighbor_key = get_Map_Key(neighbor_x, neighbor_y, grid_w); + Node& neighbor_node = all_nodes[neighbor_key]; + + // Initialize new node if it's the first visit + if (neighbor_node.g_cost == std::numeric_limits<float>::infinity()) { + neighbor_node.x = neighbor_x; + neighbor_node.y = neighbor_y; + // H-cost still points to the original goal tile to guide the search + neighbor_node.h_cost = get_Heuristic(neighbor_x, neighbor_y, goal_x, goal_y); + } + + // 3. Update Path/Add to Open Set + if (tentative_g_cost < neighbor_node.g_cost) { + neighbor_node.parent = current_node; + neighbor_node.g_cost = tentative_g_cost; + + open_set.push(&neighbor_node); + } + } + } + } + + + // Path not found + return {}; +} diff --git a/src/map/tile.cpp b/src/map/tile.cpp new file mode 100644 index 0000000..9e89b70 --- /dev/null +++ b/src/map/tile.cpp @@ -0,0 +1,1569 @@ +#include <SDL3/SDL.h> +#include <SDL3_image/SDL_image.h> + +#include <vector> +#include <unordered_map> +#include <fstream> +#include <iostream> +#include <algorithm> + +#include "map/tile.hpp" +#include "defaults/input.hpp" +#include "map/map.hpp" +#include "defaults/ui.hpp" + +namespace Tile { + size_t active_tileset_id = 0; + TileType active_tileset_type = TILE_BACKGROUND; + TileSet* active_tileset = nullptr; + + bool draw_tile_set = true; + bool tile_selected = false; + + bool object_selected = false; + size_t selected_object_id = SIZE_MAX; + SDL_Point selected_position = {0,0}; + + TileObjectPropSettingStates object_props_setting_state = TileObjectPropSettingStates::OBJECT_SETTING_STATE_TYPE; + + std::unordered_map<TileType, std::vector<TileSet>> tilesets; + std::vector<SDL_Point> selected_tiles; + SDL_FPoint tileset_offset = {0, Ui::top_bar_height}; + SDL_FPoint tileset_offset_to_set = {0, 0}; + bool setting_tileset_offset = false; + + float tileset_scale = 0; + float tileset_scale_to_set = 0; + bool setting_tileset_scale = false; + + bool hovering_set = false; + + SDL_Point selection_tile_dimension = {1, 1}; + SDL_Point selected_tile_dimension = {1, 1}; + + std::string save_tileset_collission_path = "saves/save.tileset_collissions"; + std::string save_tileset_objects_path = "saves/save.tileset_objects"; + std::string save_tileset_floortype_path = "saves/save.tileset_floortype"; + + std::vector<TileSettingHistory> tile_setting_history; + + std::vector<FloorProps> floor_props; + + std::unordered_map<TileCategory, std::unordered_map<size_t,TilesetFloorProps>> tileset_floor_props; + + const char* to_String(TileTypeFloors type) { + switch (type) { + case NONE: return "NONE"; + case MEADOW: return "MEADOW"; + case CLAY: return "CLAY"; + case SOIL: return "SOIL"; + case BRICKS: return "BRICKS"; + case ICE: return "ICE"; + case DESERT: return "DESERT"; + case WATER: return "WATER"; + default: return "UNKNOWN"; + } + } + + bool + Init(SDL_Renderer* renderer) { + Tile::tilesets[TILE_BACKGROUND].push_back( + {IMG_LoadTexture(renderer, "Pixel_Crawler/Environment/Tilesets/Floors_Tiles.png"), + {25, 26}, + TILE_GROUND, {}, {}, {} + }); + Tile::tilesets[TILE_BACKGROUND].push_back( + {IMG_LoadTexture(renderer, "Pixel_Crawler/Environment/Tilesets/Water_tiles.png"), + {25, 25}, + TILE_WATER, {}, {}, {} + }); + Tile::tilesets[TILE_BACKGROUND].push_back( + {IMG_LoadTexture(renderer, "Pixel_Crawler/Environment/Tilesets/Dungeon_Tiles.png"), + {25, 25}, + TILE_DUNGEON, {}, {}, {} + }); + Tile::tilesets[TILE_BACKGROUND].push_back( + {IMG_LoadTexture(renderer, "Pixel_Crawler/Environment/Tilesets/Wall_Tiles.png"), + {25, 25}, + TILE_WALL, {}, {}, {} + }); + Tile::tilesets[TILE_BACKGROUND].push_back( + {IMG_LoadTexture(renderer, "Pixel_Crawler/Environment/Tilesets/Wall_Variations.png"), + {16, 30}, + TILE_WALL_VARIATION, {}, {}, {} + }); + Tile::tilesets[TILE_OVERLAY].push_back( + {IMG_LoadTexture(renderer, "Pixel_Crawler/Environment/Tilesets/Overlay_tiles.png"), + {25,25}, + TILE_OVERLAY_FARM, {}, {}, {} + }); + Tile::tilesets[TILE_BUILDING].push_back( + {IMG_LoadTexture(renderer, "Pixel_Crawler/Environment/Structures/Buildings/Floors.png"), + {25, 25}, + TILE_FLOORS, {}, {}, {} + }); + Tile::tilesets[TILE_BUILDING].push_back( + {IMG_LoadTexture(renderer, "Pixel_Crawler/Environment/Structures/Buildings/Props.png"), + {25, 25}, + TILE_PROPS, {}, {}, {} + }); + Tile::tilesets[TILE_BUILDING].push_back( + {IMG_LoadTexture(renderer, "Pixel_Crawler/Environment/Structures/Buildings/Roofs.png"), + {25, 25}, + TILE_ROOFS, {}, {}, {} + }); + Tile::tilesets[TILE_BUILDING].push_back( + {IMG_LoadTexture(renderer, "Pixel_Crawler/Environment/Structures/Buildings/Walls.png"), + {42, 50}, + TILE_WALLS, {}, {}, {} + }); + Tile::tilesets[TILE_BUILDING].push_back( + {IMG_LoadTexture(renderer, "Pixel_Crawler/Environment/Props/Static/Furniture.png"), + {50, 54}, + TILE_FURNITURE, {}, {}, {} + }); + Tile::tilesets[TILE_BUILDING].push_back( + {IMG_LoadTexture(renderer, "Pixel_Crawler/Environment/Structures/Stations/Workbench/Workbench.png"), + {12, 22}, + TILE_WORKBENCH, {}, {}, {} + }); + Tile::tilesets[TILE_OBJECT].push_back( + {IMG_LoadTexture(renderer, "Pixel_Crawler/Environment/Props/Static/Vegetation.png"), + {25, 27}, + TILE_VEGETATION, {}, {}, {} + }); + Tile::tilesets[TILE_OBJECT].push_back( + {IMG_LoadTexture(renderer, "Pixel_Crawler/Environment/Props/Static/Rocks.png"), + {13, 19}, + TILE_ROCK, {}, {}, {} + }); + Tile::tilesets[TILE_OBJECT].push_back( + {IMG_LoadTexture(renderer, "Pixel_Crawler/Environment/Props/Static/Trees/Model_01/Size_02.png"), + {16, 8}, + TILE_TREE, {}, {}, {} + }); + Tile::tilesets[TILE_OBJECT].push_back( + {IMG_LoadTexture(renderer, "Pixel_Crawler/Environment/Props/Static/Trees/Model_01/Size_03.png"), + {13, 12}, + TILE_TREE, {}, {}, {} + }); + Tile::tilesets[TILE_OBJECT].push_back( + {IMG_LoadTexture(renderer, "Pixel_Crawler/Environment/Props/Static/Trees/Model_01/Size_04.png"), + {23, 16}, + TILE_TREE, {}, {}, {} + }); + Tile::tilesets[TILE_OBJECT].push_back( + {IMG_LoadTexture(renderer, "Pixel_Crawler/Environment/Props/Static/Trees/Model_01/Size_05.png"), + {28, 23}, + TILE_TREE, {}, {}, {} + }); + Tile::tilesets[TILE_FARM].push_back( + {IMG_LoadTexture(renderer, "Pixel_Crawler/Environment/Props/Static/Farm.png"), + {25, 25}, + TILE_FARMING, {}, {}, {} + }); + + for (auto& [tile_type, tileset_vector] : Tile::tilesets) { + for (auto& tileset : tileset_vector) { + SDL_Texture* tex = tileset.texture; + if (tex) { + SDL_SetTextureScaleMode(tex, SDL_SCALEMODE_NEAREST); + } + } + } + + if (!Tile::tilesets[TILE_BACKGROUND][0].texture) { + SDL_Log("Couldn't load texture: %s\n", SDL_GetError()); + return false; + } + const int cells_per_tile = Tile::get_Size() / Tile::tile_collider_size; + for (auto& tileset : Tile::tilesets[TILE_BACKGROUND]) { + if (tileset.texture) { + SDL_SetTextureScaleMode(tileset.texture, SDL_SCALEMODE_NEAREST); + } + } + + for (auto &pair : Tile::tilesets) { + for (auto &tile : pair.second) { + size_t total_cells = static_cast<size_t>(tile.size.x * cells_per_tile * tile.size.y * cells_per_tile); + tile.collission_map.assign(total_cells, false); + } + } + + Tile::load_Collissions(); + Tile::load_Objects(); + ResourceData::load_Resources(); + Tile::load_TilesetFloorProps(); + + Tile::active_tileset = &Tile::tilesets[TILE_BACKGROUND][0]; + + + floor_props.push_back({NONE, true, false}); + floor_props.push_back({MEADOW, true, false}); + floor_props.push_back({CLAY, true, false}); + floor_props.push_back({SOIL, true, true}); + floor_props.push_back({BRICKS, true, false}); + floor_props.push_back({ICE, false, false}); + floor_props.push_back({DESERT, false, false}); + floor_props.push_back({WATER, false, false}); + return true; + } + + TileType + get_Type(TileCategory category) { + switch (category) { + case TILE_GROUND: + case TILE_WATER: + case TILE_WALL: + case TILE_WALL_VARIATION: + case TILE_DUNGEON: + return TILE_BACKGROUND; + case TILE_OVERLAY_FARM: + return TILE_OVERLAY; + case TILE_FLOORS: + case TILE_PROPS: + case TILE_ROOFS: + case TILE_WALLS: + case TILE_WORKBENCH: + case TILE_FURNITURE: + return TILE_BUILDING; + + case TILE_TREE: + case TILE_ROCK: + case TILE_VEGETATION: + case TILE_FARMING: + return TILE_OBJECT; + + } + return TILE_TYPE_LAST; + } + + size_t + get_Size() { + return (tile_size); + } + size_t + get_SelectionSize(ModifyState_s modify_state) { + if (modify_state == MODIFY_COLLISSION) + return (tile_collider_size); + + return (tile_size); + } + + size_t + get_ObjectIdFromTileset(SDL_Point selected_tile, TileSet tileset) { + for (const auto& pair : tileset.objects) { + SDL_Rect position = pair.second.position; + if (position.x <= static_cast<int>(selected_tile.x) && + position.y <= static_cast<int>(selected_tile.y) && + position.x+pair.second.position.w > static_cast<int>(selected_tile.x) && + position.y+pair.second.position.h > static_cast<int>(selected_tile.y)) { + return pair.first; + } + } + return SIZE_MAX; + } + + void + set_HoveringTileset(SDL_FPoint mouse_state) { + size_t selection_size = get_Size(); + + float logical_x = mouse_state.x - tileset_offset.x; + float logical_y = mouse_state.y - tileset_offset.y; + + int tile_x = static_cast<int>(logical_x / selection_size); + int tile_y = static_cast<int>(logical_y / selection_size); + + hovering_set = (tile_x >= 0 && tile_x < static_cast<int>(active_tileset->size.x) && + tile_y >= 0 && tile_y < static_cast<int>(active_tileset->size.y)); + } + + + TileSet& + get_TilesetFromMapTile(Tile_s tile) { + return tilesets[get_Type(tile.set_category)][tile.set_id]; + } + + + void + save_Objects() { + std::ofstream file(save_tileset_objects_path, std::ios::binary); + if (!file) return; + + uint32_t types_count = tilesets.size(); + file.write(reinterpret_cast<const char*>(&types_count), sizeof(types_count)); + + for (const auto& [type, vec] : tilesets) { + uint32_t t = static_cast<uint32_t>(type); + file.write(reinterpret_cast<const char*>(&t), sizeof(t)); + + uint32_t set_count = vec.size(); + file.write(reinterpret_cast<const char*>(&set_count), sizeof(set_count)); + + for (const auto& tile : vec) { + uint64_t obj_count = tile.objects.size(); + file.write(reinterpret_cast<const char*>(&obj_count), sizeof(obj_count)); + + for (const auto& [key, obj] : tile.objects) { + file.write(reinterpret_cast<const char*>(&key), sizeof(key)); + + // --- TilesetObject serialization --- + file.write(reinterpret_cast<const char*>(&obj.position.x), sizeof(obj.position.x)); + file.write(reinterpret_cast<const char*>(&obj.position.y), sizeof(obj.position.y)); + file.write(reinterpret_cast<const char*>(&obj.position.w), sizeof(obj.position.w)); + file.write(reinterpret_cast<const char*>(&obj.position.h), sizeof(obj.position.h)); + + file.write(reinterpret_cast<const char*>(&obj.draw_from_this_tile), sizeof(obj.draw_from_this_tile)); + + int type_value = static_cast<int>(obj.object_type); + file.write(reinterpret_cast<const char*>(&type_value), sizeof(type_value)); + + file.write(reinterpret_cast<const char*>(&obj.collectable), sizeof(obj.collectable)); + //int building_status = static_cast<int>(obj.building_status); + // file.write(reinterpret_cast<const char*>(&building_status), sizeof(building_status)); + file.write(reinterpret_cast<const char*>(&obj.z_index), sizeof(obj.z_index)); + // --- Tile_s serialization --- + file.write(reinterpret_cast<const char*>(&obj.tileset_info.set_id), sizeof(obj.tileset_info.set_id)); + file.write(reinterpret_cast<const char*>(&obj.tileset_info.object_id), sizeof(obj.tileset_info.object_id)); + + int category = static_cast<int>(obj.tileset_info.set_category); + file.write(reinterpret_cast<const char*>(&category), sizeof(category)); + + file.write(reinterpret_cast<const char*>(&obj.tileset_info.set_position.x), sizeof(obj.tileset_info.set_position.x)); + file.write(reinterpret_cast<const char*>(&obj.tileset_info.set_position.y), sizeof(obj.tileset_info.set_position.y)); + + } + } + } + } + void + load_Objects() { + std::ifstream file(save_tileset_objects_path, std::ios::binary); + if (!file) return; + + uint32_t types_count = 0; + file.read(reinterpret_cast<char*>(&types_count), sizeof(types_count)); + + for (uint32_t i = 0; i < types_count; ++i) { + uint32_t t = 0; + file.read(reinterpret_cast<char*>(&t), sizeof(t)); + TileType type = static_cast<TileType>(t); + + uint32_t set_count = 0; + file.read(reinterpret_cast<char*>(&set_count), sizeof(set_count)); + + auto& vec = tilesets[type]; + for (uint32_t j = 0; j < set_count && j < vec.size(); ++j) { + uint64_t obj_count = 0; + file.read(reinterpret_cast<char*>(&obj_count), sizeof(obj_count)); + + vec[j].objects.clear(); + for (uint64_t k = 0; k < obj_count; ++k) { + size_t key = 0; + file.read(reinterpret_cast<char*>(&key), sizeof(key)); + + TilesetObject obj{}; + + + file.read(reinterpret_cast<char*>(&obj.position.x), sizeof(obj.position.x)); + file.read(reinterpret_cast<char*>(&obj.position.y), sizeof(obj.position.y)); + file.read(reinterpret_cast<char*>(&obj.position.w), sizeof(obj.position.w)); + file.read(reinterpret_cast<char*>(&obj.position.h), sizeof(obj.position.h)); + + + file.read(reinterpret_cast<char*>(&obj.draw_from_this_tile), sizeof(obj.draw_from_this_tile)); + + + int type_value = 0; + file.read(reinterpret_cast<char*>(&type_value), sizeof(type_value)); + obj.object_type = static_cast<ObjectType>(type_value); + + file.read(reinterpret_cast<char*>(&obj.collectable), sizeof(obj.collectable)); + file.read(reinterpret_cast<char*>(&obj.z_index), sizeof(obj.z_index)); + + // --- Tile_s deserialization --- + file.read(reinterpret_cast<char*>(&obj.tileset_info.set_id), sizeof(obj.tileset_info.set_id)); + file.read(reinterpret_cast<char*>(&obj.tileset_info.object_id), sizeof(obj.tileset_info.object_id)); + + int category = 0; + file.read(reinterpret_cast<char*>(&category), sizeof(category)); + obj.tileset_info.set_category = static_cast<TileCategory>(category); + + file.read(reinterpret_cast<char*>(&obj.tileset_info.set_position.x), sizeof(obj.tileset_info.set_position.x)); + file.read(reinterpret_cast<char*>(&obj.tileset_info.set_position.y), sizeof(obj.tileset_info.set_position.y)); + + vec[j].objects.emplace(key, obj); + } + } + } + } + + void + save_Collissions() { + std::ofstream file(save_tileset_collission_path, std::ios::binary); + if (!file) return; + + uint32_t types_count = tilesets.size(); + file.write(reinterpret_cast<char*>(&types_count), sizeof(types_count)); + + for (const auto &[type, vec] : tilesets) { + uint32_t t = static_cast<uint32_t>(type); + file.write(reinterpret_cast<char*>(&t), sizeof(t)); + + uint32_t set_count = vec.size(); + file.write(reinterpret_cast<char*>(&set_count), sizeof(set_count)); + + for (const auto &tile : vec) { + uint64_t map_size = tile.collission_map.size(); + file.write(reinterpret_cast<char*>(&map_size), sizeof(map_size)); + + for (bool v : tile.collission_map) { + uint8_t b = v ? 1 : 0; + file.write(reinterpret_cast<char*>(&b), 1); + } + } + } + } + + + void + load_Collissions() { + std::ifstream file(save_tileset_collission_path, std::ios::binary); + if (!file) return; + + uint32_t types_count = 0; + file.read(reinterpret_cast<char*>(&types_count), sizeof(types_count)); + + for (uint32_t i = 0; i < types_count; ++i) { + uint32_t t = 0; + file.read(reinterpret_cast<char*>(&t), sizeof(t)); + TileType type = static_cast<TileType>(t); + + uint32_t set_count = 0; + file.read(reinterpret_cast<char*>(&set_count), sizeof(set_count)); + + auto &vec = tilesets[type]; + for (uint32_t j = 0; j < set_count && j < vec.size(); ++j) { + uint64_t map_size = 0; + file.read(reinterpret_cast<char*>(&map_size), sizeof(map_size)); + + vec[j].collission_map.resize(map_size); + for (uint64_t k = 0; k < map_size; ++k) { + uint8_t b = 0; + file.read(reinterpret_cast<char*>(&b), 1); + vec[j].collission_map[k] = (b != 0); + } + } + } + } + + + inline int TileCategoryToInt(TileCategory t) { return static_cast<int>(t); } + inline int TileTypeFloorsToInt(TileTypeFloors f) { return static_cast<int>(f); } + + inline TileCategory IntToTileCategory(int i) { return static_cast<TileCategory>(i); } + inline TileTypeFloors IntToTileTypeFloors(int i) { return static_cast<TileTypeFloors>(i); } + + void + save_TilesetFloorProps() { + std::ofstream out(save_tileset_floortype_path, std::ios::binary); + if (!out) { + std::cerr << "Failed to open file for saving: " << save_tileset_floortype_path << "\n"; + return; + } + + size_t map_size = tileset_floor_props.size(); + out.write(reinterpret_cast<const char*>(&map_size), sizeof(map_size)); + + for (auto& [tile_type, inner_map] : tileset_floor_props) { + int tt = TileCategoryToInt(tile_type); + out.write(reinterpret_cast<const char*>(&tt), sizeof(tt)); + + size_t inner_size = inner_map.size(); + out.write(reinterpret_cast<const char*>(&inner_size), sizeof(inner_size)); + + for (auto& [index, props] : inner_map) { + out.write(reinterpret_cast<const char*>(&index), sizeof(index)); + + int floor = TileTypeFloorsToInt(props.tiletype); + out.write(reinterpret_cast<const char*>(&floor), sizeof(floor)); + + out.write(reinterpret_cast<const char*>(&props.z_index), sizeof(props.z_index)); + } + } + } + + + void + load_TilesetFloorProps() { + std::ifstream in(save_tileset_floortype_path, std::ios::binary); + if (!in) { + std::cerr << "Failed to open file for loading: " << save_tileset_floortype_path << "\n"; + return; + } + + tileset_floor_props.clear(); + + size_t map_size = 0; + in.read(reinterpret_cast<char*>(&map_size), sizeof(map_size)); + + for (size_t i = 0; i < map_size; ++i) { + int tt_int; + in.read(reinterpret_cast<char*>(&tt_int), sizeof(tt_int)); + TileCategory tt = IntToTileCategory(tt_int); + + size_t inner_size = 0; + in.read(reinterpret_cast<char*>(&inner_size), sizeof(inner_size)); + + std::unordered_map<size_t, TilesetFloorProps> inner_map; + for (size_t j = 0; j < inner_size; ++j) { + size_t index; + int floor_int; + int z_index; + + in.read(reinterpret_cast<char*>(&index), sizeof(index)); + in.read(reinterpret_cast<char*>(&floor_int), sizeof(floor_int)); + in.read(reinterpret_cast<char*>(&z_index), sizeof(z_index)); + + inner_map[index] = TilesetFloorProps{IntToTileTypeFloors(floor_int), z_index}; + } + + tileset_floor_props[tt] = std::move(inner_map); + } + } + + + void + draw_SelectedObject(SDL_Renderer* renderer, Input input) { + // render selected object + if (Tile::object_selected && Default::modify_state == MODIFY_TILES) { + TilesetObject object = active_tileset->objects[selected_object_id]; + SDL_FRect obj_src = { + object.position.x * static_cast<float>(Tile::tile_size), + object.position.y * static_cast<float>(Tile::tile_size), + object.position.w * static_cast<float>(Tile::tile_size), + object.position.h * static_cast<float>(Tile::tile_size) + }; + + SDL_FPoint tile_offset = { + (static_cast<float>(selected_position.x) - object.position.x) * static_cast<float>(Tile::tile_size), + (static_cast<float>(selected_position.y) - object.position.y) * static_cast<float>(Tile::tile_size) + }; + + SDL_FPoint offset = {(float)tileset_offset.x, (float)tileset_offset.y}; + if (!hovering_set) { + offset.x = Map::offset.x; + offset.y = Map::offset.y; + } + SDL_FRect dst {Scale(input.mouse_tile_position.x* static_cast<int>(Tile::tile_size) + offset.x - tile_offset.x), + Scale(input.mouse_tile_position.y* static_cast<int>(Tile::tile_size) + offset.y - tile_offset.y), + Scale(object.position.w * static_cast<float>(Tile::tile_size)), + Scale(object.position.h * static_cast<float>(Tile::tile_size))}; + + SDL_Texture* tex = Tile::tilesets[active_tileset_type][active_tileset_id].texture; + SDL_SetTextureAlphaMod(tex, 100); + SDL_RenderTexture(renderer, tex, &obj_src, &dst); + SDL_SetTextureAlphaMod(tex, 255); + + } + } + + void + draw_Tileset(SDL_Renderer* renderer, Input input) { + // render Set + float cell_size = Tile::get_SelectionSize(Default::modify_state); + SDL_FRect dst = { + 0.0f + tileset_offset.x * Default::game_scale, + 0.0f + tileset_offset.y * Default::game_scale, + Scale(Tile::active_tileset->size.x * tile_size), + Scale(Tile::active_tileset->size.y * tile_size) + }; + + SDL_FRect bg_rect = dst; + SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); + SDL_RenderFillRect(renderer, &bg_rect); + + SDL_RenderTexture(renderer, Tile::active_tileset->texture, NULL, &dst); + + // Render Set-Border + float border_thickness = 4.0f; + SDL_FRect top = { dst.x-border_thickness, dst.y-border_thickness, dst.w+border_thickness*2, border_thickness }; + SDL_FRect bottom = { dst.x-border_thickness, dst.y + dst.h, dst.w+border_thickness*2, border_thickness }; + SDL_FRect left = { dst.x-border_thickness, dst.y-border_thickness, border_thickness, dst.h+border_thickness*2 }; + SDL_FRect right = { dst.x + dst.w, dst.y-border_thickness, border_thickness, dst.h+border_thickness*2 }; + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); + SDL_RenderFillRect(renderer, &top); + SDL_RenderFillRect(renderer, &bottom); + SDL_RenderFillRect(renderer, &left); + SDL_RenderFillRect(renderer, &right); + + + // render object cells + if (Default::modify_state == MODIFY_FLOOR_TYPE) { + SDL_SetRenderDrawColor(renderer, 0, 160, 255, 255); + SDL_Point tileset_size = active_tileset->size; + for (const auto& pair : tileset_floor_props[active_tileset->category]) { + if (pair.second.tiletype == NONE) continue; + int x = static_cast<int>(pair.first) % tileset_size.x; + int y = static_cast<int>(pair.first) / tileset_size.x; + SDL_FRect cell_rect = { + Scale(x * tile_size + tileset_offset.x), + Scale(y * tile_size + tileset_offset.y), + Scale(tile_size), + Scale(tile_size) + }; + + // draw cell outline + SDL_RenderRect(renderer, &cell_rect); + + // draw cross + SDL_RenderLine(renderer, + cell_rect.x, + cell_rect.y, + cell_rect.x + cell_rect.w, cell_rect.y + cell_rect.h); + SDL_RenderLine(renderer, + cell_rect.x + cell_rect.w, + cell_rect.y, + cell_rect.x, cell_rect.y + cell_rect.h); + } + + } else if (Default::modify_state == MODIFY_OBJECTS || Default::modify_state == MODIFY_OBJECTS_PROPS || Default::modify_state == MODIFY_OBJECTS_PROPS_RESOURCE) { + + SDL_SetRenderDrawColor(renderer, 0, 255, Default::modify_state == MODIFY_OBJECTS_PROPS ? 160 : 255, 255); + for (const auto& pair : active_tileset->objects) { + if (Default::modify_state == MODIFY_OBJECTS_PROPS_RESOURCE && !pair.second.collectable) continue; + if (pair.second.object_type == ObjectType::NONE) + SDL_SetRenderDrawColor(renderer, 200, 0, 0, 255); + else + SDL_SetRenderDrawColor(renderer, 0, 255, Default::modify_state == MODIFY_OBJECTS_PROPS ? 160 : 255, 255); + + SDL_FRect cell_rect = { + Scale(pair.second.position.x * cell_size + tileset_offset.x), + Scale(pair.second.position.y * cell_size + tileset_offset.y), + Scale(pair.second.position.w * cell_size), + Scale(pair.second.position.h * cell_size) + }; + + // draw cell outline + SDL_RenderRect(renderer, &cell_rect); + + // draw cross + SDL_RenderLine(renderer, + cell_rect.x, + cell_rect.y, + cell_rect.x + cell_rect.w, cell_rect.y + cell_rect.h); + SDL_RenderLine(renderer, + cell_rect.x + cell_rect.w, + cell_rect.y, + cell_rect.x, cell_rect.y + cell_rect.h); + } + // render collision cells + } else if (Default::modify_state == MODIFY_COLLISSION) { + size_t map_width = static_cast<size_t>(Tile::active_tileset->size.x); + size_t map_height = static_cast<size_t>(Tile::active_tileset->size.y); + + SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); + SDL_SetRenderDrawColor(renderer, 255, 0, 0, 100); + + size_t cells_per_tile = tile_size/tile_collider_size; + for (size_t y = 0; y < map_height*cells_per_tile; ++y) { + for (size_t x = 0; x < map_width*cells_per_tile; ++x) { + size_t index = y * map_width*cells_per_tile + x; + if (!Tile::active_tileset->collission_map[index]) + continue; + + SDL_FRect cell_rect = { + Scale(x * cell_size + tileset_offset.x), + Scale(y * cell_size + tileset_offset.y), + Scale(cell_size), + Scale(cell_size) + }; + + // draw cell outline + SDL_RenderRect(renderer, &cell_rect); + + // draw cross + SDL_RenderLine(renderer, + cell_rect.x, + cell_rect.y, + cell_rect.x + cell_rect.w, cell_rect.y + cell_rect.h); + SDL_RenderLine(renderer, + cell_rect.x + cell_rect.w, + cell_rect.y, + cell_rect.x, cell_rect.y + cell_rect.h); + } + } + } + + // render selection_border + if (hovering_set) { + SDL_FRect tile_rect {Scale(input.mouse_tile_position.x*cell_size + tileset_offset.x), + Scale(input.mouse_tile_position.y*cell_size + tileset_offset.y), + Scale(cell_size*Tile::selection_tile_dimension.x), + Scale(cell_size*Tile::selection_tile_dimension.y)}; + + SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255); + SDL_RenderRect(renderer, &tile_rect); + } + // render selected border + if (Tile::tile_selected) { + SDL_FRect tile_rect_selected + {Scale(Tile::selected_tiles[0].x*tile_size + tileset_offset.x), + Scale(Tile::selected_tiles[0].y*tile_size + tileset_offset.y), + Scale(tile_size*Tile::selected_tile_dimension.x), + Scale(tile_size*Tile::selected_tile_dimension.y)}; + + SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255); + SDL_RenderRect(renderer, &tile_rect_selected); + } else if (Tile::object_selected) { + TilesetObject object = active_tileset->objects[selected_object_id]; + SDL_FRect tile_rect_selected + {Scale(object.position.x*static_cast<int>(tile_size) + tileset_offset.x), + Scale(object.position.y*static_cast<int>(tile_size) + tileset_offset.y), + Scale(object.position.w*static_cast<int>(tile_size)), + Scale(object.position.h*static_cast<int>(tile_size))}; + + SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255); + SDL_RenderRect(renderer, &tile_rect_selected); + + SDL_FRect tile_rect_selected_position + {Scale(selected_position.x * static_cast<int>(tile_size) + tileset_offset.x), + Scale(selected_position.y * static_cast<int>(tile_size) + tileset_offset.y), + Scale(tile_size), + Scale(tile_size)}; + SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); + SDL_SetRenderDrawColor(renderer, 0, 255, 0, 60); + SDL_RenderFillRect(renderer, &tile_rect_selected_position); + SDL_SetRenderDrawColor(renderer, 0, 255, 255, 60); + SDL_RenderRect(renderer, &tile_rect_selected_position); + } + } + + void + clear_Objects(Input& input) { + for (int y = 0; y < Tile::selection_tile_dimension.y; y++) { + for (int x = 0; x < Tile::selection_tile_dimension.x; x++) { + + int map_x = input.mouse_tile_position.x + x; + int map_y = input.mouse_tile_position.y + y; + + if (map_x >= Map::size.x || map_y >= Map::size.y) + continue; + + size_t index = static_cast<size_t>(map_y * Map::size.x + map_x); + auto& tile_objects = Map::tile_map[index].objects; + if (!input.pressed_c || tile_objects.empty()) + continue; + + TileObject &obj = tile_objects[0]; + Object* object = Object::get_ObjectById(obj.object_id); + if (!object) continue; + + int world_tile_x = map_x - obj.position.x; + int world_tile_y = map_y - obj.position.y; + + for (int wx = world_tile_x; wx < world_tile_x + object->dimension.x; ++wx) { + + for (int wy = world_tile_y; wy < world_tile_y + object->dimension.y; ++wy) { + + if (wx < 0 || wy < 0 || wx >= Map::size.x || wy >= Map::size.y) + continue; + + + size_t i = static_cast<size_t>(wy * Map::size.x + wx); + auto &objects = Map::tile_map[i].objects; + + for (auto it = objects.begin(); it != objects.end();) { + + Object* oo = Object::get_ObjectById(it->object_id); + + if (!oo || oo->id == object->id) { + it = objects.erase(it); + } else ++it; + } + + Map::set_TileCollissionForObjects({wx, wy}); + } + } + + delete object; + } + } + } + + void + set_Collission(Input& input) { + const int map_width = Tile::active_tileset->size.x * (tile_size/tile_collider_size); + + for (int y = 0; y < Tile::selection_tile_dimension.y; ++y) { + for (int x = 0; x < Tile::selection_tile_dimension.x; ++x) { + + int cell_x = input.mouse_tile_position.x + x; + int cell_y = input.mouse_tile_position.y + y; + size_t id = static_cast<size_t>(cell_y * map_width + cell_x); + + if (id >= Tile::active_tileset->collission_map.size()) + continue; + + Tile::active_tileset->collission_map[id] = !Tile::active_tileset->collission_map[id]; + } + } + } + + bool + objec_HasCollission(TilesetObject& object) { + TileType type = get_Type( object.tileset_info.set_category); + std::vector<bool> collision_map = + Tile::get_ObjectCollisionsFromTileset(object.tileset_info.set_id, + object.tileset_info.object_id, type); + + for (bool collission : collision_map) { + if (collission) return true; + } + return false; + } + + std::vector<bool> + get_CollissionsOfTileFromObject(TilesetObject& obj, SDL_Point tile) { + const size_t scale = Tile::tile_size / Tile::tile_collider_size; + + // convert rectangle to collider coordinates + + // 0 2 + TileType type = get_Type( obj.tileset_info.set_category); + std::vector<bool> collision_map = + Tile::get_ObjectCollisionsFromTileset(obj.tileset_info.set_id, + obj.tileset_info.object_id, type); + + int y_start = tile.y * (tile_size/tile_collider_size); + int y_end = y_start + static_cast<int>(tile_size/tile_collider_size); + int x_start = tile.x * (tile_size/tile_collider_size); + int x_end = x_start + static_cast<int>(tile_size/tile_collider_size); + int obj_w = static_cast<size_t>(obj.position.w) * scale; + //int obj_h = static_cast<size_t>(obj.position.h) * scale; + std::vector<bool> collissions; + for (int y = y_start; y < y_end; y++) { + for (int x = x_start; x < x_end; x++) { + size_t index = static_cast<size_t>(y * obj_w + x); + bool cell_value = index < collision_map.size() ? collision_map[index] : false; + collissions.push_back(cell_value); + } + } + /* + int obj_abs_x = static_cast<int>(tile.x) - obj.position.x; + int obj_abs_y = static_cast<int>(tile.y) - obj.position.y; + + int obj_cx = obj_abs_x * static_cast<int>(scale); + int obj_cy = obj_abs_y * static_cast<int>(scale); + size_t obj_cw = static_cast<size_t>(obj.position.w) * scale; + size_t obj_ch = static_cast<size_t>(obj.position.h) * scale; + + int start_cx = obj_cx; + int end_cx = obj_cx + static_cast<int>(Tile::tile_size) / static_cast<int>(Tile::tile_collider_size); + int start_cy = obj_cy; + int end_cy = obj_cy + static_cast<int>(Tile::tile_size) / static_cast<int>(Tile::tile_collider_size); + + for (int cy = start_cy; cy < end_cy; ++cy) { + for (int cx = start_cx; cx < end_cx; ++cx) { + int rel_x = cx - obj_cx; + int rel_y = cy - obj_cy; + + if (rel_x < 0 || rel_y < 0 || static_cast<size_t>(rel_x) >= obj_cw || static_cast<size_t>(rel_y) >= obj_ch) { + continue; + } + + size_t obj_index = static_cast<size_t>(rel_y) * obj_cw + static_cast<size_t>(rel_x); + bool cell_value = obj_index < obj.collission_map.size() ? obj.collission_map[obj_index] : false; + + std::cout << (int)cell_value; + collissions.push_back(cell_value); + } + std::cout << std::endl; + } + */ + return collissions; + } + + void + set_Object(Input& input) { + std::unordered_map<size_t, TilesetObject>& objects = active_tileset->objects; + + size_t object_id = objects.size(); + + size_t mouse_tile_x = static_cast<size_t>(input.mouse_tile_position.x); + size_t mouse_tile_y = static_cast<size_t>(input.mouse_tile_position.y); + + // check if any tile already in objects map + bool removed_object = false; + for (size_t y = 0; y < static_cast<size_t>(Tile::selection_tile_dimension.y); ++y) { + for (size_t x = 0; x < static_cast<size_t>(Tile::selection_tile_dimension.x); ++x) { + size_t cell_x = mouse_tile_x + x; + size_t cell_y = mouse_tile_y + y; + + for (size_t i = 0; i < object_id; i++) { + if (objects[i].position.x == static_cast<int>(cell_x) && objects[i].position.y == static_cast<int>(cell_y)) { + objects.erase(i); + removed_object = true; + break; + } + } + } + } + std::cout<< "NEW OBJ ID " << object_id << " " << selected_object_id << std::endl; + if (removed_object) return; + + // add objecz to map + objects[object_id].position.x = static_cast<int>(mouse_tile_x); + objects[object_id].position.y = static_cast<int>(mouse_tile_y); + objects[object_id].position.w = Tile::selection_tile_dimension.x, + objects[object_id].position.h = Tile::selection_tile_dimension.y, + objects[object_id].object_type = ObjectType::NONE, + objects[object_id].collectable = false; + //objects[object_id].building_status = TileBuildingStatus::NONE; + Tile_s tileset_info = {Tile::active_tileset_id, + object_id, + Tile::tilesets[Tile::active_tileset_type][Tile::active_tileset_id].category , + {static_cast<int>(objects[object_id].position.x), + static_cast<int>(objects[object_id].position.y)}}; + objects[object_id].tileset_info = tileset_info; + // std::cout << mouse_tile_x << " " << mouse_tile_y << " " << Tile::selection_tile_dimension.x << " " << Tile::selection_tile_dimension.x << std::endl; + } + + void + set_ObjectProps(Input& input) { + static ObjectType set_type = ObjectType::NONE; + static bool set_collectable = 0; + static int set_zindex = 1; + if (input.click_left_released) { + object_props_setting_state = TileObjectPropSettingStates::OBJECT_SETTING_STATE_TYPE; + + size_t id = get_ObjectIdFromTileset({input.mouse_tile_position.x, + input.mouse_tile_position.y}); + if (id == SIZE_MAX) return; + + Tile::object_selected = true; + Tile::selected_object_id = id; + Tile::selected_position = {input.mouse_tile_position.x, input.mouse_tile_position.y}; + + Tile::tile_selected = false; + + TilesetObject object = active_tileset->objects[selected_object_id]; + + if (object.object_type != ObjectType::NONE) { + set_type = object.object_type; + set_collectable = object.collectable; + set_zindex = object.z_index; + } + + std::cout << "Type: " << Object::to_String(set_type) + << ", Collectable: " << set_collectable << ", Z-Index: " << set_zindex + << std::endl; + std::cout << "Setting: "; + } else if (object_selected) { + if (input.pressed_return_released) { + // get to next + object_props_setting_state = static_cast<TileObjectPropSettingStates>(static_cast<int>(object_props_setting_state) + 1); + + std::cout << "Setting: "; + switch ( object_props_setting_state ) { + case TileObjectPropSettingStates::OBJECT_SETTING_STATE_TYPE: + std::cout << "-> Type\n active: " << Object::to_String(set_type) << std::endl; + break; + case TileObjectPropSettingStates::OBJECT_SETTING_STATE_COLLECTING_METHODE: + std::cout << "-> Collecting Methode\n active: " << set_collectable << std::endl; + break; + case TileObjectPropSettingStates::OBJECT_SETTING_STATE_ZINDEX_METHODE: + std::cout << "-> Z-Index\n active: " << set_zindex << std::endl; + break; + case TileObjectPropSettingStates::OBJECT_SETTING_STATE_SAVE: + std::cout << "Save ?\n"; + break; + case TileObjectPropSettingStates::OBJECT_SETTING_STATE_LAST: { + // Save current + TilesetObject& object = active_tileset->objects[selected_object_id]; + object.object_type = set_type; + object.collectable = set_collectable; + object.z_index = set_zindex; + save_Objects(); + + std::cout << "Saving!" + << "\n Type :" << Object::to_String(object.object_type) + << "\n Collectable :" << object.collectable + << "\n Z-Index :" << object.z_index + << std::endl; + object_selected = false; + + break; } + default: + break; + } + } else if (input.pressed_arrowdown_released) { + switch ( object_props_setting_state ) { + case TileObjectPropSettingStates::OBJECT_SETTING_STATE_TYPE: + set_type = static_cast<ObjectType>( + (static_cast<int>(set_type) + 1) % static_cast<int>(ObjectType::LAST) + ); + + std::cout << "Type: " << Object::to_String(set_type) << std::endl; + break; + case TileObjectPropSettingStates::OBJECT_SETTING_STATE_COLLECTING_METHODE: + set_collectable = !set_collectable; + std::cout << "Collectable: " << set_collectable << "\n"; + break; + case TileObjectPropSettingStates::OBJECT_SETTING_STATE_ZINDEX_METHODE: + set_zindex -= 1; + std::cout << "Z-Index " << set_zindex << "\n"; + break; + default: + break; + } + std::cout << "Type: " << Object::to_String(set_type) + << ", Collectable: " << set_collectable + << ", Z-Index: "<< set_zindex + << std::endl; + } else if (input.pressed_arrowup_released) { + switch ( object_props_setting_state ) { + case TileObjectPropSettingStates::OBJECT_SETTING_STATE_TYPE: + { + int type = static_cast<int>(set_type); + int last = static_cast<int>(ObjectType::LAST); + type = (type - 1 + last) % last; + set_type = static_cast<ObjectType>(type); + } + std::cout << "Type: " << Object::to_String(set_type) << std::endl; + break; + case TileObjectPropSettingStates::OBJECT_SETTING_STATE_COLLECTING_METHODE: + set_collectable = !set_collectable; + std::cout << "Collectable: " << set_collectable << "\n"; + break; + case TileObjectPropSettingStates::OBJECT_SETTING_STATE_ZINDEX_METHODE: + set_zindex += 1; + std::cout << "Z-Index " << set_zindex << "\n"; + break; + default: + break; + } + std::cout << "Type: " << Object::to_String(set_type) + << ", Collectable: " << set_collectable + << ", Z-Index: "<< set_zindex + << std::endl; + } + } + }; + + void + set_FloorType(Input& input) { + static TileTypeFloors set_type = TileTypeFloors::NONE; + static size_t set_state = 0; + static int set_zindex = 0; + static TilesetFloorProps* props = nullptr; + if (input.click_left_released) { + size_t id = static_cast<size_t>(input.mouse_tile_position.x + + input.mouse_tile_position.y * active_tileset->size.x); + if (id == SIZE_MAX) return; + + Tile::tile_selected = false; + Tile::object_selected = true; + Tile::selected_object_id = id; + Tile::selected_position = {input.mouse_tile_position.x, input.mouse_tile_position.y}; + set_state = 0; + props = nullptr; + + + props = &tileset_floor_props[active_tileset->category][id]; + + if (props->tiletype != NONE) { + set_type = props->tiletype; + set_zindex = props->z_index; + } + + std::cout << "Type: " << to_String(set_type) << std::endl; + std::cout << "Z-Index: " << set_zindex << std::endl; + + if (set_state == 2) std::cout << "Save?\n"; + } else if (object_selected) { + if ( input.pressed_return_released ) { + set_state++; + if (set_state > 2) { + std::cout << "Saving...\n"; + props->tiletype = set_type; + props->z_index = set_zindex; + save_TilesetFloorProps(); + set_state = 0; + } else + std::cout << "Setting: \n"; + std::cout << "Type: " << to_String(set_type) << std::endl; + std::cout << "Z-Index: " << set_zindex << std::endl; + } else if (set_state == 0) { + if (input.pressed_arrowup_released) { + int type = static_cast<int>(set_type); + int last = static_cast<int>(TileTypeFloors::LAST); + type = (type - 1 + last) % last; + set_type = static_cast<TileTypeFloors>(type); + } else if (input.pressed_arrowdown_released) { + set_type = static_cast<TileTypeFloors>( + (static_cast<int>(set_type) + 1) % static_cast<int>(TileTypeFloors::LAST) + ); + } + if ( input.pressed_arrowdown_released || input.pressed_arrowup_released || input.pressed_return_released) { + std::cout << "Type: " << to_String(set_type) << std::endl; + } + } else if (set_state == 1) { + if (input.pressed_arrowup_released) { + set_zindex++; + } else if (input.pressed_arrowdown_released) { + set_zindex--; + } + if ( input.pressed_arrowdown_released || input.pressed_arrowup_released) { + std::cout << "Z-Index: " << set_zindex << std::endl; + } + } + } + } + + TileTypeFloors + get_FloorType(Tile_s& tile_s) { + SDL_Point& position = tile_s.set_position; + TileSet& tileset = get_TilesetFromMapTile(tile_s); + size_t id = static_cast<size_t>(position.y * tileset.size.x + position.x); + return tileset_floor_props[tile_s.set_category][id].tiletype; + } + TileTypeFloors + get_FloorType(SDL_Point& world_tile) { + if (Map::tile_map[Map::get_IdFromTilePoint(world_tile)].overlays.size() > 0) { + for (Tile_s t : Map::tile_map[Map::get_IdFromTilePoint(world_tile)].overlays) { + if (t.set_position.x == 0 && t.set_position.y == 0) + return TileTypeFloors::SOIL; + } + } + Tile_s& tile_s = Map::tile_map[Map::get_IdFromTilePoint(world_tile)].background; + SDL_Point& position = tile_s.set_position; + TileSet& tileset = get_TilesetFromMapTile(tile_s); + size_t id = static_cast<size_t>(position.y * tileset.size.x + position.x); + return tileset_floor_props[tile_s.set_category][id].tiletype; + } + + void + transfer_ToMap(Input& input) { + // If pressing on tileset + if (hovering_set) { + if (!input.click_left) { + if (active_tileset_type == TILE_BACKGROUND || input.pressed_shift) { + + Tile::selected_tiles.clear(); + for (int y = 0; y < Tile::selection_tile_dimension.y; y++) { + for (int x = 0; x < Tile::selection_tile_dimension.x; x++) { + Tile::selected_tiles.push_back({input.mouse_tile_position.x+x, + input.mouse_tile_position.y+y + }); + } + } + Tile::selected_tile_dimension.x = Tile::selection_tile_dimension.x; + Tile::selected_tile_dimension.y = Tile::selection_tile_dimension.y; + Tile::tile_selected = true; + return; + } + + size_t id = get_ObjectIdFromTileset({input.mouse_tile_position.x, + input.mouse_tile_position.y}); + if (id == SIZE_MAX) return; + Tile::object_selected = true; + Tile::selected_object_id = id; + Tile::selected_position = {input.mouse_tile_position.x, input.mouse_tile_position.y}; + + Tile::tile_selected = false; + print_TileObject(active_tileset->objects[selected_object_id]); + } + } + + // If pressing on map + else if ( input.click_left_released && !input.pressed_c && (Tile::tile_selected || Tile::object_selected) && !Map::setting_offset && + ( input.mouse_tile_position.x >= 0 && input.mouse_tile_position.y >= 0 ) && + ( input.mouse_tile_position.x < Map::size.x ) && + ( input.mouse_tile_position.y < Map::size.y ) + ) { + std::cout << "MOUS: " << input.mouse_tile_position.x << " " << input.mouse_tile_position.y << std::endl; + + // Set selected tile in map + if (Tile::active_tileset_type == TILE_OBJECT) { + TilesetObject object = active_tileset->objects[selected_object_id]; + std::vector<bool> collision_map = get_ObjectCollisionsFromTileset(object.tileset_info.set_id, object.tileset_info.object_id, get_Type(object.tileset_info.set_category)); + + bool has_collission = objec_HasCollission(object); + SDL_Point tile_offset = { + selected_position.x - object.position.x, + selected_position.y - object.position.y + }; + int map_origin_x = input.mouse_tile_position.x - tile_offset.x; + int map_origin_y = input.mouse_tile_position.y - tile_offset.y; + std::cout << "WP " << map_origin_x << " " << map_origin_y << std::endl; + + TileType type = get_Type(object.tileset_info.set_category); + + Resource_s res; + if (object.collectable) { + res = get_ResourceFromTileSet(object.tileset_info.set_id, object.tileset_info.object_id); + } + Object* new_object = !object.collectable ? + new Object(object.object_type, + object.collectable ? + ObjectCategory::RESOURCE : + ObjectCategory::STATIC, + type, + object.tileset_info.set_id, + object.tileset_info.object_id, + {map_origin_x, map_origin_y}, + {object.position.w, object.position.h}, + object.z_index) + : + new Resource(object.object_type, + ObjectCategory::RESOURCE, + type, + object.tileset_info.set_id, + object.tileset_info.object_id, + {map_origin_x, map_origin_y}, + {object.position.w, object.position.h}, + object.z_index, + res.resource, + res.quantity, + res.collecting_methode, + res.collecting_duration + ); + Object::objects.push_back(new_object); + TileObject o ={ {0,0}, false, new_object->id }; + bool tile_exists = false; + bool check_existence = true; + bool draw_is_set = false; + std::cout << "##################################\n"; + + for (int y = 0; y < object.position.h && !tile_exists; y++) { + for (int x = 0; x < object.position.w && !tile_exists; x++) { + //bool shall_set_on_tile = true; + o.draw_from_this_tile = false; + + o.position.x = x; o.position.y = y; + int map_x = map_origin_x + x ; + int map_y = map_origin_y + y ; + if (map_x < 0 || map_y < 0 || + map_x >= static_cast<int>(Map::size.x) || + map_y >= static_cast<int>(Map::size.y)) + continue; + int index = map_y * static_cast<int>(Map::size.x) + map_x; + if (has_collission) { + size_t s = Tile::tile_size / Tile::tile_collider_size; + size_t width_c = static_cast<size_t>(object.position.w) * s; + + bool check = false; + for (size_t yc = static_cast<size_t>(y) * s; yc < static_cast<size_t>(y + 1) * s && !check; yc++) { + for (size_t xc = static_cast<size_t>(x) * s; xc < static_cast<size_t>(x + 1) * s && !check; xc++) { + size_t i = yc * width_c + xc; + if (collision_map[i]) { + check = true; + if (!draw_is_set) { + o.draw_from_this_tile = true; + draw_is_set = true; + } + } + std::cout << (collision_map[i] ? '#' : '.') << ' '; + } + std::cout << '\n'; + } + //shall_set_on_tile = check; + + std::cout << "---- tile (" << x << "," << y << ") ----\n"; + } else { + if (!draw_is_set) + o.draw_from_this_tile = true; + draw_is_set = true; + } + //if (!shall_set_on_tile) continue; + + // make sure we dont get dublicates + if (check_existence) { + for (const TileObject& t : Map::tile_map[static_cast<size_t>(index)].objects) { + Object* map_o = Object::get_ObjectById(t.object_id); + if (t.position.x == x && t.position.y == y && map_o->tileset_object_id == selected_object_id) { + std::cout << "Object already set!\n"; + tile_exists = true; + break; + } + } + check_existence = false; + if (tile_exists) break; + } + + Map::tile_map[static_cast<size_t>(index)].objects.push_back(o); + + std::sort(Map::tile_map[static_cast<size_t>(index)].objects.begin(), + Map::tile_map[static_cast<size_t>(index)].objects.end(), + [](const TileObject& a, const TileObject& b) { + return Object::get_ObjectById(a.object_id)->z_index < Object::get_ObjectById(b.object_id)->z_index; + }); + //print_TileObject(o); + } + } + // SET OBJECT COLLISION ON TILE_MAP + + if (tile_exists) { + delete Object::objects.back(); + return; + } + if (!has_collission) return; + + Map::set_ObjectCollisionOnTilemap(new_object->id, {map_origin_x, map_origin_y}); + + return; + } + else if (Tile::active_tileset_type == TILE_BACKGROUND) { + for (int y = 0; y < Tile::selection_tile_dimension.y; y++) { + for (int x = 0; x < Tile::selection_tile_dimension.x; x++) { + + int map_x = input.mouse_tile_position.x + x; + int map_y = input.mouse_tile_position.y + y; + + if (map_x < Map::size.x && map_y < Map::size.y) { + size_t index = static_cast<size_t>(map_y * Map::size.x + map_x); + // Repeat selection if placing is bigger than original + int wrapped_x = x % Tile::selected_tile_dimension.x; + int wrapped_y = y % Tile::selected_tile_dimension.y; + size_t t_id = static_cast<size_t>(wrapped_y * Tile::selected_tile_dimension.x + wrapped_x); + + Tile_s& background = Map::tile_map[index].background; + TileSet tileset = get_TilesetFromMapTile(background); + /* + tile_setting_history.push_back({ + TILE_BACKGROUND, + index, + {background.set_id, + background.set_category, + {background.set_position.x, + background.set_position.y + } + } + }); + */ + background.set_id = Tile::active_tileset_id; + background.set_position.x = Tile::selected_tiles[t_id].x; + background.set_position.y = Tile::selected_tiles[t_id].y; + background.object_id = static_cast<size_t>(map_y*tileset.size.x + map_x); + background.set_category = Tile::tilesets[TILE_BACKGROUND][background.set_id].category; + } + } + } + } + + } + } + void + set_TilesetOffset(Input& input) { + // START UNUSED FUNCTION + // reset scale + if (!input.click_left && tileset_scale_to_set != 0) { + tileset_scale_to_set = 0; + setting_tileset_scale = false; + } + // Set scale + else if (tileset_scale_to_set != 0) { + tileset_scale = input.mouse_state.y - tileset_scale_to_set; + } + // Update scale + if (input.click_left && input.pressed_shift && + (tileset_scale_to_set == 0)) { + tileset_scale_to_set = input.mouse_state.y - tileset_scale; + setting_tileset_scale = true; + } + // END UNUSED FUNCTION + + + // Reset tileset offset + if (!input.click_left && tileset_offset_to_set.x != 0 && tileset_offset_to_set.y != 0) { + tileset_offset_to_set.x = 0; + tileset_offset_to_set.y = 0; + setting_tileset_offset = false; + } + // Set tileset offset + else if (tileset_offset_to_set.x != 0 && tileset_offset_to_set.y != 0) { + tileset_offset.x = input.mouse_state.x - tileset_offset_to_set.x; + tileset_offset.y = input.mouse_state.y - tileset_offset_to_set.y; + } + + + // Update tileset_offset set + if (input.click_left && input.pressed_ctrl && + (tileset_offset_to_set.x == 0 && tileset_offset_to_set.y == 0)) { + tileset_offset_to_set.x = input.mouse_state.x - tileset_offset.x; + tileset_offset_to_set.y = input.mouse_state.y - tileset_offset.y; + setting_tileset_offset = true; + } + } + + Resource_s + get_ResourceFromTileSet(size_t tileset_id, size_t object_id) { + return tilesets[TILE_OBJECT][tileset_id].resources[object_id]; + } + + TilesetObject + get_ObjectFromTileSet(size_t tileset_id, size_t object_id, TileType type) { + return tilesets[type][tileset_id].objects[object_id]; + } + + std::vector<bool> + get_ObjectCollisionsFromTileset(size_t tileset_id, size_t object_id, TileType type) { + TileSet& ts = tilesets[type][tileset_id]; + auto it = ts.objects.find(object_id); + if (it == ts.objects.end()) { + return {}; + } + + TilesetObject& obj = it->second; + + std::vector<bool> vec; + + int scale = Tile::tile_size / Tile::tile_collider_size; + int collider_w = obj.position.w * scale; + int collider_h = obj.position.h * scale; + int collider_x = obj.position.x * scale; + int collider_y = obj.position.y * scale; + + int row_width = ts.size.x * scale; + + if (collider_x + collider_w > row_width || + collider_y + collider_h > ts.size.y * scale) { + std::cerr << "Object rectangle out of collider bounds!\n"; + return vec; + } + + vec.reserve(static_cast<size_t>(collider_w * collider_h)); + + for (int y = 0; y < collider_h; ++y) { + for (int x = 0; x < collider_w; ++x) { + size_t index = static_cast<size_t>((collider_y + y) * row_width + (collider_x + x)); + vec.push_back(ts.collission_map[index]); + } + } + + return vec; + } + + void + print_CollisionMap(const TilesetObject& obj) { + size_t collider_w = static_cast<size_t>(obj.position.w) * Tile::tile_size / Tile::tile_collider_size; + size_t collider_h = static_cast<size_t>(obj.position.h) * Tile::tile_size / Tile::tile_collider_size; + + std::cout << "Collision Map for object " + << obj.tileset_info.object_id + << " (collider size: " << collider_w << "x" << collider_h << "):\n"; + + std::vector<bool> collision_map = get_ObjectCollisionsFromTileset(obj.tileset_info.set_id, obj.tileset_info.object_id, get_Type(obj.tileset_info.set_category)); + + for (size_t y = 0; y < collider_h; ++y) { + for (size_t x = 0; x < collider_w; ++x) { + size_t index = y * collider_w + x; + if (index >= collision_map.size()) { + std::cout << "? "; // safety: missing data + } else { + std::cout << (collision_map[index] ? "1 " : "0 "); + } + } + std::cout << "\n"; + } + } + + void + print_TileObject(const TilesetObject& obj) { + std::cout << "TilesetObject {\n"; + std::cout << " position: { x: " << obj.position.x + << ", y: " << obj.position.y + << ", w: " << obj.position.w + << ", h: " << obj.position.h << " }\n"; + std::cout << " object_type: " << static_cast<int>(obj.object_type) << "\n"; + std::cout << " collectable: " << std::boolalpha << obj.collectable << "\n"; + std::cout << " z_index: " << obj.z_index << "\n"; + std::cout << " tileset_info: {\n"; + std::cout << " set_id: " << obj.tileset_info.set_id << "\n"; + std::cout << " object_id: " << obj.tileset_info.object_id << "\n"; + std::cout << " set_category: " << static_cast<int>(obj.tileset_info.set_category) << "\n"; + std::cout << " set_position: { x: " << obj.tileset_info.set_position.x + << ", y: " << obj.tileset_info.set_position.y << " }\n"; + std::cout << " }\n"; + std::cout << "}\n"; + print_CollisionMap(obj); + } + + + /* + bool + is_BehindTileObject(TilesetObject object, SDL_FPoint position, SDL_FRect rect) { + const int scale = Tile::tile_size / Tile::tile_collider_size; + + const int obj_w = object.position.w * scale; + const int obj_h = object.position.h * scale; + const int obj_x = position.x / scale; + const int obj_y = position.y / scale; + + const int rect_x = rect.x / Tile::tile_collider_size; + const int rect_y = rect.y / Tile::tile_collider_size; + const int rect_w = + (rect.w + Tile::tile_collider_size - 1) / Tile::tile_collider_size; + + //std::cout << "OB " << obj_x << " " << obj_y << " " << obj_w << " " << obj_h << std::endl; + //std::cout << "RE " << rect_x << " " << rect_y << " " << rect_w << std::endl; + const int row_width = obj_w; + + // horizontal overlap? + if (rect_x + rect_w <= obj_x || rect_x >= obj_x + obj_w) + return true; + + int start_x = std::max(rect_x, obj_x) - obj_x; + int end_x = std::min(rect_x + rect_w, obj_x + obj_w) - obj_x; + + // rect completely above object + if (rect_y < obj_y) + return true; + + int rect_row = rect_y - obj_y; + + // rect completely below object + if (rect_row >= obj_h) + return true; + + // -------------------------------------------------------- + // SCAN COLLIDER ROWS BELOW THE RECT + // -------------------------------------------------------- + //bool collission_above = false; + bool collission_below = false; + bool anywhere_above = false; + bool anywhere_below = false; + for (int y = 0; y < obj_h; ++y) { + int base = y * row_width; + for (int x = 0; x < obj_w; ++x) { + if (object.collission_map[static_cast<size_t>(base + x)]) { + if (y < rect_row) { + //std::cout << "ABOVE "; + anywhere_above = true; + if (x > start_x && x < end_x) { + //collission_above = true; + return false; + } + } else { + //std::cout << "BELOW\n"; + anywhere_below = true; + if (x > start_x && x < end_x) { + //std::cout << "BELOW"; + collission_below = true; + } + } + } + } + } + if (anywhere_below && !collission_below) + return true; + if (collission_below) + return true; + if (!anywhere_above && !collission_below) + return false; + return false; + + } +*/ +} diff --git a/src/map/tile.hpp b/src/map/tile.hpp new file mode 100644 index 0000000..50fa4cf --- /dev/null +++ b/src/map/tile.hpp @@ -0,0 +1,231 @@ +#pragma once + +#include <SDL3/SDL.h> + +#include <vector> +#include <unordered_map> +#include <fstream> +#include <iostream> + +#include "defaults/defaults.hpp" +#include "defaults/input.hpp" +#include "resource/resource_data.hpp" + +// Tile + + +enum class ObjectType; + +struct TileObject { + SDL_Point position; + bool draw_from_this_tile; + size_t object_id; +}; + +enum TileType { + TILE_TYPE_FIRST, + TILE_BACKGROUND, + TILE_OBJECT, + TILE_BUILDING, + TILE_OVERLAY, + TILE_FARM, + TILE_TYPE_LAST +}; + +enum TileCategory { + TILE_GROUND, + TILE_WALL, + TILE_WATER, + TILE_TREE, + TILE_ROCK, + TILE_VEGETATION, + TILE_FURNITURE, + TILE_FLOORS, + TILE_PROPS, + TILE_ROOFS, + TILE_WALLS, + TILE_DUNGEON, + TILE_WALL_VARIATION, + TILE_WORKBENCH, + TILE_FARMING, + TILE_OVERLAY_FARM, +}; + +struct Tile_s { + size_t set_id; + size_t object_id; + + TileCategory set_category; + SDL_Point set_position; +}; + +struct TilesetObject { + SDL_Rect position; + bool draw_from_this_tile; + ObjectType object_type; + + bool collectable; + int z_index; + + Tile_s tileset_info; + size_t object_id; +}; + +enum TileTypeFloors { + NONE, + MEADOW, + CLAY, + SOIL, + BRICKS, + ICE, + DESERT, + WATER, + LAST +}; + +struct FloorProps { + TileTypeFloors type; + bool can_buid_on; + bool can_plant_on; +}; + +struct TilesetFloorProps { + TileTypeFloors tiletype; + int z_index; +}; + +enum class TileObjectPropSettingStates { + OBJECT_SETTING_STATE_FIRST, + OBJECT_SETTING_STATE_TYPE, + OBJECT_SETTING_STATE_COLLECTING_METHODE, + OBJECT_SETTING_STATE_ZINDEX_METHODE, + OBJECT_SETTING_STATE_SAVE, + OBJECT_SETTING_STATE_LAST, +}; + +enum class TileBuildingStatus { + NONE, + CONSTRUCT, + DECONSTRUCT, + BUILD +}; + +struct TileSet { + SDL_Texture* texture; + SDL_Point size; + TileCategory category; + std::vector<bool> collission_map; + std::unordered_map<size_t, TilesetObject> objects; + std::unordered_map<size_t, Resource_s> resources; +}; + +struct TileSettingHistory { + TileType tileset_type; + size_t index; + Tile_s old_tile; +}; + + +struct OLDMapTileObject { + TilesetObject position_and_size; + Tile_s tile_info; +}; + +namespace Tile { + constexpr int tile_size = 16; + constexpr int tile_collider_size = 4; + + extern size_t active_tileset_id; + extern TileType active_tileset_type; + extern TileSet* active_tileset; + + extern bool draw_tile_set; + extern bool tile_selected; // make this an enum so we can select object or tile in one type.. + extern bool object_selected; + extern size_t selected_object; + extern size_t selected_object_id; + extern SDL_Point selected_position; + + extern TileObjectPropSettingStates object_props_setting_state; + + extern std::unordered_map<TileType, std::vector<TileSet>> tilesets; + + extern std::vector<FloorProps> floor_props; + extern std::unordered_map<TileCategory, std::unordered_map<size_t,TilesetFloorProps>> tileset_floor_props; + + extern SDL_FPoint tileset_offset; + extern SDL_FPoint tileset_offset_to_set; + extern bool setting_tileset_offset; + + extern float tileset_scale; + extern float tileset_scale_to_set; + extern bool setting_tileset_scale; + + extern std::vector<SDL_Point> selected_tiles; + + extern SDL_Point selection_tile_dimension; + extern SDL_Point selected_tile_dimension; + + extern std::string save_tileset_collission_path; + extern std::string save_tileset_objects_path; + extern std::string save_tileset_resources_path; + extern std::string save_tileset_floortype_path; + + extern std::vector<TileSettingHistory> tile_setting_history; + + extern bool hovering_set; + + + bool Init(SDL_Renderer* renderer); + + + TileType get_Type(TileCategory category); + size_t get_Size(); + size_t get_SelectionSize(ModifyState_s modify_state); + size_t get_ObjectIdFromTileset(SDL_Point selected_tile, TileSet tileset = *active_tileset); + + void set_HoveringTileset(SDL_FPoint mouse_state); + + TileSet& get_TilesetFromMapTile(Tile_s tile); + + void save_Objects(); + void load_Objects(); + + void save_Collissions(); + void load_Collissions(); + + void load_TilesetFloorProps(); + void save_TilesetFloorProps(); + + void set_TilesetOffset(Input& input); + + void draw_SelectedObject(SDL_Renderer* renderer, Input input); + void draw_Tileset(SDL_Renderer* renderer, Input input); + + void clear_Objects(Input& input); + + void set_Object(Input& input); + void set_ObjectProps(Input& input); + + void set_Collission(Input& input); + + const char* to_String(TileTypeFloors type); + void set_FloorType(Input& input); + TileTypeFloors + get_FloorType(Tile_s&); + TileTypeFloors + get_FloorType(SDL_Point& world_tile); + + bool objec_HasCollission(TilesetObject& object); + std::vector<bool> get_CollissionsOfTileFromObject(TilesetObject& obj, SDL_Point tile); + + void transfer_ToMap(Input& input); + + Resource_s get_ResourceFromTileSet(size_t tileset_id, size_t object_id); + TilesetObject get_ObjectFromTileSet(size_t tileset_id, size_t object_id, TileType type = TILE_OBJECT); + std::vector<bool> get_ObjectCollisionsFromTileset(size_t tileset_id, size_t object_id, TileType type = TILE_OBJECT); + + void print_CollisionMap(const TilesetObject& obj); + void print_TileObject(const TilesetObject& obj); + +} diff --git a/src/objects/object.cpp b/src/objects/object.cpp new file mode 100644 index 0000000..adce898 --- /dev/null +++ b/src/objects/object.cpp @@ -0,0 +1,332 @@ +#include "object.hpp" + +#include <iostream> +#include <algorithm> + +#include "map/tile.hpp" +#include "map/map.hpp" + + + +std::vector<Object*> Object::objects; + + +Object::~Object() { + for (int y = 0; y < dimension.y; y++) { + for (int x = 0; x < dimension.x; x++) { + size_t m_id = static_cast<size_t>((y+world_tile_position.y)*Map::size.x+(x+world_tile_position.x)); + if (m_id >= static_cast<size_t>(Map::size.x*Map::size.y)) + continue; + std::vector<TileObject>& t_objects = Map::tile_map[m_id].objects; + + for (auto it = t_objects.begin(); it != t_objects.end(); ) { + if (it->object_id == id) + it = t_objects.erase(it); + else ++it; + } + } + } +}; + +const char* Object::to_String(ObjectType type) { + switch (type) { + case ObjectType::NONE: return "NONE"; + case ObjectType::ROCK: return "ROCK"; + case ObjectType::TREE: return "TREE"; + case ObjectType::STICK: return "STICK"; + case ObjectType::BUSH: return "BUSH"; + case ObjectType::FLOWER: return "FLOWER"; + case ObjectType::FOOD: return "FOOD"; + case ObjectType::FURNITURE: return "FURNITURE"; + case ObjectType::ROOF: return "ROOF"; + case ObjectType::FLOOR: return "FLOOR"; + case ObjectType::FURNISHING: return "FURNISHING"; + case ObjectType::WORKBENCH: return "WORKBENCH"; + default: return "UNKNOWN"; + } +} + +std::vector<Object*> +Object::get_ObjectsByWorldPosition(SDL_Point position) { + std::vector<Object*> objects; + for (Object* object : Object::objects) { + if (object->world_tile_position.x == position.x && object->world_tile_position.y == position.y) { + objects.push_back(object); + } + } + return objects; +} + +Object* +Object::get_ObjectByWorldPositionAndTilesetObjectID(SDL_Point position, size_t ts_object_id) { + std::vector<Object*> os = Object::get_ObjectsByWorldPosition(position); + for (Object* o : os) { + if (o->tileset_object_id == ts_object_id) + return o; + } + return nullptr; +} + +Object* +Object::get_ObjectById(size_t id) { + //std::cout << "GETTT " << id << std::endl; + for (Object* object : Object::objects) + if (object->id == id) return object; + return nullptr; +} + +SDL_Point +Object::get_SetPosition() { + return Tile::tilesets[tileset_type][tileset_id].objects[tileset_object_id].tileset_info.set_position; +} + +int +Object::is_InFrontOf(SDL_FPoint world_position, SDL_FRect rect) { + const int scale = Tile::tile_size / Tile::tile_collider_size; + + const int obj_w = dimension.x * scale; + const int obj_h = dimension.y * scale; + const int obj_x = world_position.x / scale; + const int obj_y = world_position.y / scale; + + const int rect_x = rect.x / Tile::tile_collider_size; + const int rect_y = rect.y / Tile::tile_collider_size; + const int rect_w = (rect.w + Tile::tile_collider_size - 1) / Tile::tile_collider_size; + const int rect_h = (rect.h + Tile::tile_collider_size - 1) / Tile::tile_collider_size; + + /* + std::cout << "WP: " << world_position.x << " " << world_position.y << std::endl; + std::cout << "OB " << obj_x << " " << obj_y << " " << obj_w << " " << obj_h << std::endl; + std::cout << "RE " << rect_x << " " << rect_y << " " << rect_w << std::endl; + */ + const int row_width = obj_w; + + // object is left or right of rect + if (rect_x + rect_w <= obj_x || rect_x >= obj_x + obj_w) + return false; + + int start_x = std::max(rect_x, obj_x) - obj_x; + int end_x = std::min(rect_x + rect_w, obj_x + obj_w) - obj_x; + + // is above object + if (rect_y+rect_h < obj_y) + return 2; + + // is below object + if (obj_y + obj_h <= rect_y) + return false; + + // + int rect_row = rect_y - obj_y; + if (rect_row >= obj_h) + return 2; + + bool collission_below = false; + bool anywhere_above = false; + bool anywhere_below = false; + std::vector<bool> collission_map = get_CollisionMap(); + bool has_collision = false; + for (int y = 0; y < obj_h; ++y) { + int base = y * row_width; + for (int x = 0; x < obj_w; ++x) { + if (collission_map[static_cast<size_t>(base + x)]) { + has_collision = true; + if (y < rect_row) { + //std::cout << "ABOVE \n"; + anywhere_above = true; + if (x > start_x && x < end_x) { + //std::cout << "SUPABOVE \n"; + //collission_above = true; + return false; + } + } else { + //std::cout << "BELOW\n"; + anywhere_below = true; + if (x > start_x && x < end_x) { + //std::cout << "SUPBELOW\n"; + collission_below = true; + } + } + } + } + } + if ( !has_collision ) { + //std::cout << "NO COLL\n"; + SDL_FRect temp_rect = { world_position.x, world_position.y, static_cast<float>(dimension.x*Tile::tile_size), static_cast<float>(dimension.y*Tile::tile_size) }; + //std::cout << "COLL " << SDL_HasRectIntersectionFloat(&temp_rect, &rect) << " " << world_position.x << " " << world_position.y << " " << rect.x << " " << rect.y <<std::endl; + //std::cout << "WIDH " << dimension.x *Tile::tile_size<< " " << dimension.y *Tile::tile_size<< " RE " << rect.w << " " << rect.h << std::endl; + if (z_index <= 0 ) return false; + return !SDL_HasRectIntersectionFloat(&temp_rect, &rect); + } + + //std::cout << "COL " << collission_below << " " << anywhere_below << " " << anywhere_above << std::endl; + if ((collission_below || anywhere_below) && !anywhere_above) + return true; + if (!anywhere_above && !collission_below) + return false; + return false; +} + +std::vector<bool> Object::get_CollisionMap() { + std::vector<bool> map = + Tile::get_ObjectCollisionsFromTileset( + tileset_id, + tileset_object_id, + tileset_type); + + if (!map.empty()) + return map; + + const size_t n = Tile::tile_collider_size * Tile::tile_collider_size; + return std::vector<bool>(n, false); +} + +bool +Object::has_Collision() { + for (bool collission : get_CollisionMap()) { + if (collission) return true; + } + return false; +} + +std::vector<bool> +Object::get_CollissionsOfTile(SDL_Point tile) { + std::vector<bool> collision_map = get_CollisionMap(); + const size_t scale = Tile::tile_size / Tile::tile_collider_size; + + int y_start = tile.y * static_cast<int>(Tile::tile_size/Tile::tile_collider_size); + int y_end = y_start + static_cast<int>(Tile::tile_size/Tile::tile_collider_size); + int x_start = tile.x * static_cast<int>(Tile::tile_size/Tile::tile_collider_size); + int x_end = x_start + static_cast<int>(Tile::tile_size/Tile::tile_collider_size); + int obj_w = static_cast<size_t>(dimension.x) * scale; + + std::vector<bool> collisions; + for (int y = y_start; y < y_end; y++) { + for (int x = x_start; x < x_end; x++) { + size_t index = static_cast<size_t>(y * obj_w + x); + collisions.push_back(collision_map[index]); + } + } + return collisions; +} + +void +Object::print_CollisionMap() { + size_t collider_w = static_cast<size_t>(dimension.x) * Tile::tile_size / Tile::tile_collider_size; + size_t collider_h = static_cast<size_t>(dimension.y) * Tile::tile_size / Tile::tile_collider_size; + + std::cout << "Collision Map for object " + << tileset_object_id + << " (collider size: " << collider_w << "x" << collider_h << "):\n"; + + std::vector<bool> collision_map = get_CollisionMap(); + + for (size_t y = 0; y < collider_h; ++y) { + for (size_t x = 0; x < collider_w; ++x) { + size_t index = y * collider_w + x; + if (index >= collision_map.size()) { + std::cout << "? "; + } else { + std::cout << (collision_map[index] ? "1 " : "0 "); + } + } + std::cout << "\n"; + } +} + +void +Object::Draw(SDL_Renderer* renderer, SDL_FPoint position, bool is_transparent, int transparency) { + SDL_Point obj_set_pos = get_SetPosition(); + SDL_FRect obj_src { + static_cast<float>(obj_set_pos.x) * static_cast<float>(Tile::tile_size), + static_cast<float>(obj_set_pos.y) * static_cast<float>(Tile::tile_size), + static_cast<float>(dimension.x * static_cast<int>(Tile::tile_size)), + static_cast<float>(dimension.y * static_cast<int>(Tile::tile_size)) + }; + + int size = Tile::get_Size(); + SDL_FRect dst; + if (object_type == ObjectType::VEGETABLE) { + dst = { Scale(position.x + Map::offset.x), + Scale(position.y + Map::offset.y-7), + Scale(dimension.x * size), + Scale(dimension.y * size) }; + } else { + dst = { Scale(position.x + Map::offset.x), + Scale(position.y + Map::offset.y), + Scale(dimension.x * size), + Scale(dimension.y * size) }; + } + + + SDL_Texture* tex = Tile::tilesets[tileset_type][tileset_id].texture; + + if (is_transparent) + SDL_SetTextureAlphaMod(tex, transparency); + + SDL_RenderTexture(renderer, tex, &obj_src, &dst); + + if (is_transparent) + SDL_SetTextureAlphaMod(tex, 255); + +#ifdef DEBUG_BUILD + std::vector<bool> collision_map = get_CollisionMap(); + size_t scale = Tile::tile_size / Tile::tile_collider_size; + size_t collider_w = static_cast<size_t>(dimension.x) * scale; + size_t collider_h = static_cast<size_t>(dimension.y) * scale; + for (size_t y = 0; y < collider_h; ++y) { + for (size_t x = 0; x < collider_w; ++x) { + size_t index = y * collider_w + x; + if (index >= collision_map.size()) continue; + + if (collision_map[index]) { + SDL_FRect col_rect = { + Scale(static_cast<float>(position.x + (x * Tile::tile_collider_size)) + Map::offset.x), + Scale(static_cast<float>(position.y + (y * Tile::tile_collider_size)) + Map::offset.y), + Scale(static_cast<float>(Tile::tile_collider_size)), + Scale(static_cast<float>(Tile::tile_collider_size)) + }; + + SDL_SetRenderDrawColor(renderer, 255, 0, 0, 120); + SDL_RenderFillRect(renderer, &col_rect); + } + } + } +#endif +} + +void +Object::Remove(Object* obj) { + if (!obj) return; + + int start_x = obj->world_tile_position.x; + int start_y = obj->world_tile_position.y; + + int end_x = start_x + obj->dimension.x; + int end_y = start_y + obj->dimension.y; + + for (int y = start_y; y < end_y; ++y) { + for (int x = start_x; x < end_x; ++x) { + size_t index = static_cast<size_t>(y * Map::size.x + x); + if (index >= Map::tile_map.size()) continue; + + auto& tile_objects = Map::tile_map[index].objects; + + tile_objects.erase( + std::remove_if(tile_objects.begin(), tile_objects.end(), + [obj](const TileObject& to) { return to.object_id == obj->id; }), + tile_objects.end()); + Map::set_TileCollissionForObjects({x, y}); + } + } + + Object::objects.erase( + std::remove(Object::objects.begin(), + Object::objects.end(), + obj), + Object::objects.end() + ); + + + delete obj; +} diff --git a/src/objects/object.hpp b/src/objects/object.hpp new file mode 100644 index 0000000..d2be430 --- /dev/null +++ b/src/objects/object.hpp @@ -0,0 +1,133 @@ +#pragma once + +#include <initializer_list> +#include <vector> + +#include "defaults/defaults.hpp" +#include "map/tile.hpp" + + +class Inventory; +class Messages; +enum class ItemType : uint32_t ; + + +enum class ObjectCategory { + STATIC, + BUILDING, + RESOURCE, + FARM_CROP, + NONE +}; + +enum class ObjectType { + NONE, + ROCK, + TREE, + STICK, + BUSH, + FLOWER, + FOOD, + FURNITURE, + ROOF, + WALL, + FLOOR, + FURNISHING, + WORKBENCH, + VEGETABLE, + LAST +}; + + +class IsCollectable { +public: + virtual ~IsCollectable() = default; + virtual bool is_Collectable() const = 0; + virtual void Collect(Inventory*, Messages*) = 0; +}; + + +class Object { + public: + static std::vector<Object*> objects; + + size_t id; + + ObjectType object_type; + ObjectCategory category; + + TileType tileset_type; + size_t tileset_id; + size_t tileset_object_id; + + SDL_Point world_tile_position; + SDL_Point dimension; + int z_index; + + + Object( ObjectType ot, + ObjectCategory oc, + TileType tt, + size_t ts_id, + size_t tso_id, + SDL_Point wtp, + SDL_Point d, + int zi) : + object_type(ot), + category(oc), + tileset_type(tt), + tileset_id(ts_id), + tileset_object_id(tso_id), + world_tile_position(wtp), + dimension(d), + z_index(zi) { + static size_t id_next = 1; + id = id_next++; + } + + virtual + ~Object(); + + virtual SDL_Point + get_SetPosition(); + + int + is_InFrontOf(SDL_FPoint ob_position, SDL_FRect rect); + + bool + has_Collision(); + + std::vector<bool> + get_CollisionMap(); + + std::vector<bool> + get_CollissionsOfTile(SDL_Point tile); + + void + print_CollisionMap(); + + virtual void + Draw(SDL_Renderer* renderer, SDL_FPoint position, bool is_transparent = false, int transparency = 200); + + static void + Remove(Object* object); + + static const char* + to_String(ObjectType type); + + static Object* + get_ObjectById(size_t id); + + static std::vector<Object*> + get_ObjectsByWorldPosition(SDL_Point position); + + static Object* + get_ObjectByWorldPositionAndTilesetObjectID(SDL_Point position, size_t ts_object_id); +}; + +class Static : public Object { + public: + Static(ObjectType ot, ObjectCategory oc, TileType tt, size_t ts_id, size_t tso_id, + SDL_Point wtp, SDL_Point d, int zi) + : Object(ot, oc, tt, ts_id, tso_id, wtp, d, zi) {} +}; diff --git a/src/resource/resource.cpp b/src/resource/resource.cpp new file mode 100644 index 0000000..9f6745b --- /dev/null +++ b/src/resource/resource.cpp @@ -0,0 +1,12 @@ +#include "resource/resource.hpp" + +#include "inventory/item.hpp" + +bool Resource::is_Collectable(ItemType item = ItemType::HAND) { + if ( collecting_methode == CollectingMethode::HAND) + return true; + if (collecting_methode == CollectingMethode::PICKAXE_STONE && item == ItemType::PICKAXE_STONE) + return true; + return false; +} + diff --git a/src/resource/resource.hpp b/src/resource/resource.hpp new file mode 100644 index 0000000..8f1f47c --- /dev/null +++ b/src/resource/resource.hpp @@ -0,0 +1,36 @@ +#pragma once + +#include "objects/object.hpp" +#include "resource/resource_data.hpp" + +enum class ItemType : uint32_t ; + +class Resource : public Object { +public: + Resource(// OBJECT STUFF + ObjectType ot, + ObjectCategory oc, + TileType tt, + size_t ts_id, + size_t tso_id, + SDL_Point wtp, + SDL_Point d, + int zi, + // RESOURCES + ResourceType rt, + unsigned qty, + CollectingMethode m, + float duration) + : Object(ot, oc, tt, ts_id, tso_id, wtp, d, zi), + resource(rt), + quantity(qty), + collecting_methode(m), + collecting_duration(duration) + {} + + ResourceType resource; + unsigned quantity; + CollectingMethode collecting_methode; + float collecting_duration; + bool is_Collectable(ItemType item); +}; diff --git a/src/resource/resource_data.cpp b/src/resource/resource_data.cpp new file mode 100644 index 0000000..15a5224 --- /dev/null +++ b/src/resource/resource_data.cpp @@ -0,0 +1,276 @@ +#include "resource/resource_data.hpp" + +#include <iostream> + +#include "map/tile.hpp" + +namespace ResourceData { + std::string save_tileset_resources_path = "saves/save.tileset_recources"; + + + const std::deque<std::string> names = { + "Nichts", + "Wood", + "Stone", + "Clay", + "Iron", + "Bone", + "Something went horribly wrong" + }; + + void + save_Resources() { + std::ofstream file(save_tileset_resources_path, std::ios::binary); + if (!file) return; + + // number of TileType entries + uint32_t types_count = Tile::tilesets.size(); + file.write(reinterpret_cast<const char*>(&types_count), sizeof(types_count)); + + for (const auto& [type, vec] : Tile::tilesets) { + uint32_t t = static_cast<uint32_t>(type); + file.write(reinterpret_cast<const char*>(&t), sizeof(t)); + + uint32_t set_count = vec.size(); + file.write(reinterpret_cast<const char*>(&set_count), sizeof(set_count)); + + for (const auto& tileset : vec) { + uint64_t res_count = tileset.resources.size(); + file.write(reinterpret_cast<const char*>(&res_count), sizeof(res_count)); + + for (const auto& [key, res] : tileset.resources) { + file.write(reinterpret_cast<const char*>(&key), sizeof(key)); + + file.write(reinterpret_cast<const char*>(&res.tileset_id), sizeof(res.tileset_id)); + file.write(reinterpret_cast<const char*>(&res.object_id), sizeof(res.object_id)); + + int resource_type = static_cast<int>(res.resource); + file.write(reinterpret_cast<const char*>(&resource_type), sizeof(resource_type)); + + int methode = static_cast<int>(res.collecting_methode); + file.write(reinterpret_cast<const char*>(&methode), sizeof(methode)); + + file.write(reinterpret_cast<const char*>(&res.collecting_duration), sizeof(res.collecting_duration)); + file.write(reinterpret_cast<const char*>(&res.quantity), sizeof(res.quantity)); + } + } + } + } + + void + load_Resources() { + std::ifstream file(save_tileset_resources_path, std::ios::binary); + if (!file) return; + + uint32_t types_count = 0; + file.read(reinterpret_cast<char*>(&types_count), sizeof(types_count)); + + for (uint32_t i = 0; i < types_count; ++i) { + uint32_t t = 0; + file.read(reinterpret_cast<char*>(&t), sizeof(t)); + TileType type = static_cast<TileType>(t); + + uint32_t set_count = 0; + file.read(reinterpret_cast<char*>(&set_count), sizeof(set_count)); + + auto& vec = Tile::tilesets[type]; + for (uint32_t j = 0; j < set_count && j < vec.size(); ++j) { + uint64_t res_count = 0; + file.read(reinterpret_cast<char*>(&res_count), sizeof(res_count)); + + vec[j].resources.clear(); + for (uint64_t k = 0; k < res_count; ++k) { + size_t key = 0; + file.read(reinterpret_cast<char*>(&key), sizeof(key)); + + Resource_s res{}; + file.read(reinterpret_cast<char*>(&res.tileset_id), sizeof(res.tileset_id)); + file.read(reinterpret_cast<char*>(&res.object_id), sizeof(res.object_id)); + + int resource_type = 0; + file.read(reinterpret_cast<char*>(&resource_type), sizeof(resource_type)); + res.resource = static_cast<ResourceType>(resource_type); + + int methode = 0; + file.read(reinterpret_cast<char*>(&methode), sizeof(methode)); + res.collecting_methode = static_cast<CollectingMethode>(methode); + + file.read(reinterpret_cast<char*>(&res.collecting_duration), sizeof(res.collecting_duration)); + file.read(reinterpret_cast<char*>(&res.quantity), sizeof(res.quantity)); + + vec[j].resources.emplace(key, res); + } + } + } + } + + + void + set_ObjectPropsResource(Input& input) { + static ResourceType last_resource_choice = ResourceType::NONE; + static CollectingMethode last_collecting_choice = CollectingMethode::NONE; + static float last_collecting_duration_choice = 1.0; + static unsigned last_quantity_choice = 1; + static Resource_s* resource_p = nullptr; + static bool resource_is_new = true; + static Resource_s change_resource; + static size_t id; + static int function_iteration = 0; + // init setting up + if (input.click_left_released) { + function_iteration = 0; + Tile::object_props_setting_state = TileObjectPropSettingStates::OBJECT_SETTING_STATE_TYPE; + + id = Tile::get_ObjectIdFromTileset({input.mouse_tile_position.x, + input.mouse_tile_position.y}); + if (id == SIZE_MAX) return; + + TilesetObject object = Tile::active_tileset->objects[id]; + if (Default::modify_state == MODIFY_OBJECTS_PROPS_RESOURCE && !object.collectable) + return; + + Tile::object_selected = true; + Tile::selected_object_id = id; + Tile::selected_position = {input.mouse_tile_position.x, input.mouse_tile_position.y}; + + Tile::tile_selected = false; + + // --- Retrieve or create resource --- + + // init variables for setting + auto it = Tile::active_tileset->resources.find(id); + if (it != Tile::active_tileset->resources.end()) { + resource_p = &it->second; + last_resource_choice = resource_p->resource; + last_collecting_choice = resource_p->collecting_methode; + last_collecting_duration_choice = resource_p->collecting_duration; + last_quantity_choice = resource_p->quantity; + change_resource = *resource_p; + resource_is_new = false; + std::cout << "SETTING PROPS RESOURCE FOR: existing object\n"; + // std::cout << id << " : " << ResourceData::to_String(resource_p->resource) << std::endl; + + } else { + change_resource = {Tile::active_tileset_id, + id, + last_resource_choice, + last_collecting_choice, + last_collecting_duration_choice, + last_quantity_choice }; + resource_is_new = true; + std::cout << "SETTING PROPS RESOURCE FOR: new object\n---\n"; + } + std::cout << "Resource Type " << ResourceData::to_String(last_resource_choice) << std::endl; + std::cout << "Collecting Methode " << ResourceData::to_String(last_collecting_choice) << std::endl; + std::cout << "Collecting Duration " << last_collecting_duration_choice << "s ?\n"; + std::cout << "Quantity " << last_quantity_choice << "\n"; + std::cout << "---" << "\n"; + + } + // key handling + if (input.pressed_return_released) { + function_iteration++; + std::cout << "---" << std::endl; + std::cout << "Iteration: " << function_iteration << std::endl; + std::cout << "Resource Type " << ResourceData::to_String(last_resource_choice) << std::endl; + std::cout << "Collecting Methode " << ResourceData::to_String(last_collecting_choice) << std::endl; + std::cout << "Collecting Duration " << last_collecting_duration_choice << "s ?\n"; + std::cout << "Quantity " << last_quantity_choice << "\n"; + std::cout << "---" << "\n"; + if (function_iteration == 5) { + change_resource.resource = last_resource_choice; + change_resource.collecting_methode = last_collecting_choice; + change_resource.collecting_duration = last_collecting_duration_choice; + change_resource.quantity = last_quantity_choice; + + if (!resource_is_new) { + std::cout << "Save Existing\n"; + *resource_p = change_resource; + } else { + Tile::active_tileset->resources.emplace(id, change_resource); + std::cout << "Save New\n"; + } + ResourceData::save_Resources(); + function_iteration = 0; + return; + } + } + if ( input.pressed_arrowdown_released || input.pressed_arrowup_released || input.pressed_return_released) { + switch ( function_iteration ) { + case 0: { + if (input.pressed_arrowup_released) { + int type = static_cast<int>(last_resource_choice); + int last = static_cast<int>(ResourceType::LAST); + type = (type - 1 + last) % last; + last_resource_choice = static_cast<ResourceType>(type); + } else if (input.pressed_arrowdown_released) { + last_resource_choice = static_cast<ResourceType>( + (static_cast<int>(last_resource_choice) + 1) % static_cast<int>(ResourceType::LAST) + ); + } + std::cout << "Resource Type " << ResourceData::to_String(last_resource_choice) << std::endl; + break; + } + case 1: + if (input.pressed_arrowup_released) { + int type = static_cast<int>(last_collecting_choice); + int last = static_cast<int>(CollectingMethode::LAST); + type = (type - 1 + last) % last; + last_collecting_choice = static_cast<CollectingMethode>(type); + } else if (input.pressed_arrowdown_released) { + last_collecting_choice = static_cast<CollectingMethode>( + (static_cast<int>(last_collecting_choice) + 1) % static_cast<int>(CollectingMethode::LAST) + ); + } + std::cout << "Collecting Methode " << ResourceData::to_String(last_collecting_choice) << std::endl; + break; + case 2: + if (input.pressed_arrowup_released) { + last_collecting_duration_choice -= 0.2; + } else if (input.pressed_arrowdown_released) { + last_collecting_duration_choice += 0.2; + } + if (last_collecting_duration_choice < 0) + last_collecting_duration_choice = 0.0; + std::cout << "Collecting Duration " << last_collecting_duration_choice << "s ?\n"; + break; + case 3: + if (input.pressed_arrowup_released) { + last_quantity_choice -= 1; + } else if (input.pressed_arrowdown_released) { + last_quantity_choice += 1; + } + if (last_quantity_choice < 1) + last_quantity_choice = 1; + std::cout << "Quantity " << last_quantity_choice << "\n"; + break; + default: + break; + } + } + + } + + + const char* to_String(CollectingMethode methode) { + switch (methode) { + case CollectingMethode::NONE: return "NONE"; + case CollectingMethode::HAND: return "HAND"; + case CollectingMethode::AXE_STONE: return "AXE STONE"; + case CollectingMethode::SWORD_WOOD: return "SWORD WOOD"; + case CollectingMethode::KNIFE: return "KNIFE"; + case CollectingMethode::FISHINGROT: return "FISHINGROT"; + case CollectingMethode::PICKAXE_STONE: return "PICKAXE STONE"; + default: return "UNKNOWN"; + } + } + + const char* to_String(ResourceType resource) { + size_t idx = static_cast<size_t>(resource); + if (idx >= ResourceData::names.size()) { + std::cerr << "ResourceType out of range: " << static_cast<int>(resource) << std::endl; + return "No valid ResourceType!"; + } + return ResourceData::names[idx].c_str(); + } +} diff --git a/src/resource/resource_data.hpp b/src/resource/resource_data.hpp new file mode 100644 index 0000000..d101b68 --- /dev/null +++ b/src/resource/resource_data.hpp @@ -0,0 +1,57 @@ +#pragma once + +#include <deque> + +#include "defaults/defaults.hpp" +#include "defaults/input.hpp" + +enum class ResourceType { + NONE, + WOOD, + STONE, + CLAY, + IRON, + BONE, + LAST +}; + +enum class CollectingMethode { + NONE, + HAND, + AXE_STONE, + SWORD_WOOD, + KNIFE, + FISHINGROT, + PICKAXE_STONE, + LAST +}; + + +struct Resource_s { + size_t tileset_id; + size_t object_id; + + ResourceType resource; + + CollectingMethode collecting_methode; + float collecting_duration; + unsigned quantity; +}; + + + +namespace ResourceData { + extern const std::deque<std::string> names; + + void save_Resources(); + void load_Resources(); + + void set_ObjectPropsResource(Input& input); + + + const char* + to_String(CollectingMethode methode); + + const char* + to_String(ResourceType resource); +} diff --git a/src/start_screen/start_screen.cpp b/src/start_screen/start_screen.cpp new file mode 100644 index 0000000..76bfb14 --- /dev/null +++ b/src/start_screen/start_screen.cpp @@ -0,0 +1,331 @@ +#include "start_screen.hpp" +#include "audio/audio.hpp" + +StartScreen::StartScreen(SDL_Renderer* r) : renderer(r) { Init(); } +StartScreen::~StartScreen() { + if (char_texture) SDL_DestroyTexture(char_texture); + if (logo_surface) SDL_DestroySurface(logo_surface); + if (props_texture) SDL_DestroyTexture(props_texture); + if (props_surface) SDL_DestroySurface(props_surface); + } + + +void StartScreen::StartShowProps() { + if (!props_surface) return; + + phase = Phase::SHOW_PROPS; + phase_start = SDL_GetTicks(); + + // Extract visible pixels + const SDL_PixelFormatDetails* details = SDL_GetPixelFormatDetails(props_surface->format); + Uint32* pixels = static_cast<Uint32*>(props_surface->pixels); + int pitch = props_surface->pitch / (int)sizeof(Uint32); + int w = props_surface->w, h = props_surface->h; + + particles.clear(); + for (int y = 0; y < h; ++y) { + for (int x = 0; x < w; ++x) { + Uint32 p = pixels[y * pitch + x]; + Uint8 r,g,b,a; + SDL_GetRGBA(p, details, NULL, &r, &g, &b, &a); + if (a > 180) { // or check color if you want black only + particles.push_back({ {static_cast<float>(x), static_cast<float>(y)}, + {screen_w/2.0f, screen_h/2.0f}, // start from center + {screen_w/2.0f, screen_h/2.0f} }); + } + } + } +} + +void StartScreen::Update() { + Uint64 now = SDL_GetTicks(); + float dt = static_cast<float>(now - last_time) / 1000.0f; + last_time = now; + + switch (phase) { + case Phase::DOT: + if (now - phase_start > 500) StartSpreadToLine(); + break; + + case Phase::SPREAD_TO_LINE: { + float p = (now - phase_start) / 280.0f; + if (p >= 1.0f) { p = 1.0f; phase = Phase::LINE_WAIT; phase_start = now; } + for (auto& pt : particles) { + SDL_FPoint from = { center_dot.x, center_dot.y }; + pt.current.x = Lerp(from.x, pt.target.x, p); + pt.current.y = Lerp(from.y, pt.target.y, p); + } + break; + } + + case Phase::LINE_WAIT: + if (now - phase_start > 300) { + phase = Phase::RUNNING; + run_start_time = now; + char_x = -300.0f; + + // Re-apply dynamic speed (in case resized just before running) + char_speed = (static_cast<float>(screen_w) + extra_distance) / desired_cross_time; + } + break; + + case Phase::RUNNING: { + char_x += char_speed * dt; + Uint64 frame_ticks = now - run_start_time; + char_frame = static_cast<int>((frame_ticks / 80ULL) % 6ULL); + + // End when character is fully off-screen right + if (char_x > static_cast<float>(screen_w) + 1420.0f) { + StartFadeToLogo(); + } + break; + } + + case Phase::FADE_TO_LOGO: { + float p = (now - phase_start) / 420.0f; + if (p >= 1.0f) { p = 1.0f; phase = Phase::SHOW_LOGO; phase_start = now; } + for (auto& pt : particles) { + SDL_FPoint logo_screen = GetScreenOriginal(pt); + pt.current.x = Lerp(pt.target.x, logo_screen.x, p); + pt.current.y = Lerp(pt.target.y, logo_screen.y, p); + } + break; + } + case Phase::SHOW_LOGO: { + if (now - phase_start > static_cast<Uint64>(logo_display_time * 1000.0f)) { + StartShowProps(); + // Time's up → quit the application + //running = false; // will break main loop + // or: SDL_Quit(); return; // but better to let main clean up + } + break; + } + + case Phase::SHOW_PROPS: { + float p = (now - phase_start) / 1000.0f; // 1 second animation + if (p >= 1.0f) p = 1.0f; + props_anim_progress = p; + + for (auto& pt : particles) { + pt.current.x = Lerp(pt.current.x, pt.original.x + (screen_w - props_surface->w)/2.0f, p); + pt.current.y = Lerp(pt.current.y, pt.original.y + (screen_h - props_surface->h)/2.0f, p); + } + + // optionally, end scene after animation finishes + if (p >= 1.0f && now - phase_start > 3500) { // 1.5s after animation ends + running = false; + } + break; + } + } +} + +void StartScreen::Render() { + SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); + SDL_RenderClear(renderer); + + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); + for (const auto& p : particles) { + SDL_FRect r { p.current.x, p.current.y, 1.0f, 1.0f }; + SDL_RenderFillRect(renderer, &r); + } + + if (phase == Phase::RUNNING) { + float scale = 4.0f; // double size as requested + float sw = char_frame_width * scale; + float sh = char_height * scale; + float dy = static_cast<float>(bottom_y) - sh + 46.0f; // feet on line + + SDL_FRect src { static_cast<float>(char_frame * char_frame_width), 0.0f, + static_cast<float>(char_frame_width), static_cast<float>(char_height) }; + SDL_FRect dst { char_x - (sw - char_frame_width) / 2.0f, dy, sw, sh }; + + SDL_RenderTexture(renderer, char_texture, &src, &dst); + } + else + if (phase == Phase::SHOW_PROPS) { + if (props_anim_progress < 2.0f) { + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); + for (const auto& p : particles) { + SDL_FRect r { p.current.x, p.current.y, 1.0f, 1.0f }; + SDL_RenderFillRect(renderer, &r); + } + } else { + SDL_FRect dst { (screen_w - props_surface->w)/2.0f, + (screen_h - props_surface->h)/2.0f, + static_cast<float>(props_surface->w), + static_cast<float>(props_surface->h) }; + SDL_SetTextureAlphaMod(props_texture, 255); + SDL_RenderTexture(renderer, props_texture, nullptr, &dst); + } + } + + SDL_RenderPresent(renderer); +} + +void StartScreen::UpdateScreen() { + if (!logo_surface) return; + SDL_GetRenderOutputSize(renderer, &screen_w, &screen_h); + + // Logo centered + int lw = logo_surface->w; + int lh = logo_surface->h; + logo_dest.x = (screen_w - lw) / 2; + logo_dest.y = (screen_h - lh) / 2 - 100; + logo_offset.x = static_cast<float>(logo_dest.x); + logo_offset.y = static_cast<float>(logo_dest.y); + + // Central dot + center_dot.x = static_cast<float>(screen_w) / 2.0f; + center_dot.y = static_cast<float>(screen_h) * 0.65f; + + // Ground bar — edge-to-edge friendly + int margin = 0; + int usable = screen_w - 2 * margin; + int pixels_per_full_row = usable / ground_row_height; + int total = static_cast<int>(particles.size()); + int full_rows = total / pixels_per_full_row; + int rem = total % pixels_per_full_row; + + std::vector<SDL_FPoint> line_targets; + line_targets.reserve(static_cast<size_t>(total)); + + bottom_y = static_cast<float>(screen_h) * 0.68f; + + // Full rows — packed densely (as before) + for (int r = 0; r < full_rows; ++r) { + float y = bottom_y - static_cast<float>(r) * static_cast<float>(ground_row_height); + float row_start_x = (screen_w - pixels_per_full_row * ground_row_height) / 2.0f; + for (int c = 0; c < pixels_per_full_row; ++c) { + float x = row_start_x + static_cast<float>(c) * static_cast<float>(ground_row_height); + line_targets.push_back({x, y}); + } + } + + // Remainder row — evenly spaced across full width + if (rem > 0) { + float y = bottom_y - static_cast<float>(full_rows) * static_cast<float>(ground_row_height); + + // Spread evenly with equal gaps + float spacing = static_cast<float>(usable) / static_cast<float>(rem + 1); + float first_x = static_cast<float>(margin) + spacing / 2.0f; + + for (int c = 0; c < rem; ++c) { + float x = first_x + static_cast<float>(c) * spacing; + line_targets.push_back({x, y}); + } + } + + line_positions = std::move(line_targets); + + // Character position above top of bar + float top_bar = bottom_y - static_cast<float>(full_rows + (rem > 0 ? 1 : 0)) * static_cast<float>(ground_row_height); + line_y = static_cast<int>(top_bar - static_cast<float>(char_height) * 2.0f - 20.0f); +} + + +void StartScreen::Init() { + logo_surface = IMG_Load("logo/logo.png"); + char_texture = IMG_LoadTexture(renderer, "logo/Run_Side-Sheet.png"); + + props_surface = IMG_Load("logo/props.png"); + props_texture = SDL_CreateTextureFromSurface(renderer, props_surface); + + SDL_GetRenderOutputSize(renderer, &screen_w, &screen_h); + + // Extract black pixels (local coords) + const SDL_PixelFormatDetails* details = SDL_GetPixelFormatDetails(logo_surface->format); + Uint32* pixels = static_cast<Uint32*>(logo_surface->pixels); + int pitch = logo_surface->pitch / (int)sizeof(Uint32); + int w = logo_surface->w, h = logo_surface->h; + + particles.clear(); + for (int y = 0; y < h; ++y) { + for (int x = 0; x < w; ++x) { + Uint32 p = pixels[y * pitch + x]; + Uint8 r,g,b,a; + SDL_GetRGBA(p, details, NULL, &r, &g, &b, &a); + if (r < 20 && g < 20 && b < 20 && a > 180) { + particles.push_back({ {static_cast<float>(x), static_cast<float>(y)}, + {0,0}, {0,0} }); + } + } + } + + UpdateScreen(); // compute dot + line positions + + // Set all particles to center dot for first phase + for (auto& p : particles) { + p.current.x = center_dot.x; + p.current.y = center_dot.y; + p.target = center_dot; + } + + rng.seed(std::random_device{}()); + last_time = SDL_GetTicks(); + phase_start = last_time; + phase = Phase::DOT; + + char_speed = (static_cast<float>(screen_w) + extra_distance) / desired_cross_time; + //char_speed = 520.0f; + char_frame_width = 64; + char_height = 64; +} + +void StartScreen::StartSpreadToLine() { + phase = Phase::SPREAD_TO_LINE; + phase_start = SDL_GetTicks(); + + int N = static_cast<int>(particles.size()); + std::vector<size_t> perm((size_t)N); + std::iota(perm.begin(), perm.end(), 0); + std::shuffle(perm.begin(), perm.end(), rng); + + for (size_t i = 0; i < (size_t)N; ++i) { + particles[i].target = line_positions[perm[i]]; + } +} + +void StartScreen::StartFadeToLogo() { + phase = Phase::FADE_TO_LOGO; + phase_start = SDL_GetTicks(); + + // targets stay at line positions → lerp back to logo in Update() +} + +SDL_FPoint StartScreen::GetScreenOriginal(const Particle& p) const { + return { p.original.x + logo_offset.x, p.original.y + logo_offset.y }; +} + +float StartScreen::Lerp(float a, float b, float t) { + return a + (b - a) * t; +} + +namespace StartScreen_Event { + void event_Loop(SDL_Renderer* renderer) { + Audio audio; + audio.RegisterSound("intro", "music/intro.wav"); + StartScreen* scene = new StartScreen(renderer); + audio.Play("intro"); + while (scene->running) { + SDL_Event e; + while (SDL_PollEvent(&e)) { + if (e.type == SDL_EVENT_QUIT) scene->running = false; + + if (e.type == SDL_EVENT_KEY_DOWN && e.key.key == SDLK_SPACE) { + scene->~StartScreen(); + scene = new StartScreen(renderer); // restart from DOT + } + + if (e.type == SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED || + e.type == SDL_EVENT_WINDOW_RESIZED) { + scene->UpdateScreen(); + } + } + + scene->Update(); + scene->Render(); + } + } +} + diff --git a/src/start_screen/start_screen.hpp b/src/start_screen/start_screen.hpp new file mode 100644 index 0000000..3bd24c5 --- /dev/null +++ b/src/start_screen/start_screen.hpp @@ -0,0 +1,92 @@ +// StartScreen.cpp (single-file SDL3 example) +// Compile: g++ -std=c++20 StartScreen.cpp -o startscreen $(pkg-config --cflags --libs sdl3 SDL3_image) + +#pragma once + +#include <SDL3/SDL.h> +#include <SDL3_image/SDL_image.h> +#include <vector> +#include <random> +#include <numeric> +#include <algorithm> +#include <cstdint> +#include <print> + +struct Particle { + SDL_FPoint original; // local logo coords (0..w, 0..h) — never change + SDL_FPoint current; + SDL_FPoint target; +}; + + +class StartScreen { +public: + bool running = true; + StartScreen(SDL_Renderer* r); + ~StartScreen(); + + void Update(); + + void Render(); + + void UpdateScreen(); + +private: + enum class Phase { SHOW_LOGO, DOT, SPREAD_TO_LINE, LINE_WAIT, RUNNING, FADE_TO_LOGO, SHOW_PROPS }; + float desired_cross_time = 1.8f; // seconds + float extra_distance = 600.0f; // px left + right + float logo_display_time = 3.2f; + float props_anim_progress = 0.0f; // 0.0 → 1.0 + + void Init(); + + void StartSpreadToLine(); + + void StartFadeToLogo(); + + SDL_FPoint GetScreenOriginal(const Particle& p) const; + + static float Lerp(float a, float b, float t); + + void StartShowProps(); + +private: + SDL_Renderer* renderer = nullptr; + SDL_Surface* logo_surface = nullptr; + SDL_Texture* char_texture = nullptr; + SDL_Surface* props_surface = nullptr; + SDL_Texture* props_texture = nullptr; + + std::vector<Particle> particles; + std::vector<SDL_FPoint> line_positions; + + int screen_w = 0, screen_h = 0; + SDL_Rect logo_dest{}; + SDL_FPoint logo_offset{0,0}; + SDL_FPoint center_dot{0,0}; + + int line_y = 0; + + Phase phase = Phase::DOT; + Uint64 phase_start = 0; + Uint64 run_start_time = 0; + Uint64 last_time = 0; + + float char_x = 0.0f; + int char_frame = 0; + + // tunable + float char_speed = 520.0f; + int char_frame_width = 64; + int char_height = 64; + int ground_row_height = 1; // thicker = denser line + + float bottom_y = 0; + + std::mt19937 rng; +}; + +namespace StartScreen_Event { + void event_Loop(SDL_Renderer* renderer); +} + diff --git a/src/vegetables/vegetables.cpp b/src/vegetables/vegetables.cpp new file mode 100644 index 0000000..46b1c91 --- /dev/null +++ b/src/vegetables/vegetables.cpp @@ -0,0 +1,165 @@ +#include "vegetables.hpp" + +#include "inventory/inventory.hpp" + + +namespace VegetableData { + std::vector<Vegetable*> all_vegetables; + + const CropDefinition crop_defs[(int)Type::COUNT] = { + // STAGE: 0 1 2 3 4 + { "",0,0,0,0,0,0,0,0,0,0,0,false , { 5.0f, 5.0f, 0.0f, 0.0f, 300.0f } }, + { "carrot", 2,1, 5,1, 6,1, 7,1, 23,0, (5-2+1)+1, false, { 0.0f, 10.0f, 0.0f, 0.0f, 300.0f } }, + { "raddish", 2,3, 5,3, 6,3, 7,3, 23,1, (5-2+1)+1, false, { 5.0f, 5.0f, 0.0f, 0.0f, 300.0f } }, + { "cabbage", 2,5, 5,5, 6,5, 7,5, 23,2, (5-2+1)+1, false, { 10.0f, 0.0f, 0.0f, 0.0f, 300.0f } }, + { "salad", 2,7, 5,7, 6,7, 7,7, 23,3, (5-2+1)+1, false, { 5.0f, 5.0f, 0.0f, 0.0f, 300.0f } }, + { "broccoli", 2,9, 5,9, 6,9, 7,9, 23,4, (5-2+1)+1, false, { 5.0f, 5.0f, 0.0f, 0.0f, 300.0f } }, + { "onion", 2,11,5,11,6,11,7,11,23,5, (5-2+1)+1, false, { 5.0f, 5.0f, 0.0f, 0.0f, 300.0f } } + }; + + const CropDefinition* get_DataByType(Type type) { + return &crop_defs[static_cast<size_t>(type)]; + } + + const SDL_Point get_IconTilePosByType(Type type, bool is_seed) { + CropDefinition data = crop_defs[(int)type]; + return {data.icon_tile_x - (!is_seed ? 0 : 1), data.icon_tile_y}; + } +} + +Vegetable::Vegetable( VegetableData::Type t, SDL_Point world_pos, bool is_s) + : + Object(ObjectType::VEGETABLE, + ObjectCategory::FARM_CROP, + TileType::TILE_FARM, + 0, + 0, + world_pos, + {1,1}, + 0), + type(t), is_seed(is_s), + growth_stage(0), + next_update_sec(Default::get_TimeSinceStartInSec()), + equipement_slot(EquipmentSlot::HAND_RIGHT) +{ + definition = &VegetableData::crop_defs[static_cast<size_t>(type)]; + tileset_object_x = definition->start_tile_x; + tileset_object_y = definition->start_tile_y; + VegetableData::all_vegetables.push_back(this); + + collecting_duration_max = 3.2; + + + objects.push_back(this); + update_TilesetId(); +} + + +const VegetableData::CropDefinition& +get_DataByType(const VegetableData::Type& type) { + return VegetableData::crop_defs[static_cast<size_t>(type)]; +} + + + +const VegetableData::CropDefinition& +Vegetable::get_DataByType() { + return *definition; +} + + +SDL_Point +Vegetable::get_SetPosition() { + return { tileset_object_x, tileset_object_y }; +} + + +static constexpr double SECONDS_PER_STAGE = 5.0; + +void Vegetable::Grow(double current_seconds) { + if (current_seconds <= next_update_sec) + return; + + double delta_sec = current_seconds - next_update_sec; + + size_t delta_stages = static_cast<size_t>(delta_sec / SECONDS_PER_STAGE); + //std::cout << "GROW " << delta_stages << " " << delta_sec << " " << SECONDS_PER_STAGE << std::endl; + + if (delta_stages == 0) + return; + + + // MULTIPLY LAST STAGE + int grow_multiplier = 3; + if (growth_stage == (definition->total_stages - 3)) + next_update_sec += static_cast<double>(delta_stages) * SECONDS_PER_STAGE*grow_multiplier; + else + next_update_sec += static_cast<double>(delta_stages) * SECONDS_PER_STAGE; + + growth_stage += delta_stages; + if (growth_stage >= definition->total_stages) + growth_stage = definition->total_stages - 1; + + update_TilesetId(); +} + +bool Vegetable::is_Rotten() const { + return growth_stage == definition->total_stages - 1; +} + +bool Vegetable::is_FullyGrown() const { + return growth_stage == (definition->total_stages - 2) || growth_stage == (definition->total_stages - 1); +} + +void Vegetable::pick_Up() { + // mark as removed → caller inserts into inventory + for (auto it = VegetableData::all_vegetables.begin(); it != VegetableData::all_vegetables.end(); ++it) { + if (*it == this) { + VegetableData::all_vegetables.erase(it); + break; + } + } + + std::cout << "REMOVE? " << id << std::endl; + Object::Remove(Object::get_ObjectById(id)); +} + +bool Vegetable::is_Collectable() const { + return is_FullyGrown(); +} + +void Vegetable::Collect(Inventory*, Messages*) { + if (!is_Collectable()) return; + + // Convert to inventory item + //Inventory::AddItem(definition->item_type, 1); + + std::cout << "I AM NOT GONNA GET CALLED ?! COLLLLEC? " << id << std::endl; + // Remove from world + delete this; +} + + + + +void Vegetable::update_TilesetId() { + const auto& d = *definition; + + int grown_end = d.grown_tile_x - d.start_tile_x; + + if (growth_stage <= static_cast<size_t>(grown_end)) { + // Regular growth stages, all on the start row + tileset_object_x = static_cast<size_t>(d.start_tile_x) + growth_stage; + tileset_object_y = d.start_tile_y; + } + else if (growth_stage == d.total_stages - 1) { + // Rotten stage + tileset_object_x = d.rotten_tile_x; + tileset_object_y = d.rotten_tile_y; + } + else { + // Fully grown but not rotten + tileset_object_x = d.grown_tile_x; + tileset_object_y = d.grown_tile_y; + } +} diff --git a/src/vegetables/vegetables.hpp b/src/vegetables/vegetables.hpp new file mode 100644 index 0000000..9f0bc9b --- /dev/null +++ b/src/vegetables/vegetables.hpp @@ -0,0 +1,97 @@ +#pragma once + +#include "objects/object.hpp" + +class Inventory; +class Messages; + +enum class ItemType : uint32_t ; +enum class EquipmentSlot; + +class Vegetable; + + +struct ConsumingStatsBonus { + float health = 0.0f; + float stamina = 0.0f; + float thirst = 0.0f; + float demage = 0.0f; + float duration = 0.0f; +}; + +namespace VegetableData { + extern std::vector<Vegetable*> all_vegetables; + + enum class Type : uint32_t { + NONE, + CARROT, + RADDISH, + CABBAGE, + SALAD, + CAULIFLOWER, + ONION, + COUNT + }; + + struct CropDefinition { + const char* name; + int start_tile_x; + int start_tile_y; + int grown_tile_x; // last stage before rotten + int grown_tile_y; + int rotten_tile_x; + int rotten_tile_y; + int collectable_tile_x; + int collectable_tile_y; + int icon_tile_x; + int icon_tile_y; + size_t total_stages; // auto-calculated = (grown-start)+1 + rotten + bool is_seed; + ConsumingStatsBonus stats_bonus; + }; + + + extern const CropDefinition crop_defs[(int)Type::COUNT]; + + const CropDefinition* get_DataByType(Type type); + const SDL_Point get_IconTilePosByType(Type type, bool is_seed = false); + + +} + + + +class Vegetable : public Object, public IsCollectable { +public: + VegetableData::Type type; + const VegetableData::CropDefinition* definition; + size_t quantity = 2; + bool is_seed = false; + size_t growth_stage; // 0 = planted, last = rotten + double next_update_sec; // seconds since game start + float collecting_duration_max; + + int tileset_object_x = 0; + int tileset_object_y = 0; + + EquipmentSlot equipement_slot; + + Vegetable(VegetableData::Type t, SDL_Point world_pos, bool is_s); + + SDL_Point get_SetPosition() override; + + const VegetableData::CropDefinition& + get_DataByType(); + + void Grow(double current_seconds); + bool is_Rotten() const; + bool is_FullyGrown() const; + void pick_Up(); + + // ICollectable + bool is_Collectable() const override; + void Collect(Inventory*, Messages*) override; + +private: + void update_TilesetId(); +};