Giter VIP home page Giter VIP logo

ldtkgo's Introduction

LDtk-Go

LDtk-Go is a loader for LDtk projects written in pure Go.

Screenshot

Generally, you first load a project using ldtkgo.LoadFile() or ldtkgo.LoadBytes(); afterward, you render the layers out to images, and then draw them onscreen with a rendering or game development framework, like ebiten, Pixel, raylib-go, or raylib-go-plus.

All of the major elements of LDtk should be supported, including Levels, Layers, Tiles, AutoLayers, IntGrids, Entities, and Properties.

Pkg.go.dev docs

Loading Projects

Using LDtk-Go is simple.

First, you load the LDTK project, either with ldtkgo.LoadFile() or ldtkgo.LoadBytes(). After that, you have access to the entire project in code. Currently, I believe all of LDtk projects and the major elements of each are fully accessible through this loader. Here's an excerpt from the provided example, showing loading an LDtk Project and then

ldtkProject *ldtkgo.Project
ebitenRenderer *renderer.EbitenRenderer

func main() {

	// Load the LDtk Project
    ldtkProject, err := ldtkgo.LoadFile("example.ldtk")

    if err != nil {
        panic(err)
    }
    
	// Choose a level...
	level := ldtkProject.Levels[0]

	// Create a new renderer...
	ebitenRenderer = renderer.NewEbitenRenderer()

	// ... And render the tiles for the level out to *ebiten.Images. We'll retrieve them to draw later in a Draw() loop.
	ebitenRenderer.Render(level)

}

As shown above, rendering is done by creating a renderer and using it to render with your framework of choice. One is already provided for the ebiten framework, which can be used as a general guide for creating other renderers.

Running the Example

cd to the example directory, and then call go run ./ to run the example (as it's self-contained within its directory). The console will give instructions for interacting with the example.

Anything Else?

The core LDtk loader requires the encoding/json and image packages, as well as tidwall's gjson package. The ebiten renderer requires ebiten package as well, of course.

ldtkgo's People

Contributors

solarlune avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.