added rooms
This commit is contained in:
@@ -1,6 +1,17 @@
|
||||
assert(editor == nil)
|
||||
editor = { room_mode = false }
|
||||
|
||||
function EditorStep()
|
||||
palette = palette or false
|
||||
AnimateTiles()
|
||||
if Keybind:CheckPressed(Keybind.editor.room_mode) then
|
||||
if love.keyboard.isDown("lshift") then
|
||||
editor.room_mode = "delete"
|
||||
else
|
||||
editor.room_mode = not editor.room_mode
|
||||
end
|
||||
editor.room_points = {}
|
||||
end
|
||||
|
||||
if Keybind:CheckPressed(Keybind.editor.palette) then
|
||||
if palette then
|
||||
@@ -13,17 +24,18 @@ function EditorStep()
|
||||
palette_scroll_y = 0
|
||||
end
|
||||
end
|
||||
-- TODO:
|
||||
if love.keyboard.isDown('a',"left") then
|
||||
Camera.pos.x = Camera.pos.x - 3*game.scale
|
||||
Camera.pos.x = Camera.pos.x - 3/game.scale
|
||||
end
|
||||
if love.keyboard.isDown('d',"right") then
|
||||
Camera.pos.x = Camera.pos.x + 3*game.scale
|
||||
Camera.pos.x = Camera.pos.x + 3/game.scale
|
||||
end
|
||||
if love.keyboard.isDown("up", "w") then
|
||||
Camera.pos.y = Camera.pos.y - 3*game.scale
|
||||
Camera.pos.y = Camera.pos.y - 3/game.scale
|
||||
end
|
||||
if love.keyboard.isDown("down", "s") then
|
||||
Camera.pos.y = Camera.pos.y + 3*game.scale
|
||||
Camera.pos.y = Camera.pos.y + 3/game.scale
|
||||
end
|
||||
|
||||
if palette then
|
||||
@@ -83,6 +95,8 @@ function EditorDraw()
|
||||
GameworldDrawEnd()
|
||||
EditorDoEdit()
|
||||
|
||||
DrawRooms()
|
||||
|
||||
DrawSelectingPaletteTile()
|
||||
if palette then
|
||||
EditorDoPalette()
|
||||
@@ -109,10 +123,39 @@ function EditorDoEdit()
|
||||
elseif vertical < 0 then
|
||||
expand_v = vertical
|
||||
end
|
||||
love.graphics.setColor(100, 100, 100, 0.8)
|
||||
love.graphics.print("> " .. horizontal .. ", " .. vertical .. "; " .. math.floor(mouse_x / game.scale + Camera.pos.x) .. ", " .. math.floor(mouse_y / game.scale + Camera.pos.y))
|
||||
love.graphics.print("> " .. LevelWidth .. "(" .. expand_h .. "), " .. LevelHeight .. "(".. expand_v .. ")", 0, 10)
|
||||
|
||||
if not palette then
|
||||
if editor.room_mode then
|
||||
local rx = horizontal * tileProperties.width
|
||||
local ry = vertical * tileProperties.height
|
||||
local r = editor.room_points
|
||||
if Keybind:CheckPressed(Keybind.generic.rclick) then
|
||||
editor.room_points = {}
|
||||
elseif Keybind:CheckPressed(Keybind.generic.lclick) then
|
||||
if editor.room_mode == "delete" then
|
||||
for i, room in ipairs(LoadedObjects.Rooms) do
|
||||
if room:ContainsPoint(rx, ry) then
|
||||
table.remove(LoadedObjects.Rooms, i)
|
||||
end
|
||||
end
|
||||
else
|
||||
table.insert(r, { x = rx, y = ry })
|
||||
end
|
||||
end
|
||||
if #editor.room_points == 2 then
|
||||
table.insert(LoadedObjects.Rooms, Collision:New(r[1].x,r[1].y,r[2].x,r[2].y))
|
||||
editor.room_points = {}
|
||||
end
|
||||
if editor.room_mode == "delete" then
|
||||
love.graphics.print("Select room to delete", 0, 20)
|
||||
elseif #editor.room_points == 0 then
|
||||
love.graphics.print("Select top left of new room", 0, 20)
|
||||
else
|
||||
love.graphics.print("Select bottom right of new room", 0, 20)
|
||||
end
|
||||
elseif not palette then
|
||||
if LevelTiles[vertical] ~= nil
|
||||
and LevelTiles[vertical][horizontal] ~= nil
|
||||
and love.keyboard.isDown("lshift") ~= true
|
||||
|
||||
Reference in New Issue
Block a user