Editor canvas modification bugfix, selected tile preview fix

This commit is contained in:
lustlion
2022-01-31 06:44:03 +01:00
parent e1bfd4f7f5
commit bb53c2787b
2 changed files with 18 additions and 8 deletions

View File

@@ -90,8 +90,8 @@ end
function EditorDoEdit()
local mouse_x = love.mouse.getX()
local mouse_y = love.mouse.getY()
local horizontal = 1 + math.floor(((mouse_x/game.scale) / tileProperties.width) + (Camera.pos.x / tileProperties.width))
local vertical = 1 + math.floor(((mouse_y/game.scale) / tileProperties.height) + (Camera.pos.y / tileProperties.height))
local horizontal = 1+math.floor(((mouse_x/game.scale) / tileProperties.width) + (Camera.pos.x / tileProperties.width))
local vertical = 1+math.floor(((mouse_y/game.scale) / tileProperties.height) + (Camera.pos.y / tileProperties.height))
local expand_h = 0
local expand_v = 0
local LevelWidth = LevelGetTileWidth()
@@ -151,14 +151,18 @@ end
function DrawSelectingPaletteTile()
if selecting_tile ~= nil and selecting_tile ~= 0 then
local mouse_x = tileProperties.width * math.floor((love.mouse.getX()/game.scale) / tileProperties.width) - Camera.pos.x % tileProperties.width
local mouse_y = tileProperties.height * math.floor((love.mouse.getY()/game.scale) / tileProperties.height) - Camera.pos.y % tileProperties.height
local mouse_x = love.mouse.getX()
local mouse_y = love.mouse.getY()
local horizontal = math.floor(((mouse_x/game.scale) / tileProperties.width) + (Camera.pos.x / tileProperties.width))
local vertical = math.floor(((mouse_y/game.scale) / tileProperties.height) + (Camera.pos.y / tileProperties.height))
local draw_x = tileProperties.width * horizontal - Camera.pos.x
local draw_y = tileProperties.height * vertical - Camera.pos.y
love.graphics.draw(
LevelData.tileset,
TileIndex[selecting_tile],
mouse_x,
mouse_y
draw_x,
draw_y
)
end
end