Sliced game loop into game, gameworld and editor. added editor keybind for palette.
This commit is contained in:
81
data/scripts/editor.lua
Normal file
81
data/scripts/editor.lua
Normal file
@@ -0,0 +1,81 @@
|
||||
function EditorStep()
|
||||
palette = palette or false
|
||||
AnimateTiles()
|
||||
if Keybind:HasPressed(Keybind.editor.palette) then
|
||||
if palette then
|
||||
palette = false
|
||||
else
|
||||
palette = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function EditorDraw()
|
||||
GameworldDraw()
|
||||
if palette then
|
||||
EditorDrawPalette()
|
||||
end
|
||||
end
|
||||
|
||||
function EditorDrawPalette()
|
||||
local width = LevelData.tileset:getPixelWidth()/tileProperties.width
|
||||
local height = LevelData.tileset:getPixelHeight()/tileProperties.height
|
||||
|
||||
local position_x = 1
|
||||
local position_y = 1
|
||||
for i = 1, #TileIndex-width-1 do
|
||||
|
||||
love.graphics.draw(
|
||||
LevelData.tileset,
|
||||
TileIndex[i],
|
||||
position_x * tileProperties.width*2,
|
||||
(--[[p_scroll +]]position_y) * tileProperties.height*2,
|
||||
0,
|
||||
2,
|
||||
2
|
||||
)
|
||||
position_x = position_x + 1
|
||||
|
||||
if position_x > width then
|
||||
position_x = position_x - width
|
||||
position_y = position_y + 1
|
||||
end
|
||||
end
|
||||
|
||||
love.graphics.rectangle(
|
||||
"line",
|
||||
tileProperties.width*2,
|
||||
(--[[p_scroll +]] 1) * tileProperties.height*2,
|
||||
2*LevelData.tileset:getPixelWidth(),
|
||||
2*LevelData.tileset:getPixelHeight()
|
||||
)
|
||||
end
|
||||
--[[
|
||||
function DrawSelectingPaletteTile()
|
||||
if selecting_tile ~= nil then
|
||||
local width = TileProperties.tileset:getPixelWidth()/TileProperties.width
|
||||
local height = TileProperties.tileset:getPixelHeight()/TileProperties.height
|
||||
|
||||
local positionx = 1
|
||||
local positiony = 1
|
||||
|
||||
for i = 1, #Tile-12 do
|
||||
if i == selecting_tile then
|
||||
love.graphics.rectangle(
|
||||
"line",
|
||||
positionx * TileProperties.width*2,
|
||||
(p_scroll + positiony) * TileProperties.height*2,
|
||||
TileProperties.width*2-1,
|
||||
TileProperties.height*2-1
|
||||
)
|
||||
end
|
||||
|
||||
positionx = positionx + 1
|
||||
|
||||
if positionx > width then
|
||||
positionx = positionx - width
|
||||
positiony = positiony + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end]]
|
||||
Reference in New Issue
Block a user