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

@@ -3,7 +3,7 @@ local bit = require("bit")
local lualzw = require 'libs.lualzw'
local bitser = require 'libs.bitser'
require 'funcs'
require 'load.save'
require 'settings'
local playedReadySE = false
local playedGoSE = false
@@ -84,8 +84,8 @@ function GameMode:new(player_name, input_file, replay_grade)
self.speed_divisor = 10000
self.line_clear_flash = 0
self.lines_cleared = 0
sounds['bgm_firsthalf']:setVolume(0.3)
sounds['bgm_secondhalf']:setVolume(0.35)
SOUNDS['bgm_firsthalf']:setVolume(0.3)
SOUNDS['bgm_secondhalf']:setVolume(0.35)
self.audio_stopped = false
self.recorded_inputs = {}
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.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
playSEOnce(self.end_game_sound)
PlaySEOnce(self.end_game_sound)
end
if self.game_over or self.completed then
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
self.spin_rng[i] = spin
end
playSE("erase")
PlaySE("erase")
self.lcd = self:getLineClearDelay()
self.last_lcd = self.lcd
self.are = self:getLineARE()
@@ -613,28 +613,28 @@ end
function GameMode:advanceOneFrame()
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
love.audio.stop()
self.audio_stopped = true
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 self.nextbgmflag and sounds['bgm_firsthalf']:isPlaying() then
if sounds['bgm_firsthalf']:getVolume() > 0.1 then
sounds['bgm_firsthalf']:setVolume(sounds['bgm_firsthalf']:getVolume()-0.01)
if self.nextbgmflag and SOUNDS['bgm_firsthalf']:isPlaying() then
if SOUNDS['bgm_firsthalf']:getVolume() > 0.1 then
SOUNDS['bgm_firsthalf']:setVolume(SOUNDS['bgm_firsthalf']:getVolume()-0.01)
else
sounds['bgm_firsthalf']:stop()
SOUNDS['bgm_firsthalf']:stop()
end
end
if self.ready_frames < 1 and not sounds['bgm_firsthalf']:isPlaying() and not sounds['bgm_secondhalf']:isPlaying() and config["music"] then
if not self.nextbgmflag then sounds['bgm_firsthalf']:play()
elseif self.total_lines < 296 then sounds['bgm_secondhalf']:play() end
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()
elseif self.total_lines < 296 then SOUNDS['bgm_secondhalf']:play() end
end
if self.total_lines >= 296 then
sounds['bgm_firsthalf']:stop()
sounds['bgm_secondhalf']:stop()
SOUNDS['bgm_firsthalf']:stop()
SOUNDS['bgm_secondhalf']:stop()
end
end
if self.clear then
@@ -688,7 +688,7 @@ function GameMode:onPieceLock(piece, cleared_row_count)
self.moved = true
end
self.lastdir = 0
playSE("lock")
PlaySE("lock")
end
function GameMode:onLineClear(cleared_row_count)
@@ -810,7 +810,7 @@ function GameMode:processDelays(inputs, ruleset, drop_speed)
if self.ready_frames > 0 then
if not playedReadySE then
playedReadySE = true
playSEOnce("ready")
PlaySEOnce("ready")
end
self.ready_frames = self.ready_frames - 1
if self.ready_frames == 0 then
@@ -822,7 +822,7 @@ function GameMode:processDelays(inputs, ruleset, drop_speed)
local cleared_row_count = self.grid:getClearedRowCount()
self.grid:clearClearedRows()
self:afterLineClear(cleared_row_count)
playSE("fall")
PlaySE("fall")
if self.are == 0 then
self:initializeOrHold(inputs, ruleset)
end
@@ -861,7 +861,7 @@ function GameMode:initializeNextPiece(inputs, ruleset, piece_data, generate_next
self.piece_soft_locked = false
if self.piece:isDropBlocked(self.grid) and
self.grid:canPlacePiece(self.piece) then
playSE("bottom")
PlaySE("bottom")
end
if generate_next_piece == nil then
table.remove(self.next_queue, 1)
@@ -893,10 +893,10 @@ function GameMode:drawLineClearAnimation()
fall_timer = (fall_timer*fall_timer)+drift
fade_timer = self.lcd/20
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
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
@@ -917,7 +917,7 @@ function GameMode:drawNextQueue(ruleset)
for index, offset in pairs(offsets) do
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
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
for i = 1, self.next_queue_length do
@@ -1067,8 +1067,8 @@ function GameMode:drawScoringInfo()
if self.clear or self.game_over then
sounds['bgm_firsthalf']:stop()
sounds['bgm_secondhalf']:stop()
SOUNDS['bgm_firsthalf']:stop()
SOUNDS['bgm_secondhalf']:stop()
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 bg == 0 or bg == 6 or bg == 9 then limit = 5 end
if bg == 5 then limit = 4.76 end
if not backgrounds[bg]:isPlaying() then
backgrounds[bg]:play()
if not BACKGROUNDS[bg]:isPlaying() then
BACKGROUNDS[bg]:play()
end
if backgrounds[bg]:tell() >= limit then
backgrounds[bg]:rewind()
if BACKGROUNDS[bg]:tell() >= limit then
BACKGROUNDS[bg]:rewind()
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.draw(
backgrounds[bg],
BACKGROUNDS[bg],
0, 0, 0,
0.5, 0.5
)