timer = 0 pages = grimoire page_idx = 1 prev_page_idx = 1 animations={} current_recipe = pages[page_idx] recipe_list_offset_x=30 recipe_list_offset_y=8 function recipe_list_move_to(x1, y1, x2, y2) return { timer = 0, active=true, before=function(s) recipe_list_offset_x = x1 recipe_list_offset_y = y1 sfx(2) end, update=function(s) recipe_list_offset_x = x1 + (s.timer/0.2)*(x2-x1) recipe_list_offset_y = y1 + (s.timer/0.2)*(y2-y1) if s.timer > 0.2 then recipe_list_offset_x = x2 recipe_list_offset_y = y2 s.active=false end end, draw=function(s) end, } end function recipe_list_move_out(x1, y1, x2, y2) new = recipe_list_move_to(x1, y1, x2, y2) new.draw = function(s) draw_paper(recipe_list_offset_x, recipe_list_offset_y, 140, 140) draw_recipe_on_paper(current_recipe, recipe_list_offset_x, recipe_list_offset_y) decorate_recipe_unfinished(current_recipe, recipe_list_offset_x, recipe_list_offset_y) end return new end function flip_away(page) return { prev_page_idx = page, timer = 0, active=true, before=function(s) sfx(2) end, update=function(s) if s.timer > 0.2 then s.active=false end end, draw=function(s) local page_flip = 600*s.timer local x = 30 + page_flip local y = 8 + 0.1*page_flip draw_paper(x,y, 140, 140) draw_recipe_on_paper(pages[s.prev_page_idx], x,y) decorate_recipe_unfinished(pages[s.prev_page_idx], x, y) end, } end function flip_in(page, new_page) return { prev_page_idx = page, new_page_idx = new_page, timer = 0, active=true, before=function(s) sfx(2) end, update=function(s) if s.timer >= 0.2 then s.active=false end end, draw=function(s) draw_paper(30, 8, 140, 140) draw_recipe_on_paper(pages[s.prev_page_idx], 30, 8) decorate_recipe_unfinished(pages[s.prev_page_idx], 30, 8) local page_flip = 600*(0.2-s.timer) local x = 30 + page_flip local y = 8 + 0.1*page_flip draw_paper(x,y, 140, 140) draw_recipe_on_paper(pages[s.new_page_idx], x,y) decorate_recipe_unfinished(pages[s.new_page_idx], x, y) end } end function pages_update() if btnp(0) and page_idx ~= 1 then animate(flip_away(page_idx)) page_idx = page_idx - 1 end if btnp(1) and page_idx ~= #pages then animate(flip_in(page_idx, page_idx+1)) page_idx = page_idx + 1 end if btnp(4) then change_screen(screen_crafting) current_recipe = pages[page_idx] end if btnp(5) then animate(recipe_list_move_out(30, 8, 30+80, 8+8)) change_screen(screen_workbench) end current_recipe = pages[page_idx] end function pages_draw() cls() draw_background() draw_paper(recipe_list_offset_x, recipe_list_offset_y, 140, 140) draw_recipe_on_paper(current_recipe, recipe_list_offset_x, recipe_list_offset_y) decorate_recipe_unfinished(current_recipe, recipe_list_offset_x, recipe_list_offset_y) end recipe_tutorial = { {phoebe_portrait, [[this is all my recipes. they each list what they need for ingredients.]]}, {phoebe_portrait, [[go through them with left and right, or]]}, {phoebe_portrait, [[press ❎ to back out to the workbench. 🅾️ will start crafting!!]]}, } screen_recipe_list = {draw=pages_draw, update=pages_update} if not testing then screen_recipe_list = screen_conversation(recipe_tutorial, function() screen_recipe_list = {draw=pages_draw, update=pages_update} change_screen(screen_recipe_list) end, screen_recipe_list) end