mirror of
https://gitea.com/SweetSea-ButImNotSweet/tromi_mobile.git
synced 2025-01-08 17:33:09 +08:00
V1 update (#1)
This commit is contained in:
committed by
Squishy (C6H12O6+NaCl+H2O)
parent
3343d8711b
commit
1d6643448e
78
main.lua
78
main.lua
@@ -2,17 +2,17 @@ if os.getenv("LOCAL_LUA_DEBUGGER_VSCODE")=="1" then
|
||||
LLDEBUGGER=require('lldebugger')
|
||||
LLDEBUGGER.start()
|
||||
end
|
||||
require 'funcs'
|
||||
DEBUG_showKey = false
|
||||
|
||||
PENTO_MODE = false
|
||||
SAVE_DIR = 'saves/'
|
||||
REPLAY_DIR = 'saves/replays/'
|
||||
CONFIG_FILE = 'config.sav'
|
||||
HIscoreFILE = 'hiscores.sav'
|
||||
if not love.filesystem.getInfo(REPLAY_DIR) then
|
||||
love.filesystem.createDirectory(REPLAY_DIR)
|
||||
end
|
||||
CONFIG_FILE = 'config.sav'
|
||||
HIscoreFILE = 'hiscores.sav'
|
||||
|
||||
BACKGROUND_COLOR = {32/255, 120/255, 88/255}
|
||||
|
||||
CURRENT_OS = love.system.getOS()
|
||||
MOBILE = CURRENT_OS == "Android" or CURRENT_OS == "iOS"
|
||||
@@ -34,6 +34,7 @@ function ShowLoadingText(thing)
|
||||
end
|
||||
|
||||
function love.load()
|
||||
require 'funcs'
|
||||
math.randomseed(os.time())
|
||||
require "modules.file" "binser"
|
||||
require "settings"
|
||||
@@ -48,19 +49,11 @@ function love.load()
|
||||
|
||||
-- Now it's real time to load all stuffs!
|
||||
require "load" -- Most game's resources are loaded in here
|
||||
require "modules.scene"
|
||||
require "scene"
|
||||
require "game.vctrl" -- VCTRL
|
||||
|
||||
function SCENE.update()
|
||||
SCENE.update = function() end
|
||||
SCENE = SETTINGS.firstTime and InputConfigScene(true) or TitleScene()
|
||||
end
|
||||
function SCENE.render()
|
||||
SCENE.render = function() end
|
||||
love.graphics.draw(LOADING_IMAGE_FILE,0,0,0,0.5)
|
||||
end
|
||||
SCENE = LoadingScene()
|
||||
|
||||
-- VCTRL.toggle(love.system.getOS()=='Android' or true)
|
||||
-- VCTRL.new{ -- up down left right --- right left down up
|
||||
-- -- {type='button',x= 100,y=320,key= 'up',r=35,iconSize=60,alpha=0.75},
|
||||
-- -- {type='button',x= 100,y=440,key= 'down',r=35,iconSize=60,alpha=0.75},
|
||||
@@ -104,14 +97,10 @@ function love.draw()
|
||||
-- love.graphics.line(0, grid_height * iy, 640, grid_height * iy)
|
||||
-- end
|
||||
|
||||
-- local x, y = GLOBAL_TRANSFORM:inverseTransformPoint(love.mouse.getPosition())
|
||||
-- love.graphics.setColor(0, 0, 0, 0.8)
|
||||
-- love.graphics.rectangle("fill", 5, 450, 115, 25)
|
||||
-- drawText(string.format("X: %.1d; Y: %.1d", x, y), 10, 455, 110, "left")
|
||||
|
||||
-- love.graphics.setColor(1, 1, 1, 1)
|
||||
-- love.graphics.setLineWidth(2)
|
||||
-- love.graphics.rectangle("line", 0, 0, 640, 480)
|
||||
local x, y = GLOBAL_TRANSFORM:inverseTransformPoint(love.mouse.getPosition())
|
||||
love.graphics.setColor(0, 0, 0, 0.8)
|
||||
love.graphics.rectangle("fill", 5, 450, 115, 25)
|
||||
drawText(string.format("X: %.1d; Y: %.1d", x, y), 10, 455, 110, "left")
|
||||
|
||||
love.graphics.pop()
|
||||
end
|
||||
@@ -156,8 +145,10 @@ function love.keypressed(key, scancode)
|
||||
if scancode == "f4" then
|
||||
SETTINGS["fullscreen"] = not SETTINGS["fullscreen"]
|
||||
love.window.setFullscreen(SETTINGS["fullscreen"])
|
||||
love.resize(love.graphics.getDimensions())
|
||||
elseif scancode == "f2" and SCENE.title ~= "Input Config" and SCENE.title ~= "Game" then
|
||||
SCENE = InputConfigScene()
|
||||
elseif scancode == "f3" then SCENE = DataManagementScene()
|
||||
elseif scancode == "f12" then LLDEBUGGER.requestBreak()
|
||||
-- elseif scancode == "f11" then SETTINGS.firstTime = true
|
||||
-- function keys are reserved
|
||||
@@ -386,30 +377,24 @@ function love.errorhandler(msg)
|
||||
print("\n"..table.concat(err,"\n",1,c-2))
|
||||
local tracebacks = table.concat(err,"\n", 4)
|
||||
|
||||
if drawText == nil then
|
||||
pcall(function()
|
||||
FONT_tromi = love.graphics.newFont('res/fonts/monofonto rg.otf', 20)
|
||||
require "funcs"
|
||||
end)
|
||||
if drawText == nil then
|
||||
love.window.setMode(640, 480, {resizable = true})
|
||||
return function() -- If "funcs" failed to load, we can only return a more simple version of error screen
|
||||
love.event.pump()
|
||||
for e, a, b, c in love.event.poll() do
|
||||
if e == "quit" then return 1 end
|
||||
end
|
||||
|
||||
love.graphics.origin()
|
||||
love.graphics.clear()
|
||||
love.graphics.setColor(1, 1, 1)
|
||||
love.graphics.setFont(FONT_tromi)
|
||||
love.graphics.printf(
|
||||
err[1]:sub(7).."\nTraceback:\n"..tracebacks,
|
||||
30, 30, love.graphics.getWidth() - 10, "left"
|
||||
)
|
||||
love.graphics.present()
|
||||
if love.timer then love.timer.sleep(0.1) end
|
||||
if drawText == nil or FONT_tromi == nil then
|
||||
love.audio.stop()
|
||||
love.graphics.origin()
|
||||
love.graphics.setFont(love.graphics.newFont(20))
|
||||
return function()
|
||||
love.event.pump()
|
||||
for e, a, b, c in love.event.poll() do
|
||||
if (
|
||||
e == "quit" or
|
||||
e == "mousepressed"
|
||||
) then return 1 end
|
||||
end
|
||||
|
||||
love.graphics.clear()
|
||||
love.graphics.print(err[1]:sub(7).."\nTraceback:\n"..tracebacks)
|
||||
love.graphics.present()
|
||||
|
||||
love.timer.sleep(0.001)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -535,6 +520,9 @@ local main_bg_draw_frame = 0
|
||||
local main_bg_last_color = nil
|
||||
|
||||
function MainBackground()
|
||||
love.graphics.setColor(BACKGROUND_COLOR)
|
||||
love.graphics.rectangle("fill", 0, 0, 640, 480)
|
||||
|
||||
if SETTINGS["music"] and not SOUNDS["bgm_title"]:isPlaying() then
|
||||
SOUNDS["bgm_title"]:setVolume(0.3)
|
||||
SOUNDS["bgm_title"]:play()
|
||||
|
||||
Reference in New Issue
Block a user