more work on editor and selecting tiles, not done yet tho
This commit is contained in:
parent
2b323fff8f
commit
15e8142c4c
|
@ -4,78 +4,112 @@ function EditorStep()
|
||||||
if Keybind:HasPressed(Keybind.editor.palette) then
|
if Keybind:HasPressed(Keybind.editor.palette) then
|
||||||
if palette then
|
if palette then
|
||||||
palette = false
|
palette = false
|
||||||
|
palette_scroll_x = nil
|
||||||
|
palette_scroll_y = nil
|
||||||
else
|
else
|
||||||
palette = true
|
palette = true
|
||||||
|
palette_scroll_x = 0
|
||||||
|
palette_scroll_y = 0
|
||||||
|
selecting_tile = 51
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function EditorScroll(y)
|
||||||
|
if palette then
|
||||||
|
if love.keyboard.isDown("lshift") then
|
||||||
|
palette_scroll_y = palette_scroll_y + y
|
||||||
|
else
|
||||||
|
palette_scroll_x = palette_scroll_x + y
|
||||||
|
end
|
||||||
|
else
|
||||||
|
local oscale = game.scale
|
||||||
|
game.scale = math.max(0.1,game.scale + y/16)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function EditorDraw()
|
function EditorDraw()
|
||||||
GameworldDraw()
|
GameworldDraw()
|
||||||
if palette then
|
if palette then
|
||||||
EditorDrawPalette()
|
EditorDoPalette()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function EditorDrawPalette()
|
function EditorDoPalette()
|
||||||
local width = LevelData.tileset:getPixelWidth()/tileProperties.width
|
|
||||||
|
local width = LevelData.tileset:getPixelWidth()/tileProperties.width
|
||||||
local height = LevelData.tileset:getPixelHeight()/tileProperties.height
|
local height = LevelData.tileset:getPixelHeight()/tileProperties.height
|
||||||
|
|
||||||
local position_x = 1
|
love.graphics.setColor(0,0,0,1)
|
||||||
local position_y = 1
|
love.graphics.rectangle(
|
||||||
for i = 1, #TileIndex-width-1 do
|
"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)
|
||||||
|
)
|
||||||
|
|
||||||
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
|
love.graphics.setColor(1,1,1,1)
|
||||||
position_x = position_x - width
|
local position_x = 1
|
||||||
position_y = position_y + 1
|
local position_y = 1
|
||||||
end
|
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)
|
||||||
|
|
||||||
|
love.graphics.draw(
|
||||||
|
LevelData.tileset,
|
||||||
|
TileIndex[i],
|
||||||
|
tile_x,
|
||||||
|
tile_y,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
1
|
||||||
|
)
|
||||||
|
if love.mouse.isDown(1) then
|
||||||
|
local mouse_x = love.mouse.getX()
|
||||||
|
local mouse_y = love.mouse.getY()
|
||||||
|
|
||||||
|
if mouse_x > tile_x
|
||||||
|
and mouse_x < tile_x + tileProperties.width + 1
|
||||||
|
and mouse_y > tile_y
|
||||||
|
and mouse_y < tile_y + tileProperties.height + 1
|
||||||
|
then
|
||||||
|
selecting_tile = position_x + (position_y * width)
|
||||||
|
|
||||||
|
love.graphics.print(selecting_tile .. " | " .. tile_x .. ", " .. tile_y)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
selecting_tile = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
if selecting_tile ~= nil and i == selecting_tile then
|
||||||
|
love.graphics.setColor(1,0,1,1)
|
||||||
|
love.graphics.rectangle(
|
||||||
|
"line",
|
||||||
|
tile_x,
|
||||||
|
tile_y,
|
||||||
|
tileProperties.width,
|
||||||
|
tileProperties.height
|
||||||
|
)
|
||||||
|
love.graphics.setColor(1,1,1,1)
|
||||||
|
end
|
||||||
|
|
||||||
|
position_x = position_x + 1
|
||||||
|
|
||||||
|
if position_x > width then
|
||||||
|
position_x = position_x - width
|
||||||
|
position_y = position_y + 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
love.graphics.rectangle(
|
|
||||||
"line",
|
love.graphics.rectangle(
|
||||||
tileProperties.width*2,
|
"line",
|
||||||
(--[[p_scroll +]] 1) * tileProperties.height*2,
|
(palette_scroll_x + 1) * (tileProperties.width+1),
|
||||||
2*LevelData.tileset:getPixelWidth(),
|
(palette_scroll_y + 1) * (tileProperties.height+1),
|
||||||
2*LevelData.tileset:getPixelHeight()
|
1 + LevelData.tileset:getPixelWidth() * ((tileProperties.width+1) / tileProperties.width),
|
||||||
|
1 + LevelData.tileset:getPixelHeight()* ((tileProperties.height+1) / tileProperties.height)
|
||||||
)
|
)
|
||||||
end
|
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]]
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
function GameStep()
|
function GameStep()
|
||||||
-- GAME STEP
|
|
||||||
if not do_pause then
|
if not do_pause then
|
||||||
SetCollisionFlags(main_Player)
|
SetCollisionFlags(main_Player)
|
||||||
for _, enty in pairs(LoadedEntities) do
|
for _, enty in pairs(LoadedEntities) do
|
||||||
|
@ -17,16 +16,16 @@ function GameDraw()
|
||||||
GameworldDraw()
|
GameworldDraw()
|
||||||
GameworldLighting()
|
GameworldLighting()
|
||||||
|
|
||||||
-- HUD
|
-- hud
|
||||||
textScale = 0.5
|
textScale = 0.5
|
||||||
|
|
||||||
--debug
|
-- pause
|
||||||
if debug then DebugUI() end
|
|
||||||
if debug_collision then
|
|
||||||
DebugColisions()
|
|
||||||
DebugEntities()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- reset color
|
|
||||||
if do_pause then PauseUI() end
|
if do_pause then PauseUI() end
|
||||||
|
|
||||||
|
-- debug
|
||||||
|
if debug then DebugUI() end
|
||||||
|
if debug_collision then
|
||||||
|
DebugColisions()
|
||||||
|
DebugEntities()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,7 +28,6 @@ function GameworldLighting()
|
||||||
love.graphics.setCanvas()
|
love.graphics.setCanvas()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- work on lighting canvas
|
-- work on lighting canvas
|
||||||
love.graphics.setCanvas(Canvas.Darkness)
|
love.graphics.setCanvas(Canvas.Darkness)
|
||||||
SetDarkness()
|
SetDarkness()
|
||||||
|
|
7
main.lua
7
main.lua
|
@ -115,12 +115,7 @@ end
|
||||||
|
|
||||||
function love.wheelmoved(_, y)
|
function love.wheelmoved(_, y)
|
||||||
if editor_mode then
|
if editor_mode then
|
||||||
if palette then
|
EditorScroll(y)
|
||||||
p_scroll = p_scroll + y or 0
|
|
||||||
else
|
|
||||||
local oscale = game.scale
|
|
||||||
game.scale = math.max(0.1,game.scale + y/16)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue