diff --git a/sonic-radiance.love/assets/gui/tilemask.png b/sonic-radiance.love/assets/gui/tilemask.png new file mode 100644 index 0000000..c74d044 Binary files /dev/null and b/sonic-radiance.love/assets/gui/tilemask.png differ diff --git a/sonic-radiance.love/scenes/battlesystem/controller/battlearena.lua b/sonic-radiance.love/scenes/battlesystem/controller/battlearena.lua index d5456e2..f4b88ee 100644 --- a/sonic-radiance.love/scenes/battlesystem/controller/battlearena.lua +++ b/sonic-radiance.love/scenes/battlesystem/controller/battlearena.lua @@ -50,6 +50,8 @@ function BattleArena:loadRessources() self.textures.borders = love.graphics.newImage("assets/backgrounds/borders.png") self.textures.shadow = love.graphics.newImage("assets/sprites/shadow.png") + self.emptytile = love.graphics.newImage("assets/gui/tilemask.png") + self.quads = {} self.quads.tiles = {} self.quads.sptiles = {} @@ -207,4 +209,47 @@ function BattleArena:drawTile(x, y, type, variant) end end +function BattleArena:showMask(ox, oy, shape, size, direction) + for i=1,12 do + for j=1,7 do + if self:isInMask(i, j, ox, oy, shape, size, direction) then + local x, y = self:gridToPixel(i, j) + love.graphics.draw(self.emptytile, x, y) + end + end + end +end + +function BattleArena:isInMask(x, y, ox, oy, shape, size, direction) + local direction = direction or 1 + local shape = shape or "point" + if shape == "point" then + return ((x == ox) and (y == oy)) + elseif shape == "square" then + local x1 = ox - math.floor(size/2) + local x2 = ox + math.ceil(size/2) + + local y1 = oy - math.floor(size/2) + local y2 = oy + math.ceil(size/2) + return ((x >= x1) and (x <= x2) and (y >= y1) and (y <= y2)) + elseif shape == "circle" then + local lenght = utils.math.pointDistance(x, y, ox, oy) + return (lenght <= size) + elseif shape == "fullheight" then + local x2 = ox + (size*direction) + return ((x >= ox) and (x <= x2)) + elseif shape == "fullwidth" then + local y2 = oy + (size*direction) + return ((y >= oy) and (y <= y2)) + elseif shape == "line" then + local x2 = ox + (size*direction) + return ((y == oy) and (x >= ox) and (x <= x2)) + elseif shape == "column" then + local y2 = oy + (size*direction) + return ((x == ox) and (y >= oy) and (y <= y2)) + elseif shape == "everything" then + return true + end +end + return BattleArena