76 lines
1.8 KiB
Lua
76 lines
1.8 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.OS~="Horizon" 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('Neutron')
|
|
w,h = love.window.getDesktopDimensions()
|
|
res = game.OSTYPE=="PC"
|
|
push:setupScreen(game.WIDTH, game.HEIGHT, w, h, {fullscreen = true,resizable = res, pixelperfect = game.OSTYPE~="Mobile"})
|
|
push:setBorderColor(0.161,0.157, 0.192,1)
|
|
end
|
|
|
|
game.scenes:main(game)
|
|
end
|
|
|
|
function love.draw(screen)
|
|
if game.OSTYPE~="Horizon" then push:start() end
|
|
game:draw(screen)
|
|
if game.OSTYPE~="Horizon" 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
|
|
if x~=nil and y~=nil then game:MouseCallback(x,y,presses) end
|
|
end
|