Cart data reset, excavate button

This commit is contained in:
Pyrex 2024-02-11 15:51:56 -08:00
parent c4b11071e5
commit 343e4a2ea9
6 changed files with 104 additions and 6 deletions

View File

@ -5,6 +5,12 @@ function completion_tracker:init()
cartdata("pyrex_fortunesfoundation_1")
end
function completion_tracker:reset()
for i=0,63 do
dset(i,0)
end
end
function completion_tracker:get_completion_level()
return dget(0)
end

View File

@ -20,9 +20,9 @@ democrap={
function democrap:distort_screen(progress)
if (progress <= 0) return
progress=min(progress,1)
for src=0x6002,0x7fc2,64 do
for src=0x6004,0x7fc4,64 do
dst=src+sin(t()+src/0x800)*(4*progress)+0.5
memcpy(dst,src,60)
memcpy(dst,src,56)
end
local ps=democrap.patterns
local p=ps[1+flr(progress*#ps)] or ps[#ps]

View File

@ -19,16 +19,19 @@ __lua__
#include progression.lua
#include seed_constants.lua
#include seeds.lua
#include state_excavate_menu.lua
#include state_manager.lua
#include state_menu.lua
#include state_gameround.lua
#include state_ironman.lua
#include state_reset_menu.lua
#include state_restartmenu.lua
#include state_wonround.lua
#include tutorial.lua
#include text.lua
#include watcher.lua
#include main.lua
--[[
srand(2)
for i=1,10 do

23
state_excavate_menu.lua Normal file
View File

@ -0,0 +1,23 @@
-- todo: actually display a level picker or something
state_excavate_menu=klass()
function state_excavate_menu:init(prior_menu)
self.prior_menu=prior_menu
self.frame=0
self.frames=4
self.progress=0
end
function state_excavate_menu:enter() end
function state_excavate_menu:exit(new_top) end
function state_excavate_menu:reenter() end
function state_excavate_menu:suspend() end
function state_excavate_menu:update()
self.frame+=1
self.progress=self.frame/self.frames
if (self.progress>1) self.done=true main.state_manager:push(state_ironman:new(tutorial))
end
function state_excavate_menu:draw()
self.prior_menu:draw()
democrap:distort_screen(self.progress)
end

View File

@ -3,27 +3,32 @@ function state_menu:init()
self.selection=1
self.options={
menu_option:new(function() return "excavate" end,function()
main.state_manager:push(state_excavate_menu:new())
main.state_manager:push(state_excavate_menu:new(self))
end),
menu_option:new(function() return "archaeology" end,function()
main.state_manager:push(state_archaeology:new())
end),
menu_option:new(),
menu_option:new(function() return "music" end,function()
-- todo: music manager
end),
menu_option:new(function() return "reset data" end,function()
main.state_manager:push(state_reset_menu:new(self))
end)
}
end
function state_menu:enter() end
function state_menu:exit(new_top) end
function state_menu:exit() end
function state_menu:reenter()
self.selection=1
end
function state_menu:suspend() end
function state_menu:suspend()
self.selection=nil
end
function state_menu:update()
if (btnp(0) or btnp(4)) self.options[self.selection]:cb()
if (btnp(1) or btnp(4)) self.options[self.selection]:cb()
local vel=0
if (btnp(2)) vel-=1

61
state_reset_menu.lua Normal file
View File

@ -0,0 +1,61 @@
state_reset_menu=klass()
function state_reset_menu:init(prior_menu)
self.prior_menu=prior_menu
self.options="⬅️➡️⬆️⬇️🅾️"
self.code={}
self.code_i=1
for i=1,5 do
local i=flr(rnd(#self.options))
add(self.code,i)
end
end
function state_reset_menu:enter() end
function state_reset_menu:exit(new_top) end
function state_reset_menu:reenter() end
function state_reset_menu:suspend() end
function state_reset_menu:update()
for o=0,5 do
if btnp(o) then
if self.code_i>#self.code then
run()
end
if self.code[self.code_i]==o then
self.code_i+=1
if (self.code_i>#self.code) completion_tracker:reset()
else
self.done=true
end
return
end
end
end
function state_reset_menu:caption()
if (self.code_i > #self.code) return "savedata reset!"
local caption="to reset your\nsavedata, type\nthis code\n\n"
local code="\f7"
for i=1,#self.code do
local o=self.code[i]+1
local c=sub(self.options,o,o)
if (i-1<self.code_i and i>=self.code_i) code..="\ff"
if (i!=1) code..=" "
code..=c
end
return caption..code
end
function state_reset_menu:draw()
self.prior_menu:draw()
local caption=self:caption()
local w,h=measure_text(caption)
h-=1
local x=64-w\2
local y=64-h\2
rect(x-2,y-2,x+w+1,y+h+1,15)
rectfill(x-1,y-1,x+w,y+h,4)
print(caption,x,y,15)
end