Renaming and moving some modules

This commit is contained in:
Squishy (C6H12O6+NaCl+H2O)
2024-04-19 22:24:22 +07:00
parent 9c8628a014
commit 35edf8fbd6
24 changed files with 261 additions and 290 deletions

View File

@@ -22,15 +22,12 @@ HIscoreFILE = 'hiscores.sav'
function love.load()
math.randomseed(os.time())
highscores = {}
require "load.graphics"
require "load.fonts"
require "load.sounds"
require "load.save"
require "load.bigint"
require "load"
require "settings"
require "scene"
require "game.vctrl" -- VCTRL
SCENE = config.firstTime and InputConfigScene() or TitleScene()
SCENE = SETTINGS.firstTime and InputConfigScene() or TitleScene()
love.mouse.setVisible(false)
love.window.setMode(love.graphics.getWidth(), love.graphics.getHeight(), {resizable = true});
@@ -38,9 +35,7 @@ function love.load()
GLOBAL_TRANSFORM = love.math.newTransform()
love.resize(love.graphics.getWidth(), love.graphics.getHeight())
-- init config
initConfig()
love.window.setFullscreen(config["fullscreen"])
love.window.setFullscreen(SETTINGS["fullscreen"])
VCTRL.new{
-- {type='button',x= 100,y=320,key= 'up',icon= 'up',r=35,iconSize=60,alpha=1},
@@ -127,8 +122,8 @@ function love.keypressed(key, scancode)
-- global hotkeys
if scancode == "f4" then
config["fullscreen"] = not config["fullscreen"]
love.window.setFullscreen(config["fullscreen"])
SETTINGS["fullscreen"] = not SETTINGS["fullscreen"]
love.window.setFullscreen(SETTINGS["fullscreen"])
elseif scancode == "f2" and SCENE.title ~= "Input Config" and SCENE.title ~= "Game" then
SCENE = InputConfigScene()
-- function keys are reserved
@@ -139,8 +134,8 @@ function love.keypressed(key, scancode)
SCENE:onInputPress({input="menu_back", type="key", key=key, scancode=scancode})
-- pass any other key to the scene, with its configured mapping
else
if config.input and config.input.keys then
input_pressed = config.input.keys[scancode]
if SETTINGS.input and SETTINGS.input.keys then
input_pressed = SETTINGS.input.keys[scancode]
end
SCENE:onInputPress({input=input_pressed, type="key", key=key, scancode=scancode})
end
@@ -159,8 +154,8 @@ function love.keyreleased(key, scancode)
return
-- handle all other keys; tab is reserved, but the input config scene keeps it from getting configured as a game input, so pass tab to the scene here
else
if config.input and config.input.keys then
input_released = config.input.keys[scancode]
if SETTINGS.input and SETTINGS.input.keys then
input_released = SETTINGS.input.keys[scancode]
end
SCENE:onInputRelease({input=input_released, type="key", key=key, scancode=scancode})
end
@@ -171,12 +166,12 @@ end
function love.joystickpressed(joystick, button)
local input_pressed = nil
if
config.input and
config.input.joysticks and
config.input.joysticks[joystick:getName()] and
config.input.joysticks[joystick:getName()].buttons
SETTINGS.input and
SETTINGS.input.joysticks and
SETTINGS.input.joysticks[joystick:getName()] and
SETTINGS.input.joysticks[joystick:getName()].buttons
then
input_pressed = config.input.joysticks[joystick:getName()].buttons[button]
input_pressed = SETTINGS.input.joysticks[joystick:getName()].buttons[button]
end
SCENE:onInputPress({input=input_pressed, type="joybutton", name=joystick:getName(), button=button})
end
@@ -184,12 +179,12 @@ end
function love.joystickreleased(joystick, button)
local input_released = nil
if
config.input and
config.input.joysticks and
config.input.joysticks[joystick:getName()] and
config.input.joysticks[joystick:getName()].buttons
SETTINGS.input and
SETTINGS.input.joysticks and
SETTINGS.input.joysticks[joystick:getName()] and
SETTINGS.input.joysticks[joystick:getName()].buttons
then
input_released = config.input.joysticks[joystick:getName()].buttons[button]
input_released = SETTINGS.input.joysticks[joystick:getName()].buttons[button]
end
SCENE:onInputRelease({input=input_released, type="joybutton", name=joystick:getName(), button=button})
end
@@ -199,17 +194,17 @@ function love.joystickaxis(joystick, axis, value)
local positive_released = nil
local negative_released = nil
if
config.input and
config.input.joysticks and
config.input.joysticks[joystick:getName()] and
config.input.joysticks[joystick:getName()].axes and
config.input.joysticks[joystick:getName()].axes[axis]
SETTINGS.input and
SETTINGS.input.joysticks and
SETTINGS.input.joysticks[joystick:getName()] and
SETTINGS.input.joysticks[joystick:getName()].axes and
SETTINGS.input.joysticks[joystick:getName()].axes[axis]
then
if math.abs(value) >= 1 then
input_pressed = config.input.joysticks[joystick:getName()].axes[axis][value >= 1 and "positive" or "negative"]
input_pressed = SETTINGS.input.joysticks[joystick:getName()].axes[axis][value >= 1 and "positive" or "negative"]
end
positive_released = config.input.joysticks[joystick:getName()].axes[axis].positive
negative_released = config.input.joysticks[joystick:getName()].axes[axis].negative
positive_released = SETTINGS.input.joysticks[joystick:getName()].axes[axis].positive
negative_released = SETTINGS.input.joysticks[joystick:getName()].axes[axis].negative
end
if math.abs(value) >= 1 then
SCENE:onInputPress({input=input_pressed, type="joyaxis", name=joystick:getName(), axis=axis, value=value})
@@ -231,14 +226,14 @@ function love.joystickhat(joystick, hat, direction)
local input_pressed = nil
local has_hat = false
if
config.input and
config.input.joysticks and
config.input.joysticks[joystick:getName()] and
config.input.joysticks[joystick:getName()].hats and
config.input.joysticks[joystick:getName()].hats[hat]
SETTINGS.input and
SETTINGS.input.joysticks and
SETTINGS.input.joysticks[joystick:getName()] and
SETTINGS.input.joysticks[joystick:getName()].hats and
SETTINGS.input.joysticks[joystick:getName()].hats[hat]
then
if direction ~= "c" then
input_pressed = config.input.joysticks[joystick:getName()].hats[hat][direction]
input_pressed = SETTINGS.input.joysticks[joystick:getName()].hats[hat][direction]
end
has_hat = true
end
@@ -247,20 +242,20 @@ function love.joystickhat(joystick, hat, direction)
local char = direction:sub(i, i)
local _, count = last_hat_direction:gsub(char, char)
if count == 0 then
SCENE:onInputPress({input=config.input.joysticks[joystick:getName()].hats[hat][char], type="joyhat", name=joystick:getName(), hat=hat, direction=char})
SCENE:onInputPress({input=SETTINGS.input.joysticks[joystick:getName()].hats[hat][char], type="joyhat", name=joystick:getName(), hat=hat, direction=char})
end
end
for i = 1, #last_hat_direction do
local char = last_hat_direction:sub(i, i)
local _, count = direction:gsub(char, char)
if count == 0 then
SCENE:onInputRelease({input=config.input.joysticks[joystick:getName()].hats[hat][char], type="joyhat", name=joystick:getName(), hat=hat, direction=char})
SCENE:onInputRelease({input=SETTINGS.input.joysticks[joystick:getName()].hats[hat][char], type="joyhat", name=joystick:getName(), hat=hat, direction=char})
end
end
last_hat_direction = direction
elseif has_hat then
for i, direction in ipairs{"d", "l", "ld", "lu", "r", "rd", "ru", "u"} do
SCENE:onInputRelease({input=config.input.joysticks[joystick:getName()].hats[hat][direction], type="joyhat", name=joystick:getName(), hat=hat, direction=direction})
SCENE:onInputRelease({input=SETTINGS.input.joysticks[joystick:getName()].hats[hat][direction], type="joyhat", name=joystick:getName(), hat=hat, direction=direction})
end
last_hat_direction = ""
elseif direction ~= "c" then
@@ -355,9 +350,9 @@ local main_bg_draw_frame = 0
local main_bg_last_color = nil
function mainBackground()
if config["music"] and not sounds["bgm_title"]:isPlaying() then
sounds["bgm_title"]:setVolume(0.3)
sounds["bgm_title"]:play()
if SETTINGS["music"] and not SOUNDS["bgm_title"]:isPlaying() then
SOUNDS["bgm_title"]:setVolume(0.3)
SOUNDS["bgm_title"]:play()
end
local y = 40
if main_bg_draw_frame >= 16 then
@@ -389,7 +384,7 @@ function mainBackground()
for y=1,30 do
if main_bg_grid[x][y] ~= 0 then
love.graphics.setColor(1, 1, 1, 0.4)
if ((x-1)*48)-560 > 0 and ((x-1)*48)-560 < 640 then love.graphics.draw(blocks["2tie"][main_bg_grid[x][y]], ((x-1)*48)-570, (((y+2)*48)+main_bg_draw_frame*3)-480,0, 3) end
if ((x-1)*48)-560 > 0 and ((x-1)*48)-560 < 640 then love.graphics.draw(BLOCKS["2tie"][main_bg_grid[x][y]], ((x-1)*48)-570, (((y+2)*48)+main_bg_draw_frame*3)-480,0, 3) end
love.graphics.setColor(1, 1, 1, 1)
end
end
@@ -398,7 +393,7 @@ function mainBackground()
for y=1,30 do
if main_bg_grid[x][y] ~= 0 then
love.graphics.setColor(1, 1, 1, 1)
love.graphics.draw(blocks["2tie"][main_bg_grid[x][y]], (x-1)*16, ((y-1)*16)+main_bg_draw_frame)
love.graphics.draw(BLOCKS["2tie"][main_bg_grid[x][y]], (x-1)*16, ((y-1)*16)+main_bg_draw_frame)
end
end
end
@@ -406,7 +401,7 @@ function mainBackground()
for y=1,30 do
if main_bg_grid[x][y] ~= 0 then
love.graphics.setColor(1, 1, 1, 0.6)
if ((x-1)*32)-320 > 0 and ((x-1)*32)-320 < 640 then love.graphics.draw(blocks["2tie"][main_bg_grid[x][y]], ((x-1)*32)-320, (((y+1)*32)+main_bg_draw_frame*2)-320,0, 2) end
if ((x-1)*32)-320 > 0 and ((x-1)*32)-320 < 640 then love.graphics.draw(BLOCKS["2tie"][main_bg_grid[x][y]], ((x-1)*32)-320, (((y+1)*32)+main_bg_draw_frame*2)-320,0, 2) end
love.graphics.setColor(1, 1, 1, 1)
end
end