2022-01-19 15:13:13 +00:00
|
|
|
function EditorStep()
|
|
|
|
palette = palette or false
|
|
|
|
AnimateTiles()
|
|
|
|
if Keybind:HasPressed(Keybind.editor.palette) then
|
|
|
|
if palette then
|
|
|
|
palette = false
|
2022-01-19 20:57:45 +00:00
|
|
|
palette_scroll_x = nil
|
|
|
|
palette_scroll_y = nil
|
2022-01-19 15:13:13 +00:00
|
|
|
else
|
2022-01-19 20:57:45 +00:00
|
|
|
palette = true
|
|
|
|
palette_scroll_x = 0
|
|
|
|
palette_scroll_y = 0
|
|
|
|
selecting_tile = 51
|
2022-01-19 15:13:13 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-01-19 20:57:45 +00:00
|
|
|
function EditorScroll(y)
|
|
|
|
if palette then
|
|
|
|
if love.keyboard.isDown("lshift") then
|
|
|
|
palette_scroll_y = palette_scroll_y + y
|
|
|
|
else
|
|
|
|
palette_scroll_x = palette_scroll_x + y
|
|
|
|
end
|
|
|
|
else
|
|
|
|
local oscale = game.scale
|
|
|
|
game.scale = math.max(0.1,game.scale + y/16)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-01-19 15:13:13 +00:00
|
|
|
function EditorDraw()
|
|
|
|
GameworldDraw()
|
|
|
|
if palette then
|
2022-01-19 20:57:45 +00:00
|
|
|
EditorDoPalette()
|
2022-01-19 15:13:13 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-01-19 20:57:45 +00:00
|
|
|
function EditorDoPalette()
|
|
|
|
|
|
|
|
local width = LevelData.tileset:getPixelWidth()/tileProperties.width
|
2022-01-19 15:13:13 +00:00
|
|
|
local height = LevelData.tileset:getPixelHeight()/tileProperties.height
|
|
|
|
|
2022-01-19 20:57:45 +00:00
|
|
|
love.graphics.setColor(0,0,0,1)
|
|
|
|
love.graphics.rectangle(
|
|
|
|
"fill",
|
|
|
|
(palette_scroll_x + 1) * (tileProperties.width+1),
|
|
|
|
(palette_scroll_y + 1) * (tileProperties.height+1),
|
|
|
|
1 + LevelData.tileset:getPixelWidth() * ((tileProperties.width+1) / tileProperties.width),
|
|
|
|
1 + LevelData.tileset:getPixelHeight()* ((tileProperties.height+1) / tileProperties.height)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
love.graphics.setColor(1,1,1,1)
|
|
|
|
local position_x = 1
|
|
|
|
local position_y = 1
|
|
|
|
for i = 1, #TileIndex-width-1 do
|
|
|
|
|
|
|
|
local tile_x = (palette_scroll_x + position_x) * (tileProperties.width+1)
|
|
|
|
local tile_y = (palette_scroll_y + position_y) * (tileProperties.height+1)
|
|
|
|
|
|
|
|
love.graphics.draw(
|
|
|
|
LevelData.tileset,
|
|
|
|
TileIndex[i],
|
|
|
|
tile_x,
|
|
|
|
tile_y,
|
|
|
|
0,
|
|
|
|
1,
|
|
|
|
1
|
|
|
|
)
|
|
|
|
if love.mouse.isDown(1) then
|
|
|
|
local mouse_x = love.mouse.getX()
|
|
|
|
local mouse_y = love.mouse.getY()
|
|
|
|
|
|
|
|
if mouse_x > tile_x
|
|
|
|
and mouse_x < tile_x + tileProperties.width + 1
|
|
|
|
and mouse_y > tile_y
|
|
|
|
and mouse_y < tile_y + tileProperties.height + 1
|
|
|
|
then
|
|
|
|
selecting_tile = position_x + (position_y * width)
|
|
|
|
|
|
|
|
love.graphics.print(selecting_tile .. " | " .. tile_x .. ", " .. tile_y)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
selecting_tile = 0
|
|
|
|
end
|
|
|
|
|
|
|
|
if selecting_tile ~= nil and i == selecting_tile then
|
|
|
|
love.graphics.setColor(1,0,1,1)
|
|
|
|
love.graphics.rectangle(
|
|
|
|
"line",
|
|
|
|
tile_x,
|
|
|
|
tile_y,
|
|
|
|
tileProperties.width,
|
|
|
|
tileProperties.height
|
|
|
|
)
|
|
|
|
love.graphics.setColor(1,1,1,1)
|
|
|
|
end
|
|
|
|
|
|
|
|
position_x = position_x + 1
|
|
|
|
|
|
|
|
if position_x > width then
|
|
|
|
position_x = position_x - width
|
|
|
|
position_y = position_y + 1
|
|
|
|
end
|
2022-01-19 15:13:13 +00:00
|
|
|
end
|
|
|
|
|
2022-01-19 20:57:45 +00:00
|
|
|
|
|
|
|
love.graphics.rectangle(
|
|
|
|
"line",
|
|
|
|
(palette_scroll_x + 1) * (tileProperties.width+1),
|
|
|
|
(palette_scroll_y + 1) * (tileProperties.height+1),
|
|
|
|
1 + LevelData.tileset:getPixelWidth() * ((tileProperties.width+1) / tileProperties.width),
|
|
|
|
1 + LevelData.tileset:getPixelHeight()* ((tileProperties.height+1) / tileProperties.height)
|
2022-01-19 15:13:13 +00:00
|
|
|
)
|
|
|
|
end
|