better shake
This commit is contained in:
parent
0f79fe99ae
commit
12c37b5fa9
3 changed files with 37 additions and 16 deletions
3
conf.lua
3
conf.lua
|
|
@ -2,4 +2,7 @@ function love.conf(t)
|
|||
t.window.width = 900
|
||||
t.window.height = 640
|
||||
t.window.title = "CHROMA SOLSTICE"
|
||||
t.window.resizable = true
|
||||
t.window.minwidth = 700
|
||||
t.window.minheight = 500
|
||||
end
|
||||
|
|
@ -21,8 +21,10 @@ function Entity:initialize(t)
|
|||
|
||||
self.drawOffset = {x = 0, y = 0}
|
||||
if self.size.w < 1 or self.size.h < 1 then
|
||||
self.drawOffset.x = (drawScale * 16 * self.size.w) / 2
|
||||
self.drawOffset.y = (drawScale * 16 * self.size.h) / 2
|
||||
-- Small sprites (notably 10px switches) are drawn inside a 16px cell.
|
||||
-- Offset by the leftover space, not by half their own size.
|
||||
self.drawOffset.x = drawScale * (16 - self.spriteSize.w) / 2
|
||||
self.drawOffset.y = drawScale * (16 - self.spriteSize.h) / 2
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -157,7 +159,7 @@ function Entity:setSprite(sprite)
|
|||
end
|
||||
|
||||
function Entity:sha()
|
||||
return math.random(-worldSha, worldSha) * .5
|
||||
return math.random(-worldSha, worldSha) * .125 * drawScale
|
||||
end
|
||||
|
||||
function Entity:bump()
|
||||
|
|
|
|||
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