naming conventions act 2: the end
This commit is contained in:
114
code/editor.lua
114
code/editor.lua
@@ -3,8 +3,8 @@ editor = { room_mode = false }
|
||||
|
||||
function stepEditor()
|
||||
palette = palette or false
|
||||
AnimateTiles()
|
||||
if Keybind:CheckPressed(Keybind.editor.room_mode) then
|
||||
animateTiles()
|
||||
if Keybind:checkPressed(Keybind.editor.room_mode) then
|
||||
if love.keyboard.isDown("lshift") then
|
||||
editor.room_mode = "delete"
|
||||
else
|
||||
@@ -13,7 +13,7 @@ function stepEditor()
|
||||
editor.room_points = {}
|
||||
end
|
||||
|
||||
if Keybind:CheckPressed(Keybind.editor.palette) then
|
||||
if Keybind:checkPressed(Keybind.editor.palette) then
|
||||
if palette then
|
||||
palette = false
|
||||
palette_scroll_x = nil
|
||||
@@ -24,7 +24,9 @@ function stepEditor()
|
||||
palette_scroll_y = 0
|
||||
end
|
||||
end
|
||||
|
||||
-- TODO:
|
||||
|
||||
if love.keyboard.isDown('a',"left") then
|
||||
Camera.pos.x = Camera.pos.x - 3/game.scale
|
||||
end
|
||||
@@ -39,7 +41,7 @@ function stepEditor()
|
||||
end
|
||||
|
||||
if palette then
|
||||
if Keybind:CheckPressed(Keybind.debug.debug) then
|
||||
if Keybind:checkPressed(Keybind.debug.debug) then
|
||||
local next = false
|
||||
local export = nil
|
||||
for k, v in pairs(tileset) do
|
||||
@@ -59,12 +61,12 @@ function stepEditor()
|
||||
if next then
|
||||
LevelData.tileset = export
|
||||
end
|
||||
LevelGetTileData()
|
||||
LevelIndexTiles()
|
||||
getLevelTileData()
|
||||
indexLevelTiles()
|
||||
end
|
||||
end
|
||||
|
||||
if Keybind:CheckPressed(Keybind.debug.reload) then
|
||||
if Keybind:checkPressed(Keybind.debug.reload) then
|
||||
Prompt:new({
|
||||
name = "level name",
|
||||
input = "unnamed",
|
||||
@@ -75,16 +77,16 @@ function stepEditor()
|
||||
input = "level.lua",
|
||||
func = function(file_prompt)
|
||||
if file_prompt.canceled then return end
|
||||
ExportLevel(name_prompt.input, file_prompt.input)
|
||||
exportLevel(name_prompt.input, file_prompt.input)
|
||||
end,
|
||||
}):activate()
|
||||
end,
|
||||
}):activate()
|
||||
end
|
||||
|
||||
if Keybind:CheckPressed(Keybind.debug.editor) then
|
||||
if Keybind:checkPressed(Keybind.debug.editor) then
|
||||
editor_mode = false
|
||||
TileCreateObjects()
|
||||
createTileObjects()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -120,34 +122,34 @@ end
|
||||
function doEditorEdit()
|
||||
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 horizontal = 1+math.floor(((mouse_x/game.scale) / tile_properties.width) + (Camera.pos.x / tile_properties.width))
|
||||
local vertical = 1+math.floor(((mouse_y/game.scale) / tile_properties.height) + (Camera.pos.y / tile_properties.height))
|
||||
local expand_h = 0
|
||||
local expand_v = 0
|
||||
local LevelWidth = LevelGetTileWidth()
|
||||
local LevelHeight = LevelGetTileHeight()
|
||||
local level_width = getLevelTileWidth()
|
||||
local level_height = getLevelTileHeight()
|
||||
|
||||
if horizontal > LevelWidth then
|
||||
expand_h = horizontal-LevelWidth
|
||||
if horizontal > level_width then
|
||||
expand_h = horizontal-level_width
|
||||
elseif horizontal < 0 then
|
||||
expand_h = horizontal
|
||||
end
|
||||
if vertical > LevelHeight then
|
||||
expand_v = vertical-LevelHeight
|
||||
if vertical > level_height then
|
||||
expand_v = vertical-level_height
|
||||
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)
|
||||
love.graphics.print("> " .. level_width .. "(" .. expand_h .. "), " .. level_height .. "(".. expand_v .. ")", 0, 10)
|
||||
|
||||
if editor.room_mode then
|
||||
local rx = horizontal * tileProperties.width
|
||||
local ry = vertical * tileProperties.height
|
||||
local rx = horizontal * tile_properties.width
|
||||
local ry = vertical * tile_properties.height
|
||||
local r = editor.room_points
|
||||
if Keybind:CheckPressed(Keybind.generic.rclick) then
|
||||
if Keybind:checkPressed(Keybind.generic.rclick) then
|
||||
editor.room_points = {}
|
||||
elseif Keybind:CheckPressed(Keybind.generic.lclick) then
|
||||
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
|
||||
@@ -175,21 +177,21 @@ function doEditorEdit()
|
||||
and love.keyboard.isDown("lshift") ~= true
|
||||
and love.keyboard.isDown("lctrl") ~= true
|
||||
then
|
||||
if Keybind:CheckDown(Keybind.generic.lclick)
|
||||
if Keybind:checkDown(Keybind.generic.lclick)
|
||||
and selecting_tile ~= nil
|
||||
then
|
||||
SetTile(vertical,horizontal,selecting_tile)
|
||||
elseif Keybind:CheckDown(Keybind.generic.rclick) then
|
||||
SetTile(vertical,horizontal,0)
|
||||
setTile(vertical,horizontal,selecting_tile)
|
||||
elseif Keybind:checkDown(Keybind.generic.rclick) then
|
||||
setTile(vertical,horizontal,0)
|
||||
end
|
||||
LevelReloadTiles()
|
||||
reloadLevelTiles()
|
||||
|
||||
elseif Keybind:CheckPressed(Keybind.generic.lshift) then
|
||||
LevelExpandCanvas(math.sign(expand_h),math.sign(expand_v))
|
||||
LevelReloadTiles()
|
||||
elseif Keybind:CheckPressed(Keybind.generic.lctrl) then
|
||||
LevelReduceCanvas(math.sign(expand_h),math.sign(expand_v))
|
||||
LevelReloadTiles()
|
||||
elseif Keybind:checkPressed(Keybind.generic.lshift) then
|
||||
expandLevelCanvas(math.sign(expand_h),math.sign(expand_v))
|
||||
reloadLevelTiles()
|
||||
elseif Keybind:checkPressed(Keybind.generic.lctrl) then
|
||||
reduceLevelCanvas(math.sign(expand_h),math.sign(expand_v))
|
||||
reloadLevelTiles()
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -199,10 +201,10 @@ function drawSelectingPaletteTile()
|
||||
|
||||
local mouse_x = love.mouse.getX()
|
||||
local mouse_y = love.mouse.getY()
|
||||
local horizontal = math.floor(((mouse_x/game.scale) / tileProperties.width) + (Camera.pos.x / tileProperties.width))
|
||||
local vertical = math.floor(((mouse_y/game.scale) / tileProperties.height) + (Camera.pos.y / tileProperties.height))
|
||||
local draw_x = tileProperties.width * horizontal - Camera.pos.x
|
||||
local draw_y = tileProperties.height * vertical - Camera.pos.y
|
||||
local horizontal = math.floor(((mouse_x/game.scale) / tile_properties.width) + (Camera.pos.x / tile_properties.width))
|
||||
local vertical = math.floor(((mouse_y/game.scale) / tile_properties.height) + (Camera.pos.y / tile_properties.height))
|
||||
local draw_x = tile_properties.width * horizontal - Camera.pos.x
|
||||
local draw_y = tile_properties.height * vertical - Camera.pos.y
|
||||
|
||||
love.graphics.draw(
|
||||
LevelData.tileset,
|
||||
@@ -215,16 +217,16 @@ end
|
||||
|
||||
function doEditorPalette()
|
||||
|
||||
local width = LevelData.tileset:getPixelWidth()/tileProperties.width
|
||||
local height = LevelData.tileset:getPixelHeight()/tileProperties.height
|
||||
local width = LevelData.tileset:getPixelWidth()/tile_properties.width
|
||||
local height = LevelData.tileset:getPixelHeight()/tile_properties.height
|
||||
|
||||
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)
|
||||
(palette_scroll_x + 1) * (tile_properties.width+1),
|
||||
(palette_scroll_y + 1) * (tile_properties.height+1),
|
||||
1 + LevelData.tileset:getPixelWidth() * ((tile_properties.width+1) / tile_properties.width),
|
||||
1 + LevelData.tileset:getPixelHeight()* ((tile_properties.height+1) / tile_properties.height)
|
||||
)
|
||||
|
||||
|
||||
@@ -233,8 +235,8 @@ function doEditorPalette()
|
||||
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)
|
||||
local tile_x = (palette_scroll_x + position_x) * (tile_properties.width+1)
|
||||
local tile_y = (palette_scroll_y + position_y) * (tile_properties.height+1)
|
||||
|
||||
love.graphics.draw(
|
||||
LevelData.tileset,
|
||||
@@ -245,14 +247,14 @@ function doEditorPalette()
|
||||
1,
|
||||
1
|
||||
)
|
||||
if Keybind:CheckDown(Keybind.generic.lclick) then
|
||||
if Keybind:checkDown(Keybind.generic.lclick) then
|
||||
local mouse_x = love.mouse.getX()
|
||||
local mouse_y = love.mouse.getY()
|
||||
|
||||
if mouse_x > (tile_x) * game.scale
|
||||
and mouse_x < (tile_x + tileProperties.width) * game.scale
|
||||
and mouse_x < (tile_x + tile_properties.width) * game.scale
|
||||
and mouse_y > (tile_y) * game.scale
|
||||
and mouse_y < (tile_y + tileProperties.height) * game.scale
|
||||
and mouse_y < (tile_y + tile_properties.height) * game.scale
|
||||
then
|
||||
selecting_tile = position_x + ((position_y-1) * width)
|
||||
|
||||
@@ -260,7 +262,7 @@ function doEditorPalette()
|
||||
end
|
||||
end
|
||||
|
||||
if Keybind:CheckDown(Keybind.generic.rclick) then
|
||||
if Keybind:checkDown(Keybind.generic.rclick) then
|
||||
selecting_tile = nil
|
||||
end
|
||||
|
||||
@@ -270,8 +272,8 @@ function doEditorPalette()
|
||||
"line",
|
||||
tile_x,
|
||||
tile_y,
|
||||
tileProperties.width,
|
||||
tileProperties.height
|
||||
tile_properties.width,
|
||||
tile_properties.height
|
||||
)
|
||||
love.graphics.setColor(1,1,1,1)
|
||||
end
|
||||
@@ -287,10 +289,10 @@ function doEditorPalette()
|
||||
|
||||
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)
|
||||
(palette_scroll_x + 1) * (tile_properties.width+1),
|
||||
(palette_scroll_y + 1) * (tile_properties.height+1),
|
||||
1 + LevelData.tileset:getPixelWidth() * ((tile_properties.width+1) / tile_properties.width),
|
||||
1 + LevelData.tileset:getPixelHeight()* ((tile_properties.height+1) / tile_properties.height)
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user