├── .gitattributes ├── .gitignore ├── GameSFML.sln ├── GameSFML ├── Box2DContactListener.h ├── Codex.h ├── Component │ ├── AnimationComponent.h │ ├── CollisionRespondComponent.h │ ├── GameplayTags.h │ ├── HealthComponent.h │ ├── PhysicComponent.h │ ├── PlayerControllerComponent.h │ ├── SpawnComponent.h │ ├── StaticObjectSpawnInfo.h │ ├── TransitionStateComponent.h │ └── UIComponent.h ├── Data │ ├── Fonts │ │ ├── Adventure Hollow.otf │ │ ├── Adventure.otf │ │ └── Splatch.ttf │ ├── Images │ │ ├── PlayerAnimation_64_64_4_9.png │ │ ├── Player_12_4_95_159.png │ │ ├── Tile │ │ │ └── terrain.png │ │ ├── enemy_01.png │ │ ├── enemy_02.png │ │ ├── enemy_03.png │ │ ├── pro_04_30_30_8.png │ │ ├── pro_05_30_30_4.png │ │ ├── pro_06_30_30_4.png │ │ └── pro_07_30_30_4.png │ └── Json │ │ ├── bulletAnimation.json │ │ ├── map.json │ │ ├── map200x200.json │ │ ├── map20x20.json │ │ ├── map5x5.json │ │ ├── playerAnimation.json │ │ └── tileMap.json ├── Game.h ├── GameResource.h ├── GameSFML.vcxproj ├── GameSFML.vcxproj.filters ├── Gird.h ├── Graphics.h ├── HashStringDataBase.h ├── Keyboard.cpp ├── Keyboard.h ├── Locator.h ├── MainWindow.h ├── MaxxConsole.h ├── Mouse.cpp ├── Mouse.h ├── System │ ├── AnimationSystem.h │ ├── CollisionRespondSystem.h │ ├── CullingSystem.h │ ├── DrawDebugSystem.h │ ├── HealthSystem.h │ ├── IDrawSystem.h │ ├── ISystemECS.h │ ├── LifeTimeSystem.h │ ├── MoveCameraSystem.h │ ├── PhysicSystem.h │ ├── PlayerControllerSystem.h │ ├── PlayerUpdateSystem.h │ ├── RenderGridSystem.h │ ├── RenderScreenBaseUISystem.h │ ├── RenderSpriteSystem.h │ ├── RenderWorldBaseUISystem.h │ ├── SpawnAndCleanDeathSystem.h │ ├── SpawnStaticObjectSystem.h │ ├── TransitionStateSystem.h │ └── UpdateUISystem.h ├── SystemInclude.h ├── World.h ├── json.hpp └── main.cpp └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | 259 | # Python Tools for Visual Studio (PTVS) 260 | __pycache__/ 261 | *.pyc -------------------------------------------------------------------------------- /GameSFML.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28010.2048 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameSFML", "GameSFML\GameSFML.vcxproj", "{38CAD35A-0EF1-4EAD-AA80-786EECE45802}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {38CAD35A-0EF1-4EAD-AA80-786EECE45802}.Debug|x64.ActiveCfg = Debug|x64 17 | {38CAD35A-0EF1-4EAD-AA80-786EECE45802}.Debug|x64.Build.0 = Debug|x64 18 | {38CAD35A-0EF1-4EAD-AA80-786EECE45802}.Debug|x86.ActiveCfg = Debug|Win32 19 | {38CAD35A-0EF1-4EAD-AA80-786EECE45802}.Debug|x86.Build.0 = Debug|Win32 20 | {38CAD35A-0EF1-4EAD-AA80-786EECE45802}.Release|x64.ActiveCfg = Release|x64 21 | {38CAD35A-0EF1-4EAD-AA80-786EECE45802}.Release|x64.Build.0 = Release|x64 22 | {38CAD35A-0EF1-4EAD-AA80-786EECE45802}.Release|x86.ActiveCfg = Release|Win32 23 | {38CAD35A-0EF1-4EAD-AA80-786EECE45802}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {E3F8CD1C-3769-4B32-B623-29CC7986BB5A} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /GameSFML/Box2DContactListener.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Component/CollisionRespondComponent.h" 3 | #include "entt/entt.hpp" 4 | class Box2DContactListener final : public b2ContactListener 5 | { 6 | public: 7 | Box2DContactListener(entt::DefaultRegistry& ECS) : ECS(ECS) {} 8 | void BeginContact(b2Contact* contact) final 9 | { 10 | auto* ptrBody1 = contact->GetFixtureA()->GetBody(); 11 | auto* ptrBody2 = contact->GetFixtureB()->GetBody(); 12 | if (ptrBody1->GetType() == b2BodyType::b2_staticBody || ptrBody2->GetType() == b2BodyType::b2_staticBody) return; 13 | 14 | auto categoryBits1 = contact->GetFixtureA()->GetFilterData().categoryBits; 15 | auto entity1 = ptrBody1->GetUserEntity(); 16 | auto categoryBits2 = contact->GetFixtureB()->GetFilterData().categoryBits; 17 | auto entity2 = ptrBody2->GetUserEntity(); 18 | if (ECS.has(entity1)) 19 | { 20 | if (ECS.has(entity1)) 21 | { 22 | ECS.get(entity1).others.emplace_back(std::make_pair(entity2, categoryBits2)); 23 | } 24 | else 25 | { 26 | ECS.assign(entity1).others.emplace_back(std::make_pair(entity2, categoryBits2)); 27 | } 28 | } 29 | if (ECS.has(entity2)) 30 | { 31 | if (ECS.has(entity2)) 32 | { 33 | ECS.get(entity2).others.emplace_back(std::make_pair(entity1, categoryBits1)); 34 | } 35 | else 36 | { 37 | ECS.assign(entity2).others.emplace_back(std::make_pair(entity1, categoryBits1)); 38 | } 39 | } 40 | } 41 | private: 42 | entt::DefaultRegistry& ECS; 43 | }; 44 | -------------------------------------------------------------------------------- /GameSFML/Codex.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "entt/resource/cache.hpp" 4 | #include "GameResource.h" 5 | #include "json.hpp" 6 | #include 7 | #include 8 | struct TextureLoader final : entt::ResourceLoader { 9 | std::shared_ptr load(entt::HashedString filename) const 10 | { 11 | auto resource = std::make_shared(); 12 | 13 | if (!resource->loadFromFile(static_cast(filename))) 14 | { 15 | assert(false); 16 | } 17 | 18 | return resource; 19 | } 20 | }; 21 | struct AnimationLoader final : entt::ResourceLoader { 22 | std::shared_ptr load(const nlohmann::json& Json, const sf::Texture& texture) const 23 | { 24 | auto resource = std::make_shared(); 25 | resource->texture = &texture; 26 | resource->width = Json["width"].get(); 27 | resource->height = Json["height"].get(); 28 | resource->tileWidth = Json["tileWidth"].get(); 29 | resource->tileHeight = Json["tileHeight"].get(); 30 | resource->frameTime = Json["frameTime"].get(); 31 | 32 | const unsigned int frameX = resource->width / resource->tileWidth; 33 | const unsigned int frameY = resource->height / resource->tileHeight; 34 | for (unsigned int y = 0; y < frameY; y++) 35 | { 36 | for (unsigned int x = 0; x < frameX; x++) 37 | { 38 | resource->frames.emplace_back(sf::IntRect(x * resource->tileWidth, y * resource->tileHeight, resource->tileWidth, resource->tileHeight)); 39 | } 40 | } 41 | 42 | for (auto& set : Json["animationSets"]) 43 | { 44 | resource->animationSets.emplace_back(set["index"].get>()); 45 | } 46 | return resource; 47 | } 48 | }; 49 | struct MapLoader final : entt::ResourceLoader { 50 | std::shared_ptr load(const nlohmann::json& Json, const sf::Texture& texture) const 51 | { 52 | auto resource = std::make_shared(); 53 | 54 | //load texture 55 | resource->tileSize = Json["tilewidth"].get(); 56 | resource->gridW = Json["width"].get(); 57 | resource->gridH = Json["height"].get(); 58 | resource->tileTexture = &texture; 59 | 60 | //load layer map 61 | for (auto& layer : Json["layers"]) 62 | { 63 | //add layer 64 | if (layer.find("data") != layer.end()) 65 | { 66 | if (layer["name"].get() == "TileObject") 67 | { 68 | resource->tilesWithObject = layer["data"].get>(); 69 | } 70 | else 71 | { 72 | resource->layers.emplace_back(layer["data"].get>()); 73 | } 74 | 75 | continue; 76 | } 77 | // add object layer 78 | if (layer.find("objects") != layer.end()) 79 | { 80 | for (auto& object : layer["objects"]) 81 | { 82 | resource->objectLayer.emplace_back(MapResource::Object{ 83 | object["height"].get(), 84 | object["width"].get(), 85 | object["x"].get(), 86 | object["y"].get(), 87 | object["rotation"].get() 88 | }); 89 | } 90 | } 91 | } 92 | 93 | //load ofject per tile 94 | for (auto& tileset : Json["tilesets"]) 95 | { 96 | for (auto& tile : tileset["tiles"]) 97 | { 98 | if (tile.find("objectgroup") != tile.end()) 99 | { 100 | const unsigned int id = tile["id"].get() + 1u; 101 | for (auto& object : tile["objectgroup"]["objects"]) 102 | { 103 | resource->objects.emplace(id, MapResource::Object{ 104 | object["height"].get(), 105 | object["width"].get(), 106 | object["x"].get(), 107 | object["y"].get(), 108 | object["rotation"].get() 109 | }); 110 | } 111 | } 112 | } 113 | } 114 | 115 | 116 | return resource; 117 | } 118 | }; 119 | struct FontLoader final : entt::ResourceLoader { 120 | std::shared_ptr load(entt::HashedString filename) const 121 | { 122 | auto resource = std::make_shared(); 123 | 124 | if (!resource->loadFromFile(static_cast(filename))) 125 | { 126 | assert(false); 127 | } 128 | 129 | return resource; 130 | } 131 | }; 132 | class Codex 133 | { 134 | public: 135 | const sf::Texture& GetTexture(entt::HashedString filename) 136 | { 137 | if (textureCache.contains(filename)) 138 | { 139 | return textureCache.handle(filename).get(); 140 | } 141 | 142 | textureCache.load(filename, filename); 143 | return textureCache.handle(filename).get(); 144 | } 145 | const AnimationResource& GetAnimation(entt::HashedString filename) 146 | { 147 | if (animationCache.contains(filename)) 148 | { 149 | return animationCache.handle(filename).get(); 150 | } 151 | const nlohmann::json Json = GetJson(filename); 152 | 153 | std::string imageName{ "Data\\Images\\" }; 154 | imageName += Json["imageName"].get(); 155 | entt::HashedString texturePath{ imageName.c_str() }; 156 | 157 | animationCache.load(filename, Json, GetTexture(texturePath)); 158 | return animationCache.handle(filename).get(); 159 | } 160 | const MapResource& GetMapResource(entt::HashedString filename) 161 | { 162 | if (mapCache.contains(filename)) 163 | { 164 | return mapCache.handle(filename).get(); 165 | } 166 | const nlohmann::json Json = GetJson(filename); 167 | 168 | std::string imageName{ "Data\\Images\\Tile\\" }; 169 | for (auto& tileset : Json["tilesets"]) 170 | { 171 | imageName += tileset["image"].get(); 172 | break; 173 | } 174 | entt::HashedString texturePath{ imageName.c_str() }; 175 | 176 | mapCache.load(filename, Json, GetTexture(texturePath)); 177 | return mapCache.handle(filename).get(); 178 | } 179 | const sf::Font& GetFont(entt::HashedString filename) 180 | { 181 | if (fontCache.contains(filename)) 182 | { 183 | return fontCache.handle(filename).get(); 184 | } 185 | 186 | fontCache.load(filename, filename); 187 | return fontCache.handle(filename).get(); 188 | } 189 | private: 190 | const nlohmann::json GetJson(entt::HashedString filename) const 191 | { 192 | std::ifstream input(static_cast(filename)); 193 | nlohmann::json Json; 194 | input >> Json; 195 | input.close(); 196 | return Json; 197 | } 198 | private: 199 | entt::ResourceCache textureCache; 200 | entt::ResourceCache fontCache; 201 | entt::ResourceCache animationCache; 202 | entt::ResourceCache mapCache; 203 | }; 204 | -------------------------------------------------------------------------------- /GameSFML/Component/AnimationComponent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "SFML/Graphics.hpp" 3 | #include "../GameResource.h" 4 | #include 5 | struct AnimationComponent 6 | { 7 | AnimationComponent(const AnimationResource& resource, unsigned int iAnimationSet = 0) 8 | : 9 | holdTime((float)resource.frameTime / 1000.0f), 10 | rangeIndex(resource.animationSets[iAnimationSet]), 11 | frames(&resource.frames), 12 | resource(&resource) 13 | { 14 | rangeIndex.second = rangeIndex.first; 15 | } 16 | float holdTime; 17 | float curFrameTime = 0.0f; 18 | unsigned char iCurFrame = 0; 19 | std::pair rangeIndex; 20 | //will use share component in the next entt update 21 | const std::vector* frames = nullptr; 22 | const AnimationResource* resource = nullptr; 23 | }; -------------------------------------------------------------------------------- /GameSFML/Component/CollisionRespondComponent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Component/PhysicComponent.h" 3 | #include "../Component/HealthComponent.h" 4 | #include "entt/entt.hpp" 5 | struct CollisionCallbackData 6 | { 7 | // First: other entity - Second: categotyMask 8 | std::vector> others; 9 | }; 10 | struct CollisionRespondComponent 11 | { 12 | //this will use by CollisionRespondSystem, and this system will use multi-thread don't remove or add new Component 13 | entt::Delegate myDelegate; 14 | 15 | 16 | static void Player(uint32_t entity, entt::DefaultRegistry& ECS) 17 | { 18 | auto& callbackData = ECS.get(entity); 19 | 20 | for (auto& other : callbackData.others) 21 | { 22 | if (other.second == CollisionFillter::PLAYER) continue; 23 | 24 | if (other.second == CollisionFillter::ENEMY) 25 | { 26 | if (ECS.has(entity)) 27 | { 28 | ECS.get(entity).curHealth -= 1.0f; 29 | } 30 | } 31 | } 32 | } 33 | static void Enemy(uint32_t entity, entt::DefaultRegistry& ECS) 34 | { 35 | auto& callbackData = ECS.get(entity); 36 | 37 | for (auto& other : callbackData.others) 38 | { 39 | if (other.second == CollisionFillter::ENEMY) continue; 40 | 41 | if (other.second == CollisionFillter::PLAYER) 42 | { 43 | if (ECS.has(entity)) 44 | { 45 | ECS.get(entity).curHealth -= 5.0f; 46 | } 47 | } 48 | } 49 | } 50 | static void Bullet(uint32_t entity, entt::DefaultRegistry& ECS) 51 | { 52 | auto& callbackData = ECS.get(entity); 53 | 54 | for (auto& other : callbackData.others) 55 | { 56 | if (other.second == CollisionFillter::BULLET) continue; 57 | 58 | if (other.second == CollisionFillter::ENEMY) 59 | { 60 | if (ECS.has(entity)) 61 | { 62 | ECS.get(entity).curHealth = 0.0f; 63 | } 64 | if (ECS.has(other.first)) 65 | { 66 | ECS.get(other.first).curHealth -= 20.0f; 67 | } 68 | } 69 | } 70 | } 71 | }; -------------------------------------------------------------------------------- /GameSFML/Component/GameplayTags.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | struct DeathTag {}; 3 | struct Viewable {}; 4 | struct UIViewable {}; 5 | struct PhysicDebug {}; 6 | struct Overlaped {}; 7 | struct CameraTracking {}; 8 | struct LifeTimeComponent 9 | { 10 | float maxLifeTime = 0.0f; 11 | float curTime = 0.0f; 12 | }; -------------------------------------------------------------------------------- /GameSFML/Component/HealthComponent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | struct HealthComponent 3 | { 4 | float curHealth; 5 | float maxHealth; 6 | }; -------------------------------------------------------------------------------- /GameSFML/Component/PhysicComponent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "Box2D/Box2D.h" 5 | #include "Locator.h" 6 | enum CollisionFillter { 7 | STATIC = 0x0001, 8 | ENEMY = 0x0002, 9 | PLAYER = 0x0004, 10 | BULLET = 0x0006 11 | }; 12 | struct PhysicComponent 13 | { 14 | PhysicComponent(uint32_t entity, const b2BodyDef& bodyDef = b2BodyDef(), const b2FixtureDef& fixtureDef = b2FixtureDef()) 15 | { 16 | body = { Locator::Physic::ref().CreateBody(&bodyDef),[](b2Body* pBody) {Locator::Physic::ref().DestroyBody(pBody); } }; 17 | body->CreateFixture(&fixtureDef); 18 | body->SetUserEntity(entity); 19 | } 20 | PhysicComponent() = default; 21 | std::unique_ptr> body; 22 | }; -------------------------------------------------------------------------------- /GameSFML/Component/PlayerControllerComponent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "SFML/System/Vector2.hpp" 3 | struct PlayerControllerComponent 4 | { 5 | sf::Vector2i direction; 6 | bool bIsShooting = false; 7 | sf::Vector2i mousePos; 8 | }; -------------------------------------------------------------------------------- /GameSFML/Component/SpawnComponent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "entt/entt.hpp" 3 | 4 | struct SpawnComponent 5 | { 6 | bool bIsEnable = true; 7 | float curTime = 0.0f; 8 | float interval; 9 | }; 10 | struct SpawnCapacity 11 | { 12 | unsigned int totalEntity = 0; 13 | unsigned int maxEntity; 14 | }; 15 | struct SpawnPosition 16 | { 17 | b2Vec2 spawnPosition; 18 | b2Vec2 speed; 19 | unsigned int variationX; 20 | unsigned int variationY; 21 | }; 22 | struct NotifyOnDead 23 | { 24 | uint32_t onwerEntity; 25 | entt::SigH mySignal; 26 | static void EnemyNotifySpawner(uint32_t entity, entt::DefaultRegistry& ECS) 27 | { 28 | auto& notifier = ECS.get(entity); 29 | if (ECS.has(notifier.onwerEntity)) 30 | { 31 | ECS.get(notifier.onwerEntity).totalEntity--; 32 | } 33 | } 34 | }; 35 | struct UpdateSpawnComponent 36 | { 37 | entt::Delegate myDelegate; 38 | 39 | static void Enemy(uint32_t spawnerEntity, entt::DefaultRegistry& ECS) 40 | { 41 | if (ECS.has(spawnerEntity)) 42 | { 43 | auto& spawnCap = ECS.get(spawnerEntity); 44 | if (spawnCap.totalEntity >= spawnCap.maxEntity) return; 45 | spawnCap.totalEntity++; 46 | } 47 | 48 | b2BodyDef bodyDef; 49 | bodyDef.type = b2_dynamicBody; 50 | 51 | if (ECS.has(spawnerEntity)) 52 | { 53 | auto& spawnPos = ECS.get(spawnerEntity); 54 | if (Locator::Random::empty() && (spawnPos.variationX == 0 && spawnPos.variationX == 0)) 55 | { 56 | bodyDef.position = spawnPos.spawnPosition; 57 | bodyDef.linearVelocity = spawnPos.speed; 58 | } 59 | else 60 | { 61 | auto& rng = Locator::Random::ref(); 62 | std::uniform_real_distribution rangeX(-(float)spawnPos.variationX, (float)spawnPos.variationX); 63 | std::uniform_real_distribution rangeY(-(float)spawnPos.variationY, (float)spawnPos.variationY); 64 | 65 | bodyDef.position = spawnPos.spawnPosition + b2Vec2(rangeX(rng), rangeY(rng)); 66 | bodyDef.linearVelocity = spawnPos.speed; 67 | } 68 | 69 | } 70 | 71 | const float size = 1.3f; 72 | b2CircleShape circle; 73 | circle.m_radius = size; 74 | 75 | b2FixtureDef fixtureDef; 76 | fixtureDef.shape = &circle; 77 | fixtureDef.filter.categoryBits = CollisionFillter::ENEMY; 78 | fixtureDef.filter.maskBits = CollisionFillter::PLAYER | CollisionFillter::STATIC | CollisionFillter::BULLET; 79 | //fixtureDef.isSensor = isSensor; 80 | fixtureDef.density = 1.0f; 81 | fixtureDef.friction = 0.0f; 82 | fixtureDef.restitution = 1.0f; 83 | 84 | auto entity = ECS.create(); 85 | auto& notifier = ECS.assign(entity); 86 | notifier.onwerEntity = spawnerEntity; 87 | notifier.mySignal.sink().connect<&NotifyOnDead::EnemyNotifySpawner>(); 88 | ECS.assign(entity, 50.0f, 50.0f); 89 | 90 | //sprite 91 | { 92 | std::uniform_int_distribution textID(0, 2); 93 | const sf::Texture* texture; 94 | switch (textID(Locator::Random::ref())) 95 | { 96 | case 0: 97 | texture = &Locator::Codex::ref().GetTexture(Database::TEnemy01); 98 | break; 99 | case 1: 100 | texture = &Locator::Codex::ref().GetTexture(Database::TEnemy02); 101 | break; 102 | case 2: 103 | texture = &Locator::Codex::ref().GetTexture(Database::TEnemy03); 104 | break; 105 | default: 106 | texture = &Locator::Codex::ref().GetTexture(Database::TEnemy01); 107 | break; 108 | } 109 | auto& sprite = ECS.assign(entity, *texture); 110 | const auto textSize = sf::Vector2f(0.5f * (float)sprite.getTexture()->getSize().x, 0.5f * (float)sprite.getTexture()->getSize().y); 111 | sprite.setOrigin(textSize); 112 | } 113 | 114 | ECS.assign(entity); 115 | ECS.assign(entity, entity, bodyDef, fixtureDef); 116 | ECS.assign(entity).myDelegate.connect<&CollisionRespondComponent::Enemy>(); 117 | 118 | //Health Bar 119 | { 120 | auto entityUI = UIFactory::GetEntity(entity, ECS); 121 | auto& progressBar = ECS.assign(entityUI, sf::Vector2f(100.0f, 15.0f)); 122 | progressBar.colorBase = sf::Color::Blue; 123 | ECS.assign(entityUI, entity); 124 | ECS.assign(entityUI).myDelegate.connect<&UpdateWorldBaseUIComponent::HealthBar>(); 125 | } 126 | //health Text 127 | { 128 | auto entityUI = UIFactory::GetEntity(entity, ECS); 129 | const auto& textFont = Locator::Codex::ref().GetFont(Database::FontSplatch); 130 | ECS.assign(entityUI, "Health: ", textFont, 15); 131 | ECS.assign(entityUI, entity); 132 | ECS.assign(entityUI).myDelegate.connect<&UpdateWorldBaseUIComponent::HealthText>(); 133 | } 134 | } 135 | }; -------------------------------------------------------------------------------- /GameSFML/Component/StaticObjectSpawnInfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "SFML/Graphics.hpp" 3 | struct StaticObjectSpawnInfo 4 | { 5 | float height, width; 6 | sf::Vector2f pos; 7 | unsigned int rotation; 8 | }; 9 | 10 | struct StaticCustomObjectSpawnInfo 11 | { 12 | float height, width; 13 | sf::Vector2f pos; 14 | unsigned int rotation; 15 | }; -------------------------------------------------------------------------------- /GameSFML/Component/TransitionStateComponent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "entt/entt.hpp" 3 | 4 | struct PlayerStateComponent 5 | { 6 | enum State 7 | { 8 | Standing, 9 | Walking 10 | } state = State::Standing; 11 | enum Direction 12 | { 13 | Up = 0, 14 | Left = 1, 15 | Down = 2, 16 | Right = 3 17 | } direction = Direction::Left; 18 | }; 19 | struct TransitionStateComponent 20 | { 21 | //this will use by TransitionStateSystem, and this system will use multi-thread don't remove or add new Component 22 | entt::Delegate myDelegate; 23 | 24 | static void Player(uint32_t entity, entt::DefaultRegistry& ECS) 25 | { 26 | if (!ECS.has(entity) || !ECS.has(entity)) return; 27 | 28 | auto& state = ECS.get(entity); 29 | auto& controller = ECS.get(entity); 30 | 31 | if (state.state == PlayerStateComponent::State::Standing) 32 | { 33 | if (controller.direction == sf::Vector2i(0, 0)) return; 34 | 35 | state.state = PlayerStateComponent::State::Walking; 36 | 37 | if (controller.direction.x < 0) 38 | { 39 | state.direction = PlayerStateComponent::Direction::Left; 40 | if (ECS.has(entity)) 41 | { 42 | auto& animation = ECS.get(entity); 43 | 44 | animation.curFrameTime = 0.0f; 45 | animation.rangeIndex = animation.resource->animationSets[static_cast(state.direction)]; 46 | animation.iCurFrame = animation.rangeIndex.first + 1; 47 | } 48 | } 49 | 50 | if (controller.direction.x > 0) 51 | { 52 | state.direction = PlayerStateComponent::Direction::Right; 53 | if (ECS.has(entity)) 54 | { 55 | auto& animation = ECS.get(entity); 56 | animation.curFrameTime = 0.0f; 57 | animation.rangeIndex = animation.resource->animationSets[static_cast(state.direction)]; 58 | animation.iCurFrame = animation.rangeIndex.first + 1; 59 | } 60 | } 61 | 62 | if (controller.direction.y < 0) 63 | { 64 | state.direction = PlayerStateComponent::Direction::Down; 65 | if (ECS.has(entity)) 66 | { 67 | auto& animation = ECS.get(entity); 68 | animation.curFrameTime = 0.0f; 69 | animation.rangeIndex = animation.resource->animationSets[static_cast(state.direction)]; 70 | animation.iCurFrame = animation.rangeIndex.first + 1; 71 | } 72 | } 73 | 74 | if (controller.direction.y > 0) 75 | { 76 | state.direction = PlayerStateComponent::Direction::Up; 77 | if (ECS.has(entity)) 78 | { 79 | auto& animation = ECS.get(entity); 80 | animation.curFrameTime = 0.0f; 81 | animation.rangeIndex = animation.resource->animationSets[static_cast(state.direction)]; 82 | animation.iCurFrame = animation.rangeIndex.first + 1; 83 | } 84 | } 85 | } 86 | else 87 | { 88 | if (controller.direction == sf::Vector2i(0, 0)) 89 | { 90 | state.state = PlayerStateComponent::State::Standing; 91 | if (ECS.has(entity)) 92 | { 93 | auto& animation = ECS.get(entity); 94 | animation.curFrameTime = 0.0f; 95 | animation.iCurFrame = animation.rangeIndex.first; 96 | animation.rangeIndex.second = animation.rangeIndex.first; 97 | } 98 | } 99 | else 100 | { 101 | state.state = PlayerStateComponent::State::Walking; 102 | 103 | if (controller.direction.x < 0) 104 | { 105 | if (state.direction != PlayerStateComponent::Direction::Left) 106 | { 107 | state.direction = PlayerStateComponent::Direction::Left; 108 | if (ECS.has(entity)) 109 | { 110 | auto& animation = ECS.get(entity); 111 | 112 | animation.curFrameTime = 0.0f; 113 | animation.rangeIndex = animation.resource->animationSets[static_cast(state.direction)]; 114 | animation.iCurFrame = animation.rangeIndex.first + 1; 115 | } 116 | } 117 | } 118 | 119 | if (controller.direction.x > 0) 120 | { 121 | if (state.direction != PlayerStateComponent::Direction::Right) 122 | { 123 | state.direction = PlayerStateComponent::Direction::Right; 124 | if (ECS.has(entity)) 125 | { 126 | auto& animation = ECS.get(entity); 127 | animation.curFrameTime = 0.0f; 128 | animation.rangeIndex = animation.resource->animationSets[static_cast(state.direction)]; 129 | animation.iCurFrame = animation.rangeIndex.first + 1; 130 | } 131 | } 132 | } 133 | 134 | if (controller.direction.y < 0) 135 | { 136 | if (state.direction != PlayerStateComponent::Direction::Down) 137 | { 138 | state.direction = PlayerStateComponent::Direction::Down; 139 | if (ECS.has(entity)) 140 | { 141 | auto& animation = ECS.get(entity); 142 | animation.curFrameTime = 0.0f; 143 | animation.rangeIndex = animation.resource->animationSets[static_cast(state.direction)]; 144 | animation.iCurFrame = animation.rangeIndex.first + 1; 145 | } 146 | } 147 | } 148 | 149 | if (controller.direction.y > 0) 150 | { 151 | if (state.direction != PlayerStateComponent::Direction::Up) 152 | { 153 | state.direction = PlayerStateComponent::Direction::Up; 154 | if (ECS.has(entity)) 155 | { 156 | auto& animation = ECS.get(entity); 157 | animation.curFrameTime = 0.0f; 158 | animation.rangeIndex = animation.resource->animationSets[static_cast(state.direction)]; 159 | animation.iCurFrame = animation.rangeIndex.first + 1; 160 | } 161 | } 162 | } 163 | } 164 | } 165 | } 166 | }; -------------------------------------------------------------------------------- /GameSFML/Component/UIComponent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "SFML/Graphics.hpp" 3 | #include "entt/entt.hpp" 4 | 5 | struct ScreenBaseUI 6 | { 7 | uint32_t ownerEntity; 8 | //this is the location offset from central of the screen 9 | sf::Vector2f offsetLocaion; 10 | }; 11 | struct OwnedUIComponent 12 | { 13 | //hold all Owned UI entity 14 | std::vector entities; 15 | 16 | static void Destruction(entt::DefaultRegistry& ECS, uint32_t entity) 17 | { 18 | auto& owend = ECS.get(entity); 19 | for (auto& e : owend.entities) 20 | { 21 | ECS.destroy(e); 22 | } 23 | } 24 | }; 25 | struct WorldBaseUI 26 | { 27 | uint32_t ownerEntity; 28 | }; 29 | 30 | struct ProgressiveBarComponent 31 | { 32 | sf::Vector2f size; 33 | float percent = 1.0f; 34 | sf::Color colorBase{ sf::Color::Green }; 35 | sf::Color colorBG{ sf::Color::Red }; 36 | }; 37 | struct UpdateScreenBaseUIComponent 38 | { 39 | entt::Delegate myDelegate; 40 | 41 | static void HealthText(uint32_t entity, entt::DefaultRegistry& ECS) 42 | { 43 | if (!ECS.has(entity) || !ECS.has(entity)) return; 44 | 45 | auto& UI = ECS.get(entity); 46 | 47 | if (!ECS.has(UI.ownerEntity)) return; 48 | 49 | auto& text = ECS.get(entity); 50 | auto& health = ECS.get(UI.ownerEntity); 51 | std::stringstream ss; 52 | ss << "Health: " << (int)health.curHealth << " / " << (int)health.maxHealth; 53 | text.setString(ss.str()); 54 | if (Locator::Graphic::empty()) return; 55 | 56 | text.setPosition(Locator::Graphic::ref().GetViewportLocation() + UI.offsetLocaion); 57 | } 58 | static void HealthBar(uint32_t entity, entt::DefaultRegistry& ECS) 59 | { 60 | if (!ECS.has(entity) || !ECS.has(entity)) return; 61 | 62 | auto& UI = ECS.get(entity); 63 | 64 | if (!ECS.has(UI.ownerEntity)) return; 65 | 66 | auto& progressBar = ECS.get(entity); 67 | auto& health = ECS.get(UI.ownerEntity); 68 | progressBar.percent = health.curHealth / health.maxHealth; 69 | } 70 | }; 71 | struct UpdateWorldBaseUIComponent 72 | { 73 | entt::Delegate myDelegate; 74 | 75 | static void HealthText(uint32_t entity, entt::DefaultRegistry& ECS) 76 | { 77 | if (!ECS.has(entity) || !ECS.has(entity)) return; 78 | 79 | auto& UI = ECS.get(entity); 80 | 81 | if (!ECS.has(UI.ownerEntity)) return; 82 | 83 | auto& text = ECS.get(entity); 84 | auto& health = ECS.get(UI.ownerEntity); 85 | std::stringstream ss; 86 | ss << (int)health.curHealth << " / " << (int)health.maxHealth; 87 | text.setString(ss.str()); 88 | } 89 | static void HealthBar(uint32_t entity, entt::DefaultRegistry& ECS) 90 | { 91 | if (!ECS.has(entity) || !ECS.has(entity)) return; 92 | 93 | auto& UI = ECS.get(entity); 94 | 95 | if (!ECS.has(UI.ownerEntity)) return; 96 | 97 | auto& progressBar = ECS.get(entity); 98 | auto& health = ECS.get(UI.ownerEntity); 99 | progressBar.percent = health.curHealth / health.maxHealth; 100 | } 101 | }; 102 | 103 | struct UIFactory 104 | { 105 | static uint32_t GetEntity(uint32_t entityOwner, entt::DefaultRegistry& ECS, bool bIsHaveOwner = true) 106 | { 107 | auto uiEntity = ECS.create(); 108 | if (bIsHaveOwner) 109 | { 110 | 111 | if (ECS.has(entityOwner)) 112 | { 113 | auto& ownedUICom = ECS.get(entityOwner); 114 | ownedUICom.entities.emplace_back(uiEntity); 115 | return uiEntity; 116 | } 117 | else 118 | { 119 | auto& ownedUICom = ECS.assign(entityOwner); 120 | ownedUICom.entities.emplace_back(uiEntity); 121 | return uiEntity; 122 | } 123 | } 124 | 125 | return uiEntity; 126 | } 127 | }; -------------------------------------------------------------------------------- /GameSFML/Data/Fonts/Adventure Hollow.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxxnino/Game-SFML/431d6e38808d8976e3a102e4a09f6ebd1d1e99fd/GameSFML/Data/Fonts/Adventure Hollow.otf -------------------------------------------------------------------------------- /GameSFML/Data/Fonts/Adventure.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxxnino/Game-SFML/431d6e38808d8976e3a102e4a09f6ebd1d1e99fd/GameSFML/Data/Fonts/Adventure.otf -------------------------------------------------------------------------------- /GameSFML/Data/Fonts/Splatch.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxxnino/Game-SFML/431d6e38808d8976e3a102e4a09f6ebd1d1e99fd/GameSFML/Data/Fonts/Splatch.ttf -------------------------------------------------------------------------------- /GameSFML/Data/Images/PlayerAnimation_64_64_4_9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxxnino/Game-SFML/431d6e38808d8976e3a102e4a09f6ebd1d1e99fd/GameSFML/Data/Images/PlayerAnimation_64_64_4_9.png -------------------------------------------------------------------------------- /GameSFML/Data/Images/Player_12_4_95_159.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxxnino/Game-SFML/431d6e38808d8976e3a102e4a09f6ebd1d1e99fd/GameSFML/Data/Images/Player_12_4_95_159.png -------------------------------------------------------------------------------- /GameSFML/Data/Images/Tile/terrain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxxnino/Game-SFML/431d6e38808d8976e3a102e4a09f6ebd1d1e99fd/GameSFML/Data/Images/Tile/terrain.png -------------------------------------------------------------------------------- /GameSFML/Data/Images/enemy_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxxnino/Game-SFML/431d6e38808d8976e3a102e4a09f6ebd1d1e99fd/GameSFML/Data/Images/enemy_01.png -------------------------------------------------------------------------------- /GameSFML/Data/Images/enemy_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxxnino/Game-SFML/431d6e38808d8976e3a102e4a09f6ebd1d1e99fd/GameSFML/Data/Images/enemy_02.png -------------------------------------------------------------------------------- /GameSFML/Data/Images/enemy_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxxnino/Game-SFML/431d6e38808d8976e3a102e4a09f6ebd1d1e99fd/GameSFML/Data/Images/enemy_03.png -------------------------------------------------------------------------------- /GameSFML/Data/Images/pro_04_30_30_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxxnino/Game-SFML/431d6e38808d8976e3a102e4a09f6ebd1d1e99fd/GameSFML/Data/Images/pro_04_30_30_8.png -------------------------------------------------------------------------------- /GameSFML/Data/Images/pro_05_30_30_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxxnino/Game-SFML/431d6e38808d8976e3a102e4a09f6ebd1d1e99fd/GameSFML/Data/Images/pro_05_30_30_4.png -------------------------------------------------------------------------------- /GameSFML/Data/Images/pro_06_30_30_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxxnino/Game-SFML/431d6e38808d8976e3a102e4a09f6ebd1d1e99fd/GameSFML/Data/Images/pro_06_30_30_4.png -------------------------------------------------------------------------------- /GameSFML/Data/Images/pro_07_30_30_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxxnino/Game-SFML/431d6e38808d8976e3a102e4a09f6ebd1d1e99fd/GameSFML/Data/Images/pro_07_30_30_4.png -------------------------------------------------------------------------------- /GameSFML/Data/Json/bulletAnimation.json: -------------------------------------------------------------------------------- 1 | { 2 | "imageName": "pro_04_30_30_8.png", 3 | "width": 240, 4 | "height": 30, 5 | "tileWidth": 30, 6 | "tileHeight": 30, 7 | "frameTime": 150, 8 | "animationSets": [ 9 | { 10 | "id": 1, 11 | "index": [0, 6] 12 | } 13 | ] 14 | } -------------------------------------------------------------------------------- /GameSFML/Data/Json/map.json: -------------------------------------------------------------------------------- 1 | { "height":30, 2 | "filePath":"Data//Images//Tile//terrain.png", 3 | "infinite":false, 4 | "layers":[ 5 | { 6 | "data":[236, 236, 234, 234, 246, 235, 244, 235, 236, 233, 232, 244, 244, 244, 236, 246, 237, 244, 245, 235, 237, 244, 235, 237, 233, 232, 236, 235, 236, 246, 232, 244, 232, 236, 234, 245, 245, 236, 244, 236, 235, 234, 246, 233, 244, 236, 236, 232, 246, 246, 244, 237, 245, 237, 236, 246, 235, 246, 237, 237, 232, 237, 234, 246, 244, 234, 235, 234, 245, 237, 244, 233, 236, 232, 234, 246, 235, 246, 235, 233, 232, 235, 233, 236, 234, 245, 245, 235, 237, 232, 233, 245, 235, 236, 245, 235, 246, 233, 234, 246, 244, 233, 233, 237, 234, 233, 235, 234, 232, 244, 234, 233, 232, 246, 246, 232, 234, 236, 237, 244, 233, 234, 232, 245, 234, 245, 236, 232, 245, 235, 233, 232, 246, 234, 233, 233, 245, 237, 246, 236, 234, 244, 245, 234, 235, 235, 232, 244, 245, 235, 245, 237, 234, 237, 244, 235, 236, 244, 232, 235, 234, 232, 246, 234, 236, 235, 236, 237, 232, 236, 235, 234, 237, 245, 245, 237, 233, 245, 246, 245, 244, 233, 245, 232, 232, 245, 245, 236, 233, 236, 237, 232, 232, 233, 236, 233, 237, 245, 236, 244, 234, 235, 244, 235, 236, 234, 244, 232, 236, 233, 244, 236, 245, 235, 245, 234, 245, 236, 236, 245, 246, 244, 234, 234, 235, 246, 245, 236, 232, 237, 232, 234, 244, 233, 235, 235, 233, 237, 244, 232, 232, 237, 237, 245, 234, 236, 245, 233, 235, 233, 237, 237, 246, 233, 234, 233, 235, 233, 237, 233, 246, 244, 237, 235, 245, 235, 233, 237, 232, 236, 234, 246, 244, 236, 244, 245, 237, 245, 237, 244, 246, 233, 233, 245, 233, 237, 232, 244, 235, 244, 244, 235, 246, 246, 235, 237, 235, 245, 233, 246, 232, 235, 245, 232, 245, 233, 234, 237, 245, 244, 237, 235, 245, 233, 246, 246, 232, 233, 236, 245, 236, 233, 246, 234, 233, 236, 244, 246, 236, 234, 244, 246, 245, 236, 244, 236, 232, 236, 237, 245, 237, 232, 233, 236, 233, 233, 246, 235, 246, 244, 236, 245, 244, 235, 236, 233, 237, 244, 237, 237, 236, 235, 236, 236, 245, 234, 246, 235, 246, 244, 232, 237, 245, 235, 234, 236, 246, 245, 246, 233, 234, 233, 244, 244, 235, 232, 237, 246, 232, 236, 236, 246, 234, 234, 236, 235, 232, 244, 235, 236, 246, 237, 237, 233, 244, 233, 246, 235, 244, 234, 234, 245, 236, 235, 235, 235, 233, 246, 234, 244, 232, 244, 234, 235, 235, 232, 233, 233, 237, 245, 235, 232, 244, 234, 246, 246, 244, 233, 236, 235, 233, 235, 246, 236, 246, 236, 234, 232, 237, 235, 246, 237, 245, 237, 235, 234, 234, 236, 246, 244, 246, 246, 245, 235, 245, 246, 233, 236, 236, 244, 246, 237, 237, 236, 233, 235, 246, 232, 235, 246, 236, 235, 235, 235, 237, 245, 244, 233, 244, 233, 232, 232, 236, 236, 235, 232, 235, 246, 232, 232, 246, 245, 233, 245, 232, 236, 233, 236, 244, 237, 236, 233, 234, 237, 232, 233, 235, 232, 235, 237, 235, 237, 233, 244, 232, 234, 245, 244, 246, 236, 245, 237, 245, 232, 233, 246, 233, 235, 233, 245, 234, 235, 236, 245, 237, 234, 244, 232, 244, 236, 237, 233, 246, 244, 233, 236, 237, 236, 245, 234, 245, 232, 233, 234, 235, 244, 237, 237, 235, 237, 245, 246, 246, 236, 232, 246, 234, 244, 245, 234, 246, 237, 245, 232, 244, 236, 236, 245, 232, 235, 232, 237, 235, 237, 233, 236, 237, 233, 233, 233, 246, 234, 232, 235, 245, 232, 234, 235, 244, 236, 245, 237, 236, 233, 233, 245, 234, 244, 244, 237, 246, 234, 236, 234, 246, 237, 244, 232, 244, 232, 237, 245, 233, 233, 233, 235, 237, 236, 237, 232, 246, 237, 234, 246, 234, 236, 232, 234, 232, 244, 232, 245, 237, 237, 236, 234, 235, 245, 232, 245, 233, 237, 236, 233, 233, 233, 232, 232, 237, 246, 237, 232, 237, 237, 236, 245, 234, 244, 236, 237, 236, 234, 236, 233, 236, 235, 234, 236, 246, 236, 236, 234, 245, 245, 233, 235, 234, 232, 244, 232, 237, 233, 236, 245, 236, 246, 235, 232, 234, 244, 234, 244, 237, 233, 245, 235, 234, 232, 245, 234, 245, 237, 232, 232, 236, 232, 237, 236, 232, 244, 246, 236, 234, 235, 237, 233, 234, 235, 237, 245, 244, 234, 236, 232, 237, 234, 246, 245, 245, 234, 246, 235, 232, 235, 236, 237, 233, 234, 232, 244, 244, 244, 245, 237, 232, 245, 244, 232, 233, 232, 236, 237, 236, 246, 232, 234, 235, 233, 234, 235, 232, 236, 232, 235, 233, 236, 235, 235, 246, 235, 235, 236, 232, 235, 236, 244, 244, 246, 236, 237, 244, 237, 236, 233, 235, 232, 246, 233, 237, 234, 244, 237, 234, 236, 235, 236, 236, 246, 237, 244, 235, 232, 236, 237, 245, 235, 237, 233, 234, 236, 232, 234, 235, 232, 235, 236, 245, 236, 236, 246, 233, 234, 237, 236, 236, 246, 234, 233, 246, 246, 244, 235, 244, 234, 244, 237, 246, 235, 237, 234, 237, 236, 236, 232, 245, 246, 233, 233, 234, 235, 236, 236, 233, 236, 245, 232, 237, 236, 232, 233, 232, 236, 245, 236, 237, 237, 234, 244, 232, 235, 236, 246, 246, 233, 236, 235, 245, 244, 245, 233, 234, 237, 236, 236, 245, 245, 233, 236, 244, 232, 244, 244, 233, 246, 233, 233, 237, 233, 246, 244, 234, 235, 245, 232, 234, 232, 234, 237, 236, 234, 246, 245, 245, 233, 244, 233, 232, 245, 245, 245, 233, 234, 246, 232, 244, 246, 246, 237, 246, 232, 234, 236, 236, 233, 236, 244, 245, 244, 244, 234, 237, 237, 246, 234, 237, 246, 244, 235, 232, 232, 232, 245, 245, 236, 245, 245, 232, 235, 245, 244, 237, 246, 246, 235, 236, 232, 246, 233, 237, 245, 233, 244, 235, 245, 233, 236, 232, 234, 237, 235, 246, 232, 235, 232, 237, 233, 237, 234, 246, 244, 234, 236, 237, 235, 245, 233, 246, 237, 232, 244, 237, 236, 235, 237, 234, 245, 235, 246, 244, 233, 246, 233, 234, 236, 245, 246, 235, 237, 232, 246, 232, 244, 236, 236, 245, 233, 246, 232, 246, 235, 246, 237, 233, 233, 245, 234, 246, 237, 235, 237, 235, 232, 234, 244, 232, 246, 234, 232, 232, 232, 246, 233, 245, 233, 246, 244, 244, 244, 244, 234, 244, 235, 245, 244, 245, 244, 235, 245, 232, 234, 236, 232, 246, 232, 235, 236, 244, 233, 236, 245, 244, 233, 235, 237, 237, 246, 234, 245, 244, 245, 245, 234, 237, 235, 246, 233, 234, 245, 245, 244, 232, 235, 233, 244, 233, 232, 245, 246, 236, 234, 235, 236, 246, 245, 246, 244, 246, 234, 237, 233, 246, 235, 235, 236, 235, 236, 236, 245, 234, 234, 244, 246, 246, 245, 237, 234, 244, 244, 236, 237, 237, 233, 236, 233, 244, 234, 246, 246, 234, 246, 232, 232, 237, 236, 235, 237, 234, 236, 232, 234, 234, 232, 234, 245, 234, 233, 244, 237, 232, 237, 237, 232, 232, 235, 235, 245, 244, 233, 232, 245], 7 | "height":30, 8 | "id":1, 9 | "name":"Grass", 10 | "opacity":1, 11 | "type":"tilelayer", 12 | "visible":true, 13 | "width":40, 14 | "x":0, 15 | "y":0 16 | }, 17 | { 18 | "data":[65, 65, 65, 108, 107, 107, 107, 107, 108, 106, 108, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 65, 65, 2, 86, 86, 86, 86, 86, 86, 86, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 108, 107, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 107, 107, 65, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 65, 2, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 107, 65, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 108, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 106, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 107, 108, 23, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 107, 107, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 108, 106, 106, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 65, 65, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 106, 106, 106, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 107, 108, 106, 23, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 108, 108, 106, 108, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 108, 107, 106, 108, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 65, 108, 2, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 107, 65, 107, 23, 45, 0, 0, 0, 0, 0, 0, 0, 0, 43, 44, 44, 44, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 45, 106, 108, 65, 65, 23, 45, 0, 0, 0, 0, 0, 0, 43, 24, 107, 108, 106, 23, 44, 44, 44, 44, 44, 44, 44, 44, 44, 24, 65, 108, 106, 108, 65, 106, 108, 108, 108, 107, 65, 23, 65, 108, 106, 65, 65, 66, 0, 0, 0, 0, 0, 0, 64, 106, 106, 107, 108, 107, 108, 107, 106, 65, 65, 106, 108, 65, 106, 65, 108, 2, 86, 86, 86, 86, 86, 86, 86, 3, 106, 107, 108, 106, 108, 106, 107, 66, 0, 0, 0, 0, 0, 0, 64, 65, 106, 107, 108, 106, 65, 106, 65, 106, 107, 106, 106, 107, 108, 107, 106, 23, 44, 44, 44, 44, 44, 44, 44, 24, 65, 107, 65, 106, 65, 65, 65, 66, 0, 0, 0, 0, 0, 0, 64, 108, 106, 108, 107, 108, 106, 106, 106, 108, 65, 108, 108, 108, 108, 65, 106, 108, 108, 65, 106, 65, 107, 106, 106, 65, 106, 65, 106, 107, 107, 65, 106, 66, 0, 0, 0, 0, 0, 0, 85, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 108, 106, 108, 108, 107, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 108, 65, 107, 107, 108, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 106, 65, 108, 107, 65, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 106, 108, 108, 107, 108, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 106, 108, 106, 108, 106, 23, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 45, 43, 44, 44, 44, 44, 44, 44, 44, 44, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 106, 108, 106, 107, 108, 107, 108, 106, 65, 107, 65, 106, 106, 106, 106, 65, 108, 23, 24, 65, 107, 108, 106, 108, 107, 65, 65, 23, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 108, 106, 65, 107, 65, 106, 65, 106, 108, 106, 65, 106, 106, 106, 107, 106, 65, 106, 106, 65, 106, 106, 107, 65, 108, 106, 65, 106, 108, 106, 107, 106, 108, 107, 108, 106, 107, 108, 65, 107], 19 | "height":30, 20 | "id":4, 21 | "name":"lightRock", 22 | "opacity":1, 23 | "type":"tilelayer", 24 | "visible":true, 25 | "width":40, 26 | "x":0, 27 | "y":0 28 | }, 29 | { 30 | "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 175, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 177, 49, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 196, 239, 239, 197, 239, 238, 239, 197, 240, 238, 238, 239, 239, 198, 70, 112, 113, 114, 71, 71, 112, 113, 71, 112, 112, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 196, 238, 197, 239, 239, 240, 197, 239, 238, 197, 239, 239, 240, 198, 70, 114, 71, 71, 114, 114, 112, 112, 114, 71, 112, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 196, 239, 239, 238, 238, 197, 239, 240, 197, 239, 197, 240, 197, 198, 70, 114, 114, 114, 71, 114, 114, 71, 114, 114, 113, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 196, 197, 197, 240, 197, 238, 238, 197, 240, 240, 239, 239, 197, 198, 70, 112, 113, 114, 112, 112, 113, 71, 114, 114, 112, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 196, 238, 238, 240, 240, 240, 240, 239, 239, 239, 240, 240, 238, 198, 70, 113, 113, 113, 113, 114, 114, 71, 114, 71, 114, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 196, 240, 197, 197, 238, 239, 197, 240, 239, 238, 238, 238, 239, 198, 70, 113, 114, 114, 71, 71, 114, 113, 71, 112, 112, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 196, 238, 197, 240, 197, 239, 239, 238, 239, 238, 240, 239, 239, 198, 70, 71, 113, 71, 114, 114, 114, 114, 71, 113, 114, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 196, 239, 240, 197, 197, 197, 238, 238, 240, 240, 240, 239, 240, 198, 70, 113, 112, 112, 114, 113, 114, 113, 114, 113, 71, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 196, 197, 197, 240, 238, 239, 239, 197, 240, 197, 239, 240, 239, 198, 70, 113, 71, 71, 113, 112, 71, 114, 71, 114, 112, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 196, 238, 239, 240, 197, 238, 197, 197, 238, 197, 197, 238, 197, 198, 70, 114, 113, 113, 112, 71, 114, 112, 113, 112, 71, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 217, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 219, 91, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 93, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 31 | "height":30, 32 | "id":2, 33 | "name":"Grass 2", 34 | "opacity":1, 35 | "type":"tilelayer", 36 | "visible":true, 37 | "width":40, 38 | "x":0, 39 | "y":0 40 | }, 41 | { 42 | "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 125, 124, 126, 126, 124, 126, 125, 126, 124, 124, 126, 124, 124, 125, 126, 126, 124, 125, 124, 124, 125, 126, 126, 125, 125, 126, 124, 126, 126, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 126, 125, 126, 126, 125, 126, 126, 125, 126, 124, 124, 125, 124, 124, 124, 126, 125, 124, 126, 125, 125, 124, 125, 126, 125, 124, 125, 125, 126, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 125, 126, 125, 124, 124, 124, 124, 126, 126, 124, 125, 124, 124, 124, 126, 124, 126, 124, 124, 124, 125, 124, 125, 126, 124, 126, 125, 124, 124, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 125, 20, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 21, 125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 126, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 124, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 124, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 124, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 124, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 125, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 125, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 126, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 126, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 124, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 124, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 124, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 125, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 125, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 126, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 126, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 124, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 124, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 125, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 125, 41, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 42, 126, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 124, 125, 124, 124, 124, 126, 124, 126, 124, 125, 124, 124, 124, 125, 125, 126, 126, 124, 125, 125, 126, 126, 125, 124, 125, 126, 126, 126, 124, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 125, 20, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 124, 84, 0, 52, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 125, 84, 0, 73, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 125, 84, 0, 94, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 126, 41, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 125, 125, 126, 125, 125, 126, 125, 126, 125, 126, 124, 126, 124, 125, 124, 124, 126, 124, 124, 126, 125, 125, 125, 125, 126, 126, 126, 125, 124, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 103, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 43 | "height":30, 44 | "id":3, 45 | "name":"Hole", 46 | "opacity":1, 47 | "type":"tilelayer", 48 | "visible":true, 49 | "width":40, 50 | "x":0, 51 | "y":0 52 | }], 53 | "nextlayerid":5, 54 | "nextobjectid":1, 55 | "orientation":"orthogonal", 56 | "renderorder":"right-down", 57 | "tiledversion":"1.2.3", 58 | "tileheight":32, 59 | "tilesets":[ 60 | { 61 | "firstgid":1, 62 | "source":"terrain.tsx" 63 | }], 64 | "tilewidth":32, 65 | "type":"map", 66 | "version":1.2, 67 | "width":40 68 | } -------------------------------------------------------------------------------- /GameSFML/Data/Json/map20x20.json: -------------------------------------------------------------------------------- 1 | { "height":20, 2 | "infinite":false, 3 | "layers":[ 4 | { 5 | "data":[244, 256, 255, 245, 252, 255, 255, 248, 245, 255, 257, 256, 256, 255, 256, 257, 245, 243, 245, 253, 247, 248, 257, 247, 245, 244, 243, 256, 257, 245, 247, 256, 243, 244, 243, 255, 252, 256, 246, 246, 256, 255, 243, 247, 244, 243, 256, 257, 255, 256, 248, 246, 246, 248, 243, 256, 253, 247, 245, 246, 252, 253, 244, 247, 244, 255, 243, 255, 243, 243, 253, 245, 244, 256, 248, 244, 244, 247, 253, 256, 253, 255, 256, 248, 248, 255, 252, 243, 245, 244, 253, 245, 252, 245, 256, 244, 256, 244, 245, 246, 247, 246, 243, 252, 243, 246, 255, 244, 248, 246, 257, 244, 244, 255, 256, 253, 253, 255, 245, 247, 255, 246, 253, 245, 246, 245, 245, 257, 247, 243, 247, 255, 257, 256, 257, 253, 248, 247, 246, 247, 244, 247, 244, 244, 246, 252, 256, 243, 256, 243, 253, 255, 256, 245, 243, 248, 256, 246, 244, 245, 245, 256, 247, 244, 246, 255, 253, 255, 243, 253, 257, 255, 246, 244, 246, 244, 243, 256, 243, 248, 252, 248, 245, 252, 243, 252, 252, 253, 255, 252, 255, 246, 243, 247, 257, 246, 257, 255, 253, 256, 252, 244, 256, 253, 257, 246, 245, 244, 252, 245, 244, 244, 243, 246, 244, 256, 256, 255, 247, 253, 247, 252, 248, 247, 256, 253, 257, 252, 257, 252, 243, 253, 252, 256, 255, 247, 256, 243, 247, 256, 253, 243, 257, 256, 256, 243, 246, 245, 247, 247, 252, 256, 252, 255, 243, 243, 243, 247, 245, 246, 252, 252, 243, 243, 245, 253, 243, 245, 244, 257, 245, 255, 257, 245, 253, 248, 255, 245, 247, 248, 256, 255, 255, 243, 248, 243, 246, 247, 245, 244, 257, 253, 257, 253, 252, 257, 252, 256, 247, 243, 253, 252, 248, 244, 244, 257, 243, 245, 245, 247, 257, 247, 243, 252, 245, 257, 246, 246, 247, 252, 256, 246, 246, 252, 244, 253, 255, 248, 244, 248, 244, 256, 253, 256, 247, 253, 257, 245, 247, 244, 248, 257, 248, 248, 255, 244, 256, 248, 246, 252, 248, 243, 253, 243, 245, 252, 257, 252, 244, 256, 243, 252, 244, 243, 256, 256, 256, 244, 247, 247, 243, 256, 255, 245, 246, 244, 256, 256, 244, 253, 255, 255, 255, 248, 248, 257, 255, 255, 246, 248, 244, 243, 257, 247, 248, 253, 253, 244, 255, 248], 6 | "height":20, 7 | "id":1, 8 | "name":"Grass", 9 | "opacity":1, 10 | "type":"tilelayer", 11 | "visible":true, 12 | "width":20, 13 | "x":0, 14 | "y":0 15 | }, 16 | { 17 | "data":[112, 111, 111, 112, 113, 112, 111, 111, 113, 111, 68, 111, 113, 111, 112, 111, 111, 111, 113, 112, 68, 2, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 3, 113, 111, 69, 0, 0, 0, 0, 0, 0, 0, 195, 196, 196, 196, 196, 196, 197, 0, 0, 67, 111, 111, 69, 0, 0, 0, 0, 0, 0, 0, 217, 218, 218, 218, 218, 218, 219, 0, 45, 25, 111, 111, 69, 0, 0, 0, 0, 0, 0, 0, 217, 218, 218, 218, 218, 218, 219, 0, 67, 111, 111, 113, 69, 0, 0, 0, 0, 0, 0, 0, 217, 218, 218, 218, 218, 218, 219, 0, 67, 68, 68, 112, 69, 0, 0, 0, 0, 0, 0, 0, 217, 218, 218, 218, 218, 218, 219, 0, 67, 111, 112, 68, 69, 0, 0, 0, 0, 0, 0, 0, 217, 218, 218, 218, 218, 218, 219, 0, 67, 112, 111, 68, 69, 0, 0, 0, 0, 0, 0, 0, 239, 240, 240, 240, 240, 240, 241, 0, 67, 68, 68, 111, 69, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 111, 68, 68, 69, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 111, 113, 113, 69, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 113, 112, 68, 69, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 89, 3, 111, 111, 69, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 68, 112, 69, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 112, 112, 69, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 111, 68, 69, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 113, 113, 69, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 113, 68, 24, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 25, 111, 113, 112, 112, 112, 113, 68, 111, 112, 111, 68, 113, 113, 68, 113, 68, 112, 111, 112, 112, 68], 18 | "height":20, 19 | "id":2, 20 | "name":"Dust", 21 | "opacity":1, 22 | "type":"tilelayer", 23 | "visible":true, 24 | "width":20, 25 | "x":0, 26 | "y":0 27 | }, 28 | { 29 | "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 63, 64, 64, 64, 64, 64, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 85, 131, 86, 129, 130, 131, 87, 0, 0, 0, 0, 0, 0, 0, 0, 183, 184, 185, 0, 0, 85, 86, 129, 129, 130, 86, 87, 0, 0, 439, 502, 502, 502, 439, 0, 205, 249, 207, 0, 0, 85, 131, 130, 130, 131, 131, 87, 0, 0, 502, 502, 502, 502, 502, 0, 205, 250, 207, 0, 0, 85, 86, 131, 129, 86, 86, 87, 0, 0, 502, 502, 502, 502, 502, 0, 205, 250, 207, 0, 0, 85, 131, 129, 131, 130, 129, 87, 0, 0, 502, 502, 502, 502, 502, 0, 205, 249, 207, 0, 0, 107, 108, 108, 108, 108, 108, 109, 0, 0, 460, 502, 502, 502, 460, 0, 205, 206, 207, 0, 0, 0, 0, 0, 0, 0, 0, 438, 0, 0, 0, 0, 0, 0, 0, 0, 205, 249, 207, 0, 0, 0, 439, 439, 0, 0, 0, 0, 438, 0, 0, 0, 0, 0, 460, 460, 205, 250, 207, 0, 0, 0, 439, 439, 0, 0, 0, 0, 0, 0, 438, 0, 0, 0, 460, 460, 205, 249, 207, 0, 183, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 163, 206, 207, 0, 205, 250, 251, 251, 249, 206, 249, 206, 206, 249, 249, 251, 249, 206, 251, 250, 250, 250, 207, 0, 227, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 141, 249, 251, 251, 207, 0, 0, 0, 0, 0, 0, 0, 0, 51, 52, 52, 52, 52, 53, 0, 205, 251, 251, 251, 207, 0, 0, 0, 0, 0, 0, 0, 0, 73, 74, 117, 118, 119, 75, 0, 205, 206, 251, 249, 207, 0, 0, 0, 0, 0, 0, 0, 0, 73, 117, 74, 118, 117, 75, 0, 205, 206, 206, 251, 207, 0, 0, 0, 0, 0, 0, 0, 0, 73, 119, 118, 74, 74, 75, 0, 205, 251, 249, 250, 207, 0, 0, 0, 0, 0, 0, 0, 0, 73, 74, 119, 118, 118, 75, 0, 205, 250, 206, 206, 207, 0, 0, 0, 0, 0, 0, 0, 0, 95, 96, 96, 96, 96, 97, 0, 227, 228, 228, 228, 229, 0], 30 | "height":20, 31 | "id":3, 32 | "name":"TileObject", 33 | "opacity":1, 34 | "type":"tilelayer", 35 | "visible":true, 36 | "width":20, 37 | "x":0, 38 | "y":0 39 | }, 40 | { 41 | "draworder":"topdown", 42 | "id":11, 43 | "name":"Collision", 44 | "objects":[ 45 | { 46 | "height":160, 47 | "id":1, 48 | "name":"", 49 | "rotation":0, 50 | "type":"", 51 | "visible":true, 52 | "width":160, 53 | "x":320, 54 | "y":95.5 55 | }, 56 | { 57 | "height":64, 58 | "id":2, 59 | "name":"", 60 | "rotation":0, 61 | "type":"", 62 | "visible":true, 63 | "width":64, 64 | "x":64, 65 | "y":288 66 | }, 67 | { 68 | "height":64, 69 | "id":3, 70 | "name":"", 71 | "rotation":0, 72 | "type":"", 73 | "visible":true, 74 | "width":64, 75 | "x":448, 76 | "y":288 77 | }, 78 | { 79 | "height":199.333333333333, 80 | "id":4, 81 | "name":"", 82 | "rotation":0, 83 | "type":"", 84 | "visible":true, 85 | "width":200.666666666667, 86 | "x":46, 87 | "y":44.6666666666667 88 | }], 89 | "opacity":1, 90 | "type":"objectgroup", 91 | "visible":true, 92 | "x":0, 93 | "y":0 94 | }], 95 | "nextlayerid":12, 96 | "nextobjectid":5, 97 | "orientation":"orthogonal", 98 | "renderorder":"right-down", 99 | "tiledversion":"1.2.3", 100 | "tileheight":32, 101 | "tilesets":[ 102 | { 103 | "columns":22, 104 | "firstgid":1, 105 | "image":"terrain.png", 106 | "imageheight":768, 107 | "imagewidth":704, 108 | "margin":0, 109 | "name":"terrain", 110 | "spacing":0, 111 | "terrains":[ 112 | { 113 | "name":"LightDust", 114 | "tile":67 115 | }, 116 | { 117 | "name":"MediumDust", 118 | "tile":70 119 | }, 120 | { 121 | "name":"DarkDust", 122 | "tile":73 123 | }, 124 | { 125 | "name":"BlackDust", 126 | "tile":343 127 | }, 128 | { 129 | "name":"LightGrass", 130 | "tile":199 131 | }, 132 | { 133 | "name":"MediumGrass", 134 | "tile":202 135 | }, 136 | { 137 | "name":"DarkGrass", 138 | "tile":205 139 | }, 140 | { 141 | "name":"LightBush", 142 | "tile":208 143 | }, 144 | { 145 | "name":"MediumBush", 146 | "tile":211 147 | }, 148 | { 149 | "name":"DarkBush", 150 | "tile":214 151 | }, 152 | { 153 | "name":"Farm", 154 | "tile":217 155 | }, 156 | { 157 | "name":"Sand", 158 | "tile":331 159 | }, 160 | { 161 | "name":"SandWater", 162 | "tile":334 163 | }, 164 | { 165 | "name":"Larva", 166 | "tile":340 167 | }, 168 | { 169 | "name":"Swarm", 170 | "tile":346 171 | }, 172 | { 173 | "name":"Concrete", 174 | "tile":349 175 | }], 176 | "tilecount":528, 177 | "tileheight":32, 178 | "tiles":[ 179 | { 180 | "id":1, 181 | "terrain":[0, 0, 0, -1] 182 | }, 183 | { 184 | "id":2, 185 | "terrain":[0, 0, -1, 0] 186 | }, 187 | { 188 | "id":4, 189 | "terrain":[1, 1, 1, -1] 190 | }, 191 | { 192 | "id":5, 193 | "terrain":[1, 1, -1, 1] 194 | }, 195 | { 196 | "id":7, 197 | "terrain":[2, 2, 2, -1] 198 | }, 199 | { 200 | "id":8, 201 | "terrain":[2, 2, -1, 2] 202 | }, 203 | { 204 | "id":23, 205 | "terrain":[0, -1, 0, 0] 206 | }, 207 | { 208 | "id":24, 209 | "terrain":[-1, 0, 0, 0] 210 | }, 211 | { 212 | "id":26, 213 | "terrain":[1, -1, 1, 1] 214 | }, 215 | { 216 | "id":27, 217 | "terrain":[-1, 1, 1, 1] 218 | }, 219 | { 220 | "id":29, 221 | "terrain":[2, -1, 2, 2] 222 | }, 223 | { 224 | "id":30, 225 | "terrain":[-1, 2, 2, 2] 226 | }, 227 | { 228 | "id":44, 229 | "terrain":[-1, -1, -1, 0] 230 | }, 231 | { 232 | "id":45, 233 | "terrain":[-1, -1, 0, 0] 234 | }, 235 | { 236 | "id":46, 237 | "terrain":[-1, -1, 0, -1] 238 | }, 239 | { 240 | "id":47, 241 | "terrain":[-1, -1, -1, 1] 242 | }, 243 | { 244 | "id":48, 245 | "terrain":[-1, -1, 1, 1] 246 | }, 247 | { 248 | "id":49, 249 | "terrain":[-1, -1, 1, -1] 250 | }, 251 | { 252 | "id":50, 253 | "terrain":[-1, -1, -1, 2] 254 | }, 255 | { 256 | "id":51, 257 | "terrain":[-1, -1, 2, 2] 258 | }, 259 | { 260 | "id":52, 261 | "terrain":[-1, -1, 2, -1] 262 | }, 263 | { 264 | "id":66, 265 | "terrain":[-1, 0, -1, 0] 266 | }, 267 | { 268 | "id":67, 269 | "terrain":[0, 0, 0, 0] 270 | }, 271 | { 272 | "id":68, 273 | "terrain":[0, -1, 0, -1] 274 | }, 275 | { 276 | "id":69, 277 | "terrain":[-1, 1, -1, 1] 278 | }, 279 | { 280 | "id":70, 281 | "terrain":[1, 1, 1, 1] 282 | }, 283 | { 284 | "id":71, 285 | "terrain":[1, -1, 1, -1] 286 | }, 287 | { 288 | "id":72, 289 | "terrain":[-1, 2, -1, 2] 290 | }, 291 | { 292 | "id":73, 293 | "terrain":[2, 2, 2, 2] 294 | }, 295 | { 296 | "id":74, 297 | "terrain":[2, -1, 2, -1] 298 | }, 299 | { 300 | "id":88, 301 | "terrain":[-1, 0, -1, -1] 302 | }, 303 | { 304 | "id":89, 305 | "terrain":[0, 0, -1, -1] 306 | }, 307 | { 308 | "id":90, 309 | "terrain":[0, -1, -1, -1] 310 | }, 311 | { 312 | "id":91, 313 | "terrain":[-1, 1, -1, -1] 314 | }, 315 | { 316 | "id":92, 317 | "terrain":[1, 1, -1, -1] 318 | }, 319 | { 320 | "id":93, 321 | "terrain":[1, -1, -1, -1] 322 | }, 323 | { 324 | "id":94, 325 | "terrain":[-1, 2, -1, -1] 326 | }, 327 | { 328 | "id":95, 329 | "terrain":[2, 2, -1, -1] 330 | }, 331 | { 332 | "id":96, 333 | "terrain":[2, -1, -1, -1] 334 | }, 335 | { 336 | "id":110, 337 | "terrain":[0, 0, 0, 0] 338 | }, 339 | { 340 | "id":111, 341 | "terrain":[0, 0, 0, 0] 342 | }, 343 | { 344 | "id":112, 345 | "terrain":[0, 0, 0, 0] 346 | }, 347 | { 348 | "id":113, 349 | "terrain":[1, 1, 1, 1] 350 | }, 351 | { 352 | "id":114, 353 | "terrain":[1, 1, 1, 1] 354 | }, 355 | { 356 | "id":115, 357 | "terrain":[1, 1, 1, 1] 358 | }, 359 | { 360 | "id":116, 361 | "terrain":[2, 2, 2, 2] 362 | }, 363 | { 364 | "id":117, 365 | "terrain":[2, 2, 2, 2] 366 | }, 367 | { 368 | "id":118, 369 | "terrain":[2, 2, 2, 2] 370 | }, 371 | { 372 | "id":133, 373 | "terrain":[4, 4, 4, -1] 374 | }, 375 | { 376 | "id":134, 377 | "terrain":[4, 4, -1, 4] 378 | }, 379 | { 380 | "id":136, 381 | "terrain":[5, 5, 5, -1] 382 | }, 383 | { 384 | "id":137, 385 | "terrain":[5, 5, -1, 5] 386 | }, 387 | { 388 | "id":139, 389 | "terrain":[6, 6, 6, -1] 390 | }, 391 | { 392 | "id":140, 393 | "terrain":[6, 6, -1, 6] 394 | }, 395 | { 396 | "id":142, 397 | "terrain":[7, 7, 7, -1] 398 | }, 399 | { 400 | "id":143, 401 | "terrain":[7, 7, -1, 7] 402 | }, 403 | { 404 | "id":144, 405 | "objectgroup": 406 | { 407 | "draworder":"index", 408 | "name":"", 409 | "objects":[ 410 | { 411 | "height":19.25, 412 | "id":1, 413 | "name":"", 414 | "rotation":0, 415 | "type":"", 416 | "visible":true, 417 | "width":29.5, 418 | "x":1, 419 | "y":12.75 420 | }], 421 | "opacity":1, 422 | "type":"objectgroup", 423 | "visible":true, 424 | "x":0, 425 | "y":0 426 | } 427 | }, 428 | { 429 | "id":145, 430 | "terrain":[8, 8, 8, -1] 431 | }, 432 | { 433 | "id":146, 434 | "terrain":[8, 8, -1, 8] 435 | }, 436 | { 437 | "id":147, 438 | "objectgroup": 439 | { 440 | "draworder":"index", 441 | "name":"", 442 | "objects":[ 443 | { 444 | "height":15.5, 445 | "id":1, 446 | "name":"", 447 | "rotation":0, 448 | "type":"", 449 | "visible":true, 450 | "width":31, 451 | "x":0.5, 452 | "y":16.25 453 | }], 454 | "opacity":1, 455 | "type":"objectgroup", 456 | "visible":true, 457 | "x":0, 458 | "y":0 459 | } 460 | }, 461 | { 462 | "id":148, 463 | "terrain":[9, 9, 9, -1] 464 | }, 465 | { 466 | "id":149, 467 | "terrain":[9, 9, -1, 9] 468 | }, 469 | { 470 | "id":151, 471 | "terrain":[10, 10, 10, -1] 472 | }, 473 | { 474 | "id":152, 475 | "terrain":[10, 10, -1, 10] 476 | }, 477 | { 478 | "id":155, 479 | "terrain":[4, -1, 4, 4] 480 | }, 481 | { 482 | "id":156, 483 | "terrain":[-1, 4, 4, 4] 484 | }, 485 | { 486 | "id":157, 487 | "objectgroup": 488 | { 489 | "draworder":"index", 490 | "name":"", 491 | "objects":[ 492 | { 493 | "height":28, 494 | "id":3, 495 | "name":"", 496 | "rotation":0, 497 | "type":"", 498 | "visible":true, 499 | "width":32, 500 | "x":0, 501 | "y":4 502 | }], 503 | "opacity":1, 504 | "type":"objectgroup", 505 | "visible":true, 506 | "x":0, 507 | "y":0 508 | } 509 | }, 510 | { 511 | "id":158, 512 | "terrain":[5, -1, 5, 5] 513 | }, 514 | { 515 | "id":159, 516 | "terrain":[-1, 5, 5, 5] 517 | }, 518 | { 519 | "id":161, 520 | "terrain":[6, -1, 6, 6] 521 | }, 522 | { 523 | "id":162, 524 | "terrain":[-1, 6, 6, 6] 525 | }, 526 | { 527 | "id":163, 528 | "objectgroup": 529 | { 530 | "draworder":"index", 531 | "name":"", 532 | "objects":[ 533 | { 534 | "height":32, 535 | "id":1, 536 | "name":"", 537 | "rotation":0, 538 | "type":"", 539 | "visible":true, 540 | "width":32, 541 | "x":0, 542 | "y":0 543 | }], 544 | "opacity":1, 545 | "type":"objectgroup", 546 | "visible":true, 547 | "x":0, 548 | "y":0 549 | } 550 | }, 551 | { 552 | "id":164, 553 | "terrain":[7, -1, 7, 7] 554 | }, 555 | { 556 | "id":165, 557 | "terrain":[-1, 7, 7, 7] 558 | }, 559 | { 560 | "id":166, 561 | "objectgroup": 562 | { 563 | "draworder":"index", 564 | "name":"", 565 | "objects":[ 566 | { 567 | "height":32, 568 | "id":1, 569 | "name":"", 570 | "rotation":0, 571 | "type":"", 572 | "visible":true, 573 | "width":32, 574 | "x":0, 575 | "y":0 576 | }], 577 | "opacity":1, 578 | "type":"objectgroup", 579 | "visible":true, 580 | "x":0, 581 | "y":0 582 | } 583 | }, 584 | { 585 | "id":167, 586 | "terrain":[8, -1, 8, 8] 587 | }, 588 | { 589 | "id":168, 590 | "terrain":[-1, 8, 8, 8] 591 | }, 592 | { 593 | "id":169, 594 | "objectgroup": 595 | { 596 | "draworder":"index", 597 | "name":"", 598 | "objects":[ 599 | { 600 | "height":32, 601 | "id":1, 602 | "name":"", 603 | "rotation":0, 604 | "type":"", 605 | "visible":true, 606 | "width":32, 607 | "x":0, 608 | "y":0 609 | }], 610 | "opacity":1, 611 | "type":"objectgroup", 612 | "visible":true, 613 | "x":0, 614 | "y":0 615 | } 616 | }, 617 | { 618 | "id":170, 619 | "terrain":[9, -1, 9, 9] 620 | }, 621 | { 622 | "id":171, 623 | "terrain":[-1, 9, 9, 9] 624 | }, 625 | { 626 | "id":173, 627 | "terrain":[10, -1, 10, 10] 628 | }, 629 | { 630 | "id":174, 631 | "terrain":[-1, 10, 10, 10] 632 | }, 633 | { 634 | "id":176, 635 | "terrain":[-1, -1, -1, 4] 636 | }, 637 | { 638 | "id":177, 639 | "terrain":[-1, -1, 4, 4] 640 | }, 641 | { 642 | "id":178, 643 | "terrain":[-1, -1, 4, -1] 644 | }, 645 | { 646 | "id":179, 647 | "terrain":[-1, -1, -1, 5] 648 | }, 649 | { 650 | "id":180, 651 | "terrain":[-1, -1, 5, 5] 652 | }, 653 | { 654 | "id":181, 655 | "terrain":[-1, -1, 5, -1] 656 | }, 657 | { 658 | "id":182, 659 | "terrain":[-1, -1, -1, 6] 660 | }, 661 | { 662 | "id":183, 663 | "terrain":[-1, -1, 6, 6] 664 | }, 665 | { 666 | "id":184, 667 | "terrain":[-1, -1, 6, -1] 668 | }, 669 | { 670 | "id":185, 671 | "terrain":[-1, -1, -1, 7] 672 | }, 673 | { 674 | "id":186, 675 | "terrain":[-1, -1, 7, 7] 676 | }, 677 | { 678 | "id":187, 679 | "terrain":[-1, -1, 7, -1] 680 | }, 681 | { 682 | "id":188, 683 | "terrain":[-1, -1, -1, 8] 684 | }, 685 | { 686 | "id":189, 687 | "terrain":[-1, -1, 8, 8] 688 | }, 689 | { 690 | "id":190, 691 | "terrain":[-1, -1, 8, -1] 692 | }, 693 | { 694 | "id":191, 695 | "terrain":[-1, -1, -1, 9] 696 | }, 697 | { 698 | "id":192, 699 | "terrain":[-1, -1, 9, 9] 700 | }, 701 | { 702 | "id":193, 703 | "terrain":[-1, -1, 9, -1] 704 | }, 705 | { 706 | "id":194, 707 | "terrain":[-1, -1, -1, 10] 708 | }, 709 | { 710 | "id":195, 711 | "terrain":[-1, -1, 10, 10] 712 | }, 713 | { 714 | "id":196, 715 | "terrain":[-1, -1, 10, -1] 716 | }, 717 | { 718 | "id":198, 719 | "terrain":[-1, 4, -1, 4] 720 | }, 721 | { 722 | "id":199, 723 | "terrain":[4, 4, 4, 4] 724 | }, 725 | { 726 | "id":200, 727 | "terrain":[4, -1, 4, -1] 728 | }, 729 | { 730 | "id":201, 731 | "terrain":[-1, 5, -1, 5] 732 | }, 733 | { 734 | "id":202, 735 | "terrain":[5, 5, 5, 5] 736 | }, 737 | { 738 | "id":203, 739 | "terrain":[5, -1, 5, -1] 740 | }, 741 | { 742 | "id":204, 743 | "terrain":[-1, 6, -1, 6] 744 | }, 745 | { 746 | "id":205, 747 | "terrain":[6, 6, 6, 6] 748 | }, 749 | { 750 | "id":206, 751 | "terrain":[6, -1, 6, -1] 752 | }, 753 | { 754 | "id":207, 755 | "terrain":[-1, 7, -1, 7] 756 | }, 757 | { 758 | "id":208, 759 | "terrain":[7, 7, 7, 7] 760 | }, 761 | { 762 | "id":209, 763 | "terrain":[7, -1, 7, -1] 764 | }, 765 | { 766 | "id":210, 767 | "terrain":[-1, 8, -1, 8] 768 | }, 769 | { 770 | "id":211, 771 | "terrain":[8, 8, 8, 8] 772 | }, 773 | { 774 | "id":212, 775 | "terrain":[8, -1, 8, -1] 776 | }, 777 | { 778 | "id":213, 779 | "terrain":[-1, 9, -1, 9] 780 | }, 781 | { 782 | "id":214, 783 | "terrain":[9, 9, 9, 9] 784 | }, 785 | { 786 | "id":215, 787 | "terrain":[9, -1, 9, -1] 788 | }, 789 | { 790 | "id":216, 791 | "terrain":[-1, 10, -1, 10] 792 | }, 793 | { 794 | "id":217, 795 | "terrain":[10, 10, 10, 10] 796 | }, 797 | { 798 | "id":218, 799 | "terrain":[10, -1, 10, -1] 800 | }, 801 | { 802 | "id":220, 803 | "terrain":[-1, 4, -1, -1] 804 | }, 805 | { 806 | "id":221, 807 | "terrain":[4, 4, -1, -1] 808 | }, 809 | { 810 | "id":222, 811 | "terrain":[4, -1, -1, -1] 812 | }, 813 | { 814 | "id":223, 815 | "terrain":[-1, 5, -1, -1] 816 | }, 817 | { 818 | "id":224, 819 | "terrain":[5, 5, -1, -1] 820 | }, 821 | { 822 | "id":225, 823 | "terrain":[5, -1, -1, -1] 824 | }, 825 | { 826 | "id":226, 827 | "terrain":[-1, 6, -1, -1] 828 | }, 829 | { 830 | "id":227, 831 | "terrain":[6, 6, -1, -1] 832 | }, 833 | { 834 | "id":228, 835 | "terrain":[6, -1, -1, -1] 836 | }, 837 | { 838 | "id":229, 839 | "terrain":[-1, 7, -1, -1] 840 | }, 841 | { 842 | "id":230, 843 | "terrain":[7, 7, -1, -1] 844 | }, 845 | { 846 | "id":231, 847 | "terrain":[7, -1, -1, -1] 848 | }, 849 | { 850 | "id":232, 851 | "terrain":[-1, 8, -1, -1] 852 | }, 853 | { 854 | "id":233, 855 | "terrain":[8, 8, -1, -1] 856 | }, 857 | { 858 | "id":234, 859 | "terrain":[8, -1, -1, -1] 860 | }, 861 | { 862 | "id":235, 863 | "terrain":[-1, 9, -1, -1] 864 | }, 865 | { 866 | "id":236, 867 | "terrain":[9, 9, -1, -1] 868 | }, 869 | { 870 | "id":237, 871 | "terrain":[9, -1, -1, -1] 872 | }, 873 | { 874 | "id":238, 875 | "terrain":[-1, 10, -1, -1] 876 | }, 877 | { 878 | "id":239, 879 | "terrain":[10, 10, -1, -1] 880 | }, 881 | { 882 | "id":240, 883 | "terrain":[10, -1, -1, -1] 884 | }, 885 | { 886 | "id":242, 887 | "terrain":[4, 4, 4, 4] 888 | }, 889 | { 890 | "id":243, 891 | "terrain":[4, 4, 4, 4] 892 | }, 893 | { 894 | "id":244, 895 | "terrain":[4, 4, 4, 4] 896 | }, 897 | { 898 | "id":245, 899 | "terrain":[5, 5, 5, 5] 900 | }, 901 | { 902 | "id":246, 903 | "terrain":[5, 5, 5, 5] 904 | }, 905 | { 906 | "id":247, 907 | "terrain":[5, 5, 5, 5] 908 | }, 909 | { 910 | "id":248, 911 | "terrain":[6, 6, 6, 6] 912 | }, 913 | { 914 | "id":249, 915 | "terrain":[6, 6, 6, 6] 916 | }, 917 | { 918 | "id":250, 919 | "terrain":[6, 6, 6, 6] 920 | }, 921 | { 922 | "id":253, 923 | "terrain":[7, 7, 7, 7] 924 | }, 925 | { 926 | "id":257, 927 | "terrain":[7, 7, 7, 7] 928 | }, 929 | { 930 | "id":258, 931 | "terrain":[7, 7, 7, 7] 932 | }, 933 | { 934 | "id":259, 935 | "terrain":[7, 7, 7, 7] 936 | }, 937 | { 938 | "id":261, 939 | "terrain":[10, 10, 10, 10] 940 | }, 941 | { 942 | "id":262, 943 | "terrain":[10, 10, 10, 10] 944 | }, 945 | { 946 | "id":265, 947 | "terrain":[11, 11, 11, -1] 948 | }, 949 | { 950 | "id":266, 951 | "terrain":[11, 11, -1, 11] 952 | }, 953 | { 954 | "id":268, 955 | "terrain":[12, 12, 12, -1] 956 | }, 957 | { 958 | "id":269, 959 | "terrain":[12, 12, -1, 12] 960 | }, 961 | { 962 | "id":274, 963 | "terrain":[13, 13, 13, -1] 964 | }, 965 | { 966 | "id":275, 967 | "terrain":[13, 13, -1, 13] 968 | }, 969 | { 970 | "id":277, 971 | "terrain":[3, 3, 3, -1] 972 | }, 973 | { 974 | "id":278, 975 | "terrain":[3, 3, -1, 3] 976 | }, 977 | { 978 | "id":280, 979 | "terrain":[14, 14, 14, -1] 980 | }, 981 | { 982 | "id":281, 983 | "terrain":[14, 14, -1, 14] 984 | }, 985 | { 986 | "id":283, 987 | "terrain":[15, 15, 15, -1] 988 | }, 989 | { 990 | "id":284, 991 | "terrain":[15, 15, -1, 15] 992 | }, 993 | { 994 | "id":287, 995 | "terrain":[11, -1, 11, 11] 996 | }, 997 | { 998 | "id":288, 999 | "terrain":[-1, 11, 11, 11] 1000 | }, 1001 | { 1002 | "id":290, 1003 | "terrain":[12, -1, 12, 12] 1004 | }, 1005 | { 1006 | "id":291, 1007 | "terrain":[-1, 12, 12, 12] 1008 | }, 1009 | { 1010 | "id":296, 1011 | "terrain":[13, -1, 13, 13] 1012 | }, 1013 | { 1014 | "id":297, 1015 | "terrain":[-1, 13, 13, 13] 1016 | }, 1017 | { 1018 | "id":299, 1019 | "terrain":[3, -1, 3, 3] 1020 | }, 1021 | { 1022 | "id":300, 1023 | "terrain":[-1, 3, 3, 3] 1024 | }, 1025 | { 1026 | "id":302, 1027 | "terrain":[14, -1, 14, 14] 1028 | }, 1029 | { 1030 | "id":303, 1031 | "terrain":[-1, 14, 14, 14] 1032 | }, 1033 | { 1034 | "id":304, 1035 | "objectgroup": 1036 | { 1037 | "draworder":"index", 1038 | "name":"", 1039 | "objects":[ 1040 | { 1041 | "height":32, 1042 | "id":1, 1043 | "name":"", 1044 | "rotation":0, 1045 | "type":"", 1046 | "visible":true, 1047 | "width":32, 1048 | "x":0, 1049 | "y":0 1050 | }], 1051 | "opacity":1, 1052 | "type":"objectgroup", 1053 | "visible":true, 1054 | "x":0, 1055 | "y":0 1056 | } 1057 | }, 1058 | { 1059 | "id":305, 1060 | "terrain":[15, -1, 15, 15] 1061 | }, 1062 | { 1063 | "id":306, 1064 | "terrain":[-1, 15, 15, 15] 1065 | }, 1066 | { 1067 | "id":308, 1068 | "terrain":[-1, -1, -1, 11] 1069 | }, 1070 | { 1071 | "id":309, 1072 | "terrain":[-1, -1, 11, 11] 1073 | }, 1074 | { 1075 | "id":310, 1076 | "terrain":[-1, -1, 11, -1] 1077 | }, 1078 | { 1079 | "id":311, 1080 | "terrain":[-1, -1, -1, 12] 1081 | }, 1082 | { 1083 | "id":312, 1084 | "terrain":[-1, -1, 12, 12] 1085 | }, 1086 | { 1087 | "id":313, 1088 | "terrain":[-1, -1, 12, -1] 1089 | }, 1090 | { 1091 | "id":317, 1092 | "terrain":[-1, -1, -1, 13] 1093 | }, 1094 | { 1095 | "id":318, 1096 | "terrain":[-1, -1, 13, 13] 1097 | }, 1098 | { 1099 | "id":319, 1100 | "terrain":[-1, -1, 13, -1] 1101 | }, 1102 | { 1103 | "id":320, 1104 | "terrain":[-1, -1, -1, 3] 1105 | }, 1106 | { 1107 | "id":321, 1108 | "terrain":[-1, -1, 3, 3] 1109 | }, 1110 | { 1111 | "id":322, 1112 | "terrain":[-1, -1, 3, -1] 1113 | }, 1114 | { 1115 | "id":323, 1116 | "terrain":[-1, -1, -1, 14] 1117 | }, 1118 | { 1119 | "id":324, 1120 | "terrain":[-1, -1, 14, 14] 1121 | }, 1122 | { 1123 | "id":325, 1124 | "terrain":[-1, -1, 14, -1] 1125 | }, 1126 | { 1127 | "id":326, 1128 | "terrain":[-1, -1, -1, 15] 1129 | }, 1130 | { 1131 | "id":327, 1132 | "terrain":[-1, -1, 15, 15] 1133 | }, 1134 | { 1135 | "id":328, 1136 | "terrain":[-1, -1, 15, -1] 1137 | }, 1138 | { 1139 | "id":330, 1140 | "terrain":[-1, 11, -1, 11] 1141 | }, 1142 | { 1143 | "id":331, 1144 | "terrain":[11, 11, 11, 11] 1145 | }, 1146 | { 1147 | "id":332, 1148 | "terrain":[11, -1, 11, -1] 1149 | }, 1150 | { 1151 | "id":333, 1152 | "terrain":[-1, 12, -1, 12] 1153 | }, 1154 | { 1155 | "id":334, 1156 | "terrain":[12, 12, 12, 12] 1157 | }, 1158 | { 1159 | "id":335, 1160 | "terrain":[12, -1, 12, -1] 1161 | }, 1162 | { 1163 | "id":339, 1164 | "terrain":[-1, 13, -1, 13] 1165 | }, 1166 | { 1167 | "id":340, 1168 | "terrain":[13, 13, 13, 13] 1169 | }, 1170 | { 1171 | "id":341, 1172 | "terrain":[13, -1, 13, -1] 1173 | }, 1174 | { 1175 | "id":342, 1176 | "terrain":[-1, 3, -1, 3] 1177 | }, 1178 | { 1179 | "id":343, 1180 | "terrain":[3, 3, 3, 3] 1181 | }, 1182 | { 1183 | "id":344, 1184 | "terrain":[3, -1, 3, -1] 1185 | }, 1186 | { 1187 | "id":345, 1188 | "terrain":[-1, 14, -1, 14] 1189 | }, 1190 | { 1191 | "id":346, 1192 | "terrain":[14, 14, 14, 14] 1193 | }, 1194 | { 1195 | "id":347, 1196 | "terrain":[14, -1, 14, -1] 1197 | }, 1198 | { 1199 | "id":348, 1200 | "terrain":[-1, 15, -1, 15] 1201 | }, 1202 | { 1203 | "id":349, 1204 | "terrain":[15, 15, 15, 15] 1205 | }, 1206 | { 1207 | "id":350, 1208 | "terrain":[15, -1, 15, -1] 1209 | }, 1210 | { 1211 | "id":352, 1212 | "terrain":[-1, 11, -1, -1] 1213 | }, 1214 | { 1215 | "id":353, 1216 | "terrain":[11, 11, -1, -1] 1217 | }, 1218 | { 1219 | "id":354, 1220 | "terrain":[11, -1, -1, -1] 1221 | }, 1222 | { 1223 | "id":355, 1224 | "terrain":[-1, 12, -1, -1] 1225 | }, 1226 | { 1227 | "id":356, 1228 | "terrain":[12, 12, -1, -1] 1229 | }, 1230 | { 1231 | "id":357, 1232 | "terrain":[12, -1, -1, -1] 1233 | }, 1234 | { 1235 | "id":361, 1236 | "terrain":[-1, 13, -1, -1] 1237 | }, 1238 | { 1239 | "id":362, 1240 | "terrain":[13, 13, -1, -1] 1241 | }, 1242 | { 1243 | "id":363, 1244 | "terrain":[13, -1, -1, -1] 1245 | }, 1246 | { 1247 | "id":364, 1248 | "terrain":[-1, 3, -1, -1] 1249 | }, 1250 | { 1251 | "id":365, 1252 | "terrain":[3, 3, -1, -1] 1253 | }, 1254 | { 1255 | "id":366, 1256 | "terrain":[3, -1, -1, -1] 1257 | }, 1258 | { 1259 | "id":367, 1260 | "terrain":[-1, 14, -1, -1] 1261 | }, 1262 | { 1263 | "id":368, 1264 | "terrain":[14, 14, -1, -1] 1265 | }, 1266 | { 1267 | "id":369, 1268 | "terrain":[14, -1, -1, -1] 1269 | }, 1270 | { 1271 | "id":370, 1272 | "terrain":[-1, 15, -1, -1] 1273 | }, 1274 | { 1275 | "id":371, 1276 | "terrain":[15, 15, -1, -1] 1277 | }, 1278 | { 1279 | "id":372, 1280 | "terrain":[15, -1, -1, -1] 1281 | }, 1282 | { 1283 | "id":374, 1284 | "terrain":[12, 12, 12, 12] 1285 | }, 1286 | { 1287 | "id":375, 1288 | "terrain":[12, 12, 12, 12] 1289 | }, 1290 | { 1291 | "id":376, 1292 | "terrain":[12, 12, 12, 12] 1293 | }, 1294 | { 1295 | "id":383, 1296 | "terrain":[13, 13, 13, 13] 1297 | }, 1298 | { 1299 | "id":384, 1300 | "terrain":[13, 13, 13, 13] 1301 | }, 1302 | { 1303 | "id":385, 1304 | "terrain":[13, 13, 13, 13] 1305 | }, 1306 | { 1307 | "id":386, 1308 | "terrain":[3, 3, 3, 3] 1309 | }, 1310 | { 1311 | "id":387, 1312 | "terrain":[3, 3, 3, 3] 1313 | }, 1314 | { 1315 | "id":388, 1316 | "terrain":[3, 3, 3, 3] 1317 | }, 1318 | { 1319 | "id":389, 1320 | "terrain":[14, 14, 14, 14] 1321 | }, 1322 | { 1323 | "id":390, 1324 | "terrain":[14, 14, 14, 14] 1325 | }, 1326 | { 1327 | "id":391, 1328 | "terrain":[14, 14, 14, 14] 1329 | }, 1330 | { 1331 | "id":392, 1332 | "terrain":[15, 15, 15, 15] 1333 | }, 1334 | { 1335 | "id":393, 1336 | "terrain":[15, 15, 15, 15] 1337 | }, 1338 | { 1339 | "id":394, 1340 | "terrain":[15, 15, 15, 15] 1341 | }, 1342 | { 1343 | "id":434, 1344 | "objectgroup": 1345 | { 1346 | "draworder":"index", 1347 | "name":"", 1348 | "objects":[ 1349 | { 1350 | "height":26, 1351 | "id":2, 1352 | "name":"", 1353 | "rotation":0, 1354 | "type":"", 1355 | "visible":true, 1356 | "width":28.3333, 1357 | "x":4, 1358 | "y":0 1359 | }], 1360 | "opacity":1, 1361 | "type":"objectgroup", 1362 | "visible":true, 1363 | "x":0, 1364 | "y":0 1365 | } 1366 | }, 1367 | { 1368 | "id":435, 1369 | "objectgroup": 1370 | { 1371 | "draworder":"index", 1372 | "name":"", 1373 | "objects":[ 1374 | { 1375 | "height":26, 1376 | "id":1, 1377 | "name":"", 1378 | "rotation":0, 1379 | "type":"", 1380 | "visible":true, 1381 | "width":15.3333, 1382 | "x":0, 1383 | "y":0 1384 | }], 1385 | "opacity":1, 1386 | "type":"objectgroup", 1387 | "visible":true, 1388 | "x":0, 1389 | "y":0 1390 | } 1391 | }, 1392 | { 1393 | "id":437, 1394 | "objectgroup": 1395 | { 1396 | "draworder":"index", 1397 | "name":"", 1398 | "objects":[ 1399 | { 1400 | "height":32, 1401 | "id":1, 1402 | "name":"", 1403 | "rotation":0, 1404 | "type":"", 1405 | "visible":true, 1406 | "width":32, 1407 | "x":0, 1408 | "y":0 1409 | }], 1410 | "opacity":1, 1411 | "type":"objectgroup", 1412 | "visible":true, 1413 | "x":0, 1414 | "y":0 1415 | } 1416 | }, 1417 | { 1418 | "id":438, 1419 | "objectgroup": 1420 | { 1421 | "draworder":"index", 1422 | "name":"", 1423 | "objects":[ 1424 | { 1425 | "height":32, 1426 | "id":1, 1427 | "name":"", 1428 | "rotation":0, 1429 | "type":"", 1430 | "visible":true, 1431 | "width":32, 1432 | "x":0, 1433 | "y":0 1434 | }], 1435 | "opacity":1, 1436 | "type":"objectgroup", 1437 | "visible":true, 1438 | "x":0, 1439 | "y":0 1440 | } 1441 | }, 1442 | { 1443 | "id":459, 1444 | "objectgroup": 1445 | { 1446 | "draworder":"index", 1447 | "name":"", 1448 | "objects":[ 1449 | { 1450 | "height":32, 1451 | "id":1, 1452 | "name":"", 1453 | "rotation":0, 1454 | "type":"", 1455 | "visible":true, 1456 | "width":32, 1457 | "x":0, 1458 | "y":0 1459 | }], 1460 | "opacity":1, 1461 | "type":"objectgroup", 1462 | "visible":true, 1463 | "x":0, 1464 | "y":0 1465 | } 1466 | }, 1467 | { 1468 | "id":478, 1469 | "objectgroup": 1470 | { 1471 | "draworder":"index", 1472 | "name":"", 1473 | "objects":[ 1474 | { 1475 | "height":27.75, 1476 | "id":1, 1477 | "name":"", 1478 | "rotation":0, 1479 | "type":"", 1480 | "visible":true, 1481 | "width":28.5, 1482 | "x":1.5, 1483 | "y":0 1484 | }], 1485 | "opacity":1, 1486 | "type":"objectgroup", 1487 | "visible":true, 1488 | "x":0, 1489 | "y":0 1490 | } 1491 | }, 1492 | { 1493 | "id":482, 1494 | "objectgroup": 1495 | { 1496 | "draworder":"index", 1497 | "name":"", 1498 | "objects":[ 1499 | { 1500 | "height":25.25, 1501 | "id":1, 1502 | "name":"", 1503 | "rotation":0, 1504 | "type":"", 1505 | "visible":true, 1506 | "width":30.5, 1507 | "x":0.5, 1508 | "y":0.75 1509 | }], 1510 | "opacity":1, 1511 | "type":"objectgroup", 1512 | "visible":true, 1513 | "x":0, 1514 | "y":0 1515 | } 1516 | }, 1517 | { 1518 | "id":499, 1519 | "objectgroup": 1520 | { 1521 | "draworder":"index", 1522 | "name":"", 1523 | "objects":[ 1524 | { 1525 | "height":29.75, 1526 | "id":1, 1527 | "name":"", 1528 | "rotation":0, 1529 | "type":"", 1530 | "visible":true, 1531 | "width":30.75, 1532 | "x":1, 1533 | "y":0 1534 | }], 1535 | "opacity":1, 1536 | "type":"objectgroup", 1537 | "visible":true, 1538 | "x":0, 1539 | "y":0 1540 | } 1541 | }, 1542 | { 1543 | "id":500, 1544 | "objectgroup": 1545 | { 1546 | "draworder":"index", 1547 | "name":"", 1548 | "objects":[ 1549 | { 1550 | "height":28, 1551 | "id":2, 1552 | "name":"", 1553 | "rotation":0, 1554 | "type":"", 1555 | "visible":true, 1556 | "width":27.75, 1557 | "x":1, 1558 | "y":0.75 1559 | }], 1560 | "opacity":1, 1561 | "type":"objectgroup", 1562 | "visible":true, 1563 | "x":0, 1564 | "y":0 1565 | } 1566 | }, 1567 | { 1568 | "id":501, 1569 | "objectgroup": 1570 | { 1571 | "draworder":"index", 1572 | "name":"", 1573 | "objects":[ 1574 | { 1575 | "height":32, 1576 | "id":1, 1577 | "name":"", 1578 | "rotation":0, 1579 | "type":"", 1580 | "visible":true, 1581 | "width":32, 1582 | "x":0, 1583 | "y":0 1584 | }], 1585 | "opacity":1, 1586 | "type":"objectgroup", 1587 | "visible":true, 1588 | "x":0, 1589 | "y":0 1590 | } 1591 | }, 1592 | { 1593 | "id":502, 1594 | "objectgroup": 1595 | { 1596 | "draworder":"index", 1597 | "name":"", 1598 | "objects":[ 1599 | { 1600 | "height":27.75, 1601 | "id":2, 1602 | "name":"", 1603 | "rotation":0, 1604 | "type":"", 1605 | "visible":true, 1606 | "width":27.5, 1607 | "x":2, 1608 | "y":2.25 1609 | }], 1610 | "opacity":1, 1611 | "type":"objectgroup", 1612 | "visible":true, 1613 | "x":0, 1614 | "y":0 1615 | } 1616 | }, 1617 | { 1618 | "id":504, 1619 | "objectgroup": 1620 | { 1621 | "draworder":"index", 1622 | "name":"", 1623 | "objects":[ 1624 | { 1625 | "height":25.75, 1626 | "id":1, 1627 | "name":"", 1628 | "rotation":0, 1629 | "type":"", 1630 | "visible":true, 1631 | "width":27.75, 1632 | "x":2.25, 1633 | "y":3.75 1634 | }], 1635 | "opacity":1, 1636 | "type":"objectgroup", 1637 | "visible":true, 1638 | "x":0, 1639 | "y":0 1640 | } 1641 | }], 1642 | "tilewidth":32 1643 | }], 1644 | "tilewidth":32, 1645 | "type":"map", 1646 | "version":1.2, 1647 | "width":20 1648 | } -------------------------------------------------------------------------------- /GameSFML/Data/Json/map5x5.json: -------------------------------------------------------------------------------- 1 | { "height":5, 2 | "infinite":false, 3 | "layers":[ 4 | { 5 | "data":[51, 52, 53, 67, 113, 73, 74, 75, 89, 90, 95, 96, 97, 183, 184, 54, 55, 56, 205, 206, 76, 77, 78, 227, 228], 6 | "height":5, 7 | "id":2, 8 | "name":"dust", 9 | "opacity":1, 10 | "type":"tilelayer", 11 | "visible":true, 12 | "width":5, 13 | "x":0, 14 | "y":0 15 | }, 16 | { 17 | "data":[0, 136, 0, 136, 0, 0, 158, 0, 158, 0, 0, 136, 0, 136, 0, 0, 158, 0, 158, 0, 0, 0, 0, 0, 0], 18 | "height":5, 19 | "id":1, 20 | "name":"Tile Layer 1", 21 | "opacity":1, 22 | "type":"tilelayer", 23 | "visible":true, 24 | "width":5, 25 | "x":0, 26 | "y":0 27 | }], 28 | "nextlayerid":3, 29 | "nextobjectid":1, 30 | "orientation":"orthogonal", 31 | "renderorder":"right-down", 32 | "tiledversion":"1.2.3", 33 | "tileheight":32, 34 | "tilesets":[ 35 | { 36 | "columns":22, 37 | "firstgid":1, 38 | "image":"terrain.png", 39 | "imageheight":768, 40 | "imagewidth":704, 41 | "margin":0, 42 | "name":"terrain", 43 | "spacing":0, 44 | "terrains":[ 45 | { 46 | "name":"LightRock", 47 | "tile":64 48 | }, 49 | { 50 | "name":"DarkRock", 51 | "tile":70 52 | }, 53 | { 54 | "name":"DarkGrass", 55 | "tile":196 56 | }, 57 | { 58 | "name":"Hole", 59 | "tile":73 60 | }, 61 | { 62 | "name":"Water", 63 | "tile":82 64 | }, 65 | { 66 | "name":"Olala", 67 | "tile":208 68 | }], 69 | "tilecount":528, 70 | "tileheight":32, 71 | "tiles":[ 72 | { 73 | "id":1, 74 | "terrain":[0, 0, 0, -1] 75 | }, 76 | { 77 | "id":2, 78 | "terrain":[0, 0, -1, 0] 79 | }, 80 | { 81 | "id":7, 82 | "terrain":[1, 1, 1, -1] 83 | }, 84 | { 85 | "id":8, 86 | "terrain":[1, 1, -1, 1] 87 | }, 88 | { 89 | "id":10, 90 | "terrain":[3, 3, 3, -1] 91 | }, 92 | { 93 | "id":11, 94 | "terrain":[3, 3, -1, 3] 95 | }, 96 | { 97 | "id":19, 98 | "terrain":[4, 4, 4, -1] 99 | }, 100 | { 101 | "id":20, 102 | "terrain":[4, 4, -1, 4] 103 | }, 104 | { 105 | "id":23, 106 | "terrain":[0, -1, 0, 0] 107 | }, 108 | { 109 | "id":24, 110 | "terrain":[-1, 0, 0, 0] 111 | }, 112 | { 113 | "id":29, 114 | "terrain":[1, -1, 1, 1] 115 | }, 116 | { 117 | "id":30, 118 | "terrain":[-1, 1, 1, 1] 119 | }, 120 | { 121 | "id":32, 122 | "terrain":[3, -1, 3, 3] 123 | }, 124 | { 125 | "id":33, 126 | "terrain":[-1, 3, 3, 3] 127 | }, 128 | { 129 | "id":41, 130 | "terrain":[4, -1, 4, 4] 131 | }, 132 | { 133 | "id":42, 134 | "terrain":[-1, 4, 4, 4] 135 | }, 136 | { 137 | "id":44, 138 | "terrain":[-1, -1, -1, 0] 139 | }, 140 | { 141 | "id":45, 142 | "terrain":[-1, -1, 0, 0] 143 | }, 144 | { 145 | "id":46, 146 | "terrain":[-1, -1, 0, -1] 147 | }, 148 | { 149 | "id":50, 150 | "terrain":[-1, -1, -1, 1] 151 | }, 152 | { 153 | "id":51, 154 | "terrain":[-1, -1, 1, 1] 155 | }, 156 | { 157 | "id":52, 158 | "terrain":[-1, -1, 1, -1] 159 | }, 160 | { 161 | "id":53, 162 | "terrain":[-1, -1, -1, 3] 163 | }, 164 | { 165 | "id":54, 166 | "terrain":[-1, -1, 3, 3] 167 | }, 168 | { 169 | "id":55, 170 | "terrain":[-1, -1, 3, -1] 171 | }, 172 | { 173 | "id":62, 174 | "terrain":[-1, -1, -1, 4] 175 | }, 176 | { 177 | "id":63, 178 | "terrain":[-1, -1, 4, 4] 179 | }, 180 | { 181 | "id":64, 182 | "terrain":[-1, -1, 4, -1] 183 | }, 184 | { 185 | "id":66, 186 | "terrain":[-1, 0, -1, 0] 187 | }, 188 | { 189 | "id":67, 190 | "terrain":[0, 0, 0, 0] 191 | }, 192 | { 193 | "id":68, 194 | "terrain":[0, -1, 0, -1] 195 | }, 196 | { 197 | "id":72, 198 | "terrain":[-1, 1, -1, 1] 199 | }, 200 | { 201 | "id":73, 202 | "terrain":[1, 1, 1, 1] 203 | }, 204 | { 205 | "id":74, 206 | "terrain":[1, -1, 1, -1] 207 | }, 208 | { 209 | "id":75, 210 | "terrain":[-1, 3, -1, 3] 211 | }, 212 | { 213 | "id":76, 214 | "terrain":[3, 3, 3, 3] 215 | }, 216 | { 217 | "id":77, 218 | "terrain":[3, -1, 3, -1] 219 | }, 220 | { 221 | "id":84, 222 | "terrain":[-1, 4, -1, 4] 223 | }, 224 | { 225 | "id":86, 226 | "terrain":[4, -1, 4, -1] 227 | }, 228 | { 229 | "id":88, 230 | "terrain":[-1, 0, -1, -1] 231 | }, 232 | { 233 | "id":89, 234 | "terrain":[0, 0, -1, -1] 235 | }, 236 | { 237 | "id":90, 238 | "terrain":[0, -1, -1, -1] 239 | }, 240 | { 241 | "id":94, 242 | "terrain":[-1, 1, -1, -1] 243 | }, 244 | { 245 | "id":95, 246 | "terrain":[1, 1, -1, -1] 247 | }, 248 | { 249 | "id":96, 250 | "terrain":[1, -1, -1, -1] 251 | }, 252 | { 253 | "id":97, 254 | "terrain":[-1, 3, -1, -1] 255 | }, 256 | { 257 | "id":98, 258 | "terrain":[3, 3, -1, -1] 259 | }, 260 | { 261 | "id":99, 262 | "terrain":[3, -1, -1, -1] 263 | }, 264 | { 265 | "id":106, 266 | "terrain":[-1, 4, -1, -1] 267 | }, 268 | { 269 | "id":107, 270 | "terrain":[4, 4, -1, -1] 271 | }, 272 | { 273 | "id":108, 274 | "terrain":[4, -1, -1, -1] 275 | }, 276 | { 277 | "id":110, 278 | "terrain":[0, 0, 0, 0] 279 | }, 280 | { 281 | "id":111, 282 | "terrain":[0, 0, 0, 0] 283 | }, 284 | { 285 | "id":112, 286 | "terrain":[0, 0, 0, 0] 287 | }, 288 | { 289 | "id":116, 290 | "terrain":[1, 1, 1, 1] 291 | }, 292 | { 293 | "id":117, 294 | "terrain":[1, 1, 1, 1] 295 | }, 296 | { 297 | "id":118, 298 | "terrain":[1, 1, 1, 1] 299 | }, 300 | { 301 | "id":128, 302 | "terrain":[4, 4, 4, 4] 303 | }, 304 | { 305 | "id":129, 306 | "terrain":[4, 4, 4, 4] 307 | }, 308 | { 309 | "id":130, 310 | "terrain":[4, 4, 4, 4] 311 | }, 312 | { 313 | "id":139, 314 | "terrain":[2, 2, 2, -1] 315 | }, 316 | { 317 | "id":140, 318 | "terrain":[2, 2, -1, 2] 319 | }, 320 | { 321 | "id":151, 322 | "terrain":[5, 5, 5, -1] 323 | }, 324 | { 325 | "id":152, 326 | "terrain":[5, 5, -1, 5] 327 | }, 328 | { 329 | "id":157, 330 | "objectgroup": 331 | { 332 | "draworder":"index", 333 | "name":"", 334 | "objects":[ 335 | { 336 | "height":28, 337 | "id":3, 338 | "name":"", 339 | "rotation":0, 340 | "type":"", 341 | "visible":true, 342 | "width":32, 343 | "x":0, 344 | "y":4 345 | }], 346 | "opacity":1, 347 | "type":"objectgroup", 348 | "visible":true, 349 | "x":0, 350 | "y":0 351 | } 352 | }, 353 | { 354 | "id":161, 355 | "terrain":[2, -1, 2, 2] 356 | }, 357 | { 358 | "id":162, 359 | "terrain":[-1, 2, 2, 2] 360 | }, 361 | { 362 | "id":173, 363 | "terrain":[5, -1, 5, 5] 364 | }, 365 | { 366 | "id":174, 367 | "terrain":[-1, 5, 5, 5] 368 | }, 369 | { 370 | "id":182, 371 | "terrain":[-1, -1, -1, 2] 372 | }, 373 | { 374 | "id":183, 375 | "terrain":[-1, -1, 2, 2] 376 | }, 377 | { 378 | "id":184, 379 | "terrain":[-1, -1, 2, -1] 380 | }, 381 | { 382 | "id":194, 383 | "terrain":[-1, -1, -1, 5] 384 | }, 385 | { 386 | "id":195, 387 | "terrain":[-1, -1, 5, 5] 388 | }, 389 | { 390 | "id":196, 391 | "terrain":[-1, -1, 5, -1] 392 | }, 393 | { 394 | "id":204, 395 | "terrain":[-1, 2, -1, 2] 396 | }, 397 | { 398 | "id":205, 399 | "terrain":[2, 2, 2, 2] 400 | }, 401 | { 402 | "id":206, 403 | "terrain":[2, -1, 2, -1] 404 | }, 405 | { 406 | "id":216, 407 | "terrain":[-1, 5, -1, 5] 408 | }, 409 | { 410 | "id":217, 411 | "terrain":[5, 5, 5, 5] 412 | }, 413 | { 414 | "id":218, 415 | "terrain":[5, -1, 5, -1] 416 | }, 417 | { 418 | "id":226, 419 | "terrain":[-1, 2, -1, -1] 420 | }, 421 | { 422 | "id":227, 423 | "terrain":[2, 2, -1, -1] 424 | }, 425 | { 426 | "id":228, 427 | "terrain":[2, -1, -1, -1] 428 | }, 429 | { 430 | "id":238, 431 | "terrain":[-1, 5, -1, -1] 432 | }, 433 | { 434 | "id":239, 435 | "terrain":[5, 5, -1, -1] 436 | }, 437 | { 438 | "id":240, 439 | "terrain":[5, -1, -1, -1] 440 | }, 441 | { 442 | "id":248, 443 | "terrain":[2, 2, 2, 2] 444 | }, 445 | { 446 | "id":249, 447 | "terrain":[2, 2, 2, 2] 448 | }, 449 | { 450 | "id":250, 451 | "terrain":[2, 2, 2, 2] 452 | }, 453 | { 454 | "id":434, 455 | "objectgroup": 456 | { 457 | "draworder":"index", 458 | "name":"", 459 | "objects":[ 460 | { 461 | "height":26, 462 | "id":2, 463 | "name":"", 464 | "rotation":0, 465 | "type":"", 466 | "visible":true, 467 | "width":28.3333, 468 | "x":3.33333, 469 | "y":0.666667 470 | }], 471 | "opacity":1, 472 | "type":"objectgroup", 473 | "visible":true, 474 | "x":0, 475 | "y":0 476 | } 477 | }, 478 | { 479 | "id":435, 480 | "objectgroup": 481 | { 482 | "draworder":"index", 483 | "name":"", 484 | "objects":[ 485 | { 486 | "height":26, 487 | "id":1, 488 | "name":"", 489 | "rotation":0, 490 | "type":"", 491 | "visible":true, 492 | "width":15.3333, 493 | "x":-0.666667, 494 | "y":0.666667 495 | }], 496 | "opacity":1, 497 | "type":"objectgroup", 498 | "visible":true, 499 | "x":0, 500 | "y":0 501 | } 502 | }], 503 | "tilewidth":32 504 | }], 505 | "tilewidth":32, 506 | "type":"map", 507 | "version":1.2, 508 | "width":5 509 | } -------------------------------------------------------------------------------- /GameSFML/Data/Json/playerAnimation.json: -------------------------------------------------------------------------------- 1 | { 2 | "imageName": "PlayerAnimation_64_64_4_9.png", 3 | "width": 576, 4 | "height": 256, 5 | "tileWidth": 64, 6 | "tileHeight": 64, 7 | "frameTime": 150, 8 | "animationSets": [ 9 | { 10 | "id": 1, 11 | "index": [0, 8] 12 | }, 13 | { 14 | "id": 2, 15 | "index": [9, 17] 16 | }, 17 | { 18 | "id": 3, 19 | "index": [18, 26] 20 | }, 21 | { 22 | "id": 4, 23 | "index": [27, 35] 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /GameSFML/Data/Json/tileMap.json: -------------------------------------------------------------------------------- 1 | { 2 | "filePath": "Data\\Images\\Tile\\ground_01.png", 3 | "tileSize": 40, 4 | "gridW": 30, 5 | "gridH": 30 6 | } 7 | -------------------------------------------------------------------------------- /GameSFML/Game.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "World.h" 3 | 4 | class Game 5 | { 6 | public: 7 | void Go() 8 | { 9 | Locator::Graphic::ref().BeginFrame(); 10 | UpdateModel(); 11 | ComposeFrame(); 12 | Locator::Graphic::ref().EndFrame(); 13 | } 14 | private: 15 | void UpdateModel() 16 | { 17 | const float dt = float(clock.restart().asMilliseconds()) / 1000.0f; 18 | wld.Update(dt); 19 | } 20 | void ComposeFrame() 21 | { 22 | wld.Draw(); 23 | } 24 | private: 25 | /**************** User Variable *******************/ 26 | sf::Clock clock; 27 | World wld; 28 | /**************** User Variable *******************/ 29 | }; -------------------------------------------------------------------------------- /GameSFML/GameResource.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "SFML/Graphics/Texture.hpp" 3 | #include "entt/core/hashed_string.hpp" 4 | #include 5 | struct AnimationResource 6 | { 7 | std::vector frames; 8 | const sf::Texture* texture = nullptr; 9 | unsigned int width, height, tileWidth, tileHeight, frameTime; 10 | //hold begin index and end index in farmes, each pair is 1 animation set 11 | std::vector> animationSets; 12 | }; 13 | 14 | 15 | struct MapResource 16 | { 17 | struct Object 18 | { 19 | float height, width, x, y; 20 | unsigned int rotation; 21 | }; 22 | int tileSize = 0, gridW = 0, gridH = 0; 23 | const sf::Texture* tileTexture = nullptr; 24 | //layers tile 25 | std::vector> layers; 26 | 27 | //layer with tile has object 28 | std::vector tilesWithObject; 29 | 30 | //object attached per tile 31 | std::unordered_map objects; 32 | 33 | //custom object, will add more in the future with sensor or static objects 34 | std::vector objectLayer; 35 | }; 36 | -------------------------------------------------------------------------------- /GameSFML/GameSFML.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 15.0 23 | {38CAD35A-0EF1-4EAD-AA80-786EECE45802} 24 | GameSFML 25 | 10.0.17134.0 26 | 27 | 28 | 29 | Application 30 | true 31 | v141 32 | MultiByte 33 | 34 | 35 | Application 36 | false 37 | v141 38 | true 39 | MultiByte 40 | 41 | 42 | Application 43 | true 44 | v141 45 | MultiByte 46 | 47 | 48 | Application 49 | false 50 | v141 51 | true 52 | MultiByte 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | D:\C++\GameSFML\GameSFML\System;D:\C++\GameSFML\GameSFML\Component;$(IncludePath) 74 | 75 | 76 | D:\C++\GameSFML\GameSFML\System;D:\C++\GameSFML\GameSFML\Component;$(IncludePath) 77 | 78 | 79 | D:\C++\GameSFML\GameSFML\System;D:\C++\GameSFML\GameSFML\Component;$(IncludePath) 80 | 81 | 82 | D:\C++\GameSFML\GameSFML\System;D:\C++\GameSFML\GameSFML\Component;$(IncludePath) 83 | 84 | 85 | 86 | Level3 87 | Disabled 88 | true 89 | true 90 | stdcpp17 91 | 92 | 93 | 94 | 95 | Level3 96 | Disabled 97 | true 98 | true 99 | stdcpp17 100 | 101 | 102 | 103 | 104 | Level3 105 | MaxSpeed 106 | true 107 | true 108 | true 109 | true 110 | stdcpp17 111 | 112 | 113 | true 114 | true 115 | 116 | 117 | 118 | 119 | Level3 120 | MaxSpeed 121 | true 122 | true 123 | true 124 | true 125 | stdcpp17 126 | 127 | 128 | true 129 | true 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | -------------------------------------------------------------------------------- /GameSFML/GameSFML.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {f111e839-abac-45f8-b6a7-294a16b93d59} 18 | 19 | 20 | {460e4c03-87c8-4cc8-ab3c-ec333e59c03b} 21 | 22 | 23 | {1eb12e05-1af1-43cf-8e44-5c25c80d469d} 24 | 25 | 26 | {a7b84ca2-75e0-44fe-a9b2-8a520fac5dfd} 27 | 28 | 29 | 30 | 31 | Source Files\Engine 32 | 33 | 34 | Source Files\Engine 35 | 36 | 37 | Source Files\Engine 38 | 39 | 40 | 41 | 42 | Header Files\Engine 43 | 44 | 45 | Header Files\Engine 46 | 47 | 48 | Header Files\Engine 49 | 50 | 51 | Header Files\Engine 52 | 53 | 54 | Header Files\Engine 55 | 56 | 57 | Header Files 58 | 59 | 60 | Header Files\Engine 61 | 62 | 63 | Header Files\Engine 64 | 65 | 66 | Header Files\Engine 67 | 68 | 69 | Header Files 70 | 71 | 72 | Header Files\Engine 73 | 74 | 75 | Header Files\Systems 76 | 77 | 78 | Header Files\Systems 79 | 80 | 81 | Header Files\Systems 82 | 83 | 84 | Header Files\Systems 85 | 86 | 87 | Header Files\Systems 88 | 89 | 90 | Header Files\Systems 91 | 92 | 93 | Header Files\Component 94 | 95 | 96 | Header Files\Component 97 | 98 | 99 | Header Files\Component 100 | 101 | 102 | Header Files\Component 103 | 104 | 105 | Header Files\Engine 106 | 107 | 108 | Header Files\Systems 109 | 110 | 111 | Header Files\Systems 112 | 113 | 114 | Header Files 115 | 116 | 117 | Header Files\Systems 118 | 119 | 120 | Header Files\Systems 121 | 122 | 123 | Header Files\Component 124 | 125 | 126 | Header Files\Engine 127 | 128 | 129 | Header Files\Systems 130 | 131 | 132 | Header Files\Systems 133 | 134 | 135 | Header Files\Systems 136 | 137 | 138 | Header Files\Systems 139 | 140 | 141 | Header Files\Component 142 | 143 | 144 | Header Files\Engine 145 | 146 | 147 | Header Files\Systems 148 | 149 | 150 | Header Files\Systems 151 | 152 | 153 | Header Files\Component 154 | 155 | 156 | Header Files\Systems 157 | 158 | 159 | Header Files\Systems 160 | 161 | 162 | Header Files\Component 163 | 164 | 165 | Header Files\Systems 166 | 167 | 168 | Header Files\Systems 169 | 170 | 171 | Header Files\Systems 172 | 173 | 174 | Header Files\Component 175 | 176 | 177 | -------------------------------------------------------------------------------- /GameSFML/Gird.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "SFML/Graphics.hpp" 5 | #include "GameResource.h" 6 | #include "HashStringDataBase.h" 7 | #include "Component/StaticObjectSpawnInfo.h" 8 | #include "Component/GameplayTags.h" 9 | //moving grid not working yet 10 | class Grid : public sf::Drawable, public sf::Transformable 11 | { 12 | public: 13 | template 14 | void LoadFromFile(Loader& loader, entt::DefaultRegistry& ECS) 15 | { 16 | const auto& resource = loader.GetMapResource(Database::GridMap); 17 | if (resource.tileSize <= 0 || resource.gridW <= 0 || resource.gridH <= 0 || resource.tileTexture == nullptr) 18 | { 19 | assert(false); 20 | return; 21 | } 22 | //grid 23 | tileSize = resource.tileSize; 24 | gridW = resource.gridW; 25 | gridH = resource.gridH; 26 | 27 | //texture 28 | tileTexture = resource.tileTexture; 29 | const int textureTileW = (int)tileTexture->getSize().x / tileSize; 30 | const int textureTileH = (int)tileTexture->getSize().y / tileSize; 31 | 32 | layers = &resource.layers; 33 | drawLayers.setPrimitiveType(sf::Quads); 34 | 35 | //make vertex form layer map 36 | for (auto& layer : resource.layers) 37 | { 38 | staticLayers.emplace_back(sf::VertexArray(sf::Quads, gridW * gridH * 4)); 39 | 40 | 41 | for (int i = 0; i < gridW; ++i) 42 | { 43 | for (int j = 0; j < gridH; ++j) 44 | { 45 | //get texture position 46 | const unsigned int textureLookup = layer[i + j * gridW]; 47 | if (textureLookup == 0) continue; 48 | 49 | const int textureX = (textureLookup % textureTileW) == 0 ? textureTileW : textureLookup % textureTileW; 50 | const int textureY = textureLookup / textureTileW; 51 | // get a pointer to the current tile's quad 52 | sf::Vertex* quad = &staticLayers.back()[(i + j * gridW) * 4]; 53 | 54 | // define its 4 corners 55 | quad[0].position = sf::Vector2f(float(i * tileSize), float(j * tileSize)); 56 | quad[1].position = sf::Vector2f(float((i + 1) * tileSize), float(j * tileSize)); 57 | quad[2].position = sf::Vector2f(float((i + 1) * tileSize), float((j + 1) * tileSize)); 58 | quad[3].position = sf::Vector2f(float(i * tileSize), float((j + 1) * tileSize)); 59 | 60 | // define its 4 texture coordinates 61 | quad[0].texCoords = sf::Vector2f(float((textureX - 1) * tileSize), float(textureY * tileSize)); 62 | quad[1].texCoords = sf::Vector2f(float(textureX * tileSize), float(textureY * tileSize)); 63 | quad[2].texCoords = sf::Vector2f(float(textureX * tileSize), float((textureY + 1) * tileSize)); 64 | quad[3].texCoords = sf::Vector2f(float((textureX - 1) * tileSize), float((textureY + 1) * tileSize)); 65 | } 66 | } 67 | 68 | } 69 | 70 | //make vertex form tileObject 71 | if (!resource.tilesWithObject.empty()) 72 | { 73 | staticLayers.emplace_back(sf::VertexArray(sf::Quads, gridW * gridH * 4)); 74 | tileObjectLayer = &resource.tilesWithObject; 75 | for (int i = 0; i < gridW; ++i) 76 | { 77 | for (int j = 0; j < gridH; ++j) 78 | { 79 | //get texture position 80 | const unsigned int textureLookup = resource.tilesWithObject[i + j * gridW]; 81 | if (textureLookup == 0) continue; 82 | 83 | const int textureX = (textureLookup % textureTileW) == 0 ? textureTileW : textureLookup % textureTileW; 84 | const int textureY = textureLookup / textureTileW; 85 | // get a pointer to the current tile's quad 86 | sf::Vertex* quad = &staticLayers.back()[(i + j * gridW) * 4]; 87 | 88 | // define its 4 corners 89 | quad[0].position = sf::Vector2f(float(i * tileSize), float(j * tileSize)); 90 | quad[1].position = sf::Vector2f(float((i + 1) * tileSize), float(j * tileSize)); 91 | quad[2].position = sf::Vector2f(float((i + 1) * tileSize), float((j + 1) * tileSize)); 92 | quad[3].position = sf::Vector2f(float(i * tileSize), float((j + 1) * tileSize)); 93 | 94 | // define its 4 texture coordinates 95 | quad[0].texCoords = sf::Vector2f(float((textureX - 1) * tileSize), float(textureY * tileSize)); 96 | quad[1].texCoords = sf::Vector2f(float(textureX * tileSize), float(textureY * tileSize)); 97 | quad[2].texCoords = sf::Vector2f(float(textureX * tileSize), float((textureY + 1) * tileSize)); 98 | quad[3].texCoords = sf::Vector2f(float((textureX - 1) * tileSize), float((textureY + 1) * tileSize)); 99 | 100 | //find ofject location 101 | auto object = resource.objects.find(textureLookup); 102 | if (object == resource.objects.end()) continue; 103 | 104 | auto entity = ECS.create(); 105 | auto& spawnInfo = ECS.assign(entity); 106 | spawnInfo.height = object->second.height * 0.5f; 107 | spawnInfo.width = object->second.width * 0.5f; 108 | spawnInfo.pos = quad[0].position + sf::Vector2f(object->second.x + spawnInfo.width, object->second.y + spawnInfo.height); 109 | spawnInfo.rotation = object->second.rotation; 110 | } 111 | } 112 | } 113 | //make Object From Layer Object 114 | for (auto& object : resource.objectLayer) 115 | { 116 | auto entity = ECS.create(); 117 | auto& spawnInfo = ECS.assign(entity); 118 | spawnInfo.height = object.height * 0.5f; 119 | spawnInfo.width = object.width * 0.5f; 120 | spawnInfo.pos = {object.x + spawnInfo.width, object.y + spawnInfo.height }; 121 | spawnInfo.rotation = object.rotation; 122 | } 123 | 124 | } 125 | void Culling(sf::Vector2f topLeft, sf::Vector2f rightBottom) 126 | { 127 | int left = 0, right = 0, top = 0, bottom = 0; 128 | //get top left point of view 129 | //topLeft -= getPosition(); 130 | left = int(topLeft.x / tileSize); 131 | top = int(topLeft.y / tileSize); 132 | 133 | //get bottom right point of view 134 | //rightBottom -= getPosition(); 135 | right = 1 + int(rightBottom.x / tileSize); 136 | bottom = 1 + int(rightBottom.y / tileSize); 137 | 138 | //clamp these to fit into array bounds: 139 | left = std::max(0, std::min(left, gridW)); 140 | top = std::max(0, std::min(top, gridH)); 141 | right = std::max(0, std::min(right, gridW)); 142 | bottom = std::max(0, std::min(bottom, gridH)); 143 | 144 | //build visible vertercies: 145 | drawLayers.clear(); 146 | for (int nl = 0; nl < staticLayers.size() - 1; nl++) 147 | { 148 | for (int i = left; i < right; ++i) 149 | { 150 | for (int j = top; j < bottom; ++j) 151 | { 152 | //skip if current tile in texture map is 0 153 | if ((*layers)[nl][i + j * gridW] == 0) continue; 154 | 155 | const int cur = (i + j * gridW) * 4; 156 | 157 | // define its 4 corners 158 | drawLayers.append(staticLayers[nl][cur]); 159 | drawLayers.append(staticLayers[nl][cur + 1]); 160 | drawLayers.append(staticLayers[nl][cur + 2]); 161 | drawLayers.append(staticLayers[nl][cur + 3]); 162 | } 163 | } 164 | } 165 | if (tileObjectLayer == nullptr) return; 166 | 167 | for (int i = left; i < right; ++i) 168 | { 169 | for (int j = top; j < bottom; ++j) 170 | { 171 | //skip if current tile in texture map is 0 172 | if ((*tileObjectLayer)[i + j * gridW] == 0) continue; 173 | 174 | const int cur = (i + j * gridW) * 4; 175 | 176 | // define its 4 corners 177 | drawLayers.append(staticLayers.back()[cur]); 178 | drawLayers.append(staticLayers.back()[cur + 1]); 179 | drawLayers.append(staticLayers.back()[cur + 2]); 180 | drawLayers.append(staticLayers.back()[cur + 3]); 181 | } 182 | } 183 | 184 | //std::cout << "Vertices: " << drawLayers.getVertexCount() << ", Tiles: " << drawLayers.getVertexCount() / 4 << std::endl; 185 | } 186 | private: 187 | void draw(sf::RenderTarget& target, sf::RenderStates states) const final 188 | { 189 | if (tileSize <= 0 || gridW <= 0 || gridH <= 0 || tileTexture == nullptr) 190 | { 191 | assert(false); 192 | return; 193 | } 194 | states.texture = tileTexture; 195 | //states.transform *= getTransform(); 196 | target.draw(drawLayers, states); 197 | } 198 | private: 199 | int tileSize = 40, gridW = 0, gridH = 0; 200 | const sf::Texture* tileTexture = nullptr; 201 | const std::vector>* layers; 202 | const std::vector* tileObjectLayer = nullptr; 203 | std::vector staticLayers; 204 | sf::VertexArray drawLayers; 205 | std::vector staticObjects; 206 | }; -------------------------------------------------------------------------------- /GameSFML/Graphics.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "SFML/Graphics.hpp" 3 | #include "Box2D/Box2D.h" 4 | #include 5 | class Graphics 6 | { 7 | public: 8 | Graphics(sf::RenderWindow& window) 9 | : 10 | window(window), 11 | vertices(sf::Quads, 4) 12 | { 13 | MoveViewport(b2Vec2(0.0f,0.0f)); 14 | } 15 | 16 | void DrawVertexArray(sf::VertexArray& vertexArray, const sf::Texture& texture) const 17 | { 18 | window.draw(vertexArray, &texture); 19 | } 20 | void Draw(const sf::Drawable& drawable) const 21 | { 22 | window.draw(drawable); 23 | } 24 | void DrawSprite(sf::Sprite& sprite) const 25 | { 26 | window.draw(sprite); 27 | } 28 | void BeginFrame() 29 | { 30 | window.clear(sf::Color::Black); 31 | } 32 | void EndFrame() 33 | { 34 | window.display(); 35 | } 36 | std::pair GetViewport() 37 | { 38 | const auto center = window.getView().getCenter(); 39 | halfSize = 0.5f * window.getView().getSize(); 40 | const auto top = ScreenToWorldPos(center - halfSize); 41 | const auto bottom = ScreenToWorldPos(center + halfSize); 42 | /*auto draw01 = WorldToScreenPos(top) + sf::Vector2f(10.0f,10.0f); 43 | auto draw02 = WorldToScreenPos(bottom) - sf::Vector2f(10.0f, 10.0f); 44 | vertices[0] = draw01; 45 | vertices[1] = sf::Vector2f(draw01.x,draw02.y); 46 | vertices[2] = draw02; 47 | vertices[3] = sf::Vector2f(draw02.x, draw01.y); 48 | window.draw(vertices);*/ 49 | return { top, bottom }; 50 | } 51 | std::pair GetViewportScreen() 52 | { 53 | const auto center = window.getView().getCenter(); 54 | halfSize = 0.5f * window.getView().getSize(); 55 | return { center - halfSize , center + halfSize }; 56 | } 57 | void MoveViewport(const b2Vec2& newWorldPos) 58 | { 59 | auto view = window.getView(); 60 | view.setCenter(WorldToScreenPos(newWorldPos)); 61 | window.setView(view); 62 | } 63 | void MoveViewport(const sf::Vector2i screenPos) 64 | { 65 | auto view = window.getView(); 66 | 67 | view.setCenter(view.getCenter() + (sf::Vector2f)screenPos); 68 | window.setView(view); 69 | } 70 | sf::Vector2f GetViewportLocation() const 71 | { 72 | return window.getView().getCenter(); 73 | } 74 | b2Vec2 ScreenToWorldPos(const sf::Vector2f& screenPos) const 75 | { 76 | return b2Vec2((screenPos.x) / scalePixel, (-screenPos.y) / scalePixel); 77 | } 78 | b2Vec2 MouseToWorldPos(const sf::Vector2i& mousePos) const 79 | { 80 | const auto newPosition = window.getView().getCenter() + sf::Vector2f(mousePos) - halfSize; 81 | 82 | return b2Vec2((newPosition.x) / scalePixel, (-newPosition.y) / scalePixel); 83 | } 84 | sf::Vector2f WorldToScreenPos(const b2Vec2& worldPos) const 85 | { 86 | return { worldPos.x * scalePixel, - worldPos.y * scalePixel}; 87 | } 88 | b2Vec2 GetWorldSize(const sf::Vector2f& screenSize) const 89 | { 90 | return b2Vec2(screenSize.x / scalePixel, screenSize.y / scalePixel); 91 | } 92 | sf::Vector2f GetScreenSize(const b2Vec2& worldSize) const 93 | { 94 | return { worldSize.x * scalePixel, worldSize.y * scalePixel }; 95 | } 96 | static constexpr float scalePixel = 20.0f; 97 | private: 98 | sf::RenderWindow& window; 99 | sf::Vector2f halfSize; 100 | sf::VertexArray vertices; 101 | }; -------------------------------------------------------------------------------- /GameSFML/HashStringDataBase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | namespace Database 4 | { 5 | #pragma warning(push) 6 | #pragma warning(disable:4307) // disable warning C4307: '*': integral constant overflow 7 | constexpr auto GridMap = "Data\\Json\\map20x20.json"_hs; 8 | constexpr auto TEnemy01 = "Data\\Images\\enemy_01.png"_hs; 9 | constexpr auto TEnemy02 = "Data\\Images\\enemy_02.png"_hs; 10 | constexpr auto TEnemy03 = "Data\\Images\\enemy_03.png"_hs; 11 | constexpr auto PlayerAnimation = "Data\\Json\\playerAnimation.json"_hs; 12 | constexpr auto BulletAnimation = "Data\\Json\\bulletAnimation.json"_hs; 13 | constexpr auto FontSplatch = "Data\\Fonts\\Adventure.otf"_hs; 14 | #pragma warning(pop) 15 | } -------------------------------------------------------------------------------- /GameSFML/Keyboard.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************************** 2 | * Chili DirectX Framework Version 16.07.20 * 3 | * Keyboard.cpp * 4 | * Copyright 2016 PlanetChili.net * 5 | * * 6 | * This file is part of The Chili DirectX Framework. * 7 | * * 8 | * The Chili DirectX Framework is free software: you can redistribute it and/or modify * 9 | * it under the terms of the GNU General Public License as published by * 10 | * the Free Software Foundation, either version 3 of the License, or * 11 | * (at your option) any later version. * 12 | * * 13 | * The Chili DirectX Framework is distributed in the hope that it will be useful, * 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 | * GNU General Public License for more details. * 17 | * * 18 | * You should have received a copy of the GNU General Public License * 19 | * along with The Chili DirectX Framework. If not, see . * 20 | ******************************************************************************************/ 21 | #include "Keyboard.h" 22 | 23 | bool Keyboard::KeyIsPressed(sf::Keyboard::Key keycode) const 24 | { 25 | return keystates[keycode]; 26 | } 27 | 28 | Keyboard::Event Keyboard::ReadKey() 29 | { 30 | if (keybuffer.size() > 0u) 31 | { 32 | Keyboard::Event e = keybuffer.front(); 33 | keybuffer.pop(); 34 | return e; 35 | } 36 | else 37 | { 38 | return Keyboard::Event(); 39 | } 40 | } 41 | 42 | bool Keyboard::KeyIsEmpty() const 43 | { 44 | return keybuffer.empty(); 45 | } 46 | 47 | char Keyboard::ReadChar() 48 | { 49 | if (charbuffer.size() > 0u) 50 | { 51 | unsigned char charcode = charbuffer.front(); 52 | charbuffer.pop(); 53 | return charcode; 54 | } 55 | else 56 | { 57 | return 0; 58 | } 59 | } 60 | 61 | bool Keyboard::CharIsEmpty() const 62 | { 63 | return charbuffer.empty(); 64 | } 65 | 66 | void Keyboard::FlushKey() 67 | { 68 | keybuffer = std::queue(); 69 | } 70 | 71 | void Keyboard::FlushChar() 72 | { 73 | charbuffer = std::queue(); 74 | } 75 | 76 | void Keyboard::Flush() 77 | { 78 | FlushKey(); 79 | FlushChar(); 80 | } 81 | 82 | void Keyboard::EnableAutorepeat() 83 | { 84 | autorepeatEnabled = true; 85 | } 86 | 87 | void Keyboard::DisableAutorepeat() 88 | { 89 | autorepeatEnabled = false; 90 | } 91 | 92 | bool Keyboard::AutorepeatIsEnabled() const 93 | { 94 | return autorepeatEnabled; 95 | } 96 | 97 | void Keyboard::OnKeyPressed(sf::Keyboard::Key keycode) 98 | { 99 | keystates[keycode] = true; 100 | keybuffer.push(Keyboard::Event(Keyboard::Event::Type::Press, keycode)); 101 | TrimBuffer(keybuffer); 102 | } 103 | 104 | void Keyboard::OnKeyReleased(sf::Keyboard::Key keycode) 105 | { 106 | keystates[keycode] = false; 107 | keybuffer.push(Keyboard::Event(Keyboard::Event::Type::Release, keycode)); 108 | TrimBuffer(keybuffer); 109 | } 110 | 111 | void Keyboard::OnChar(char character) 112 | { 113 | charbuffer.push(character); 114 | TrimBuffer(charbuffer); 115 | } 116 | 117 | void Keyboard::ClearState() 118 | { 119 | keystates.reset(); 120 | } 121 | 122 | template 123 | void Keyboard::TrimBuffer(std::queue& buffer) 124 | { 125 | while (buffer.size() > bufferSize) 126 | { 127 | buffer.pop(); 128 | } 129 | } 130 | 131 | -------------------------------------------------------------------------------- /GameSFML/Keyboard.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************************** 2 | * Chili DirectX Framework Version 16.07.20 * 3 | * Keyboard.h * 4 | * Copyright 2016 PlanetChili.net * 5 | * * 6 | * This file is part of The Chili DirectX Framework. * 7 | * * 8 | * The Chili DirectX Framework is free software: you can redistribute it and/or modify * 9 | * it under the terms of the GNU General Public License as published by * 10 | * the Free Software Foundation, either version 3 of the License, or * 11 | * (at your option) any later version. * 12 | * * 13 | * The Chili DirectX Framework is distributed in the hope that it will be useful, * 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 | * GNU General Public License for more details. * 17 | * * 18 | * You should have received a copy of the GNU General Public License * 19 | * along with The Chili DirectX Framework. If not, see . * 20 | ******************************************************************************************/ 21 | #pragma once 22 | #include 23 | #include 24 | #include "SFML/Graphics.hpp" 25 | class Keyboard 26 | { 27 | friend class MainWindow; 28 | public: 29 | class Event 30 | { 31 | public: 32 | enum class Type 33 | { 34 | Press, 35 | Release, 36 | Invalid 37 | }; 38 | private: 39 | Type type; 40 | sf::Keyboard::Key code; 41 | public: 42 | Event() 43 | : 44 | type(Type::Invalid), 45 | code(sf::Keyboard::Key::Unknown) 46 | {} 47 | Event(Type type, sf::Keyboard::Key code) 48 | : 49 | type(type), 50 | code(code) 51 | {} 52 | bool IsPress() const 53 | { 54 | return type == Type::Press; 55 | } 56 | bool IsRelease() const 57 | { 58 | return type == Type::Release; 59 | } 60 | bool IsValid() const 61 | { 62 | return type != Type::Invalid; 63 | } 64 | sf::Keyboard::Key GetCode() const 65 | { 66 | return code; 67 | } 68 | }; 69 | public: 70 | Keyboard() = default; 71 | Keyboard(const Keyboard&) = delete; 72 | Keyboard& operator=(const Keyboard&) = delete; 73 | bool KeyIsPressed(sf::Keyboard::Key keycode) const; 74 | Event ReadKey(); 75 | bool KeyIsEmpty() const; 76 | char ReadChar(); 77 | bool CharIsEmpty() const; 78 | void FlushKey(); 79 | void FlushChar(); 80 | void Flush(); 81 | void EnableAutorepeat(); 82 | void DisableAutorepeat(); 83 | bool AutorepeatIsEnabled() const; 84 | private: 85 | void OnKeyPressed(sf::Keyboard::Key keycode); 86 | void OnKeyReleased(sf::Keyboard::Key keycode); 87 | void OnChar(char character); 88 | void ClearState(); 89 | template 90 | void TrimBuffer(std::queue& buffer); 91 | private: 92 | static constexpr int bufferSize = 4u; 93 | bool autorepeatEnabled = false; 94 | std::bitset keystates; 95 | std::queue keybuffer; 96 | std::queue charbuffer; 97 | }; 98 | -------------------------------------------------------------------------------- /GameSFML/Locator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "entt/entt.hpp" 3 | #include "Box2D/Box2D.h" 4 | #include "Codex.h" 5 | #include "Graphics.h" 6 | #include "Keyboard.h" 7 | #include "Mouse.h" 8 | #include "Gird.h" 9 | #include 10 | struct Locator 11 | { 12 | using Physic = entt::ServiceLocator; 13 | using Graphic = entt::ServiceLocator; 14 | using ECS = entt::ServiceLocator; 15 | using Random = entt::ServiceLocator; 16 | using Mouse = entt::ServiceLocator; 17 | using Keyboard = entt::ServiceLocator; 18 | using Codex = entt::ServiceLocator; 19 | using Grid = entt::ServiceLocator; 20 | }; -------------------------------------------------------------------------------- /GameSFML/MainWindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "Locator.h" 4 | //#include 5 | class MainWindow 6 | { 7 | public: 8 | MainWindow() 9 | : 10 | window(sf::VideoMode(1280, 720), "SFML Game") 11 | { 12 | //enable v-sync 13 | window.setVerticalSyncEnabled(true); 14 | //disable key auto repeat 15 | window.setKeyRepeatEnabled(false); 16 | InitServiceLocator(); 17 | 18 | } 19 | bool Update() 20 | { 21 | if (window.isOpen()) 22 | { 23 | ProcessEvent(); 24 | return true; 25 | } 26 | return false; 27 | } 28 | private: 29 | void InitServiceLocator() 30 | { 31 | Locator::Graphic::set(window); 32 | Locator::Mouse::set(); 33 | Locator::Keyboard::set(); 34 | } 35 | void ProcessEvent() 36 | { 37 | sf::Event event; 38 | auto& mouse = Locator::Mouse::ref(); 39 | auto& kbd = Locator::Keyboard::ref(); 40 | while (window.pollEvent(event)) 41 | { 42 | switch (event.type) 43 | { 44 | /*----------------------Mouse Event---------------------*/ 45 | case sf::Event::MouseMoved: 46 | mouse.OnMouseMove(event.mouseMove.x, event.mouseMove.y); 47 | break; 48 | case sf::Event::MouseButtonPressed: 49 | { 50 | switch (event.mouseButton.button) 51 | { 52 | case sf::Mouse::Left: 53 | mouse.OnLeftPressed(); 54 | break; 55 | case sf::Mouse::Right: 56 | mouse.OnRightPressed(); 57 | break; 58 | default: 59 | break; 60 | } 61 | break; 62 | } 63 | case sf::Event::MouseButtonReleased: 64 | { 65 | switch (event.mouseButton.button) 66 | { 67 | case sf::Mouse::Left: 68 | mouse.OnLeftReleased(); 69 | break; 70 | case sf::Mouse::Right: 71 | mouse.OnRightReleased(); 72 | break; 73 | default: 74 | break; 75 | } 76 | break; 77 | } 78 | case sf::Event::MouseWheelScrolled: 79 | { 80 | if (event.mouseWheelScroll.wheel == sf::Mouse::VerticalWheel) 81 | mouse.OnWheel(event.mouseWheelScroll.delta); 82 | break; 83 | } 84 | break; 85 | //mouse cursor has entered the window 86 | case sf::Event::MouseEntered: 87 | break; 88 | //mouse cursor has left the window 89 | case sf::Event::MouseLeft: 90 | mouse.Flush(); 91 | break; 92 | /*-------------------Mouse Event----------------------*/ 93 | 94 | /*-------------------Keyboard Event-------------------*/ 95 | case sf::Event::KeyPressed: 96 | kbd.OnKeyPressed(event.key.code); 97 | break; 98 | case sf::Event::KeyReleased: 99 | kbd.OnKeyReleased(event.key.code); 100 | break; 101 | 102 | /*-------------------Keyboard Event-------------------*/ 103 | 104 | /*--------------------Window Event--------------------*/ 105 | //happen when user closed the program by many way 106 | case sf::Event::Closed: 107 | window.close(); 108 | break; 109 | //hapen when user change active window like alt+tab 110 | case sf::Event::LostFocus: 111 | mouse.Flush(); 112 | break; 113 | //hapen when user comeback to program 114 | case sf::Event::GainedFocus: 115 | break; 116 | // catch the resize events 117 | case sf::Event::Resized: 118 | { 119 | // update the view to the new size of the window 120 | auto view = window.getView(); 121 | view.setSize(sf::Vector2f((float)event.size.width, (float)event.size.height)); 122 | window.setView(view); 123 | break; 124 | } 125 | /*---------------------Window Event-------------------*/ 126 | default: 127 | break; 128 | } 129 | } 130 | 131 | } 132 | public: 133 | sf::RenderWindow window; 134 | }; -------------------------------------------------------------------------------- /GameSFML/MaxxConsole.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | namespace MaxxConsole 3 | { 4 | static unsigned int r_showDebugPhysic = 0; 5 | } -------------------------------------------------------------------------------- /GameSFML/Mouse.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************************** 2 | * Chili DirectX Framework Version 16.07.20 * 3 | * Mouse.cpp * 4 | * Copyright 2016 PlanetChili * 5 | * * 6 | * This file is part of The Chili DirectX Framework. * 7 | * * 8 | * The Chili DirectX Framework is free software: you can redistribute it and/or modify * 9 | * it under the terms of the GNU General Public License as published by * 10 | * the Free Software Foundation, either version 3 of the License, or * 11 | * (at your option) any later version. * 12 | * * 13 | * The Chili DirectX Framework is distributed in the hope that it will be useful, * 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 | * GNU General Public License for more details. * 17 | * * 18 | * You should have received a copy of the GNU General Public License * 19 | * along with The Chili DirectX Framework. If not, see . * 20 | ******************************************************************************************/ 21 | #include "Mouse.h" 22 | 23 | 24 | sf::Vector2i Mouse::GetPos() const 25 | { 26 | return { x,y }; 27 | } 28 | 29 | int Mouse::GetPosX() const 30 | { 31 | return x; 32 | } 33 | 34 | int Mouse::GetPosY() const 35 | { 36 | return y; 37 | } 38 | 39 | bool Mouse::LeftIsPressed() const 40 | { 41 | return leftIsPressed; 42 | } 43 | 44 | bool Mouse::RightIsPressed() const 45 | { 46 | return rightIsPressed; 47 | } 48 | 49 | Mouse::Event Mouse::Read() 50 | { 51 | if (buffer.size() > 0u) 52 | { 53 | Mouse::Event e = buffer.front(); 54 | buffer.pop(); 55 | return e; 56 | } 57 | else 58 | { 59 | return Mouse::Event(); 60 | } 61 | } 62 | 63 | void Mouse::Flush() 64 | { 65 | buffer = std::queue(); 66 | } 67 | 68 | 69 | void Mouse::OnMouseMove(int newx, int newy) 70 | { 71 | x = newx; 72 | y = newy; 73 | 74 | buffer.push(Mouse::Event(Mouse::Event::Type::Move, *this)); 75 | TrimBuffer(); 76 | } 77 | 78 | void Mouse::OnLeftPressed() 79 | { 80 | leftIsPressed = true; 81 | 82 | buffer.push(Mouse::Event(Mouse::Event::Type::LPress, *this)); 83 | TrimBuffer(); 84 | } 85 | 86 | void Mouse::OnLeftReleased() 87 | { 88 | leftIsPressed = false; 89 | 90 | buffer.push(Mouse::Event(Mouse::Event::Type::LRelease, *this)); 91 | TrimBuffer(); 92 | } 93 | 94 | void Mouse::OnRightPressed() 95 | { 96 | rightIsPressed = true; 97 | 98 | buffer.push(Mouse::Event(Mouse::Event::Type::RPress, *this)); 99 | TrimBuffer(); 100 | } 101 | 102 | void Mouse::OnRightReleased() 103 | { 104 | rightIsPressed = false; 105 | 106 | buffer.push(Mouse::Event(Mouse::Event::Type::RRelease, *this)); 107 | TrimBuffer(); 108 | } 109 | 110 | void Mouse::OnWheel(float delta) 111 | { 112 | if (delta >= 0 ) 113 | { 114 | OnWheelUp(); 115 | } 116 | else 117 | { 118 | OnWheelDown(); 119 | } 120 | } 121 | 122 | void Mouse::OnWheelUp() 123 | { 124 | buffer.push(Mouse::Event(Mouse::Event::Type::WheelUp, *this)); 125 | TrimBuffer(); 126 | } 127 | 128 | void Mouse::OnWheelDown() 129 | { 130 | buffer.push(Mouse::Event(Mouse::Event::Type::WheelDown, *this)); 131 | TrimBuffer(); 132 | } 133 | 134 | void Mouse::TrimBuffer() 135 | { 136 | while (buffer.size() > bufferSize) 137 | { 138 | buffer.pop(); 139 | } 140 | } -------------------------------------------------------------------------------- /GameSFML/Mouse.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************************** 2 | * Chili DirectX Framework Version 16.07.20 * 3 | * Mouse.h * 4 | * Copyright 2016 PlanetChili * 5 | * * 6 | * This file is part of The Chili DirectX Framework. * 7 | * * 8 | * The Chili DirectX Framework is free software: you can redistribute it and/or modify * 9 | * it under the terms of the GNU General Public License as published by * 10 | * the Free Software Foundation, either version 3 of the License, or * 11 | * (at your option) any later version. * 12 | * * 13 | * The Chili DirectX Framework is distributed in the hope that it will be useful, * 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 | * GNU General Public License for more details. * 17 | * * 18 | * You should have received a copy of the GNU General Public License * 19 | * along with The Chili DirectX Framework. If not, see . * 20 | ******************************************************************************************/ 21 | #pragma once 22 | #include 23 | #include "SFML/Graphics.hpp" 24 | class Mouse 25 | { 26 | friend class MainWindow; 27 | public: 28 | class Event 29 | { 30 | public: 31 | enum class Type 32 | { 33 | LPress, 34 | LRelease, 35 | RPress, 36 | RRelease, 37 | WheelUp, 38 | WheelDown, 39 | Move, 40 | Invalid 41 | }; 42 | private: 43 | Type type; 44 | bool leftIsPressed; 45 | bool rightIsPressed; 46 | int x; 47 | int y; 48 | public: 49 | Event() 50 | : 51 | type(Type::Invalid), 52 | leftIsPressed(false), 53 | rightIsPressed(false), 54 | x(0), 55 | y(0) 56 | {} 57 | Event(Type type, const Mouse& parent) 58 | : 59 | type(type), 60 | leftIsPressed(parent.leftIsPressed), 61 | rightIsPressed(parent.rightIsPressed), 62 | x(parent.x), 63 | y(parent.y) 64 | {} 65 | bool IsValid() const 66 | { 67 | return type != Type::Invalid; 68 | } 69 | Type GetType() const 70 | { 71 | return type; 72 | } 73 | sf::Vector2i GetPos() const 74 | { 75 | return{ x,y }; 76 | } 77 | int GetPosX() const 78 | { 79 | return x; 80 | } 81 | int GetPosY() const 82 | { 83 | return y; 84 | } 85 | bool LeftIsPressed() const 86 | { 87 | return leftIsPressed; 88 | } 89 | bool RightIsPressed() const 90 | { 91 | return rightIsPressed; 92 | } 93 | }; 94 | public: 95 | Mouse() = default; 96 | Mouse(const Mouse&) = delete; 97 | Mouse& operator=(const Mouse&) = delete; 98 | sf::Vector2i GetPos() const; 99 | int GetPosX() const; 100 | int GetPosY() const; 101 | bool LeftIsPressed() const; 102 | bool RightIsPressed() const; 103 | Mouse::Event Read(); 104 | bool IsEmpty() const 105 | { 106 | return buffer.empty(); 107 | } 108 | void Flush(); 109 | private: 110 | void OnMouseMove(int x, int y); 111 | void OnLeftPressed(); 112 | void OnLeftReleased(); 113 | void OnRightPressed(); 114 | void OnRightReleased(); 115 | void OnWheel(float delta); 116 | void OnWheelUp(); 117 | void OnWheelDown(); 118 | void TrimBuffer(); 119 | private: 120 | static constexpr unsigned int bufferSize = 4u; 121 | int x; 122 | int y; 123 | bool leftIsPressed = false; 124 | bool rightIsPressed = false; 125 | std::queue buffer; 126 | }; -------------------------------------------------------------------------------- /GameSFML/System/AnimationSystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../System/ISystemECS.h" 3 | #include "../Component/AnimationComponent.h" 4 | class AnimationSystem final : public ISystemECS 5 | { 6 | public: 7 | void Update(entt::DefaultRegistry& ECS, float dt) final 8 | { 9 | auto view = ECS.view(); 10 | std::for_each(std::execution::par, view.begin(), view.end(), [&ECS, dt](auto entity) { 11 | auto& animation = ECS.get(entity); 12 | 13 | animation.curFrameTime += dt; 14 | //const auto prevFrame = animation.iCurFrame; 15 | while (animation.curFrameTime >= animation.holdTime) 16 | { 17 | animation.curFrameTime -= animation.holdTime; 18 | animation.iCurFrame++; 19 | if (animation.iCurFrame >= animation.rangeIndex.second) 20 | { 21 | animation.iCurFrame = animation.rangeIndex.first; 22 | } 23 | } 24 | }); 25 | } 26 | }; -------------------------------------------------------------------------------- /GameSFML/System/CollisionRespondSystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Locator.h" 3 | #include "../Component/CollisionRespondComponent.h" 4 | #include "../Component/PhysicComponent.h" 5 | #include "../Component/HealthComponent.h" 6 | #include "../System/ISystemECS.h" 7 | 8 | class CollisionRespondSystem : public ISystemECS 9 | { 10 | void Update(entt::DefaultRegistry& ECS, float dt) final 11 | { 12 | auto view = ECS.view(); 13 | std::for_each(std::execution::par, view.begin(), view.end(), [&ECS](auto entity) { 14 | auto& respond = ECS.get(entity); 15 | if (respond.myDelegate.empty()) return; 16 | 17 | respond.myDelegate(entity, ECS); 18 | }); 19 | 20 | ECS.reset(); 21 | } 22 | }; -------------------------------------------------------------------------------- /GameSFML/System/CullingSystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Locator.h" 3 | #include "../System/ISystemECS.h" 4 | #include "../Component/PhysicComponent.h" 5 | #include "../Component/AnimationComponent.h" 6 | #include "../Component/GameplayTags.h" 7 | #include "../HashStringDataBase.h" 8 | #include "entt/entt.hpp" 9 | #include 10 | #include 11 | #include 12 | class CullingSystem : public ISystemECS 13 | { 14 | struct CullingQuerySelector final : public b2QueryCallback 15 | { 16 | bool ReportFixture(b2Fixture* fixture) final 17 | { 18 | foundBodies.emplace_back(fixture->GetBody()->GetUserEntity()); 19 | return true;//keep going to find all fixtures in the query area 20 | } 21 | void Sort() 22 | { 23 | std::sort(std::execution::par_unseq, foundBodies.begin(), foundBodies.end()); 24 | } 25 | std::vector foundBodies; 26 | }; 27 | public: 28 | void Update(entt::DefaultRegistry& ECS, float dt) final 29 | { 30 | ECS.reset(); 31 | cullingQueryCallback.foundBodies.clear(); 32 | auto viewport = Locator::Graphic::ref().GetViewport(); 33 | b2AABB aabb; 34 | if (viewport.first.x > viewport.second.x) 35 | { 36 | std::swap(viewport.first.x, viewport.second.x); 37 | } 38 | if (viewport.first.y > viewport.second.y) 39 | { 40 | std::swap(viewport.first.y, viewport.second.y); 41 | } 42 | aabb.lowerBound = viewport.first; 43 | aabb.upperBound = viewport.second; 44 | Locator::Physic::ref().QueryAABB(&cullingQueryCallback, aabb); 45 | 46 | for (auto e : cullingQueryCallback.foundBodies) 47 | { 48 | ECS.assign(e); 49 | } 50 | } 51 | private: 52 | CullingQuerySelector cullingQueryCallback; 53 | }; -------------------------------------------------------------------------------- /GameSFML/System/DrawDebugSystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Graphics.h" 3 | #include "../Component/PhysicComponent.h" 4 | #include "../System/IDrawSystem.h" 5 | #include "../Locator.h" 6 | #include "../Component/GameplayTags.h" 7 | #include "../MaxxConsole.h" 8 | class DrawDebugSystem final : public IDrawSystem 9 | { 10 | public: 11 | void Draw(Graphics& gfx, entt::DefaultRegistry& ECS) const final 12 | { 13 | if (MaxxConsole::r_showDebugPhysic == 0) return; 14 | 15 | ECS.view().each([&ECS, &gfx](auto entity, auto&, auto&, PhysicComponent &physic) { 16 | switch (physic.body->GetFixtureList()->GetShape()->m_type) 17 | { 18 | case b2Shape::Type::e_polygon: 19 | { 20 | sf::RectangleShape rectangle; 21 | const b2Vec2 boxExtents = static_cast(physic.body->GetFixtureList()->GetShape())->m_vertices[2]; 22 | const auto screenSize = 2.0f * gfx.GetScreenSize(boxExtents); 23 | rectangle.setPosition(gfx.WorldToScreenPos(physic.body->GetPosition() + b2Vec2(-boxExtents.x, boxExtents.y))); 24 | rectangle.setSize(screenSize); 25 | rectangle.setFillColor(sf::Color(255, 0, 0, 128)); 26 | gfx.Draw(rectangle); 27 | break; 28 | } 29 | case b2Shape::Type::e_circle: 30 | { 31 | sf::CircleShape shape; 32 | const auto radius = physic.body->GetFixtureList()->GetShape()->m_radius; 33 | shape.setRadius(radius * gfx.scalePixel); 34 | shape.setPosition(gfx.WorldToScreenPos(physic.body->GetPosition() + b2Vec2(-radius, radius))); 35 | shape.setFillColor(sf::Color(0, 0, 255, 128)); 36 | gfx.Draw(shape); 37 | break; 38 | } 39 | default: 40 | break; 41 | } 42 | }); 43 | } 44 | }; -------------------------------------------------------------------------------- /GameSFML/System/HealthSystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../System/ISystemECS.h" 3 | #include "../Graphics.h" 4 | #include "../Component/HealthComponent.h" 5 | #include "../Component/PhysicComponent.h" 6 | #include "../Component/GameplayTags.h" 7 | class HealthSystem : public ISystemECS 8 | { 9 | public: 10 | void Update(entt::DefaultRegistry& ECS, float dt) final 11 | { 12 | ECS.view().each([&ECS](auto entity, HealthComponent &Health) { 13 | if (Health.curHealth > Health.maxHealth) 14 | { 15 | Health.curHealth = Health.maxHealth; 16 | return; 17 | } 18 | if (Health.curHealth > 0) return; 19 | 20 | ECS.assign(entity); 21 | }); 22 | } 23 | }; -------------------------------------------------------------------------------- /GameSFML/System/IDrawSystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Graphics.h" 3 | #include "entt/entt.hpp" 4 | class IDrawSystem 5 | { 6 | public: 7 | virtual void Draw(Graphics& gfx, entt::DefaultRegistry& ECS) const = 0; 8 | }; -------------------------------------------------------------------------------- /GameSFML/System/ISystemECS.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "entt/entt.hpp" 3 | #include 4 | class ISystemECS 5 | { 6 | public: 7 | virtual void Update(entt::DefaultRegistry& ECS, float dt) = 0; 8 | }; -------------------------------------------------------------------------------- /GameSFML/System/LifeTimeSystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../System/ISystemECS.h" 3 | #include "../Component/GameplayTags.h" 4 | class LifeTimeSystem : public ISystemECS 5 | { 6 | public: 7 | void Update(entt::DefaultRegistry& ECS, float dt) 8 | { 9 | ECS.view().each([&ECS,dt](auto entity, LifeTimeComponent& lifeTime) { 10 | lifeTime.curTime += dt; 11 | if (lifeTime.curTime >= lifeTime.maxLifeTime) 12 | { 13 | ECS.destroy(entity); 14 | } 15 | }); 16 | } 17 | }; -------------------------------------------------------------------------------- /GameSFML/System/MoveCameraSystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../System/ISystemECS.h" 3 | #include "../Locator.h" 4 | #include "../Component/GameplayTags.h" 5 | #include "../Component/PhysicComponent.h" 6 | 7 | class MoveCameraSystem : public ISystemECS 8 | { 9 | public: 10 | void Update(entt::DefaultRegistry& ECS, float dt) final 11 | { 12 | ECS.view().each([](auto entity, auto&, PhysicComponent& physic) { 13 | if (Locator::Graphic::empty()) return; 14 | 15 | Locator::Graphic::ref().MoveViewport(physic.body->GetPosition()); 16 | }); 17 | } 18 | private: 19 | }; 20 | /* Move Camera by mouse 21 | class MoveCameraSystem : public ISystemECS 22 | { 23 | public: 24 | void Update(entt::DefaultRegistry& ECS, float dt) final 25 | { 26 | auto& mouse = Locator::Mouse::ref(); 27 | while (!mouse.IsEmpty()) 28 | { 29 | const auto mouseEvent = mouse.Read(); 30 | switch (mouseEvent.GetType()) 31 | { 32 | case Mouse::Event::Type::RPress: 33 | engaged = true; 34 | lastPos = mouse.GetPos(); 35 | break; 36 | case Mouse::Event::Type::RRelease: 37 | engaged = false; 38 | break; 39 | } 40 | 41 | } 42 | 43 | if (engaged) 44 | { 45 | const auto curPos = mouse.GetPos(); 46 | Locator::Graphic::ref().MoveViewport(lastPos - mouse.GetPos()); 47 | lastPos = curPos; 48 | } 49 | } 50 | private: 51 | bool engaged = false; 52 | sf::Vector2i lastPos; 53 | };*/ 54 | 55 | -------------------------------------------------------------------------------- /GameSFML/System/PhysicSystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Locator.h" 3 | #include "../System/ISystemECS.h" 4 | 5 | class PhysicSystem : public ISystemECS 6 | { 7 | void Update(entt::DefaultRegistry& ECS, float dt) final 8 | { 9 | if (Locator::Physic::empty()) return; 10 | Locator::Physic::ref().Step(dt, 4, 2); 11 | } 12 | }; -------------------------------------------------------------------------------- /GameSFML/System/PlayerControllerSystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Locator.h" 3 | #include "../System/ISystemECS.h" 4 | #include "../Component/PlayerControllerComponent.h" 5 | #include "../MaxxConsole.h" 6 | class PlayerControllerSystem final : public ISystemECS 7 | { 8 | public: 9 | void Update(entt::DefaultRegistry& ECS, float dt) final 10 | { 11 | //keyboard 12 | auto& kbd = Locator::Keyboard::ref(); 13 | sf::Vector2i dir{ 0,0 }; 14 | if (kbd.KeyIsPressed(sf::Keyboard::A)) 15 | { 16 | dir.x = -1; 17 | } 18 | if (kbd.KeyIsPressed(sf::Keyboard::D)) 19 | { 20 | dir.x = 1; 21 | } 22 | if (kbd.KeyIsPressed(sf::Keyboard::S)) 23 | { 24 | dir.y = -1; 25 | } 26 | if (kbd.KeyIsPressed(sf::Keyboard::W)) 27 | { 28 | dir.y = 1; 29 | } 30 | if (kbd.KeyIsPressed(sf::Keyboard::Space)) 31 | { 32 | if (MaxxConsole::r_showDebugPhysic == 0) 33 | { 34 | MaxxConsole::r_showDebugPhysic = 1; 35 | } 36 | else 37 | { 38 | MaxxConsole::r_showDebugPhysic = 0; 39 | } 40 | } 41 | //mouse 42 | auto& mouse = Locator::Mouse::ref(); 43 | bool bIsShooting = false; 44 | while (!mouse.IsEmpty()) 45 | { 46 | auto e = mouse.Read(); 47 | if (e.GetType() == Mouse::Event::Type::LPress) 48 | { 49 | bIsShooting = true; 50 | continue; 51 | } 52 | /*if (e.GetType() == Mouse::Event::Type::RPress) 53 | { 54 | 55 | continue; 56 | }*/ 57 | } 58 | ECS.view().each([&dir, bIsShooting, &mouse](auto entity, PlayerControllerComponent& controller) { 59 | controller.direction = dir; 60 | controller.bIsShooting = bIsShooting; 61 | controller.mousePos = mouse.GetPos(); 62 | }); 63 | } 64 | }; -------------------------------------------------------------------------------- /GameSFML/System/PlayerUpdateSystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../System/ISystemECS.h" 3 | #include "../Component/PlayerControllerComponent.h" 4 | #include "../Component/PhysicComponent.h" 5 | #include "../Component/GameplayTags.h" 6 | class PlayerUpdateSystem final : public ISystemECS 7 | { 8 | public: 9 | void Update(entt::DefaultRegistry& ECS, float dt) final 10 | { 11 | auto& gfx = Locator::Graphic::ref(); 12 | ECS.view().each([&ECS, &gfx](auto entity, PlayerControllerComponent& controller, PhysicComponent& physic) { 13 | b2Vec2 vel = physic.body->GetLinearVelocity(); 14 | b2Vec2 desiredVel{(float)controller.direction.x, (float)controller.direction.y }; 15 | desiredVel.Normalize(); 16 | desiredVel = 15.0f * desiredVel; 17 | physic.body->ApplyLinearImpulseToCenter(physic.body->GetMass() * (desiredVel - vel), true); 18 | 19 | if (controller.bIsShooting) 20 | { 21 | auto entityBullet = ECS.create(); 22 | ECS.assign(entityBullet, 5.0f, 0.0f); 23 | ECS.assign(entityBullet, 10.0f, 10.0f); 24 | //animation 25 | auto& animation = ECS.assign(entityBullet, Locator::Codex::ref().GetAnimation(Database::BulletAnimation)); 26 | b2CircleShape circle; 27 | //sprite 28 | { 29 | auto& sprite = ECS.assign(entityBullet); 30 | sprite.setTexture(*animation.resource->texture); 31 | const auto textSize = 0.5f * sf::Vector2f((float)animation.resource->tileWidth, (float)animation.resource->tileHeight); 32 | sprite.setOrigin(textSize); 33 | circle.m_radius = 0.8f * textSize.x / gfx.scalePixel; 34 | } 35 | 36 | //physic 37 | const auto parentPosition = physic.body->GetPosition(); 38 | auto direction = gfx.MouseToWorldPos(controller.mousePos) - parentPosition; 39 | direction.Normalize(); 40 | b2BodyDef bodyDef; 41 | bodyDef.type = b2_dynamicBody; 42 | bodyDef.position = parentPosition + direction; 43 | 44 | 45 | b2FixtureDef fixtureDef; 46 | fixtureDef.shape = &circle; 47 | fixtureDef.filter.categoryBits = CollisionFillter::BULLET; 48 | fixtureDef.filter.maskBits = CollisionFillter::ENEMY; 49 | //fixtureDef.isSensor = true; 50 | fixtureDef.density = 1.0f; 51 | fixtureDef.friction = 0.0f; 52 | fixtureDef.restitution = 1.0f; 53 | 54 | ECS.assign(entityBullet); 55 | auto& bulletPhysic = ECS.assign(entityBullet, entityBullet, bodyDef, fixtureDef); 56 | bulletPhysic.body->ApplyForceToCenter(5000.0f * direction, true); 57 | ECS.assign(entityBullet).myDelegate.connect<&CollisionRespondComponent::Bullet>(); 58 | } 59 | }); 60 | } 61 | }; -------------------------------------------------------------------------------- /GameSFML/System/RenderGridSystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Locator.h" 3 | #include "../System/ISystemECS.h" 4 | #include "../System/IDrawSystem.h" 5 | class GridUpdateSystem final : public ISystemECS 6 | { 7 | public: 8 | void Update(entt::DefaultRegistry& ECS, float dt) final 9 | { 10 | if (Locator::Graphic::empty() || Locator::Grid::empty()) return; 11 | 12 | auto viewport = Locator::Graphic::ref().GetViewportScreen(); 13 | Locator::Grid::ref().Culling(viewport.first, viewport.second); 14 | } 15 | }; 16 | class RenderGridSystem final : public IDrawSystem 17 | { 18 | public: 19 | void Draw(Graphics& gfx, entt::DefaultRegistry& ECS) const final 20 | { 21 | if (Locator::Grid::empty()) return; 22 | 23 | gfx.Draw(Locator::Grid::ref()); 24 | } 25 | }; -------------------------------------------------------------------------------- /GameSFML/System/RenderScreenBaseUISystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Locator.h" 3 | #include "../System/IDrawSystem.h" 4 | #include "../Component/UIComponent.h" 5 | class RenderScreenBaseUISystem final : public IDrawSystem 6 | { 7 | public: 8 | void Draw(Graphics& gfx, entt::DefaultRegistry& ECS) const final 9 | { 10 | ECS.view().each([&gfx](auto entity, ScreenBaseUI& UI, ProgressiveBarComponent& bar) { 11 | const auto location = gfx.GetViewportLocation() + UI.offsetLocaion; 12 | 13 | sf::RectangleShape rectBG; 14 | sf::RectangleShape rectBase; 15 | 16 | rectBG.setPosition(location); 17 | rectBase.setPosition(location); 18 | rectBG.setSize(bar.size); 19 | rectBase.setSize({ bar.size.x * bar.percent, bar.size.y }); 20 | rectBG.setFillColor(bar.colorBG); 21 | rectBase.setFillColor(bar.colorBase); 22 | gfx.Draw(rectBG); 23 | gfx.Draw(rectBase); 24 | }); 25 | 26 | ECS.view().each([&gfx](auto entity, ScreenBaseUI& UI, sf::Text& text) { 27 | gfx.Draw(text); 28 | }); 29 | } 30 | }; -------------------------------------------------------------------------------- /GameSFML/System/RenderSpriteSystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Locator.h" 3 | #include "../System/ISystemECS.h" 4 | #include "../System/IDrawSystem.h" 5 | #include "../Component/PhysicComponent.h" 6 | #include "../Component/AnimationComponent.h" 7 | #include "../Component/GameplayTags.h" 8 | #include "../HashStringDataBase.h" 9 | #include "entt/entt.hpp" 10 | #include 11 | #include 12 | #include 13 | class SpirteUpdateSystem final : public ISystemECS 14 | { 15 | public: 16 | //update before Culling, animation, physic 17 | void Update(entt::DefaultRegistry& ECS, float dt) final 18 | { 19 | { 20 | auto view = ECS.view(); 21 | 22 | std::for_each(std::execution::par, view.begin(), view.end(), [&ECS](auto entity) { 23 | auto& animCom = ECS.get(entity); 24 | ECS.get(entity).setTextureRect(animCom.frames->at(animCom.iCurFrame)); 25 | }); 26 | } 27 | 28 | { 29 | auto view = ECS.view(); 30 | std::for_each(std::execution::par, view.begin(), view.end(), [&ECS](auto entity) { 31 | auto& sprite = ECS.get(entity); 32 | 33 | sprite.setPosition( 34 | Locator::Graphic::ref().WorldToScreenPos(ECS.get(entity).body->GetPosition()) 35 | ); 36 | }); 37 | } 38 | } 39 | }; 40 | class RenderSpriteSystem final : public IDrawSystem 41 | { 42 | public: 43 | void Draw(Graphics& gfx, entt::DefaultRegistry& ECS) const final 44 | { 45 | ECS.view().each([&gfx](auto entity, auto&, sf::Sprite &sprite) { 46 | gfx.DrawSprite(sprite); 47 | }); 48 | } 49 | }; -------------------------------------------------------------------------------- /GameSFML/System/RenderWorldBaseUISystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Locator.h" 3 | #include "../System/IDrawSystem.h" 4 | #include "../Component/UIComponent.h" 5 | #include "../Component/PhysicComponent.h" 6 | class RenderWorldBaseUISystem final : public IDrawSystem 7 | { 8 | public: 9 | void Draw(Graphics& gfx, entt::DefaultRegistry& ECS) const final 10 | { 11 | ECS.view().each([&ECS, &gfx](auto entity, auto&, WorldBaseUI& UI, ProgressiveBarComponent& bar) { 12 | if (!ECS.has(UI.ownerEntity)) return; 13 | auto& sprite = ECS.get(UI.ownerEntity); 14 | auto location = sprite.getPosition() - sf::Vector2f(0.5f * bar.size.x, (float)sprite.getTextureRect().height); 15 | sf::RectangleShape rect; 16 | rect.setPosition(location); 17 | 18 | //draw background 19 | rect.setSize(bar.size); 20 | rect.setFillColor(bar.colorBG); 21 | gfx.Draw(rect); 22 | 23 | //draw base 24 | rect.setSize({ bar.size.x * bar.percent, bar.size.y }); 25 | rect.setFillColor(bar.colorBase); 26 | gfx.Draw(rect); 27 | }); 28 | 29 | ECS.view().each([&gfx, &ECS](auto entity, auto&, WorldBaseUI& UI, sf::Text& text) { 30 | if (!ECS.has(UI.ownerEntity)) return; 31 | auto& sprite = ECS.get(UI.ownerEntity); 32 | auto location = sprite.getPosition() - sf::Vector2f(0.5f * text.getLocalBounds().width, (float)sprite.getTextureRect().height); 33 | text.setPosition(location); 34 | gfx.Draw(text); 35 | }); 36 | } 37 | }; -------------------------------------------------------------------------------- /GameSFML/System/SpawnAndCleanDeathSystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../System/ISystemECS.h" 3 | #include "../Component/GameplayTags.h" 4 | #include "../Component/SpawnComponent.h" 5 | #include "../Locator.h" 6 | class CleanDeadSystem : public ISystemECS 7 | { 8 | public: 9 | void Update(entt::DefaultRegistry& ECS, float dt) final 10 | { 11 | ECS.view().each([&ECS, dt](auto entity, auto&, NotifyOnDead& notifier) { 12 | notifier.mySignal.publish(entity, ECS); 13 | ECS.destroy(entity); 14 | }); 15 | ECS.destroy(); 16 | } 17 | }; 18 | class SpawnSystem : public ISystemECS 19 | { 20 | public: 21 | void Update(entt::DefaultRegistry& ECS, float dt) final 22 | { 23 | ECS.view().each([&ECS, dt](auto entity, SpawnComponent& spawn, UpdateSpawnComponent& update) { 24 | if (!spawn.bIsEnable) return; 25 | 26 | spawn.curTime += dt; 27 | while (spawn.curTime >= spawn.interval) 28 | { 29 | spawn.curTime -= spawn.interval; 30 | update.myDelegate(entity, ECS); 31 | } 32 | }); 33 | } 34 | }; -------------------------------------------------------------------------------- /GameSFML/System/SpawnStaticObjectSystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../System/ISystemECS.h" 3 | #include "../Component/PhysicComponent.h" 4 | #include "../Locator.h" 5 | #include "../Component/StaticObjectSpawnInfo.h" 6 | #include "../Component/GameplayTags.h" 7 | class SpawnStaticObjectSystem : public ISystemECS 8 | { 9 | struct OverlapQuerySelector final : public b2QueryCallback 10 | { 11 | bool ReportFixture(b2Fixture* fixture) final 12 | { 13 | const auto pos = fixture->GetBody()->GetPosition(); 14 | if (aabb.upperBound.x > pos.x && aabb.upperBound.y > pos.y && aabb.lowerBound.x < pos.x && aabb.lowerBound.y < pos.y) 15 | { 16 | const auto entity = fixture->GetBody()->GetUserEntity(); 17 | if (entity != exclutedEntity) 18 | { 19 | foundBodies.emplace_back(entity); 20 | } 21 | 22 | } 23 | return true;//keep going to find all fixtures in the query area 24 | } 25 | std::vector foundBodies; 26 | b2AABB aabb; 27 | uint32_t exclutedEntity; 28 | }; 29 | public: 30 | void Update(entt::DefaultRegistry& ECS, float dt) final 31 | { 32 | auto& gfx = Locator::Graphic::ref(); 33 | //spawn static object from tile 34 | ECS.view().each([&ECS, &gfx](auto entity, StaticObjectSpawnInfo &info) { 35 | const b2Vec2 worldSize = gfx.GetWorldSize({ info.width, info.height }); 36 | const auto pos = gfx.ScreenToWorldPos(info.pos); 37 | 38 | 39 | b2BodyDef bodyDef; 40 | bodyDef.type = b2_staticBody; 41 | bodyDef.position = pos; 42 | 43 | b2PolygonShape boxShape; 44 | boxShape.SetAsBox(worldSize.x, worldSize.y); 45 | 46 | b2FixtureDef fixtureDef; 47 | fixtureDef.shape = &boxShape; 48 | fixtureDef.density = 1.0f; 49 | fixtureDef.friction = 0.0f; 50 | fixtureDef.restitution = 1.0f; 51 | 52 | ECS.assign(entity, entity, bodyDef, fixtureDef); 53 | ECS.assign(entity); 54 | }); 55 | ECS.reset(); 56 | 57 | //spawn custom object 58 | ECS.view().each([&ECS, &gfx, this](auto entity, StaticCustomObjectSpawnInfo &info) { 59 | const b2Vec2 worldSize = gfx.GetWorldSize({ info.width, info.height }); 60 | const auto pos = gfx.ScreenToWorldPos(info.pos); 61 | 62 | 63 | b2BodyDef bodyDef; 64 | bodyDef.type = b2_staticBody; 65 | bodyDef.position = pos; 66 | 67 | b2PolygonShape boxShape; 68 | boxShape.SetAsBox(worldSize.x, worldSize.y); 69 | 70 | b2FixtureDef fixtureDef; 71 | fixtureDef.shape = &boxShape; 72 | fixtureDef.density = 1.0f; 73 | fixtureDef.friction = 0.0f; 74 | fixtureDef.restitution = 1.0f; 75 | 76 | ECS.assign(entity, entity, bodyDef, fixtureDef); 77 | ECS.assign(entity); 78 | 79 | //check if overlap with any tile object and delete the tile 80 | b2AABB aabb; 81 | aabb.lowerBound = pos - worldSize; 82 | aabb.upperBound = pos + worldSize; 83 | 84 | overlapQuery.foundBodies.clear(); 85 | overlapQuery.aabb = aabb; 86 | overlapQuery.exclutedEntity = entity; 87 | Locator::Physic::ref().QueryAABB(&overlapQuery, aabb); 88 | 89 | for (auto e : overlapQuery.foundBodies) 90 | { 91 | ECS.assign(e); 92 | } 93 | }); 94 | 95 | ECS.reset(); 96 | ECS.destroy(); 97 | } 98 | private: 99 | OverlapQuerySelector overlapQuery; 100 | }; -------------------------------------------------------------------------------- /GameSFML/System/TransitionStateSystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../System/ISystemECS.h" 3 | #include "../Component/TransitionStateComponent.h" 4 | class TransitionStateSystem final : public ISystemECS 5 | { 6 | public: 7 | void Update(entt::DefaultRegistry& ECS, float dt) final 8 | { 9 | auto view = ECS.view(); 10 | std::for_each(std::execution::par, view.begin(), view.end(), [&ECS](auto entity) { 11 | auto& respond = ECS.get(entity); 12 | if (respond.myDelegate.empty()) return; 13 | 14 | respond.myDelegate(entity, ECS); 15 | }); 16 | } 17 | }; -------------------------------------------------------------------------------- /GameSFML/System/UpdateUISystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "../Locator.h" 4 | #include "../System/ISystemECS.h" 5 | #include "../Component/UIComponent.h" 6 | 7 | class UpdateScreenBaseUISystem : public ISystemECS 8 | { 9 | void Update(entt::DefaultRegistry& ECS, float dt) final 10 | { 11 | auto view = ECS.view(); 12 | std::for_each(std::execution::par, view.begin(), view.end(), [&ECS](auto entity) { 13 | auto& updateUI = ECS.get(entity); 14 | if (updateUI.myDelegate.empty()) return; 15 | 16 | updateUI.myDelegate(entity, ECS); 17 | }); 18 | } 19 | }; 20 | 21 | class UpdateWorldBaseUISystem : public ISystemECS 22 | { 23 | void Update(entt::DefaultRegistry& ECS, float dt) final 24 | { 25 | ECS.reset(); 26 | 27 | ECS.view().each([&ECS](auto entity, auto&, OwnedUIComponent& owned) { 28 | for (auto e : owned.entities) 29 | { 30 | ECS.assign(e); 31 | } 32 | }); 33 | 34 | auto view = ECS.view(); 35 | std::for_each(std::execution::par, view.begin(), view.end(), [&ECS](auto entity) { 36 | auto& updateUI = ECS.get(entity); 37 | if (updateUI.myDelegate.empty()) return; 38 | 39 | updateUI.myDelegate(entity, ECS); 40 | }); 41 | } 42 | }; -------------------------------------------------------------------------------- /GameSFML/SystemInclude.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "System/PhysicSystem.h" 3 | #include "System/CollisionRespondSystem.h" 4 | #include "System/RenderSpriteSystem.h" 5 | #include "System/RenderGridSystem.h" 6 | #include "System/DrawDebugSystem.h" 7 | #include "System/RenderScreenBaseUISystem.h" 8 | #include "System/RenderWorldBaseUISystem.h" 9 | #include "System/HealthSystem.h" 10 | #include "System/SpawnAndCleanDeathSystem.h" 11 | #include "System/AnimationSystem.h" 12 | #include "System/MoveCameraSystem.h" 13 | #include "System/PlayerControllerSystem.h" 14 | #include "System/SpawnStaticObjectSystem.h" 15 | #include "System/CullingSystem.h" 16 | #include "System/TransitionStateSystem.h" 17 | #include "System/PlayerUpdateSystem.h" 18 | #include "System/LifeTimeSystem.h" 19 | #include "System/UpdateUISystem.h" -------------------------------------------------------------------------------- /GameSFML/World.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "HashStringDataBase.h" 3 | #include "Box2DContactListener.h" 4 | #include "SystemInclude.h" 5 | #include 6 | class World 7 | { 8 | public: 9 | World() 10 | { 11 | InitServiceLocator(); 12 | InitSystem(); 13 | TestSomething(); 14 | 15 | } 16 | void Update(float dt) 17 | { 18 | if (Locator::ECS::empty()) return; 19 | 20 | for (auto& sys : ecsSystems) 21 | { 22 | sys->Update(Locator::ECS::ref(), dt); 23 | } 24 | } 25 | void Draw()const 26 | { 27 | if (Locator::Graphic::empty() || Locator::ECS::empty()) return; 28 | auto& gfx = Locator::Graphic::ref(); 29 | auto& ECS = Locator::ECS::ref(); 30 | for (auto& sys : drawSystems) 31 | { 32 | sys->Draw(gfx, ECS); 33 | } 34 | 35 | } 36 | void AddECSSystem(std::unique_ptr newSystem) 37 | { 38 | ecsSystems.emplace_back(std::move(newSystem)); 39 | } 40 | void AddDrawSystem(std::unique_ptr newSystem) 41 | { 42 | drawSystems.emplace_back(std::move(newSystem)); 43 | } 44 | void AddSpawner(entt::DefaultRegistry& ECS, float worldSize) 45 | { 46 | auto entity = ECS.create(); 47 | ECS.assign(entity).interval = 1.0f; 48 | ECS.assign(entity).maxEntity = 20; 49 | ECS.assign(entity).myDelegate.connect(); 50 | 51 | if (Locator::Random::empty()) return; 52 | auto& rng = Locator::Random::ref(); 53 | std::uniform_real_distribution posRange(-worldSize, worldSize); 54 | std::uniform_real_distribution speedRange(-20.0f, 20.0f); 55 | auto& spawnPos = ECS.assign(entity); 56 | spawnPos.spawnPosition = b2Vec2(posRange(rng), posRange(rng)); 57 | spawnPos.variationX = 5; 58 | spawnPos.variationX = 2; 59 | spawnPos.speed = b2Vec2(speedRange(rng), speedRange(rng)); 60 | } 61 | void AddPlayer(entt::DefaultRegistry& ECS) 62 | { 63 | b2BodyDef bodyDef; 64 | bodyDef.type = b2_dynamicBody; 65 | const float size = 1.3f; 66 | b2CircleShape circle; 67 | circle.m_radius = size; 68 | 69 | b2FixtureDef fixtureDef; 70 | fixtureDef.shape = &circle; 71 | fixtureDef.filter.categoryBits = CollisionFillter::PLAYER; 72 | //fixtureDef.filter.maskBits = CollisionFillter::ENEMY | CollisionFillter::STATIC; 73 | //fixtureDef.isSensor = isSensor; 74 | fixtureDef.density = 1.0f; 75 | fixtureDef.friction = 0.0f; 76 | fixtureDef.restitution = 1.0f; 77 | auto entity = ECS.create(); 78 | ECS.assign(entity, 50.0f, 50.0f); 79 | ECS.assign(entity); 80 | 81 | auto& animation = ECS.assign(entity, 82 | Locator::Codex::ref().GetAnimation(Database::PlayerAnimation), 83 | ECS.assign(entity).state); 84 | 85 | ECS.assign(entity).myDelegate.connect<&TransitionStateComponent::Player>(); 86 | //sprite 87 | { 88 | auto& sprite = ECS.assign(entity); 89 | sprite.setTexture(*animation.resource->texture); 90 | const auto textSize = 0.5f * sf::Vector2f((float)animation.resource->tileWidth, (float)animation.resource->tileHeight); 91 | sprite.setOrigin(textSize); 92 | } 93 | 94 | 95 | ECS.assign(entity); 96 | ECS.assign(entity); 97 | ECS.assign(entity, entity, bodyDef, fixtureDef); 98 | ECS.assign(entity).myDelegate.connect<&CollisionRespondComponent::Player>(); 99 | 100 | //health text 101 | { 102 | auto entityUI = UIFactory::GetEntity(entity, ECS); 103 | const auto& textFont = Locator::Codex::ref().GetFont(Database::FontSplatch); 104 | ECS.assign(entityUI, "Health: ", textFont, 50); 105 | ECS.assign(entityUI, entity, sf::Vector2f(-640.0f, -360.0f)); 106 | ECS.assign(entityUI).myDelegate.connect<&UpdateScreenBaseUIComponent::HealthText>(); 107 | } 108 | 109 | 110 | //Health Bar 111 | { 112 | auto entityUI = UIFactory::GetEntity(entity, ECS); 113 | auto& progressBar = ECS.assign(entityUI, sf::Vector2f(400.0f, 55.0f)); 114 | ECS.assign(entityUI, entity, sf::Vector2f(-640.0f, -360.0f)); 115 | ECS.assign(entityUI).myDelegate.connect<&UpdateScreenBaseUIComponent::HealthBar>(); 116 | } 117 | } 118 | private: 119 | void SignalComponent(entt::DefaultRegistry& ECS) 120 | { 121 | ECS.destruction().connect<&OwnedUIComponent::Destruction>(); 122 | } 123 | void InitServiceLocator() 124 | { 125 | Locator::Random::set(std::random_device{}()); 126 | Locator::ECS::set(); 127 | SignalComponent(Locator::ECS::ref()); 128 | 129 | Locator::Physic::set(b2Vec2(0.0f, 0.0f)); 130 | if (!Locator::ECS::empty()) 131 | { 132 | static Box2DContactListener mrListener{ Locator::ECS::ref() }; 133 | Locator::Physic::ref().SetContactListener(&mrListener); 134 | } 135 | 136 | Locator::Codex::set(); 137 | Locator::Grid::set(); 138 | Locator::Grid::ref().LoadFromFile(Locator::Codex::ref(), Locator::ECS::ref()); 139 | } 140 | void InitSystem() 141 | { 142 | AddECSSystem(std::make_unique()); 143 | AddECSSystem(std::make_unique()); 144 | AddECSSystem(std::make_unique()); 145 | AddECSSystem(std::make_unique()); 146 | AddECSSystem(std::make_unique()); 147 | AddECSSystem(std::make_unique()); 148 | AddECSSystem(std::make_unique()); 149 | AddECSSystem(std::make_unique()); 150 | AddECSSystem(std::make_unique()); 151 | AddECSSystem(std::make_unique()); 152 | AddECSSystem(std::make_unique()); 153 | AddECSSystem(std::make_unique()); 154 | AddECSSystem(std::make_unique()); 155 | AddECSSystem(std::make_unique()); 156 | AddECSSystem(std::make_unique()); 157 | AddECSSystem(std::make_unique()); 158 | AddECSSystem(std::make_unique()); 159 | 160 | //render Grid should be before render sprite and after move camera; 161 | AddDrawSystem(std::make_unique()); 162 | //render Sprite should be the last 163 | AddDrawSystem(std::make_unique()); 164 | drawSystems.emplace_back(std::make_unique()); 165 | drawSystems.emplace_back(std::make_unique()); 166 | drawSystems.emplace_back(std::make_unique()); 167 | } 168 | void AddWall(b2Vec2 p1, b2Vec2 p2) 169 | { 170 | const auto entity = Locator::ECS::ref().create(); 171 | b2BodyDef bodyDef; 172 | bodyDef.type = b2_staticBody; 173 | bodyDef.position.Set(0, 0); 174 | 175 | b2EdgeShape edgeShape; 176 | edgeShape.Set(p1, p2); 177 | 178 | b2FixtureDef fixtureDef; 179 | fixtureDef.shape = &edgeShape; 180 | 181 | Locator::ECS::ref().assign(entity, entity, bodyDef, fixtureDef); 182 | } 183 | void TestSomething() 184 | { 185 | auto& ECS = Locator::ECS::ref(); 186 | auto& rng = Locator::Random::ref(); 187 | const float worldSize = 100.0f; 188 | AddWall(b2Vec2(worldSize, -worldSize), b2Vec2(worldSize, worldSize)); 189 | AddWall(b2Vec2(worldSize, worldSize), b2Vec2(-worldSize, worldSize)); 190 | AddWall(b2Vec2(-worldSize, worldSize), b2Vec2(-worldSize, -worldSize)); 191 | AddWall(b2Vec2(-worldSize, -worldSize), b2Vec2(worldSize, -worldSize)); 192 | 193 | AddPlayer(ECS); 194 | 195 | std::uniform_real_distribution pos(-worldSize + 5.0f, worldSize - 5.0f); 196 | std::uniform_real_distribution speed(-20.0f, 20.0f); 197 | for (size_t i = 0; i < 10; i++) 198 | { 199 | AddSpawner(ECS, worldSize - 10.0f); 200 | } 201 | } 202 | private: 203 | std::vector> ecsSystems; 204 | std::vector> drawSystems; 205 | }; -------------------------------------------------------------------------------- /GameSFML/main.cpp: -------------------------------------------------------------------------------- 1 | #include "MainWindow.h" 2 | #include "Game.h" 3 | 4 | int main() 5 | { 6 | MainWindow wnd; 7 | Game game; 8 | while (wnd.Update()) 9 | { 10 | game.Go(); 11 | } 12 | 13 | return 0; 14 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Game-SFML 2 | 3 | # 3rd Libary 4 | * [Chili Framework](https://github.com/planetchili/chili_framework) : For mouse and keyboard. 5 | * [SFML](https://github.com/SFML/SFML) : For graphic, sound and network. 6 | * [Entt](https://github.com/skypjack/entt) : For ECS libary. 7 | * [nlohmann/json](https://github.com/nlohmann/json) : For parse json. 8 | * [Box2d](https://github.com/erincatto/Box2D) : For physic 2d. 9 | 10 | # How To Install 11 | Need SFML and Entt install using vcpkg 12 | ```c 13 | vcpkg install sfml:x64-windows 14 | vcpkg install entt:x64-windows 15 | vcpkg install box2d:x64-windows 16 | ``` 17 | --------------------------------------------------------------------------------