ability to move spawns in editor
This commit is contained in:
parent
39b65571a0
commit
93bfe0bda4
@ -115,6 +115,7 @@ function stepEditor()
|
|||||||
|
|
||||||
if Keybind:checkPressed(Keybind.debug.editor) then
|
if Keybind:checkPressed(Keybind.debug.editor) then
|
||||||
editor_mode = not editor_mode
|
editor_mode = not editor_mode
|
||||||
|
deselectSpawns()
|
||||||
createTileObjects()
|
createTileObjects()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -216,8 +217,12 @@ function doEditorEdit()
|
|||||||
reloadLevelTiles()
|
reloadLevelTiles()
|
||||||
else
|
else
|
||||||
if Keybind:checkDown(Keybind.generic.lclick) then
|
if Keybind:checkDown(Keybind.generic.lclick) then
|
||||||
|
deselectSpawns()
|
||||||
selectSpawns(mouse_x,mouse_y)
|
selectSpawns(mouse_x,mouse_y)
|
||||||
end
|
end
|
||||||
|
if Keybind:checkDown(Keybind.generic.rclick) then
|
||||||
|
moveSpawns(mouse_x,mouse_y)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
elseif Keybind:checkPressed(Keybind.generic.lshift) then
|
elseif Keybind:checkPressed(Keybind.generic.lshift) then
|
||||||
expandLevelCanvas(math.sign(expand_h),math.sign(expand_v))
|
expandLevelCanvas(math.sign(expand_h),math.sign(expand_v))
|
||||||
|
@ -10,13 +10,18 @@ end
|
|||||||
|
|
||||||
function activateSpawns()
|
function activateSpawns()
|
||||||
for _, spawn in pairs(LoadedObjects.Spawns) do
|
for _, spawn in pairs(LoadedObjects.Spawns) do
|
||||||
spawn.archetype:new(unpack(spawn.args))
|
spawn.archetype:new(unpack(spawn.args))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function deselectSpawns()
|
||||||
|
for _, spawn in pairs(LoadedObjects.Spawns) do
|
||||||
|
spawn.selected = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function selectSpawns(x,y)
|
function selectSpawns(x,y)
|
||||||
for _, spawn in pairs(LoadedObjects.Spawns) do
|
for _, spawn in pairs(LoadedObjects.Spawns) do
|
||||||
spawn.selected = nil
|
|
||||||
local offset_x, offset_y = spawn.archetype.display:getCenteredOffset()
|
local offset_x, offset_y = spawn.archetype.display:getCenteredOffset()
|
||||||
local left = spawn.args[1] - Camera.pos.x - offset_x
|
local left = spawn.args[1] - Camera.pos.x - offset_x
|
||||||
local top = spawn.args[2] - Camera.pos.y - offset_y
|
local top = spawn.args[2] - Camera.pos.y - offset_y
|
||||||
@ -40,6 +45,15 @@ function selectSpawns(x,y)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function moveSpawns(x,y)
|
||||||
|
for _, spawn in pairs(LoadedObjects.Spawns) do
|
||||||
|
if spawn.selected then
|
||||||
|
spawn.args[1] = math.floor(x/game.scale)+Camera.pos.x
|
||||||
|
spawn.args[2] = math.floor(y/game.scale)+Camera.pos.y
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function drawSpawns()
|
function drawSpawns()
|
||||||
for _, spawn in pairs(LoadedObjects.Spawns) do
|
for _, spawn in pairs(LoadedObjects.Spawns) do
|
||||||
local offset_x, offset_y = spawn.archetype.display:getCenteredOffset()
|
local offset_x, offset_y = spawn.archetype.display:getCenteredOffset()
|
||||||
@ -64,19 +78,15 @@ function drawSpawns()
|
|||||||
)
|
)
|
||||||
|
|
||||||
if spawn.selected then
|
if spawn.selected then
|
||||||
local text = ""
|
local text = spawn.archetype.type.."\n["..spawn.args[1]..","..spawn.args[2].."]\n"
|
||||||
for i=1, #spawn.args do
|
for i=3, #spawn.args do
|
||||||
text = text .. tostring(spawn.args[i])..", "
|
if i > 3 then text = text .. ", " end
|
||||||
|
text = text .. tostring(spawn.args[i])
|
||||||
end
|
end
|
||||||
love.graphics.print(
|
|
||||||
spawn.archetype.type,
|
|
||||||
spawn.args[1] - Camera.pos.x + 20,
|
|
||||||
spawn.args[2] - Camera.pos.y
|
|
||||||
)
|
|
||||||
love.graphics.print(
|
love.graphics.print(
|
||||||
text,
|
text,
|
||||||
spawn.args[1] - Camera.pos.x + 20,
|
spawn.args[1] - Camera.pos.x + 20,
|
||||||
spawn.args[2] - Camera.pos.y + 20
|
spawn.args[2] - Camera.pos.y
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user