Merge pull request 'glitch' (#32) from feature/glitch into master
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Reviewed-on: #32
This commit was merged in pull request #32.
This commit is contained in:
@@ -11,6 +11,7 @@ logic/logic.day.lua
|
||||
logic/logic.timer.lua
|
||||
logic/logic.trigger.lua
|
||||
logic/logic.minigame.lua
|
||||
logic/logic.glitch.lua
|
||||
system/system.ui.lua
|
||||
audio/audio.manager.lua
|
||||
audio/audio.songs.lua
|
||||
|
||||
@@ -2,6 +2,7 @@ Decision.register({
|
||||
id = "go_to_office",
|
||||
label = "Go to Office",
|
||||
handle = function()
|
||||
Glitch.show()
|
||||
Util.go_to_screen_by_id("office")
|
||||
end,
|
||||
})
|
||||
|
||||
@@ -42,6 +42,11 @@ function Context.initial_data()
|
||||
current_situation = nil,
|
||||
},
|
||||
day_count = 1,
|
||||
glitch = {
|
||||
enabled = false,
|
||||
state = "active",
|
||||
timer = 0,
|
||||
},
|
||||
_end = {
|
||||
state = "choice",
|
||||
selection = 1,
|
||||
|
||||
57
inc/logic/logic.glitch.lua
Normal file
57
inc/logic/logic.glitch.lua
Normal file
@@ -0,0 +1,57 @@
|
||||
Glitch = {}
|
||||
|
||||
--- Shows the glitch effect.
|
||||
--- @within Glitch
|
||||
function Glitch.show()
|
||||
if Context and Context.glitch then
|
||||
Context.glitch.enabled = true
|
||||
end
|
||||
end
|
||||
|
||||
--- Hides the glitch effect.
|
||||
--- @within Glitch
|
||||
function Glitch.hide()
|
||||
if Context and Context.glitch then
|
||||
Context.glitch.enabled = false
|
||||
end
|
||||
end
|
||||
|
||||
--- Draws the glitch effect if active.
|
||||
--- @within Glitch
|
||||
function Glitch.draw()
|
||||
if not Context or not Context.glitch or not Context.glitch.enabled then return end
|
||||
|
||||
-- Update state timer
|
||||
Context.glitch.timer = Context.glitch.timer - 1
|
||||
if Context.glitch.timer <= 0 then
|
||||
if Context.glitch.state == "active" then
|
||||
Context.glitch.state = "waiting"
|
||||
Context.glitch.timer = math.random(20, 60) -- Time to stay fixed
|
||||
else
|
||||
Context.glitch.state = "active"
|
||||
Context.glitch.timer = math.random(40, 100) -- Time to stay glitchy
|
||||
end
|
||||
end
|
||||
|
||||
-- Draw stripes only when active
|
||||
if Context.glitch.state == "active" then
|
||||
for i = 1, 15 do
|
||||
local rx = math.random(0, Config.screen.width - 1)
|
||||
local ry = math.random(0, Config.screen.height - 1)
|
||||
|
||||
-- Sample color at the random point
|
||||
local color = pix(rx, ry)
|
||||
|
||||
-- Determine random length for the stripe (2-40)
|
||||
local length = math.random(2, 40)
|
||||
|
||||
-- Draw the vertical stripe
|
||||
for sy = 0, length - 1 do
|
||||
local dy = ry + sy
|
||||
if dy < Config.screen.height then
|
||||
pix(rx, dy, color)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -27,5 +27,6 @@ function TIC()
|
||||
if Context.game_in_progress then
|
||||
Meter.draw()
|
||||
Timer.draw()
|
||||
Glitch.draw()
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user