feat: added ascension logic 4-7, added new decision (eating fast food), indicating meter changes better, added discussions (needs more work, but meh ... fine like this)
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
@@ -8,6 +8,8 @@ local METER_DECAY_PER_DAY = 20
|
||||
local COMBO_BASE_BONUS = 0.02
|
||||
local COMBO_MAX_BONUS = 0.16
|
||||
local COMBO_TIMEOUT_FRAMES = 600
|
||||
local FLASH_DURATION = 2.0
|
||||
local FLASH_COLOR = 4
|
||||
|
||||
-- Internal meters for tracking game progress and player stats.
|
||||
Meter.COLOR_ISM = Config.colors.orange
|
||||
@@ -16,6 +18,12 @@ Meter.COLOR_BM = Config.colors.red
|
||||
Meter.COLOR_BG = Config.colors.meter_bg
|
||||
Meter.COLOR_CONTOUR = Config.colors.white
|
||||
|
||||
local _flash = {
|
||||
wpm = { timer = 0, delta = 0 },
|
||||
ism = { timer = 0, delta = 0 },
|
||||
bm = { timer = 0, delta = 0 },
|
||||
}
|
||||
|
||||
--- Gets initial meter values.
|
||||
--- @within Meter
|
||||
--- @return result table Initial meter values. </br>
|
||||
@@ -95,6 +103,12 @@ function Meter.update()
|
||||
end
|
||||
end
|
||||
end
|
||||
local dt = Context.delta_time or 0
|
||||
for _, key in ipairs({ "wpm", "ism", "bm" }) do
|
||||
if _flash[key].timer > 0 then
|
||||
_flash[key].timer = _flash[key].timer - dt
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Adds amount to a meter.
|
||||
@@ -109,7 +123,18 @@ function Meter.add(key, amount)
|
||||
GameOverWindow.show(key)
|
||||
return
|
||||
end
|
||||
local prev_wpm = (key == "wpm") and m.wpm or nil
|
||||
local old_val = m[key]
|
||||
m[key] = math.max(0, math.min(METER_MAX, m[key] + amount))
|
||||
local actual_delta = m[key] - old_val
|
||||
if actual_delta ~= 0 and _flash[key] then
|
||||
_flash[key].delta = actual_delta
|
||||
_flash[key].timer = FLASH_DURATION
|
||||
end
|
||||
if prev_wpm and prev_wpm > 0 and m.wpm == 0 and Context.game_in_progress
|
||||
and Ascension.get_level() == 5 then
|
||||
Context.should_ascend = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -258,12 +283,32 @@ function Meter.draw()
|
||||
local fill_w = math.max(0, math.floor((m[meter.key] / max) * bar_w))
|
||||
rect(bar_x - 1, bar_y - 1, bar_w + 2, bar_h + 2, Meter.COLOR_CONTOUR)
|
||||
rect(bar_x, bar_y, bar_w, bar_h, Meter.COLOR_BG)
|
||||
if fill_w > 0 then
|
||||
local flash = _flash[meter.key]
|
||||
if flash and flash.timer > 0 then
|
||||
local old_val = m[meter.key] - flash.delta
|
||||
local old_fill_w = math.max(0, math.floor((old_val / max) * bar_w))
|
||||
local stable_w = math.min(fill_w, old_fill_w)
|
||||
if stable_w > 0 then
|
||||
rect(bar_x, bar_y, stable_w, bar_h, meter.color)
|
||||
end
|
||||
if flash.delta > 0 then
|
||||
local hi_w = fill_w - stable_w
|
||||
if hi_w > 0 then
|
||||
rect(bar_x + stable_w, bar_y, hi_w, bar_h, FLASH_COLOR)
|
||||
end
|
||||
else
|
||||
local hi_w = old_fill_w - fill_w
|
||||
if hi_w > 0 then
|
||||
rect(bar_x + fill_w, bar_y, hi_w, bar_h, FLASH_COLOR)
|
||||
end
|
||||
end
|
||||
elseif fill_w > 0 then
|
||||
rect(bar_x, bar_y, fill_w, bar_h, meter.color)
|
||||
end
|
||||
---print(meter.label, label_x, label_y, meter.color, false, 1, true)
|
||||
end
|
||||
|
||||
local ascension_y = start_y + 3 * line_h + 1
|
||||
Ascension.draw(bar_x, ascension_y, { spacing = 8 })
|
||||
Ascension.draw(bar_x - 4, ascension_y, { spacing = 8 })
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user