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

@@ -107,7 +107,7 @@ function table.lowest(table)
return lowest return lowest
end end
function clamp(x, min, max) function math.clamp(x, min, max)
if max < min then if max < min then
min, max = max, min min, max = max, min
end end
@@ -116,7 +116,7 @@ end
function drawText(text, x, y, size, orientation, color) function drawText(text, x, y, size, orientation, color)
if color == nil then color = {1, 1, 1, 1} end if color == nil then color = {1, 1, 1, 1} end
love.graphics.setFont(tromi_font) love.graphics.setFont(FONT_tromi)
love.graphics.setColor(0, 0, 0, 0.8) love.graphics.setColor(0, 0, 0, 0.8)
love.graphics.printf(text, x+1, y+1, size*2, orientation, nil, 0.50) love.graphics.printf(text, x+1, y+1, size*2, orientation, nil, 0.50)
love.graphics.setColor(color) love.graphics.setColor(color)
@@ -125,7 +125,7 @@ end
function drawBigText(text, x, y, size, orientation, color) function drawBigText(text, x, y, size, orientation, color)
if color == nil then color = {1, 1, 1, 1} end if color == nil then color = {1, 1, 1, 1} end
love.graphics.setFont(big_font) love.graphics.setFont(FONT_big)
love.graphics.setColor(0, 0, 0, 0.8) love.graphics.setColor(0, 0, 0, 0.8)
love.graphics.printf(text, x+1, y+1, size*2, orientation, nil, 0.50) love.graphics.printf(text, x+1, y+1, size*2, orientation, nil, 0.50)
love.graphics.setColor(color) love.graphics.setColor(color)

View File

