Skip to content

Commit

Permalink
bump plugin a bit less dumb
Browse files Browse the repository at this point in the history
* Drawing now shows all objects in the world, not just STI-derived ones.
* No longer need to pass the world into functions aside from init.
  • Loading branch information
karai17 committed Sep 10, 2020
1 parent 2a08bf4 commit 50ef76c
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions sti/plugins/bump.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ local lg = require((...):gsub('plugins.bump', 'graphics'))
return {
bump_LICENSE = "MIT/X11",
bump_URL = "https://github.com/karai17/Simple-Tiled-Implementation",
bump_VERSION = "3.1.7.0",
bump_VERSION = "3.1.7.1",
bump_DESCRIPTION = "Bump hooks for STI.",

--- Adds each collidable tile to the Bump world.
Expand Down Expand Up @@ -139,19 +139,15 @@ return {
end
end
end

end

map.bump_world = world
map.bump_collidables = collidables
end,

--- Remove layer
-- @param index to layer to be removed
-- @param world bump world the holds the tiles
-- @param tx Translate on X
-- @param ty Translate on Y
-- @param sx Scale on X
-- @param sy Scale on Y
bump_removeLayer = function(map, index, world)
bump_removeLayer = function(map, index)
local layer = assert(map.layers[index], "Layer not found: " .. index)
local collidables = map.bump_collidables

Expand All @@ -164,7 +160,7 @@ return {
layer.properties.collidable == true
or obj.properties.collidable == true
) then
world:remove(obj)
map.bump_world:remove(obj)
table.remove(collidables, i)
end
end
Expand All @@ -176,13 +172,14 @@ return {
-- @param ty Translate on Y
-- @param sx Scale on X
-- @param sy Scale on Y
bump_draw = function(map, world, tx, ty, sx, sy)
bump_draw = function(map, tx, ty, sx, sy)
lg.push()
lg.scale(sx or 1, sy or sx or 1)
lg.translate(math.floor(tx or 0), math.floor(ty or 0))

for _, collidable in pairs(map.bump_collidables) do
lg.rectangle("line", world:getRect(collidable))
local items = map.bump_world:getItems()
for _, item in ipairs(items) do
lg.rectangle("line", map.bump_world:getRect(item))
end

lg.pop()
Expand Down

0 comments on commit 50ef76c

Please sign in to comment.