editor progress, generic keybinds, player coyote value, cursed book entity, level changes, camera adjustments
This commit is contained in:
@@ -46,6 +46,7 @@ function EditorDraw()
|
||||
GridDisplay()
|
||||
GameworldDrawForeground()
|
||||
GameworldDrawEnd()
|
||||
EditorDoEdit()
|
||||
|
||||
DrawSelectingPaletteTile()
|
||||
if palette then
|
||||
@@ -54,35 +55,39 @@ function EditorDraw()
|
||||
end
|
||||
|
||||
function EditorDoEdit()
|
||||
if love.mouse.isDown(1) then
|
||||
local vertical = 1+math.floor((mouse.pos.y+Camera.pos.y)/(tileProperties.scale*tileProperties.height))
|
||||
local horizontal = 1+math.floor((mouse.pos.x+Camera.pos.x)/(tileProperties.scale*tileProperties.width))
|
||||
local h, v = GetCanvasSize()
|
||||
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 expand_h = 0
|
||||
local expand_v = 0
|
||||
local LevelWidth = LevelGetTileWidth()
|
||||
local LevelHeight = LevelGetTileHeight()
|
||||
|
||||
local expand_h = 0
|
||||
local expand_v = 0
|
||||
if horizontal > LevelWidth then
|
||||
expand_h = horizontal-LevelWidth
|
||||
elseif horizontal < 0 then
|
||||
expand_h = horizontal
|
||||
end
|
||||
if vertical > LevelHeight then
|
||||
expand_v = vertical-LevelHeight
|
||||
elseif vertical < 0 then
|
||||
expand_v = vertical
|
||||
end
|
||||
love.graphics.print("> " .. horizontal .. ", " .. vertical)
|
||||
love.graphics.print("> " .. LevelWidth .. "(" .. expand_h .. "), " .. LevelHeight .. "(".. expand_v .. ")", 0, 10)
|
||||
|
||||
if horizontal > h then
|
||||
expand_h = horizontal-h
|
||||
elseif horizontal <= 0 then
|
||||
expand_h = horizontal-1
|
||||
end
|
||||
|
||||
if vertical > v then
|
||||
expand_v = math.sign(vertical-v)
|
||||
elseif vertical <= 0 then
|
||||
expand_v = math.sign(vertical-1)
|
||||
end
|
||||
|
||||
if Level[vertical] ~= nil
|
||||
and Level[vertical][horizontal] ~= nil
|
||||
if Keybind:HasPressed(Keybind.generic.lclick) and not palette then
|
||||
if LevelTiles[vertical] ~= nil
|
||||
and LevelTiles[vertical][horizontal] ~= nil
|
||||
and love.keyboard.isDown("lshift") ~= true
|
||||
and love.keyboard.isDown("lctrl") ~= true
|
||||
and selecting_tile ~= nil
|
||||
then
|
||||
Level[vertical][horizontal] = tile_carrying
|
||||
elseif love.keyboard.isDown("lshift") and not expanded then
|
||||
expanded = true
|
||||
ExpandCanvas(math.sign(expand_h),math.sign(expand_v))
|
||||
InstanceTile(vertical,horizontal,selecting_tile)
|
||||
--[[
|
||||
elseif love.keyboard.isDown("lshift") then
|
||||
--ExpandCanvas(math.sign(expand_h),math.sign(expand_v))
|
||||
|
||||
if expand_h < 0 then
|
||||
Camera.pos.x = Camera.pos.x - expand_h*tileProperties.scale*tileProperties.width
|
||||
@@ -91,24 +96,22 @@ function EditorDoEdit()
|
||||
Camera.pos.y = Camera.pos.y - expand_v*tileProperties.scale*tileProperties.height
|
||||
end
|
||||
|
||||
elseif love.keyboard.isDown("lctrl") and not expanded then
|
||||
expanded = true
|
||||
ReduceCanvas(math.sign(expand_h),math.sign(expand_v))
|
||||
elseif love.keyboard.isDown("lctrl") then
|
||||
--ReduceCanvas(math.sign(expand_h),math.sign(expand_v))
|
||||
|
||||
if expand_h < 0 then
|
||||
Camera.pos.x = Camera.pos.x - expand_h*tileProperties.scale*tileProperties.width
|
||||
end
|
||||
if expand_v < 0 then
|
||||
Camera.pos.y = Camera.pos.y - expand_v*tileProperties.scale*tileProperties.height
|
||||
end
|
||||
end]]
|
||||
end
|
||||
elseif love.mouse.isDown(1) ~= true then
|
||||
expanded = false
|
||||
LevelReloadTiles()
|
||||
end
|
||||
end
|
||||
|
||||
function DrawSelectingPaletteTile()
|
||||
if selecting_tile ~= nil then
|
||||
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
|
||||
@@ -154,7 +157,7 @@ function EditorDoPalette()
|
||||
1,
|
||||
1
|
||||
)
|
||||
if love.mouse.isDown(1) then
|
||||
if Keybind:CheckDown(Keybind.generic.lclick) then
|
||||
local mouse_x = love.mouse.getX()
|
||||
local mouse_y = love.mouse.getY()
|
||||
|
||||
@@ -165,13 +168,15 @@ function EditorDoPalette()
|
||||
then
|
||||
selecting_tile = position_x + ((position_y-1) * width)
|
||||
|
||||
love.graphics.print(selecting_tile .. " | " .. tile_x .. ", " .. tile_y)
|
||||
else
|
||||
--selecting_tile = nil
|
||||
love.graphics.print(selecting_tile .. " | " .. tile_x .. ", " .. tile_y, 0, 20)
|
||||
end
|
||||
end
|
||||
|
||||
if selecting_tile ~= nil and i == selecting_tile then
|
||||
if Keybind:CheckDown(Keybind.generic.rclick) then
|
||||
selecting_tile = 0
|
||||
end
|
||||
|
||||
if selecting_tile ~= nil and selecting_tile ~= 0 and i == selecting_tile then
|
||||
love.graphics.setColor(1,0,1,1)
|
||||
love.graphics.rectangle(
|
||||
"line",
|
||||
|
||||
Reference in New Issue
Block a user