@@ -3,7 +3,7 @@ local bit = require("bit")
local lualzw = require 'libs.lualzw' local lualzw = require 'libs.lualzw'
local bitser = require 'libs.bitser' local bitser = require 'libs.bitser'
require 'funcs' require 'funcs'
require 'load.save' require 'settings'
local playedReadySE = false local playedReadySE = false
local playedGoSE = false local playedGoSE = false
@@ -84,8 +84,8 @@ function GameMode:new(player_name, input_file, replay_grade)
self.speed_divisor = 10000 self.speed_divisor = 10000
self.line_clear_flash = 0 self.line_clear_flash = 0
self.lines_cleared = 0 self.lines_cleared = 0
sounds['bgm_firsthalf']:setVolume(0.3) SOUNDS['bgm_firsthalf']:setVolume(0.3)
sounds['bgm_secondhalf']:setVolume(0.35) SOUNDS['bgm_secondhalf']:setVolume(0.35)
self.audio_stopped = false self.audio_stopped = false
self.recorded_inputs = {} self.recorded_inputs = {}
self.input_saved = false self.input_saved = false
@@ -373,7 +373,7 @@ function GameMode:update(inputs, ruleset)
if self.grade_change_flash > 0 and self.game_over_frames >= 2 then self.grade_change_flash = self.grade_change_flash - 1 end if self.grade_change_flash > 0 and self.game_over_frames >= 2 then self.grade_change_flash = self.grade_change_flash - 1 end
if self.point_flash > 0 and self.game_over_frames >= 2 then self.point_flash = self.point_flash - 1 end if self.point_flash > 0 and self.game_over_frames >= 2 then self.point_flash = self.point_flash - 1 end
if self.game_over_frames == 2 then if self.game_over_frames == 2 then
playSEOnce(self.end_game_sound) PlaySEOnce(self.end_game_sound)
end end
if self.game_over or self.completed then if self.game_over or self.completed then
self.game_over_frames = self.game_over_frames + 1 self.game_over_frames = self.game_over_frames + 1
@@ -500,7 +500,7 @@ function GameMode:update(inputs, ruleset)
--if spin < 0 then spin = 0 end --if spin < 0 then spin = 0 end
self.spin_rng[i] = spin self.spin_rng[i] = spin
end end
playSE("erase") PlaySE("erase")
self.lcd = self:getLineClearDelay() self.lcd = self:getLineClearDelay()
self.last_lcd = self.lcd self.last_lcd = self.lcd
self.are = self:getLineARE() self.are = self:getLineARE()
@@ -613,28 +613,28 @@ end
function GameMode:advanceOneFrame() function GameMode:advanceOneFrame()
if self.ready_frames ~= 0 and not self.audio_stopped and not self.training then if self.ready_frames ~= 0 and not self.audio_stopped and not self.training then
if sounds['bgm_title']:getVolume() > 0.01 then sounds['bgm_title']:setVolume(sounds['bgm_title']:getVolume()-0.01) end if SOUNDS['bgm_title']:getVolume() > 0.01 then SOUNDS['bgm_title']:setVolume(SOUNDS['bgm_title']:getVolume()-0.01) end
if self.ready_frames == 5 then if self.ready_frames == 5 then
love.audio.stop() love.audio.stop()
self.audio_stopped = true self.audio_stopped = true
end end
end end
if self.training and not sounds['bgm_title']:isPlaying() and config["music"] then sounds['bgm_title']:play() end if self.training and not SOUNDS['bgm_title']:isPlaying() and SETTINGS["music"] then SOUNDS['bgm_title']:play() end
if not self.training then if not self.training then
if self.nextbgmflag and sounds['bgm_firsthalf']:isPlaying() then if self.nextbgmflag and SOUNDS['bgm_firsthalf']:isPlaying() then
if sounds['bgm_firsthalf']:getVolume() > 0.1 then if SOUNDS['bgm_firsthalf']:getVolume() > 0.1 then
sounds['bgm_firsthalf']:setVolume(sounds['bgm_firsthalf']:getVolume()-0.01) SOUNDS['bgm_firsthalf']:setVolume(SOUNDS['bgm_firsthalf']:getVolume()-0.01)
else else
sounds['bgm_firsthalf']:stop() SOUNDS['bgm_firsthalf']:stop()
end end
end end
if self.ready_frames < 1 and not sounds['bgm_firsthalf']:isPlaying() and not sounds['bgm_secondhalf']:isPlaying() and config["music"] then if self.ready_frames < 1 and not SOUNDS['bgm_firsthalf']:isPlaying() and not SOUNDS['bgm_secondhalf']:isPlaying() and SETTINGS["music"] then
if not self.nextbgmflag then sounds['bgm_firsthalf']:play() if not self.nextbgmflag then SOUNDS['bgm_firsthalf']:play()
elseif self.total_lines < 296 then sounds['bgm_secondhalf']:play() end elseif self.total_lines < 296 then SOUNDS['bgm_secondhalf']:play() end
end end
if self.total_lines >= 296 then if self.total_lines >= 296 then
sounds['bgm_firsthalf']:stop() SOUNDS['bgm_firsthalf']:stop()
sounds['bgm_secondhalf']:stop() SOUNDS['bgm_secondhalf']:stop()
end end
end end
if self.clear then if self.clear then
@@ -688,7 +688,7 @@ function GameMode:onPieceLock(piece, cleared_row_count)
self.moved = true self.moved = true
end end
self.lastdir = 0 self.lastdir = 0
playSE("lock") PlaySE("lock")
end end
function GameMode:onLineClear(cleared_row_count) function GameMode:onLineClear(cleared_row_count)
@@ -810,7 +810,7 @@ function GameMode:processDelays(inputs, ruleset, drop_speed)
if self.ready_frames > 0 then if self.ready_frames > 0 then
if not playedReadySE then if not playedReadySE then
playedReadySE = true playedReadySE = true
playSEOnce("ready") PlaySEOnce("ready")
end end
self.ready_frames = self.ready_frames - 1 self.ready_frames = self.ready_frames - 1
if self.ready_frames == 0 then if self.ready_frames == 0 then
@@ -822,7 +822,7 @@ function GameMode:processDelays(inputs, ruleset, drop_speed)
local cleared_row_count = self.grid:getClearedRowCount() local cleared_row_count = self.grid:getClearedRowCount()
self.grid:clearClearedRows() self.grid:clearClearedRows()
self:afterLineClear(cleared_row_count) self:afterLineClear(cleared_row_count)
playSE("fall") PlaySE("fall")
if self.are == 0 then if self.are == 0 then
self:initializeOrHold(inputs, ruleset) self:initializeOrHold(inputs, ruleset)
end end
@@ -861,7 +861,7 @@ function GameMode:initializeNextPiece(inputs, ruleset, piece_data, generate_next
self.piece_soft_locked = false self.piece_soft_locked = false
if self.piece:isDropBlocked(self.grid) and if self.piece:isDropBlocked(self.grid) and
self.grid:canPlacePiece(self.piece) then self.grid:canPlacePiece(self.piece) then
playSE("bottom") PlaySE("bottom")
end end
if generate_next_piece == nil then if generate_next_piece == nil then
table.remove(self.next_queue, 1) table.remove(self.next_queue, 1)
@@ -893,10 +893,10 @@ function GameMode:drawLineClearAnimation()
fall_timer = (fall_timer*fall_timer)+drift fall_timer = (fall_timer*fall_timer)+drift
fade_timer = self.lcd/20 fade_timer = self.lcd/20
love.graphics.setColor(1,1,1,fade_timer) love.graphics.setColor(1,1,1,fade_timer)
love.graphics.draw(blocks[block.skin][block.colour..'_d'], real_x, real_y+fall_timer) love.graphics.draw(BLOCKS[block.skin][block.colour..'_d'], real_x, real_y+fall_timer)
if self.lcd > self:getLineClearDelay() - 5 then if self.lcd > self:getLineClearDelay() - 5 then
love.graphics.setColor(1,1,1,fade_timer*0.3) love.graphics.setColor(1,1,1,fade_timer*0.3)
love.graphics.draw(blocks[block.skin]['W'], real_x, real_y+fall_timer) love.graphics.draw(BLOCKS[block.skin]['W'], real_x, real_y+fall_timer)
end end
end end
end end
@@ -917,7 +917,7 @@ function GameMode:drawNextQueue(ruleset)
for index, offset in pairs(offsets) do for index, offset in pairs(offsets) do
local x = offset.x + ruleset:getDrawOffset(piece, rotation).x + ruleset.spawn_positions[piece].x local x = offset.x + ruleset:getDrawOffset(piece, rotation).x + ruleset.spawn_positions[piece].x
local y = offset.y + ruleset:getDrawOffset(piece, rotation).y + 4.7 local y = offset.y + ruleset:getDrawOffset(piece, rotation).y + 4.7
love.graphics.draw(blocks[skin][ColourSchemes.Arika[piece]], pos_x+x*16, pos_y+y*16) love.graphics.draw(BLOCKS[skin][COLOUR_SCHEMES.Arika[piece]], pos_x+x*16, pos_y+y*16)
end end
end end
for i = 1, self.next_queue_length do for i = 1, self.next_queue_length do
@@ -1067,8 +1067,8 @@ function GameMode:drawScoringInfo()
if self.clear or self.game_over then if self.clear or self.game_over then
sounds['bgm_firsthalf']:stop() SOUNDS['bgm_firsthalf']:stop()
sounds['bgm_secondhalf']:stop() SOUNDS['bgm_secondhalf']:stop()
end end
end end
@@ -1080,16 +1080,16 @@ function GameMode:drawBackground()
--if self.training then bg = math.mod(math.floor(((self.frames+1)/1200)), 10) end --if self.training then bg = math.mod(math.floor(((self.frames+1)/1200)), 10) end
if bg == 0 or bg == 6 or bg == 9 then limit = 5 end if bg == 0 or bg == 6 or bg == 9 then limit = 5 end
if bg == 5 then limit = 4.76 end if bg == 5 then limit = 4.76 end
if not backgrounds[bg]:isPlaying() then if not BACKGROUNDS[bg]:isPlaying() then
backgrounds[bg]:play() BACKGROUNDS[bg]:play()
end end
if backgrounds[bg]:tell() >= limit then if BACKGROUNDS[bg]:tell() >= limit then
backgrounds[bg]:rewind() BACKGROUNDS[bg]:rewind()
end end
if bg == 0 or bg == 8 or bg == 9 or bg == 3 then brightness = 0.7 end if bg == 0 or bg == 8 or bg == 9 or bg == 3 then brightness = 0.7 end
love.graphics.setColor(brightness, brightness, brightness, 1) love.graphics.setColor(brightness, brightness, brightness, 1)
love.graphics.draw( love.graphics.draw(
backgrounds[bg], BACKGROUNDS[bg],
0, 0, 0, 0, 0, 0,
0.5, 0.5 0.5, 0.5
) )

View File

@@ -185,23 +185,23 @@ function Grid:draw(greyscale, timer)
love.graphics.line(256,31+45,256+80,31+45) love.graphics.line(256,31+45,256+80,31+45)
for y = 1, self.height do for y = 1, self.height do
for x = 1, self.width do for x = 1, self.width do
if blocks[self.grid[y][x].skin] and if BLOCKS[self.grid[y][x].skin] and
blocks[self.grid[y][x].skin][self.grid[y][x].colour] then BLOCKS[self.grid[y][x].skin][self.grid[y][x].colour] then
if self.grid[y][x].flash ~= nil then if self.grid[y][x].flash ~= nil then
if self.grid[y][x].flash > 0 then if self.grid[y][x].flash > 0 then
love.graphics.setColor(0.4+(self.grid[y][x].flash*0.1), 0.4+(self.grid[y][x].flash*0.1), 0.4+(self.grid[y][x].flash*0.1), 1) love.graphics.setColor(0.4+(self.grid[y][x].flash*0.1), 0.4+(self.grid[y][x].flash*0.1), 0.4+(self.grid[y][x].flash*0.1), 1)
love.graphics.draw(blocks[self.grid[y][x].skin]['W'], 200+x*16, 64+y*16) love.graphics.draw(BLOCKS[self.grid[y][x].skin]['W'], 200+x*16, 64+y*16)
self.grid[y][x].flash = self.grid[y][x].flash - 1 self.grid[y][x].flash = self.grid[y][x].flash - 1
else else
love.graphics.setColor(1, 1, 1, 1) love.graphics.setColor(1, 1, 1, 1)
love.graphics.draw(blocks[self.grid[y][x].skin][self.grid[y][x].colour..'_d'], 200+x*16, 64+y*16) love.graphics.draw(BLOCKS[self.grid[y][x].skin][self.grid[y][x].colour..'_d'], 200+x*16, 64+y*16)
end end
end end
if greyscale then if greyscale then
if timer > 1 then timer = 1 end if timer > 1 then timer = 1 end
love.graphics.setColor(0.7, 0.7, 0.7, 0+timer) love.graphics.setColor(0.7, 0.7, 0.7, 0+timer)
if self.grid[y][x] ~= empty and self.grid[y][x].colour ~= 'X' then if self.grid[y][x] ~= empty and self.grid[y][x].colour ~= 'X' then
love.graphics.draw(blocks[self.grid[y][x].skin]["A"], 200+x*16, 64+y*16) love.graphics.draw(BLOCKS[self.grid[y][x].skin]["A"], 200+x*16, 64+y*16)
end end
end end
end end

View File

@@ -135,14 +135,14 @@ function Piece:addGravity(gravity, grid, classic_lock)
self.gravity = new_frac_gravity self.gravity = new_frac_gravity
self:dropSquares(dropped_squares, grid) self:dropSquares(dropped_squares, grid)
if self:isDropBlocked(grid) then if self:isDropBlocked(grid) then
playSE("bottom") PlaySE("bottom")
end end
else else
local new_frac_gravity = new_gravity + dropped_squares local new_frac_gravity = new_gravity + dropped_squares
self.gravity = new_frac_gravity self.gravity = new_frac_gravity
self:moveInGrid({ x=0, y=-1 }, dropped_squares, grid) self:moveInGrid({ x=0, y=-1 }, dropped_squares, grid)
if self:isMoveBlocked(grid, { x=0, y=-1 }) then if self:isMoveBlocked(grid, { x=0, y=-1 }) then
playSE("bottom") PlaySE("bottom")
end end
end end
else else
@@ -164,7 +164,7 @@ function Piece:draw(opacity, brightness, grid, partial_das)
local x = self.position.x + offset.x local x = self.position.x + offset.x
local y = self.position.y + offset.y local y = self.position.y + offset.y
love.graphics.draw( love.graphics.draw(
blocks[self.skin][self.colour], BLOCKS[self.skin][self.colour],
216+x*16+partial_das, 80+y*16+gravity_offset 216+x*16+partial_das, 80+y*16+gravity_offset
) )
end end

View File

@@ -96,7 +96,7 @@ function Rotation:rotatePiece(inputs, piece, grid, prev_inputs, initial, lastdir
end end
if not initial and not was_drop_blocked and piece:isDropBlocked(grid) then if not initial and not was_drop_blocked and piece:isDropBlocked(grid) then
playSE("bottom") PlaySE("bottom")
end end
-- prev_inputs becomes the previous inputs -- prev_inputs becomes the previous inputs
@@ -201,7 +201,7 @@ function Rotation:movePiece(piece, grid, move, instant)
end end
end end
if not was_drop_blocked and piece:isDropBlocked(grid) then if not was_drop_blocked and piece:isDropBlocked(grid) then
playSE("bottom") PlaySE("bottom")
end end
end end

View File

@@ -96,7 +96,7 @@ function Rotation:rotatePiece(inputs, piece, grid, prev_inputs, initial, lastdir
end end
if not initial and not was_drop_blocked and piece:isDropBlocked(grid) then if not initial and not was_drop_blocked and piece:isDropBlocked(grid) then
playSE("bottom") PlaySE("bottom")
end end
-- prev_inputs becomes the previous inputs -- prev_inputs becomes the previous inputs
@@ -189,7 +189,7 @@ function Rotation:movePiece(piece, grid, move, instant)
end end
end end
if not was_drop_blocked and piece:isDropBlocked(grid) then if not was_drop_blocked and piece:isDropBlocked(grid) then
playSE("bottom") PlaySE("bottom")
end end
end end

108
load.lua Normal file
View File

@@ -0,0 +1,108 @@
-- Bigint library
bigint = require "libs.bigint.bigint"
number_names = require "libs.bigint.named-powers-of-ten"
-- Fonts
FONT_tromi = love.graphics.newFont('res/fonts/monofonto rg.otf', 28)
FONT_big = love.graphics.newFont('res/fonts/monofonto rg.otf', 56)
-- GRAPHICS
BACKGROUNDS = {
[0] = love.graphics.newVideo("res/backgrounds/green_waterfall.ogv", {audio=false}),
love.graphics.newVideo("res/backgrounds/water.ogv", {audio=false}),
love.graphics.newVideo("res/backgrounds/green_streams.ogv", {audio=false}),
love.graphics.newVideo("res/backgrounds/streams.ogv", {audio=false}),
love.graphics.newVideo("res/backgrounds/red_forest_waterfall.ogv", {audio=false}),
love.graphics.newVideo("res/backgrounds/flowers_rain.ogv", {audio=false}),
love.graphics.newVideo("res/backgrounds/moonlight_tree.ogv", {audio=false}),
love.graphics.newVideo("res/backgrounds/lisa_frank.ogv", {audio=false}),
love.graphics.newVideo("res/backgrounds/snowy_trees.ogv", {audio=false}),
love.graphics.newVideo("res/backgrounds/snowy_cabin.ogv", {audio=false}),
}
BLOCKS = {
["2tie"] = {
R = love.graphics.newImage("res/img/r.png"),
O = love.graphics.newImage("res/img/o.png"),
Y = love.graphics.newImage("res/img/y.png"),
G = love.graphics.newImage("res/img/g.png"),
C = love.graphics.newImage("res/img/b.png"),
B = love.graphics.newImage("res/img/i.png"),
M = love.graphics.newImage("res/img/v.png"),
F = love.graphics.newImage("res/img/bl.png"),
A = love.graphics.newImage("res/img/bl.png"),
X = love.graphics.newImage("res/img/t.png"),
W = love.graphics.newImage("res/img/w.png"),
R_d = love.graphics.newImage("res/img/r_d.png"),
O_d = love.graphics.newImage("res/img/o_d.png"),
Y_d = love.graphics.newImage("res/img/y_d.png"),
G_d = love.graphics.newImage("res/img/g_d.png"),
C_d = love.graphics.newImage("res/img/b_d.png"),
B_d = love.graphics.newImage("res/img/i_d.png"),
M_d = love.graphics.newImage("res/img/v_d.png"),
}
}
COLOUR_SCHEMES = {
Arika = {
I = "R",
L = "O",
J = "B",
S = "M",
Z = "G",
O = "Y",
T = "C",
}
}
-- BGMs and SFXs
SOUNDS = {
bottom = love.audio.newSource("res/se/bottom.wav", "static"),
lock = love.audio.newSource("res/se/lock.wav", "static"),
erase = love.audio.newSource("res/se/erase.wav", "static"),
fall = love.audio.newSource("res/se/fall.wav", "static"),
ready = love.audio.newSource("res/se/ready.wav", "static"),
promote = love.audio.newSource("res/se/promote.wav", "static"),
demote = love.audio.newSource("res/se/demote.wav", "static"),
autopromote = love.audio.newSource("res/se/autopromote.wav", "static"),
bgm_firsthalf = love.audio.newSource("res/bgm/firsthalf.flac", "static"),
bgm_secondhalf = love.audio.newSource("res/bgm/secondhalf.flac", "static"),
bgm_title = love.audio.newSource("res/bgm/title.flac", "static")
}
function PlaySE(sound, subsound)
if sound ~= nil then
if subsound ~= nil then
SOUNDS[sound][subsound]:setVolume(0.4)
if SOUNDS[sound][subsound]:isPlaying() then
SOUNDS[sound][subsound]:stop()
end
SOUNDS[sound][subsound]:play()
else
SOUNDS[sound]:setVolume(0.4)
if SOUNDS[sound]:isPlaying() then
SOUNDS[sound]:stop()
end
SOUNDS[sound]:play()
end
end
end
function PlaySEOnce(sound, subsound)
if sound ~= nil then
if subsound ~= nil then
SOUNDS[sound][subsound]:setVolume(0.4)
if SOUNDS[sound][subsound]:isPlaying() then
return
end
SOUNDS[sound][subsound]:play()
else
SOUNDS[sound]:setVolume(0.4)
if SOUNDS[sound]:isPlaying() then
return
end
SOUNDS[sound]:play()
end
end
end

View File

@@ -1,2 +0,0 @@
bigint = require "libs.bigint.bigint"
number_names = require "libs.bigint.named-powers-of-ten"

View File

@@ -1,2 +0,0 @@
tromi_font = love.graphics.newFont('res/fonts/monofonto rg.otf', 28)
big_font = love.graphics.newFont('res/fonts/monofonto rg.otf', 56)

View File

@@ -1,48 +0,0 @@
backgrounds = {
[0] = love.graphics.newVideo("res/backgrounds/green_waterfall.ogv", {audio=false}),
love.graphics.newVideo("res/backgrounds/water.ogv", {audio=false}),
love.graphics.newVideo("res/backgrounds/green_streams.ogv", {audio=false}),
love.graphics.newVideo("res/backgrounds/streams.ogv", {audio=false}),
love.graphics.newVideo("res/backgrounds/red_forest_waterfall.ogv", {audio=false}),
love.graphics.newVideo("res/backgrounds/flowers_rain.ogv", {audio=false}),
love.graphics.newVideo("res/backgrounds/moonlight_tree.ogv", {audio=false}),
love.graphics.newVideo("res/backgrounds/lisa_frank.ogv", {audio=false}),
love.graphics.newVideo("res/backgrounds/snowy_trees.ogv", {audio=false}),
love.graphics.newVideo("res/backgrounds/snowy_cabin.ogv", {audio=false}),
}
blocks = {
["2tie"] = {
R = love.graphics.newImage("res/img/r.png"),
O = love.graphics.newImage("res/img/o.png"),
Y = love.graphics.newImage("res/img/y.png"),
G = love.graphics.newImage("res/img/g.png"),
C = love.graphics.newImage("res/img/b.png"),
B = love.graphics.newImage("res/img/i.png"),
M = love.graphics.newImage("res/img/v.png"),
F = love.graphics.newImage("res/img/bl.png"),
A = love.graphics.newImage("res/img/bl.png"),
X = love.graphics.newImage("res/img/t.png"),
W = love.graphics.newImage("res/img/w.png"),
R_d = love.graphics.newImage("res/img/r_d.png"),
O_d = love.graphics.newImage("res/img/o_d.png"),
Y_d = love.graphics.newImage("res/img/y_d.png"),
G_d = love.graphics.newImage("res/img/g_d.png"),
C_d = love.graphics.newImage("res/img/b_d.png"),
B_d = love.graphics.newImage("res/img/i_d.png"),
M_d = love.graphics.newImage("res/img/v_d.png"),
}
}
ColourSchemes = {
Arika = {
I = "R",
L = "O",
J = "B",
S = "M",
Z = "G",
O = "Y",
T = "C",
}
}

View File

@@ -1,65 +0,0 @@
local bitser = require 'libs.bitser'
local fs = love.filesystem
function loadSave()
-- config = loadFromFile(CONFIG_FILE)
end
function loadFromFile(filename)
if fs.read(filename) == nil then
return {} -- new object
end
return bitser.loadLoveFile(filename)
end
function initConfig()
-- if config.fullscreen == nil then config.fullscreen = false end
-- if config.music == nil then config.music = true end
-- if not config.input then
-- scene = InputConfigScene(true)
-- else
-- scene = TitleScene()
-- end
end
local _config = loadFromFile(CONFIG_FILE) or {}
local _defaultConfig = {
firstTime = true,
fullscreen = false,
music = true,
input = {
keys = {},
mobile = { -- Should not be changed for any reason, used for mobile only
enter = 'menu_decide',
f13 = 'up',
f14 = 'down',
f15 = 'left',
f16 = 'right',
f17 = 'rotate_left',
f18 = 'rotate_left2',
f19 = 'rotate_right',
f20 = 'rotate_right2',
}
}
}
function saveConfig()
bitser.dumpLoveFile(CONFIG_FILE, _config)
end
config = setmetatable(
{},
{
__index = function(_, k)
if _config[k] == nil then _config[k] = _defaultConfig[k] end
return _config[k]
end,
__newindex = function(_, k, v)
_config[k] = v
saveConfig()
end
}
)

View File

@@ -1,49 +0,0 @@
sounds = {
bottom = love.audio.newSource("res/se/bottom.wav", "static"),
lock = love.audio.newSource("res/se/lock.wav", "static"),
erase = love.audio.newSource("res/se/erase.wav", "static"),
fall = love.audio.newSource("res/se/fall.wav", "static"),
ready = love.audio.newSource("res/se/ready.wav", "static"),
promote = love.audio.newSource("res/se/promote.wav", "static"),
demote = love.audio.newSource("res/se/demote.wav", "static"),
autopromote = love.audio.newSource("res/se/autopromote.wav", "static"),
bgm_firsthalf = love.audio.newSource("res/bgm/firsthalf.flac", "static"),
bgm_secondhalf = love.audio.newSource("res/bgm/secondhalf.flac", "static"),
bgm_title = love.audio.newSource("res/bgm/title.flac", "static")
}
function playSE(sound, subsound)
if sound ~= nil then
if subsound ~= nil then
sounds[sound][subsound]:setVolume(0.4)
if sounds[sound][subsound]:isPlaying() then
sounds[sound][subsound]:stop()
end
sounds[sound][subsound]:play()
else
sounds[sound]:setVolume(0.4)
if sounds[sound]:isPlaying() then
sounds[sound]:stop()
end
sounds[sound]:play()
end
end
end
function playSEOnce(sound, subsound)
if sound ~= nil then
if subsound ~= nil then
sounds[sound][subsound]:setVolume(0.4)
if sounds[sound][subsound]:isPlaying() then
return
end
sounds[sound][subsound]:play()
else
sounds[sound]:setVolume(0.4)
if sounds[sound]:isPlaying() then
return
end
sounds[sound]:play()
end
end
end

View File

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

View File

@@ -1,5 +1,5 @@
local ExitScene = SCENE:extend() local ExitScene = SCENE:extend()
require 'load.save' require 'settings'
ExitScene.title = "Exit Game" ExitScene.title = "Exit Game"

View File

@@ -1,5 +1,5 @@
local FullscreenScene = SCENE:extend() local FullscreenScene = SCENE:extend()
require 'load.save' require 'settings'
FullscreenScene.title = "Fullscreen" FullscreenScene.title = "Fullscreen"
@@ -7,9 +7,8 @@ function FullscreenScene:new()
end end
function FullscreenScene:update() function FullscreenScene:update()
config["fullscreen"] = not config["fullscreen"] SETTINGS["fullscreen"] = not SETTINGS["fullscreen"]
saveConfig() love.window.setFullscreen(SETTINGS["fullscreen"])
love.window.setFullscreen(config["fullscreen"])
SCENE = TitleScene() SCENE = TitleScene()
end end

View File

@@ -2,7 +2,7 @@ local GameScene = SCENE:extend()
GameScene.title = "Game" GameScene.title = "Game"
local tas = false local tas = false
require 'load.save' require 'settings'
function GameScene:new(player_name, replay_file, replay_grade) function GameScene:new(player_name, replay_file, replay_grade)
game_mode = require 'game.gamemode' game_mode = require 'game.gamemode'

View File

@@ -50,7 +50,7 @@ function ConfigScene:onInputPress(e)
self:changeOption(-1) self:changeOption(-1)
elseif e.input == "down" or e.scancode == "down" then elseif e.input == "down" or e.scancode == "down" then
self:changeOption(1) self:changeOption(1)
elseif config.input and ( elseif SETTINGS.input and (
e.input == "menu_back" or e.input == "rotate_right" or e.scancode == "backspace" or e.scancode == "delete" e.input == "menu_back" or e.input == "rotate_right" or e.scancode == "backspace" or e.scancode == "delete"
) then ) then
SCENE = TitleScene() SCENE = TitleScene()

View File

@@ -2,7 +2,7 @@ local KeyConfigScene = SCENE:extend()
KeyConfigScene.title = "Key Config" KeyConfigScene.title = "Key Config"
require 'load.save' require 'settings'
local minos = {'R_d', 'O_d', 'Y_d', 'G_d', 'C_d', 'B_d', 'M_d'} local minos = {'R_d', 'O_d', 'Y_d', 'G_d', 'C_d', 'B_d', 'M_d'}
@@ -59,7 +59,7 @@ function KeyConfigScene:render()
end end
end end
if self.input_state > #configurable_inputs then if self.input_state > #configurable_inputs then
drawText("Press enter to confirm, delete/backspace to retry" .. (config.input and ", escape to cancel" or ""),0,0,1000) drawText("Press enter to confirm, delete/backspace to retry" .. (SETTINGS.input and ", escape to cancel" or ""),0,0,1000)
else else
drawText("Press key input for " .. input_names[configurable_inputs[self.input_state]] .. ", tab to skip, escape to cancel",0,0,1000) drawText("Press key input for " .. input_names[configurable_inputs[self.input_state]] .. ", tab to skip, escape to cancel",0,0,1000)
drawText("Function keys (F1, F2, etc.), escape, and tab can't be changed", 0, 20,1000) drawText("Function keys (F1, F2, etc.), escape, and tab can't be changed", 0, 20,1000)
@@ -73,10 +73,9 @@ function KeyConfigScene:onInputPress(e)
SCENE = InputConfigScene() SCENE = InputConfigScene()
elseif self.input_state > #configurable_inputs then elseif self.input_state > #configurable_inputs then
if e.scancode == "return" then if e.scancode == "return" then
config.input.keys = self.new_input SETTINGS.input.keys = self.new_input
saveConfig() SCENE = SETTINGS.firstTime and TitleScene() or InputConfigScene()
SCENE = config.firstTime and TitleScene() or InputConfigScene() SETTINGS.firstTime = false
config.firstTime = false
elseif e.scancode == "delete" or e.scancode == "backspace" then elseif e.scancode == "delete" or e.scancode == "backspace" then
-- retry -- retry
self.input_state = 1 self.input_state = 1

View File

@@ -1,5 +1,5 @@
local MusicToggleScene = SCENE:extend() local MusicToggleScene = SCENE:extend()
require 'load.save' require 'settings'
MusicToggleScene.title = "Play music during game:" MusicToggleScene.title = "Play music during game:"
@@ -7,8 +7,7 @@ function MusicToggleScene:new()
end end
function MusicToggleScene:update() function MusicToggleScene:update()
config["music"] = not config["music"] SETTINGS["music"] = not SETTINGS["music"]
saveConfig()
SCENE = TitleScene() SCENE = TitleScene()
end end

View File

@@ -1,7 +1,7 @@
local NameEntryScene = SCENE:extend() local NameEntryScene = SCENE:extend()
local Grid = require 'game.grid' local Grid = require 'game.grid'
local bitser = require 'libs.bitser' local bitser = require 'libs.bitser'
require 'load.save' require 'settings'
NameEntryScene.title = "Game Start" NameEntryScene.title = "Game Start"
@@ -26,8 +26,8 @@ function NameEntryScene:new()
"10k", "9k", "8k", "7k", "6k", "5k", "4k", "3k", "2k", "1k", "10k", "9k", "8k", "7k", "6k", "5k", "4k", "3k", "2k", "1k",
"1D", "2D", "3D", "4D", "5D", "6D", "7D", "8D", "9D" "1D", "2D", "3D", "4D", "5D", "6D", "7D", "8D", "9D"
} }
if config['last_entry'] ~= nil then if SETTINGS['last_entry'] ~= nil then
self.name_entry = {config['last_entry']:sub(1,1),config['last_entry']:sub(2,2),config['last_entry']:sub(3,3)} self.name_entry = {SETTINGS['last_entry']:sub(1,1),SETTINGS['last_entry']:sub(2,2),SETTINGS['last_entry']:sub(3,3)}
self.entry_pos = 3 self.entry_pos = 3
end end
if love.filesystem.getInfo(HIscoreFILE) then if love.filesystem.getInfo(HIscoreFILE) then
@@ -115,8 +115,7 @@ function NameEntryScene:onInputPress(e)
self.delete_confirm = false self.delete_confirm = false
self.delete_input_count = 0 self.delete_input_count = 0
if self.entry_pos == 4 then if self.entry_pos == 4 then
config['last_entry'] = name:upper() SETTINGS['last_entry'] = name:upper()
saveConfig()
SCENE = GameScene(name:lower()) SCENE = GameScene(name:lower())
else else
if self.entry_pos == 3 then if self.entry_pos == 3 then

View File

@@ -2,7 +2,7 @@ local StickConfigScene = SCENE:extend()
StickConfigScene.title = "Controller Config" StickConfigScene.title = "Controller Config"
require 'load.save' require 'settings'
local minos = {'R_d', 'O_d', 'Y_d', 'G_d', 'C_d', 'B_d', 'M_d'} local minos = {'R_d', 'O_d', 'Y_d', 'G_d', 'C_d', 'B_d', 'M_d'}
@@ -59,7 +59,7 @@ function StickConfigScene:render()
end end
end end
if self.input_state > #configurable_inputs then if self.input_state > #configurable_inputs then
drawText("Press enter to confirm, delete/backspace to retry" .. (config.input and ", escape to cancel" or ""), 0, 0, 1000) drawText("Press enter to confirm, delete/backspace to retry" .. (SETTINGS.input and ", escape to cancel" or ""), 0, 0, 1000)
else else
drawText("Press joystick input for " .. input_names[configurable_inputs[self.input_state]] .. ", tab to skip, escape to cancel", 0, 0, 1000) drawText("Press joystick input for " .. input_names[configurable_inputs[self.input_state]] .. ", tab to skip, escape to cancel", 0, 0, 1000)
end end
@@ -81,10 +81,9 @@ function StickConfigScene:onInputPress(e)
elseif self.input_state > #configurable_inputs then elseif self.input_state > #configurable_inputs then
if e.scancode == "return" then if e.scancode == "return" then
-- save new input, then load next scene -- save new input, then load next scene
local had_config = config.input ~= nil local had_config = SETTINGS.input ~= nil
if not config.input then config.input = {} end if not SETTINGS.input then SETTINGS.input = {} end
config.input.joysticks = self.new_input SETTINGS.input.joysticks = self.new_input
saveConfig()
SCENE = had_config and InputConfigScene() or TitleScene() SCENE = had_config and InputConfigScene() or TitleScene()
elseif e.scancode == "delete" or e.scancode == "backspace" then elseif e.scancode == "delete" or e.scancode == "backspace" then
-- retry -- retry

View File

@@ -1,5 +1,5 @@
local TitleScene = SCENE:extend() local TitleScene = SCENE:extend()
require 'load.save' require 'settings'
require 'funcs' require 'funcs'
TitleScene.title = "Title" TitleScene.title = "Title"
@@ -16,7 +16,7 @@ local main_menu_screens = {
} }
function TitleScene:new() function TitleScene:new()
if sounds['bgm_firsthalf']:isPlaying() or sounds['bgm_secondhalf']:isPlaying() or not config["music"] then if SOUNDS['bgm_firsthalf']:isPlaying() or SOUNDS['bgm_secondhalf']:isPlaying() or not SETTINGS["music"] then
love.audio.stop() love.audio.stop()
end end
self.main_menu_state = 1 self.main_menu_state = 1
@@ -68,7 +68,7 @@ function TitleScene:render()
drawText("Based on Cambridge - t-sp.in/cambridge", 20, 420, 1000) drawText("Based on Cambridge - t-sp.in/cambridge", 20, 420, 1000)
drawText("Music for Tromi by Jerry Martin, all rights reserved - jerrymartinmusic.com", 20, 435, 1000) drawText("Music for Tromi by Jerry Martin, all rights reserved - jerrymartinmusic.com", 20, 435, 1000)
drawText("Game backgrounds by Pixabay users Joe_hackney, yokim, Favorisxp, Any_Ann, VisualSkyFX ", 20, 450, 1000) drawText("Game backgrounds by Pixabay users Joe_hackney, yokim, Favorisxp, Any_Ann, VisualSkyFX ", 20, 450, 1000)
if config["music"] == true then if SETTINGS["music"] == true then
drawText("On", 230, 320, 1000) drawText("On", 230, 320, 1000)
else else
drawText("Off", 230, 320, 1000) drawText("Off", 230, 320, 1000)

