pico8-0hh1/states/endgame.lua

54 lines
1.1 KiB
Lua
Raw Normal View History

2022-07-12 21:47:10 +02:00
function state_endgame()
2023-10-07 19:12:53 +02:00
local board
local message = "웃웃 yay! 웃웃"
local message_x = 0
local function go_to_menu()
set_state(states.menu)
end
local btn_back = make_button({
x = 1, y = 118, h = 7, text = "🅾️/C bACK TO mENU", color = 8,
on_click = function() go_to_menu() end,
on_hover = function(btn) btn.color = 7 end
})
local function _enter(_board)
board = _board
message_x = (128 - print(message, 0, -100)) / 2
end
local function _update()
btn_back:update()
if btnp(BTN_O) then
go_to_menu()
end
end
local function _draw()
cls()
board:draw()
-- wavy message
local offset = 0
for i = 1, #message, 1 do
-- loop through every letter
letter = sub(message, i, i) -- grab this letter
local st = t() + 0.125 * i -- create a modified time for this letter
print(letter, message_x + offset, 20 + sin(st * 0.5) * 10, 7) -- draw this letter
offset += print(letter, 0, -100)
end
btn_back:draw()
end
local function _leave()
end
return {
_enter = _enter,
_update = _update,
_draw = _draw,
_leave = _leave
}
2022-07-12 21:47:10 +02:00
end