You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you like STI, consider tossing me a few monies via PayPal.
Simple Tiled Implementation is a Tiled map loader and renderer designed for the awesomeLÖVE framework. Please read the documentation to learn how it works, or check out the tutorials included in this repo.
Quick Example
-- This example uses the included Box2D (love.physics) plugin!!localsti=require"sti"functionlove.load()
-- Grab window sizewindowWidth=love.graphics.getWidth()
windowHeight=love.graphics.getHeight()
-- Set world meter size (in pixels)love.physics.setMeter(32)
-- Load a map exported to Lua from Tiledmap=sti("assets/maps/map01.lua", { "box2d" })
-- Prepare physics world with horizontal and vertical gravityworld=love.physics.newWorld(0, 0)
-- Prepare collision objectsmap:box2d_init(world)
-- Create a Custom Layermap:addCustomLayer("Sprite Layer", 3)
-- Add data to Custom LayerlocalspriteLayer=map.layers["Sprite Layer"]
spriteLayer.sprites= {
player= {
image=love.graphics.newImage("assets/sprites/player.png"),
x=64,
y=64,
r=0,
}
}
-- Update callback for Custom LayerfunctionspriteLayer:update(dt)
for_, spriteinpairs(self.sprites) dosprite.r=sprite.r+math.rad(90*dt)
endend-- Draw callback for Custom LayerfunctionspriteLayer:draw()
for_, spriteinpairs(self.sprites) dolocalx=math.floor(sprite.x)
localy=math.floor(sprite.y)
localr=sprite.rlove.graphics.draw(sprite.image, x, y, r)
endendendfunctionlove.update(dt)
map:update(dt)
endfunctionlove.draw()
-- Draw the map and all objects withinlove.graphics.setColor(1, 1, 1)
map:draw()
-- Draw Collision Map (useful for debugging)love.graphics.setColor(1, 0, 0)
map:box2d_draw()
-- Please note that map:draw, map:box2d_draw, and map:bump_draw take-- translate and scale arguments (tx, ty, sx, sy) for when you want to-- grow, shrink, or reposition your map on screen.end
Requirements
This library recommends LÖVE 11.x and Tiled 1.2.x. If you are updating from an older version of Tiled, please re-export your Lua map files.
License
This code is licensed under the MIT/X11 Open Source License. Check out the LICENSE file for more information.