Skip to content

mediaexplorer74/LDtkMonogame

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LDtkMonogame 1.0-prealpha

Discord Link  

About

LDtkMonogame is an level importer for the LDtk level editor.

Tech details

  • UWP library : Min Win. SDK is 16299, Main Win. SDK is 19041. So, no W10M compatibility yet.
  • This is veeery quick (fast) and dirty "UWP-Remake" of LDtkMonogame project.
  • To be continued (I hope)

Getting Started

The easiest way to start using LDtkMonogame is to import it into the project using NuGet package.

Make sure to import the namespace at the top

using LDtk;
// Optional
using LDtk.Renderer;

LDtk.Renderer is a premade renderer for the levels, you can create your own if you have more specific needs ExampleRenderer.cs is an example of how to make one. Or you can inherit it and extend it.

To get started loading ldtk files load the file in Initialize.

LDtkFile file = LDtkFile.FromFile("World", Content);
LDtkFile file = LDtkFile.FromFile("Data/World.ldtk");

Then load the world right after for now ldtk only supports one file but make sure to enable the multiworlds flag in the project settings under advanced.

LDtkWorld world = file.LoadWorld(Worlds.World.Iid);

The Worlds.World.Iid is generated from the ldtkgen tool and is recommended that you use it for static typing of entities and levels.
It is a class within in a class that represents the world name and the levels name and holds the iid you can use to load that specific level.

Create the renderer in Initialize.

ExampleRenderer renderer = new ExampleRenderer(spriteBatch, Content);
ExampleRenderer renderer = new ExampleRenderer(spriteBatch);

Prerender Levels

foreach (LDtkLevel level in world.Levels)
{
    renderer.PrerenderLevel(level);
}

Now to render the level and entities we loaded in Draw

GraphicsDevice.Clear(world.BgColor);

spriteBatch.Begin(samplerState: SamplerState.PointClamp);
{
    foreach (LDtkLevel level in world.Levels)
    {
        renderer.RenderPrerenderedLevel(level);
    }
}
spriteBatch.End();

Showcase

Unnamed

screenshot

by Fypur

Play the game on Itch

Example Game

screenshot

.

As is. No support. DIY. Learn purposes only.

Reference(s)

https://github.com/IrishBruse/LDtkMonogame Original LDtkMonogame (by Ethan Conneely aka IrishBruse)

..

[m][e] March 2025

About

Monogame importer, renderer and code generator for LDtk Level editor. UWP edition. Draft.

Topics

Resources

License

Stars

Watchers

Forks

Languages

  • C# 100.0%