function state_game_loading() local covering local event_bus local turn local banner local function show_transition() -- slightly scale up the transition dice for i, die in ipairs(covering) do die.scale = die.scale - 0.03 / i * 80 die.angle = die.angle - i / 50 if die.scale < 0 then die.scale = 0 end swap_color(12, 15) swap_color(13, 15) swap_color(14, 15) swap_color(0, 15) die:draw(-1) end -- clean if table.count(covering, function(d) return d.scale == 0 end) == #covering then covering = {} end end local function _enter(self, data) assert(data.covering, "needs data.covering") assert(data.event_bus, "needs data.event_bus") covering = data.covering event_bus = data.event_bus turn = data.turn banner = { h = 0, w = 1, } addcoroutine(function() while banner.w < 240 do banner.w = banner.w *1.1 waitframes(1) end if banner.w > 240 then banner.w = 240 end while banner.h < 20 do banner.h = banner.h + 1 waitframes(1) end waitsecs(1.5) while banner.h > 0.5 do banner.h = banner.h - 1 waitframes(1) end while banner.w > 1 do banner.w = banner.w * 0.9 waitframes(1) end waitsecs(0.5) event_bus:emit(EVENT_RESET_DIE) event_bus:emit(EVENT_SET_STEP, "rolling") end) end local function update(self) -- black banner in the middle rect(120 - banner.w / 2, 67 - banner.h / 2, banner.w, banner.h, 0) rectb(120 - banner.w / 2, 67 - banner.h / 2, banner.w, banner.h, 15) clip(120 - banner.w / 2, 67 - banner.h / 2, banner.w, banner.h) -- show who's going first local text local color if turn == "player" then color = COLOR_PLAYER text = "You begin this round" else color = COLOR_ENEMY text = "Your opponent begins this round" end prn_border(text, 120, 67 - 4, 12, ALIGN.Center, color) clip() if #covering > 0 then show_transition() end end return { _enter = _enter, update = update } end