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.width = 900
|
||||||
t.window.height = 640
|
t.window.height = 640
|
||||||
t.window.title = "CHROMA SOLSTICE"
|
t.window.title = "CHROMA SOLSTICE"
|
||||||
|
t.window.resizable = true
|
||||||
|
t.window.minwidth = 700
|
||||||
|
t.window.minheight = 500
|
||||||
end
|
end
|
||||||
|
|
@ -21,8 +21,10 @@ function Entity:initialize(t)
|
||||||
|
|
||||||
self.drawOffset = {x = 0, y = 0}
|
self.drawOffset = {x = 0, y = 0}
|
||||||
if self.size.w < 1 or self.size.h < 1 then
|
if self.size.w < 1 or self.size.h < 1 then
|
||||||
self.drawOffset.x = (drawScale * 16 * self.size.w) / 2
|
-- Small sprites (notably 10px switches) are drawn inside a 16px cell.
|
||||||
self.drawOffset.y = (drawScale * 16 * self.size.h) / 2
|
-- 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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -157,7 +159,7 @@ function Entity:setSprite(sprite)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Entity:sha()
|
function Entity:sha()
|
||||||
return math.random(-worldSha, worldSha) * .5
|
return math.random(-worldSha, worldSha) * .125 * drawScale
|
||||||
end
|
end
|
||||||
|
|
||||||
function Entity:bump()
|
function Entity:bump()
|
||||||
|
|
|
||||||
42
main.lua
42
main.lua
|
|
@ -25,10 +25,7 @@ function love.load()
|
||||||
gameWorld = World:new()
|
gameWorld = World:new()
|
||||||
_initLevelEditor()
|
_initLevelEditor()
|
||||||
|
|
||||||
gameCanvas = love.graphics.newCanvas()
|
_initCanvases()
|
||||||
sideBarCanvas = love.graphics.newCanvas(sideBarBox.w, sideBarBox.h)
|
|
||||||
finalCanvas = love.graphics.newCanvas()
|
|
||||||
|
|
||||||
|
|
||||||
inputTimer = Timer.new()
|
inputTimer = Timer.new()
|
||||||
|
|
||||||
|
|
@ -141,12 +138,32 @@ function love.textinput(t)
|
||||||
editorTextHandler(response)
|
editorTextHandler(response)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function love.resize(w, h)
|
||||||
|
_computeDimensions()
|
||||||
|
drawScale = width / gridWidth / 16
|
||||||
|
_initCanvases()
|
||||||
|
end
|
||||||
|
|
||||||
function _initDefaults()
|
function _initDefaults()
|
||||||
--set filter
|
--set filter
|
||||||
love.graphics.setDefaultFilter("linear", "nearest")
|
love.graphics.setDefaultFilter("linear", "nearest")
|
||||||
love.filesystem.createDirectory("rooms")
|
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()
|
width = love.graphics.getWidth()
|
||||||
height = love.graphics.getHeight()
|
height = love.graphics.getHeight()
|
||||||
if width > height then
|
if width > height then
|
||||||
|
|
@ -155,17 +172,16 @@ function _initDefaults()
|
||||||
height = width
|
height = width
|
||||||
end
|
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}
|
sideBarBox = {x = width, y = 0, w = love.graphics.getWidth() - width, h = height}
|
||||||
end
|
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()
|
function _initGridVars()
|
||||||
gridWidth, gridHeight = 11, 11
|
gridWidth, gridHeight = 11, 11
|
||||||
drawScale = width / gridWidth / 16
|
drawScale = width / gridWidth / 16
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue