Simple Tiled Implementation - STI v1.2.3.0
Re: Simple Tiled Implementation - STI v0.7.4
map.layers is a table of all the layers in your map. What that comment is suggesting is that you cannot change the tiles in a map (yet) since they are all batched and I haven't put any code in to update batches.
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é
- Cryogenical
- Prole
- Posts: 49
- Joined: Mon Apr 28, 2014 5:23 pm
Re: Simple Tiled Implementation - STI v0.7.4
I think I'm missing a key component to this whole thing.
I've altered the act_x and act_y variables to what you earlier on suggested, and I've tried to put in the .data array, but even when I changed the act_y and act_x to y and x in the"if collision.data[player.act_y - 1][player.act_x] ~= 1 then" statements on the love.keypressed events, nothing still happened, but it didn't crash.
I've altered the act_x and act_y variables to what you earlier on suggested, and I've tried to put in the .data array, but even when I changed the act_y and act_x to y and x in the"if collision.data[player.act_y - 1][player.act_x] ~= 1 then" statements on the love.keypressed events, nothing still happened, but it didn't crash.
- Attachments
-
- Love2D.love
- (35.06 KiB) Downloaded 123 times
Re: Simple Tiled Implementation - STI v0.7.4
I don't think you're tying the player's drawn location to act_x and act_y. When you update the player's location, you need to use that new data to determine where on the screen it is actually drawn.
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é
- Cryogenical
- Prole
- Posts: 49
- Joined: Mon Apr 28, 2014 5:23 pm
Re: Simple Tiled Implementation - STI v0.7.4
Can I bother you to explain what each part of this means?
From what I understand, the key would be the up arrow when pressed, the if statement occurs, if coordinate [y-1][x] (ie: 7,6) is within 1 (what does this 1 represent? a "within" barrier?)
then it'll execute your player's movement (act_y - 1) (in which the 1 would have to be a bigger number, probably 32 for pixel size of tile?)
Code: Select all
function love.keypressed(key, isrepeat)
if key == "up" then
if collision.data[y - 1][x] ~= 1 then
-- the block above us is not collidable, so we can walk there!
player.act_y = player.act_y - 1
end
return
end
end
then it'll execute your player's movement (act_y - 1) (in which the 1 would have to be a bigger number, probably 32 for pixel size of tile?)
Re: Simple Tiled Implementation - STI v0.7.4
~= is "not equal to". If you check the data, you will see that all the values are either 0 or 1. 0 is the walkable space, 1 is the solid space.
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é
- Cryogenical
- Prole
- Posts: 49
- Joined: Mon Apr 28, 2014 5:23 pm
Re: Simple Tiled Implementation - STI v0.7.4
In the map file, the tileset consists of many different numbers, not just 0s and 1s though? It's recognizing all other tiles as like 60s and 9s and 7s, etc.
Re: Simple Tiled Implementation - STI v0.7.4
getCollisionMap() grabs a copy of a layer, converts all the non-zero tiles to 1, and returns it.
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é
- Cryogenical
- Prole
- Posts: 49
- Joined: Mon Apr 28, 2014 5:23 pm
Re: Simple Tiled Implementation - STI v0.7.4
Code: Select all
function player.update(dt)
player.act_y = player.act_y - ((player.act_y - player.grid_y) * player.speed * dt)
player.act_x = player.act_x - ((player.act_x - player.grid_x) * player.speed * dt)
end
I keep rubber-banding back to the starting position whenever I try to move.
Re: Simple Tiled Implementation - STI v0.7.4
Code: Select all
function player.update(dt)
if love.keyboard.isDown("up") then player.act_y = player.act_y - player.speed * dt end
if love.keyboard.isDown("down") then player.act_y = player.act_y + player.speed * dt end
if love.keyboard.isDown("left") then player.act_x = player.act_x - player.speed * dt end
if love.keyboard.isDown("right") then player.act_x = player.act_x + player.speed * dt end
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é
- Cryogenical
- Prole
- Posts: 49
- Joined: Mon Apr 28, 2014 5:23 pm
Re: Simple Tiled Implementation - STI v0.7.4
While so, it's not processing any sort of collision nor moving by tile. I have a very simple platformer that I created; so I do know how to move a player freely, but I just don't fully understand how to restrict the player's movement to a grid.
Can you add me on skype or something? I really want to understand this but I think I'm just missing some key points.
Can you add me on skype or something? I really want to understand this but I think I'm just missing some key points.
Who is online
Users browsing this forum: No registered users and 1 guest