better shake
This commit is contained in:
parent
0f79fe99ae
commit
12c37b5fa9
3 changed files with 37 additions and 16 deletions
42
main.lua
42
main.lua
|
|
@ -25,10 +25,7 @@ function love.load()
|
|||
gameWorld = World:new()
|
||||
_initLevelEditor()
|
||||
|
||||
gameCanvas = love.graphics.newCanvas()
|
||||
sideBarCanvas = love.graphics.newCanvas(sideBarBox.w, sideBarBox.h)
|
||||
finalCanvas = love.graphics.newCanvas()
|
||||
|
||||
_initCanvases()
|
||||
|
||||
inputTimer = Timer.new()
|
||||
|
||||
|
|
@ -141,12 +138,32 @@ function love.textinput(t)
|
|||
editorTextHandler(response)
|
||||
end
|
||||
|
||||
function love.resize(w, h)
|
||||
_computeDimensions()
|
||||
drawScale = width / gridWidth / 16
|
||||
_initCanvases()
|
||||
end
|
||||
|
||||
function _initDefaults()
|
||||
--set filter
|
||||
love.graphics.setDefaultFilter("linear", "nearest")
|
||||
love.filesystem.createDirectory("rooms")
|
||||
|
||||
--set global width / height variables
|
||||
--set global width / height / sidebar variables
|
||||
_computeDimensions()
|
||||
|
||||
--set randomseed
|
||||
math.randomseed(os.time())
|
||||
|
||||
--font
|
||||
font = love.graphics.newFont("font/LCD_Solid.ttf", 16)
|
||||
love.graphics.setFont(font)
|
||||
end
|
||||
|
||||
-- Derive the square play area (side = smaller window dimension) and the
|
||||
-- sidebar that fills the remaining horizontal space. Safe to call any time
|
||||
-- the window size changes.
|
||||
function _computeDimensions()
|
||||
width = love.graphics.getWidth()
|
||||
height = love.graphics.getHeight()
|
||||
if width > height then
|
||||
|
|
@ -155,17 +172,16 @@ function _initDefaults()
|
|||
height = width
|
||||
end
|
||||
|
||||
--set randomseed
|
||||
math.randomseed(os.time())
|
||||
|
||||
--font
|
||||
font = love.graphics.newFont("font/LCD_Solid.ttf", 16)
|
||||
love.graphics.setFont(font)
|
||||
|
||||
--sidebar
|
||||
sideBarBox = {x = width, y = 0, w = love.graphics.getWidth() - width, h = height}
|
||||
end
|
||||
|
||||
-- (Re)create the render targets at the current window size.
|
||||
function _initCanvases()
|
||||
gameCanvas = love.graphics.newCanvas()
|
||||
finalCanvas = love.graphics.newCanvas()
|
||||
sideBarCanvas = love.graphics.newCanvas(math.max(1, sideBarBox.w), math.max(1, sideBarBox.h))
|
||||
end
|
||||
|
||||
function _initGridVars()
|
||||
gridWidth, gridHeight = 11, 11
|
||||
drawScale = width / gridWidth / 16
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue