From 877a9ffcdacec389925a00dcb50c0d4450010941 Mon Sep 17 00:00:00 2001 From: "theo@manjaro" Date: Thu, 24 Mar 2022 11:30:44 +0100 Subject: [PATCH] Prepared for web export --- conf.lua | 4 ++++ main.lua | 20 +++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 conf.lua diff --git a/conf.lua b/conf.lua new file mode 100644 index 0000000..6fb5671 --- /dev/null +++ b/conf.lua @@ -0,0 +1,4 @@ +function love.conf(t) + t.window.width = 416 + t.window.height = 234 +end diff --git a/main.lua b/main.lua index 660815c..e7d1d86 100644 --- a/main.lua +++ b/main.lua @@ -10,7 +10,7 @@ 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 +if game.OS~="Horizon" and game.OS~="Web" then push = require "lib/push" end function love.load() lg.setBackgroundColor(31/255,14/255,28/255) @@ -26,17 +26,23 @@ function love.load() 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) + 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 end game.scenes:main(game) end function love.draw(screen) - if game.OSTYPE~="Horizon" then push:start() end + if game.OSTYPE~="Horizon" and game.OS~="Web" then push:start() end game:draw(screen) - if game.OSTYPE~="Horizon" then push:finish() end + 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) end function love.update() @@ -63,12 +69,12 @@ function love.gamepadaxis( joystick, axis, value ) end function love.resize(w, h) - if game.OSTYPE~="3DS" then push:resize(w, h) end + if game.OSTYPE~="3DS" and game.OS ~= "Web" 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 + if game.OS ~= "Horizon" and game.OS ~="Web" then x,y = push:toGame(x,y) end if x~=nil and y~=nil then game:MouseCallback(x,y,presses) end