You need to download the code off of github and put it into your game directory. When you download it, you should get a folder called Simple-Tiled-Implementation-master (or something to that effect) and iside it there area few other folders such as tests, docs, and sti. Copy the sti folder into your game and then require it like the readme states.rodi wrote:Hi, I am completely new, first time posting on here and am trying to learn Love2D/Lua/STI I've basically done the hello world and went through some basic video tutorials. I'm trying to get the basic example found on the STI github page working, (copied and pasted it verbatim) but I get: module 'sti' not found
I apologize in advance for the dumb question, I have local sti = require "sti" but do I need to install sti somehow? I tried googling and searching this forum but didn't really get an answer, maybe this question is too basic to find a post on. Help?
Simple Tiled Implementation - STI v1.2.3.0
Re: Simple Tiled Implementation - STI v0.16.0.2
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.16.0.2
I'm using the bump.lua plugin and I was wondering if there is there any way to do this without having to use integers, for example this:Karai17 wrote:You can use the map:convertPixelToTile method convert the player's position to a tile, and then determine which tiles it may be touching base don proximity.
Code: Select all
love.graphics.print(map:convertScreenToWorld(player.x, player.y), 0, 0, 0, 0.4)
i.e
Code: Select all
function collisioncheck()
if player colliding with tileProperty: 'right_wall' then -- pseudocode
player.die() -- just for example
end
end
rather than
Code: Select all
function collisioncheck()
if map:convertScreenToWorld(player.x, player.y) == 16 then
player.die() -- just for example
end
end
Re: Simple Tiled Implementation - STI v0.16.0.2
First off, the convert functions returns 2 numbers, not 1, so your code is only interacting with the X axis and not the Y axis. You should store the results of the convert functions into local variables first, and then test.
Also, that function was renamed convertPixelToTile in the most recent version of STI, so you might want to try upgrading.
Finally, the convert function that returns the position in tile/world space should not be giving you an integer, it should be giving you a double. To get the actual tile object, you'd want to do something like the following:
Code: Select all
local x, y = map:convertScreenToWorld(player.x, player.y)
Finally, the convert function that returns the position in tile/world space should not be giving you an integer, it should be giving you a double. To get the actual tile object, you'd want to do something like the following:
Code: Select all
local x, y = map:convertPixelToTile(player.x, player.y)
local tile = map.layers["Tile Layer 1"].data[math.floor(y)][math.floor(x)]
if tile and tile.properties["right_wall"] then
player.die()
end
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.16.0.2
Is it possible to desynchronize animation of tiles?
Say, I have animated grass but don't want all animations to be at exact same frame.
Sorry if it was asked and answered before, but the forums' search ignores "STI" as a too short word.
Say, I have animated grass but don't want all animations to be at exact same frame.
Sorry if it was asked and answered before, but the forums' search ignores "STI" as a too short word.
Re: Simple Tiled Implementation - STI v0.16.0.2
You'll need to create several different animations with different starting frames.
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.16.0.2
I'm trying something similar to another post (link below) and running into an issue drawing multiple maps. I'm relatively new to Love2d and finding STI to work quite well. Thanks for library!
Possibly relevant post: viewtopic.php?f=5&t=76983&p=192950&hili ... aw#p192950
Right now, I understand my problem to be that if I have two maps loaded, then call each map's draw() function, only the last call the draw() appears to work. It looks like each map.draw() call is clearing the screen (or canvas?)? Maybe I'm going about this in the wrong way.
Goal: load multiple maps, position them using the offset parameters, and draw some of them simultaneously.
In the code below, for instance, map1 will be drawn, then cleared, then map2 will be drawn (leaving a blank area in map1's postiion).
Essentially, I'm moving toward a solution in which I can build a "world" made up of an arbitrary number of small maps. As my camera/player move from map to map, I'm able to load newly needed maps into memory, and unload unneeded ones.
Crudely drawn below. Think, as player approaches the right boundary of map1, map2 is loaded and drawn. As player approaches the right boundary of map2, map3 is loaded and drawn, while map1 is unloaded.
[map1][map2][map3]
[map4][map5][map6]
[map4][map5][map6]
Maybe I'm going about this in the wrong way, or completely missing something about how map:draw() works. Any help would be much appreciated!
Possibly relevant post: viewtopic.php?f=5&t=76983&p=192950&hili ... aw#p192950
Right now, I understand my problem to be that if I have two maps loaded, then call each map's draw() function, only the last call the draw() appears to work. It looks like each map.draw() call is clearing the screen (or canvas?)? Maybe I'm going about this in the wrong way.
Goal: load multiple maps, position them using the offset parameters, and draw some of them simultaneously.
In the code below, for instance, map1 will be drawn, then cleared, then map2 will be drawn (leaving a blank area in map1's postiion).
Code: Select all
local map1 = sti('path/to/map1', {"bump"}, offsetX, offsetY)
local map2 = sti('path/to/map2', {"bump"}, offsetX, offsetY)
-- ... later in the draw function
map1:draw()
map2:draw()
Crudely drawn below. Think, as player approaches the right boundary of map1, map2 is loaded and drawn. As player approaches the right boundary of map2, map3 is loaded and drawn, while map1 is unloaded.
[map1][map2][map3]
[map4][map5][map6]
[map4][map5][map6]
Maybe I'm going about this in the wrong way, or completely missing something about how map:draw() works. Any help would be much appreciated!
Re: Simple Tiled Implementation - STI v0.16.0.2
Each map has its own internal canvas so there should be no overwriting going on. Are you properly using the offsetx and offsety values when creating a new map? Unless you use those offsets, they will all be placed at 0,0.
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é
-
- Party member
- Posts: 730
- Joined: Sat Apr 26, 2014 7:46 pm
Re: Simple Tiled Implementation - STI v0.16.0.2
Hello. I wrote the bump plugin and currently the tile properties are added to the collision item in such a way that it can be accessed by doing:milk wrote:I'm using the bump.lua plugin and I was wondering if there is there any way to do this without having to use integers, for example this:Karai17 wrote:You can use the map:convertPixelToTile method convert the player's position to a tile, and then determine which tiles it may be touching base don proximity.prints '16' when I've collided with the right wall, whereas I'd want the tile property returned as a string, which is in the tiled map's custom properties is specified as 'right_wall'.Code: Select all
love.graphics.print(map:convertScreenToWorld(player.x, player.y), 0, 0, 0, 0.4)
i.e
What I'm trying to explain is, for each tile with the custom property of 'right_wall' the function player.die is called on collision, (which is handled by bump.lua no?)Code: Select all
function collisioncheck() if player colliding with tileProperty: 'right_wall' then -- pseudocode player.die() -- just for example end end
rather thanI looked at Map:getTileProperties (layer, x, y) but I'm not overly sure how to implement is as shown in the manner above, any help would be greatly appreciated!Code: Select all
function collisioncheck() if map:convertScreenToWorld(player.x, player.y) == 16 then player.die() -- just for example end end
Code: Select all
tile.properties.property
Code: Select all
for i,v in ipairs(cols) do
v.other.properties.property
end
Re: Simple Tiled Implementation - STI v0.16.0.2
Re: multiple maps drawing at the same time, in different positions using the offset parameters.
Following up from a few days ago, thanks for the response. I put together a small love file with 4 maps to test this. It loads 4 small maps, positions them, then makes 4 :draw calls. The order matters, the last draw call wins, and only that map is displayed (positioned correctly).
I think I must be missing something about how this is supposed to work. Thanks!
Following up from a few days ago, thanks for the response. I put together a small love file with 4 maps to test this. It loads 4 small maps, positions them, then makes 4 :draw calls. The order matters, the last draw call wins, and only that map is displayed (positioned correctly).
I think I must be missing something about how this is supposed to work. Thanks!
Re: Simple Tiled Implementation - STI v0.16.0.2
So I think I know what the issue is. Each map's canvas is being cleared before drawing, which is the right thing to do, but the colour it is being cleared with is love's background colour, which is black in this case, but always solid in any other case as well. This means that if the map canvases are over lapping each other, parts will not be shown. The map's canvas is the size of the window. So if you have maps smaller than 1 window size, it will cause issues.
Now, I don't know if the proper fix here is to change the canvas size to be either the size of the map or the size of the window, whichever is smaller; or if I should leave it as-is and tell people maps should be a certain size if you are going to have several of them. Both methods have pros and cons.
Now, I don't know if the proper fix here is to change the canvas size to be either the size of the map or the size of the window, whichever is smaller; or if I should leave it as-is and tell people maps should be a certain size if you are going to have several of them. Both methods have pros and cons.
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é
Who is online
Users browsing this forum: No registered users and 3 guests