Simple Tiled Implementation - STI v1.2.3.0
Re: Simple Tiled Implementation - STI v0.7.4
Join the #love IRC channel and pm me (Karai)
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
- Cucurbitacée
- Prole
- Posts: 47
- Joined: Fri Dec 14, 2012 10:22 am
- Location: Frankfurt am Main
Re: Simple Tiled Implementation - STI v0.7.4
Hi there,
I've been using a previous version of STI in my current project and it was working fine. It was version 0.6.4, I think. As I'm getting to the point where I want to really use Tiled to design a level I decided to update to the current version.
And I have a problem with love.graphics.scale. My implementation is very basic:
If I play with scale 1, it's fine, like this:
But if I play with scale 2, it shows only a quarter of the screen like this:
I tried to add setDrawRange(, but it didn't change anything... I'd be really glad if someone can tell me what I do wrong.
I've been using a previous version of STI in my current project and it was working fine. It was version 0.6.4, I think. As I'm getting to the point where I want to really use Tiled to design a level I decided to update to the current version.
And I have a problem with love.graphics.scale. My implementation is very basic:
Code: Select all
local sti = require "Libs.STI"
function love.load()
...
level.load(sti)
...
end
function love.update(dt)
...
level.update(dt)
...
end
function level.draw()
...
level.draw()
...
end
function level.load(sti)
...
map = sti.new(maps/level1)
end
function level.update(dt)
...
map.update(dt)
end
function level.draw()
map:draw()
...
end
But if I play with scale 2, it shows only a quarter of the screen like this:
I tried to add setDrawRange(, but it didn't change anything... I'd be really glad if someone can tell me what I do wrong.
Re: Simple Tiled Implementation - STI v0.7.4
You need to add map:resize to love.resize. sti uses a canvas now to fix a lot of scaling issues, which needs to be resized when the screen changes.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
- Cucurbitacée
- Prole
- Posts: 47
- Joined: Fri Dec 14, 2012 10:22 am
- Location: Frankfurt am Main
Re: Simple Tiled Implementation - STI v0.7.4
Thanks a lot! Silly me, it was in the documentation.
Re: Simple Tiled Implementation - STI v0.7.4
Updated the documentation to be nice looking and more digestible. Whoop whoop!
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
Re: Simple Tiled Implementation - STI v0.7.4
i'm checking for collisions like this, but whenever i go to move my player, i get an error that looks like this -Karai17 wrote:Code: Select all
local sti = require "sti" function love.load() map = sti.new("map") collision = map:getCollisionMap("Collision Layer") player = { x = 24, y = 36 } -- player is standing on the 24,36 block of the map end function love.keypressed(key, isrepeat) if key == "up" then if collision.data[player.y - 1][player.x] ~= 1 then -- the block above us is not collidable, so we can walk there! player.y = player.y - 1 end return end if key == "down" then if collision.data[player.y + 1][player.x] ~= 1 then -- the block below us is not collidable, so we can walk there! player.y = player.y + 1 end return end if key == "left" then if collision.data[player.y][player.x - 1] ~= 1 then -- the block to the left of us is not collidable, so we can walk there! player.x = player.x - 1 end return end if key == "right" then if collision.data[player.y][player.x + 1] ~= 1 then -- the block to the right of us is not collidable, so we can walk there! player.x = player.x + 1 end return end end
the code i'm using to set up my player looks like this -
Code: Select all
function bolo_load()
img = love.graphics.newImage("gfx/bolo.png")
img:setFilter("nearest")
anim = newAnimation(img, 34, 38, 0, 0)
x = 0
y = 0
spd = 90
dir = 1
grassmap = sti.new("maps/grass")
grasscol = grassmap:getCollisionMap("collisions")
end
function bolo_update(dt)
if love.keyboard.isDown("up") and grasscol.data[y - 1][x] ~= 1 then
y = y - spd * dt
end
if love.keyboard.isDown("down") and grasscol.data[y + 1][x] ~= 1 then
y = y + spd * dt
end
if love.keyboard.isDown("left") and grasscol.data[y][x - 1] ~= 1 then
x = x - spd * dt
dir = -1
end
if love.keyboard.isDown("right") and grasscol.data[y][x + 1] ~= 1 then
x = x + spd * dt
dir = 1
end
end
Re: Simple Tiled Implementation - STI v0.7.4
You are having scope issues. You are using global x and y values for both you rmap indices and your movement speed.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
Re: Simple Tiled Implementation - STI v0.7.4
Karai17 wrote:You are having scope issues. You are using global x and y values for both you rmap indices and your movement speed.
Code: Select all
function bolo_load()
img = love.graphics.newImage("gfx/bolo.png")
img:setFilter("nearest")
anim = newAnimation(img, 34, 38, 0, 0)
bolo = {
x = 40,
y = 40
}
spd = 90
dir = 1
grassmap = sti.new("maps/grass")
grasscol = grassmap:getCollisionMap("collisions")
end
function bolo_update(dt)
if love.keyboard.isDown("up") and grasscol.data[bolo.y - 1][bolo.x] ~= 1 then
bolo.y = bolo.y - spd * dt
end
if love.keyboard.isDown("down") and grasscol.data[bolo.y + 1][bolo.x] ~= 1 then
bolo.y = bolo.y + spd * dt
end
if love.keyboard.isDown("left") and grasscol.data[bolo.y][bolo.x - 1] ~= 1 then
bolo.x = bolo.x - spd * dt
dir = -1
end
if love.keyboard.isDown("right") and grasscol.data[bolo.y][bolo.x + 1] ~= 1 then
bolo.x = bolo.x + spd * dt
dir = 1
end
end
Re: Simple Tiled Implementation - STI v0.7.4
Yes. bolo.x = bolo.x + spd * dt is the problem. You are changing x and y to non-indexed numbers.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
Re: Simple Tiled Implementation - STI v0.7.4
sorry, i'm somewhat new to lua so i'm kind of unclear on how to fix this (i came from a GML background). i have what you have in terms of movement (bolo.x = bolo.x + spd) so i'm unsure of what to do next.Karai17 wrote:Yes. bolo.x = bolo.x + spd * dt is the problem. You are changing x and y to non-indexed numbers.
Who is online
Users browsing this forum: No registered users and 0 guests