├── .gitignore ├── Content ├── Content.mgcb ├── exampleMap.tmx ├── exampleTileset.png └── exampleTileset.tsx ├── Game1.cs ├── Icon.bmp ├── Icon.ico ├── LICENSE ├── Program.cs ├── README.md ├── TiledCS-MonoGame-Example.csproj ├── TiledCS-MonoGame-Example.sln ├── app.manifest └── preview.png /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/csharp,visualstudio 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=csharp,visualstudio 4 | 5 | ### Csharp ### 6 | ## Ignore Visual Studio temporary files, build results, and 7 | ## files generated by popular Visual Studio add-ons. 8 | ## 9 | ## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore 10 | 11 | # User-specific files 12 | *.rsuser 13 | *.suo 14 | *.user 15 | *.userosscache 16 | *.sln.docstates 17 | 18 | # User-specific files (MonoDevelop/Xamarin Studio) 19 | *.userprefs 20 | 21 | # Mono auto generated files 22 | mono_crash.* 23 | 24 | # Build results 25 | [Dd]ebug/ 26 | [Dd]ebugPublic/ 27 | [Rr]elease/ 28 | [Rr]eleases/ 29 | x64/ 30 | x86/ 31 | [Ww][Ii][Nn]32/ 32 | [Aa][Rr][Mm]/ 33 | [Aa][Rr][Mm]64/ 34 | bld/ 35 | [Bb]in/ 36 | [Oo]bj/ 37 | [Ll]og/ 38 | [Ll]ogs/ 39 | 40 | # Visual Studio 2015/2017 cache/options directory 41 | .vs/ 42 | # Uncomment if you have tasks that create the project's static files in wwwroot 43 | #wwwroot/ 44 | 45 | # Visual Studio 2017 auto generated files 46 | Generated\ Files/ 47 | 48 | # MSTest test Results 49 | [Tt]est[Rr]esult*/ 50 | [Bb]uild[Ll]og.* 51 | 52 | # NUnit 53 | *.VisualState.xml 54 | TestResult.xml 55 | nunit-*.xml 56 | 57 | # Build Results of an ATL Project 58 | [Dd]ebugPS/ 59 | [Rr]eleasePS/ 60 | dlldata.c 61 | 62 | # Benchmark Results 63 | BenchmarkDotNet.Artifacts/ 64 | 65 | # .NET Core 66 | project.lock.json 67 | project.fragment.lock.json 68 | artifacts/ 69 | 70 | # ASP.NET Scaffolding 71 | ScaffoldingReadMe.txt 72 | 73 | # StyleCop 74 | StyleCopReport.xml 75 | 76 | # Files built by Visual Studio 77 | *_i.c 78 | *_p.c 79 | *_h.h 80 | *.ilk 81 | *.meta 82 | *.obj 83 | *.iobj 84 | *.pch 85 | *.pdb 86 | *.ipdb 87 | *.pgc 88 | *.pgd 89 | *.rsp 90 | *.sbr 91 | *.tlb 92 | *.tli 93 | *.tlh 94 | *.tmp 95 | *.tmp_proj 96 | *_wpftmp.csproj 97 | *.log 98 | *.tlog 99 | *.vspscc 100 | *.vssscc 101 | .builds 102 | *.pidb 103 | *.svclog 104 | *.scc 105 | 106 | # Chutzpah Test files 107 | _Chutzpah* 108 | 109 | # Visual C++ cache files 110 | ipch/ 111 | *.aps 112 | *.ncb 113 | *.opendb 114 | *.opensdf 115 | *.sdf 116 | *.cachefile 117 | *.VC.db 118 | *.VC.VC.opendb 119 | 120 | # Visual Studio profiler 121 | *.psess 122 | *.vsp 123 | *.vspx 124 | *.sap 125 | 126 | # Visual Studio Trace Files 127 | *.e2e 128 | 129 | # TFS 2012 Local Workspace 130 | $tf/ 131 | 132 | # Guidance Automation Toolkit 133 | *.gpState 134 | 135 | # ReSharper is a .NET coding add-in 136 | _ReSharper*/ 137 | *.[Rr]e[Ss]harper 138 | *.DotSettings.user 139 | 140 | # TeamCity is a build add-in 141 | _TeamCity* 142 | 143 | # DotCover is a Code Coverage Tool 144 | *.dotCover 145 | 146 | # AxoCover is a Code Coverage Tool 147 | .axoCover/* 148 | !.axoCover/settings.json 149 | 150 | # Coverlet is a free, cross platform Code Coverage Tool 151 | coverage*.json 152 | coverage*.xml 153 | coverage*.info 154 | 155 | # Visual Studio code coverage results 156 | *.coverage 157 | *.coveragexml 158 | 159 | # NCrunch 160 | _NCrunch_* 161 | .*crunch*.local.xml 162 | nCrunchTemp_* 163 | 164 | # MightyMoose 165 | *.mm.* 166 | AutoTest.Net/ 167 | 168 | # Web workbench (sass) 169 | .sass-cache/ 170 | 171 | # Installshield output folder 172 | [Ee]xpress/ 173 | 174 | # DocProject is a documentation generator add-in 175 | DocProject/buildhelp/ 176 | DocProject/Help/*.HxT 177 | DocProject/Help/*.HxC 178 | DocProject/Help/*.hhc 179 | DocProject/Help/*.hhk 180 | DocProject/Help/*.hhp 181 | DocProject/Help/Html2 182 | DocProject/Help/html 183 | 184 | # Click-Once directory 185 | publish/ 186 | 187 | # Publish Web Output 188 | *.[Pp]ublish.xml 189 | *.azurePubxml 190 | # Note: Comment the next line if you want to checkin your web deploy settings, 191 | # but database connection strings (with potential passwords) will be unencrypted 192 | *.pubxml 193 | *.publishproj 194 | 195 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 196 | # checkin your Azure Web App publish settings, but sensitive information contained 197 | # in these scripts will be unencrypted 198 | PublishScripts/ 199 | 200 | # NuGet Packages 201 | *.nupkg 202 | # NuGet Symbol Packages 203 | *.snupkg 204 | # The packages folder can be ignored because of Package Restore 205 | **/[Pp]ackages/* 206 | # except build/, which is used as an MSBuild target. 207 | !**/[Pp]ackages/build/ 208 | # Uncomment if necessary however generally it will be regenerated when needed 209 | #!**/[Pp]ackages/repositories.config 210 | # NuGet v3's project.json files produces more ignorable files 211 | *.nuget.props 212 | *.nuget.targets 213 | 214 | # Microsoft Azure Build Output 215 | csx/ 216 | *.build.csdef 217 | 218 | # Microsoft Azure Emulator 219 | ecf/ 220 | rcf/ 221 | 222 | # Windows Store app package directories and files 223 | AppPackages/ 224 | BundleArtifacts/ 225 | Package.StoreAssociation.xml 226 | _pkginfo.txt 227 | *.appx 228 | *.appxbundle 229 | *.appxupload 230 | 231 | # Visual Studio cache files 232 | # files ending in .cache can be ignored 233 | *.[Cc]ache 234 | # but keep track of directories ending in .cache 235 | !?*.[Cc]ache/ 236 | 237 | # Others 238 | ClientBin/ 239 | ~$* 240 | *~ 241 | *.dbmdl 242 | *.dbproj.schemaview 243 | *.jfm 244 | *.pfx 245 | *.publishsettings 246 | orleans.codegen.cs 247 | 248 | # Including strong name files can present a security risk 249 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 250 | #*.snk 251 | 252 | # Since there are multiple workflows, uncomment next line to ignore bower_components 253 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 254 | #bower_components/ 255 | 256 | # RIA/Silverlight projects 257 | Generated_Code/ 258 | 259 | # Backup & report files from converting an old project file 260 | # to a newer Visual Studio version. Backup files are not needed, 261 | # because we have git ;-) 262 | _UpgradeReport_Files/ 263 | Backup*/ 264 | UpgradeLog*.XML 265 | UpgradeLog*.htm 266 | ServiceFabricBackup/ 267 | *.rptproj.bak 268 | 269 | # SQL Server files 270 | *.mdf 271 | *.ldf 272 | *.ndf 273 | 274 | # Business Intelligence projects 275 | *.rdl.data 276 | *.bim.layout 277 | *.bim_*.settings 278 | *.rptproj.rsuser 279 | *- [Bb]ackup.rdl 280 | *- [Bb]ackup ([0-9]).rdl 281 | *- [Bb]ackup ([0-9][0-9]).rdl 282 | 283 | # Microsoft Fakes 284 | FakesAssemblies/ 285 | 286 | # GhostDoc plugin setting file 287 | *.GhostDoc.xml 288 | 289 | # Node.js Tools for Visual Studio 290 | .ntvs_analysis.dat 291 | node_modules/ 292 | 293 | # Visual Studio 6 build log 294 | *.plg 295 | 296 | # Visual Studio 6 workspace options file 297 | *.opt 298 | 299 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 300 | *.vbw 301 | 302 | # Visual Studio 6 auto-generated project file (contains which files were open etc.) 303 | *.vbp 304 | 305 | # Visual Studio 6 workspace and project file (working project files containing files to include in project) 306 | *.dsw 307 | *.dsp 308 | 309 | # Visual Studio 6 technical files 310 | 311 | # Visual Studio LightSwitch build output 312 | **/*.HTMLClient/GeneratedArtifacts 313 | **/*.DesktopClient/GeneratedArtifacts 314 | **/*.DesktopClient/ModelManifest.xml 315 | **/*.Server/GeneratedArtifacts 316 | **/*.Server/ModelManifest.xml 317 | _Pvt_Extensions 318 | 319 | # Paket dependency manager 320 | .paket/paket.exe 321 | paket-files/ 322 | 323 | # FAKE - F# Make 324 | .fake/ 325 | 326 | # CodeRush personal settings 327 | .cr/personal 328 | 329 | # Python Tools for Visual Studio (PTVS) 330 | __pycache__/ 331 | *.pyc 332 | 333 | # Cake - Uncomment if you are using it 334 | # tools/** 335 | # !tools/packages.config 336 | 337 | # Tabs Studio 338 | *.tss 339 | 340 | # Telerik's JustMock configuration file 341 | *.jmconfig 342 | 343 | # BizTalk build output 344 | *.btp.cs 345 | *.btm.cs 346 | *.odx.cs 347 | *.xsd.cs 348 | 349 | # OpenCover UI analysis results 350 | OpenCover/ 351 | 352 | # Azure Stream Analytics local run output 353 | ASALocalRun/ 354 | 355 | # MSBuild Binary and Structured Log 356 | *.binlog 357 | 358 | # NVidia Nsight GPU debugger configuration file 359 | *.nvuser 360 | 361 | # MFractors (Xamarin productivity tool) working folder 362 | .mfractor/ 363 | 364 | # Local History for Visual Studio 365 | .localhistory/ 366 | 367 | # Visual Studio History (VSHistory) files 368 | .vshistory/ 369 | 370 | # BeatPulse healthcheck temp database 371 | healthchecksdb 372 | 373 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 374 | MigrationBackup/ 375 | 376 | # Ionide (cross platform F# VS Code tools) working folder 377 | .ionide/ 378 | 379 | # Fody - auto-generated XML schema 380 | FodyWeavers.xsd 381 | 382 | # VS Code files for those working on multiple tools 383 | .vscode/* 384 | !.vscode/settings.json 385 | !.vscode/tasks.json 386 | !.vscode/launch.json 387 | !.vscode/extensions.json 388 | *.code-workspace 389 | 390 | # Local History for Visual Studio Code 391 | .history/ 392 | 393 | # Windows Installer files from build outputs 394 | *.cab 395 | *.msi 396 | *.msix 397 | *.msm 398 | *.msp 399 | 400 | # JetBrains Rider 401 | *.sln.iml 402 | 403 | ### VisualStudio ### 404 | 405 | # User-specific files 406 | 407 | # User-specific files (MonoDevelop/Xamarin Studio) 408 | 409 | # Mono auto generated files 410 | 411 | # Build results 412 | 413 | # Visual Studio 2015/2017 cache/options directory 414 | # Uncomment if you have tasks that create the project's static files in wwwroot 415 | 416 | # Visual Studio 2017 auto generated files 417 | 418 | # MSTest test Results 419 | 420 | # NUnit 421 | 422 | # Build Results of an ATL Project 423 | 424 | # Benchmark Results 425 | 426 | # .NET Core 427 | 428 | # ASP.NET Scaffolding 429 | 430 | # StyleCop 431 | 432 | # Files built by Visual Studio 433 | 434 | # Chutzpah Test files 435 | 436 | # Visual C++ cache files 437 | 438 | # Visual Studio profiler 439 | 440 | # Visual Studio Trace Files 441 | 442 | # TFS 2012 Local Workspace 443 | 444 | # Guidance Automation Toolkit 445 | 446 | # ReSharper is a .NET coding add-in 447 | 448 | # TeamCity is a build add-in 449 | 450 | # DotCover is a Code Coverage Tool 451 | 452 | # AxoCover is a Code Coverage Tool 453 | 454 | # Coverlet is a free, cross platform Code Coverage Tool 455 | 456 | # Visual Studio code coverage results 457 | 458 | # NCrunch 459 | 460 | # MightyMoose 461 | 462 | # Web workbench (sass) 463 | 464 | # Installshield output folder 465 | 466 | # DocProject is a documentation generator add-in 467 | 468 | # Click-Once directory 469 | 470 | # Publish Web Output 471 | # Note: Comment the next line if you want to checkin your web deploy settings, 472 | # but database connection strings (with potential passwords) will be unencrypted 473 | 474 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 475 | # checkin your Azure Web App publish settings, but sensitive information contained 476 | # in these scripts will be unencrypted 477 | 478 | # NuGet Packages 479 | # NuGet Symbol Packages 480 | # The packages folder can be ignored because of Package Restore 481 | # except build/, which is used as an MSBuild target. 482 | # Uncomment if necessary however generally it will be regenerated when needed 483 | # NuGet v3's project.json files produces more ignorable files 484 | 485 | # Microsoft Azure Build Output 486 | 487 | # Microsoft Azure Emulator 488 | 489 | # Windows Store app package directories and files 490 | 491 | # Visual Studio cache files 492 | # files ending in .cache can be ignored 493 | # but keep track of directories ending in .cache 494 | 495 | # Others 496 | 497 | # Including strong name files can present a security risk 498 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 499 | 500 | # Since there are multiple workflows, uncomment next line to ignore bower_components 501 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 502 | 503 | # RIA/Silverlight projects 504 | 505 | # Backup & report files from converting an old project file 506 | # to a newer Visual Studio version. Backup files are not needed, 507 | # because we have git ;-) 508 | 509 | # SQL Server files 510 | 511 | # Business Intelligence projects 512 | 513 | # Microsoft Fakes 514 | 515 | # GhostDoc plugin setting file 516 | 517 | # Node.js Tools for Visual Studio 518 | 519 | # Visual Studio 6 build log 520 | 521 | # Visual Studio 6 workspace options file 522 | 523 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 524 | 525 | # Visual Studio 6 auto-generated project file (contains which files were open etc.) 526 | 527 | # Visual Studio 6 workspace and project file (working project files containing files to include in project) 528 | 529 | # Visual Studio 6 technical files 530 | 531 | # Visual Studio LightSwitch build output 532 | 533 | # Paket dependency manager 534 | 535 | # FAKE - F# Make 536 | 537 | # CodeRush personal settings 538 | 539 | # Python Tools for Visual Studio (PTVS) 540 | 541 | # Cake - Uncomment if you are using it 542 | # tools/** 543 | # !tools/packages.config 544 | 545 | # Tabs Studio 546 | 547 | # Telerik's JustMock configuration file 548 | 549 | # BizTalk build output 550 | 551 | # OpenCover UI analysis results 552 | 553 | # Azure Stream Analytics local run output 554 | 555 | # MSBuild Binary and Structured Log 556 | 557 | # NVidia Nsight GPU debugger configuration file 558 | 559 | # MFractors (Xamarin productivity tool) working folder 560 | 561 | # Local History for Visual Studio 562 | 563 | # Visual Studio History (VSHistory) files 564 | 565 | # BeatPulse healthcheck temp database 566 | 567 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 568 | 569 | # Ionide (cross platform F# VS Code tools) working folder 570 | 571 | # Fody - auto-generated XML schema 572 | 573 | # VS Code files for those working on multiple tools 574 | 575 | # Local History for Visual Studio Code 576 | 577 | # Windows Installer files from build outputs 578 | 579 | # JetBrains Rider 580 | 581 | ### VisualStudio Patch ### 582 | # Additional files built by Visual Studio 583 | 584 | # End of https://www.toptal.com/developers/gitignore/api/csharp,visualstudio 585 | -------------------------------------------------------------------------------- /Content/Content.mgcb: -------------------------------------------------------------------------------- 1 | 2 | #----------------------------- Global Properties ----------------------------# 3 | 4 | /outputDir:bin/$(Platform) 5 | /intermediateDir:obj/$(Platform) 6 | /platform:DesktopGL 7 | /config: 8 | /profile:Reach 9 | /compress:False 10 | 11 | #-------------------------------- References --------------------------------# 12 | 13 | 14 | #---------------------------------- Content ---------------------------------# 15 | 16 | #begin exampleTileset.png 17 | /importer: 18 | /processor: 19 | /build:exampleTileset.png 20 | 21 | -------------------------------------------------------------------------------- /Content/exampleMap.tmx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | eJxjZmBgYKQAwwALDjaMjy6PrgafOLH60DEIMEHZTGgYJgYALAgAZw== 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Content/exampleTileset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NaakkaDev/TiledCS-MonoGame-Example/9e0709e94fe268ae2a1a3c676cd1ccf2712c38a1/Content/exampleTileset.png -------------------------------------------------------------------------------- /Content/exampleTileset.tsx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Game1.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using Microsoft.Xna.Framework.Graphics; 3 | using Microsoft.Xna.Framework.Input; 4 | using System; 5 | using TiledCS; 6 | 7 | namespace TiledCS_MonoGame_Example 8 | { 9 | public class Game1 : Game 10 | { 11 | private GraphicsDeviceManager _graphics; 12 | private SpriteBatch _spriteBatch; 13 | 14 | private TiledMap _map; 15 | private TiledTileset _tileset; 16 | private Texture2D _tilesetTexture; 17 | 18 | private int _tileWidth; 19 | private int _tileHeight; 20 | private int _tilesetTilesWide; 21 | private int _tilesetTilesHeight; 22 | 23 | public Game1() 24 | { 25 | _graphics = new GraphicsDeviceManager(this); 26 | Content.RootDirectory = "Content"; 27 | IsMouseVisible = true; 28 | } 29 | 30 | protected override void Initialize() 31 | { 32 | // TODO: Add your initialization logic here 33 | 34 | base.Initialize(); 35 | } 36 | 37 | protected override void LoadContent() 38 | { 39 | _spriteBatch = new SpriteBatch(GraphicsDevice); 40 | 41 | // Set the "Copy to Output Directory" property of these two files to `Copy if newer` 42 | // by clicking them in the solution explorer. 43 | _map = new TiledMap(Content.RootDirectory + "\\exampleMap.tmx"); 44 | _tileset = new TiledTileset(Content.RootDirectory + "\\exampleTileset.tsx"); 45 | 46 | // Not the best way to do this but it works. It looks for "exampleTileset.xnb" file 47 | // which is the result of building the image file with "Content.mgcb". 48 | _tilesetTexture = Content.Load("exampleTileset"); 49 | 50 | _tileWidth = _tileset.TileWidth; 51 | _tileHeight = _tileset.TileHeight; 52 | 53 | // Amount of tiles on each row (left right) 54 | _tilesetTilesWide = _tileset.Columns; 55 | // Amount of tiels on each column (up down) 56 | _tilesetTilesHeight = _tileset.TileCount / _tileset.Columns; 57 | 58 | // Print "Sun" to the debug console. This is an object in "Object Layer 1". 59 | System.Diagnostics.Debug.WriteLine(_map.Layers[1].objects[0].name); 60 | 61 | // TODO: use this.Content to load your game content here 62 | } 63 | 64 | protected override void Update(GameTime gameTime) 65 | { 66 | if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) 67 | Exit(); 68 | 69 | // TODO: Add your update logic here 70 | 71 | base.Update(gameTime); 72 | } 73 | 74 | protected override void Draw(GameTime gameTime) 75 | { 76 | GraphicsDevice.Clear(Color.CornflowerBlue); 77 | 78 | _spriteBatch.Begin(); 79 | 80 | for (var i = 0; i < _map.Layers[0].data.Length; i++) 81 | { 82 | int gid = _map.Layers[0].data[i]; 83 | 84 | // Empty tile, do nothing 85 | if (gid == 0) 86 | { 87 | 88 | } 89 | else 90 | { 91 | // Tileset tile ID 92 | // Looking at the exampleTileset.png 93 | // 0 = Blue 94 | // 1 = Green 95 | // 2 = Dark Yellow 96 | // 3 = Magenta 97 | int tileFrame = gid - 1; 98 | 99 | // Print the tile type into the debug console. 100 | // This assumes only one (1) `tiled tileset` is being used, so getting the first one. 101 | var tile = _map.GetTiledTile(_map.Tilesets[0], _tileset, gid); 102 | if (tile != null) { 103 | // This should print "Grass" for each grass tile in the map each draw call 104 | // so six (6) times. 105 | System.Diagnostics.Debug.WriteLine(tile.type); 106 | } 107 | 108 | int column = tileFrame % _tilesetTilesWide; 109 | int row = (int)Math.Floor((double)tileFrame / (double)_tilesetTilesWide); 110 | 111 | float x = (i % _map.Width) * _map.TileWidth; 112 | float y = (float)Math.Floor(i / (double)_map.Width) * _map.TileHeight; 113 | 114 | Rectangle tilesetRec = new Rectangle(_tileWidth * column, _tileHeight * row, _tileWidth, _tileHeight); 115 | 116 | _spriteBatch.Draw(_tilesetTexture, new Rectangle((int)x, (int)y, _tileWidth, _tileHeight), tilesetRec, Color.White); 117 | } 118 | } 119 | 120 | _spriteBatch.End(); 121 | 122 | base.Draw(gameTime); 123 | 124 | // Separate draw calls in the debug console 125 | System.Diagnostics.Debug.WriteLine("------------------------"); 126 | } 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /Icon.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NaakkaDev/TiledCS-MonoGame-Example/9e0709e94fe268ae2a1a3c676cd1ccf2712c38a1/Icon.bmp -------------------------------------------------------------------------------- /Icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NaakkaDev/TiledCS-MonoGame-Example/9e0709e94fe268ae2a1a3c676cd1ccf2712c38a1/Icon.ico -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2022 Temeez 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TiledCS_MonoGame_Example 4 | { 5 | public static class Program 6 | { 7 | [STAThread] 8 | static void Main() 9 | { 10 | using (var game = new Game1()) 11 | game.Run(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [TiledCS](https://github.com/TheBoneJarmer/TiledCS) [MonoGame 3.8](https://github.com/mono/MonoGame) Example 2 | 3 | This example shows how simple it is to draw a (TMX) map made with [Tiled](http://www.mapeditor.org/) in MonoGame project. 4 | 5 | Used the `MonoGame Cross-Platform Desktop Application (OpenGL)` template. 6 | 7 | **Note:** Because someone wanted to learn, I have updated this example to work with the newest (3.8) MonoGame version and the new TiledCS that succeeded TiledSharp. 8 | 9 | ![How it should look image](preview.png) 10 | 11 | ## Notes: 12 | The TMX and TSX map files is **not** supposed to be build with content pipeline. Just add it to the project and set **Copy if newer** from the files properties. 13 | 14 | TiledCS does not seem to like embedded tilesets so make sure "Embed in map" is false when adding new tilesets in Tiled. 15 | -------------------------------------------------------------------------------- /TiledCS-MonoGame-Example.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | WinExe 4 | netcoreapp3.1 5 | false 6 | false 7 | 8 | 9 | app.manifest 10 | Icon.ico 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | PreserveNewest 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | PreserveNewest 38 | 39 | 40 | PreserveNewest 41 | 42 | 43 | -------------------------------------------------------------------------------- /TiledCS-MonoGame-Example.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.32228.343 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TiledCS-MonoGame-Example", "TiledCS-MonoGame-Example.csproj", "{73A2B69B-593A-4874-BC11-50F563934B08}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {73A2B69B-593A-4874-BC11-50F563934B08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {73A2B69B-593A-4874-BC11-50F563934B08}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {73A2B69B-593A-4874-BC11-50F563934B08}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {73A2B69B-593A-4874-BC11-50F563934B08}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {B1D550A6-8B39-4353-8C5D-C50ACDDC4234} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /app.manifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | true/pm 39 | permonitorv2,permonitor 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NaakkaDev/TiledCS-MonoGame-Example/9e0709e94fe268ae2a1a3c676cd1ccf2712c38a1/preview.png --------------------------------------------------------------------------------