82 lines
1.9 KiB
Lua
82 lines
1.9 KiB
Lua
local game = require "game"
|
|
|
|
game.OS = love.system.getOS()
|
|
game.OSTYPE = "PC"
|
|
if game.OS == 'Horizon' then
|
|
game.OSTYPE = love._console_name -- 3DS or Switch
|
|
end
|
|
if game.OS == "Android" or game.OS == "iOS" then game.OSTYPE = "Mobile" end
|
|
|
|
lg = love.graphics
|
|
|
|
|
|
if game.OSTYPE=="PC" then push = require "lib/push" end
|
|
|
|
function love.load()
|
|
lg.setBackgroundColor(31/255,14/255,28/255)
|
|
|
|
if pcall (lg.set3D, true) == true then
|
|
lg.set3D(true)
|
|
end
|
|
|
|
game:changesize(400,240)
|
|
lg.setDefaultFilter("nearest")
|
|
if game.OS ~= "Horizon" then
|
|
game:changesize(416,234)
|
|
love.window.setTitle('Overflown')
|
|
w,h = love.window.getDesktopDimensions()
|
|
res = game.OSTYPE=="PC"
|
|
push:setupScreen(game.WIDTH, game.HEIGHT, w, h, {fullscreen = true,resizable = res, pixelperfect = true})
|
|
push:setBorderColor(0.161,0.157, 0.192,1)
|
|
end
|
|
local cellsize = 44
|
|
local x = (game.WIDTH-cellsize*5)/2
|
|
local y = (game.HEIGHT-cellsize*5)/2
|
|
local grid = game.objects.grid:new(game,x,y,cellsize)
|
|
game:summon(grid)
|
|
end
|
|
|
|
function love.draw(screen)
|
|
if game.OSTYPE=="PC" then push:start() end
|
|
game:draw(screen)
|
|
if game.OSTYPE=="PC" then push:finish() end
|
|
end
|
|
|
|
function love.update()
|
|
dt = love.timer.getDelta()
|
|
game:step(dt)
|
|
end
|
|
|
|
function love.keypressed(key,scancode)
|
|
game.inputs.keys[scancode] = true
|
|
end
|
|
|
|
function love.gamepadpressed(joystick, button)
|
|
game.inputs.buttons[button] = true
|
|
end
|
|
|
|
function love.keyreleased(key,scancode)
|
|
game.inputs.keys[scancode] = false
|
|
end
|
|
|
|
function love.gamepadreleased(joystick, button)
|
|
game.inputs.buttons[button] = false
|
|
end
|
|
|
|
function love.gamepadaxis( joystick, axis, value )
|
|
game.inputs.axis[axis] = value
|
|
end
|
|
|
|
function love.resize(w, h)
|
|
if game.OSTYPE~="3DS" then push:resize(w, h) end
|
|
end
|
|
|
|
function love.mousepressed(x,y,button,istouch,presses)
|
|
-- Format positions according to screen
|
|
|
|
if game.OS ~= "Horizon" then
|
|
x,y = push:toGame(x,y)
|
|
end
|
|
game:MouseCallback(x,y,presses)
|
|
end
|