View File

@@ -2,7 +2,7 @@ local TrainingScene = SCENE:extend()
TrainingScene.title = "Max Gravity Training" TrainingScene.title = "Max Gravity Training"
require 'load.save' require 'settings'
function TrainingScene:new() function TrainingScene:new()
game_mode = require 'game.gamemode' game_mode = require 'game.gamemode'

39
settings.lua Normal file
View File

@@ -0,0 +1,39 @@
local bitser = require 'libs.bitser'
local fs = love.filesystem
local _settings = fs.read(CONFIG_FILE) ~= nil and bitser.loadLoveFile(CONFIG_FILE) or {}
local _defaultSettings = {
firstTime = true,
fullscreen = false,
music = true,
input = {
keys = {},
mobile = { -- Should not be changed for any reason, used for mobile only
enter = 'menu_decide',
f13 = 'up',
f14 = 'down',
f15 = 'left',
f16 = 'right',
f17 = 'rotate_left',
f18 = 'rotate_left2',
f19 = 'rotate_right',
f20 = 'rotate_right2',
}
}
}
SETTINGS = setmetatable(
{},
{
__index = function(_, k)
if _settings[k] == nil then _settings[k] = _defaultSettings[k] end
return _settings[k]
end,
__newindex = function(_, k, v)
_settings[k] = v
bitser.dumpLoveFile(CONFIG_FILE,_settings)
end
}
)