NeutronLoved/main.lua

82 lines
2.1 KiB
Lua
Raw Permalink Normal View History

2022-03-03 20:24:10 +01:00
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
2022-03-24 11:30:44 +01:00
if game.OS~="Horizon" and game.OS~="Web" then push = require "lib/push" end
2022-03-03 20:24:10 +01:00
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)
2022-03-04 14:17:14 +01:00
love.window.setTitle('Neutron')
2022-03-03 20:24:10 +01:00
w,h = love.window.getDesktopDimensions()
res = game.OSTYPE=="PC"
2022-03-24 11:30:44 +01:00
if game.OS~="Web" then
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
2022-03-03 20:24:10 +01:00
end
2022-03-04 14:03:06 +01:00
game.scenes:main(game)
2022-03-03 20:24:10 +01:00
end
function love.draw(screen)
2022-03-24 11:30:44 +01:00
if game.OSTYPE~="Horizon" and game.OS~="Web" then push:start() end
2022-03-03 20:24:10 +01:00
game:draw(screen)
2022-03-24 11:30:44 +01:00
if game.OSTYPE~="Horizon" and game.OS~="Web" then push:finish() end
local width
local height
width,height = lg.getDimensions()
--lg.print("OS : "..game.OS.."; OSTYPE : "..game.OSTYPE.."; WIDTH : "..width.."; HEIGHT : "..height)
2022-03-03 20:24:10 +01:00
end
function love.update()
dt = love.timer.getDelta()
game:step(dt)
end
function love.keypressed(key,scancode)
game.inputs.keys[scancode] = true
end
2022-03-04 14:17:14 +01:00
function love.gamepadpressed(joystick, button) game.inputs.buttons[button] = true
2022-03-03 20:24:10 +01:00
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)
2022-03-24 11:30:44 +01:00
if game.OSTYPE~="3DS" and game.OS ~= "Web" then push:resize(w, h) end
2022-03-03 20:24:10 +01:00
end
2022-03-04 10:39:02 +01:00
function love.mousepressed(x,y,button,istouch,presses)
-- Format positions according to screen
2022-03-24 11:30:44 +01:00
if game.OS ~= "Horizon" and game.OS ~="Web" then
2022-03-04 10:39:02 +01:00
x,y = push:toGame(x,y)
end
if x~=nil and y~=nil then game:MouseCallback(x,y,presses) end
2022-03-04 10:39:02 +01:00
end