Progressive board display while loading
This commit is contained in:
+35
-19
@@ -3,26 +3,24 @@ function state_loading()
|
||||
|
||||
local spinner = split"-,\\,|,/"
|
||||
local loading_messages = {
|
||||
"lOADING PATHFINDING ALGORITHM",
|
||||
"rETICULATING SPLINES",
|
||||
"aLLOCATING MEMORY BANDWIDTH",
|
||||
"iNITIALIZING HARDWARE",
|
||||
"aLLOCATING RESSOURCES",
|
||||
"eMULATING HARDWARE",
|
||||
"uNCLOGGING MEMORY BUS",
|
||||
"sPINNING UP ai AGENT",
|
||||
"PINGING aZURE AGENT POOL",
|
||||
"bOOTING VIRTUAL MACHINE",
|
||||
"cOUNTING PIXELS",
|
||||
"cOLORING TILES",
|
||||
"tIP: THIS GAME RUNS BETTER ON iNTERNET eXPLORER 6",
|
||||
"lOADING A NEW BOARD",
|
||||
"iF YOU CAN'T SOLVE A BOARD, ASK HELP FROM AN ADULT",
|
||||
"lOADING RAY-TRACING SETTINGS",
|
||||
"aDJUSTING DIFFICULTY FOR YOUR PLAY STYLE",
|
||||
"cOLLECTING PIXELS TO BUILD TILES",
|
||||
"lOADING RAY-TRACING ALGORITHM",
|
||||
"sWEEPING PARTICLES",
|
||||
"pRESSURIZING USER INTERFACE",
|
||||
"rECOMPUTING BOARD MATRIX"
|
||||
}
|
||||
|
||||
local message = ""
|
||||
local messages_str = ""
|
||||
local messages_x = 128
|
||||
local loaded = false
|
||||
local removing_tile = 0
|
||||
|
||||
local create_board = cocreate(function()
|
||||
repeat
|
||||
@@ -36,18 +34,17 @@ function state_loading()
|
||||
printh("b: " .. time())
|
||||
-- Remove tiles until randomness is unavoidable
|
||||
local previous = {board:get_tiles_copy()} -- initial state
|
||||
local i = 0
|
||||
while true do
|
||||
board:set_tiles(previous[#previous])
|
||||
-- remove a random tile
|
||||
repeat
|
||||
i += 1
|
||||
until i == 100 or board:get_tiles_copy()[i] ~= 0
|
||||
if i == 100 then
|
||||
removing_tile += 1
|
||||
until removing_tile == 100 or board:get_tiles_copy()[iremoving_tile] ~= 0
|
||||
if removing_tile == 100 then
|
||||
break
|
||||
end
|
||||
|
||||
board:fill(i, 0)
|
||||
board:fill(removing_tile, 0)
|
||||
add(previous, board:get_tiles_copy())
|
||||
|
||||
-- try to solve the board
|
||||
@@ -69,6 +66,19 @@ function state_loading()
|
||||
loaded = true
|
||||
end)
|
||||
|
||||
local function draw_tiles(board)
|
||||
local w = board:get_size()
|
||||
local tiles = board:get_tiles_copy()
|
||||
for k,v in ipairs(tiles) do
|
||||
if k<removing_tile and v > 0 then
|
||||
local x,y = board:draw_coords(k)
|
||||
local color = v == BLUE and 12 or 8
|
||||
if color == 1 then fillp(▒) else fillp(█) end
|
||||
rectfill2(x, y, w, w, color)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function _enter()
|
||||
loaded = false
|
||||
|
||||
@@ -80,7 +90,7 @@ function state_loading()
|
||||
messages_str ..= m .. " "
|
||||
del(copy_messages, m)
|
||||
end
|
||||
messages_str ..= "[END OF MESSAGES, THANK YOU FOR YOUR PATIENCE]"
|
||||
messages_str ..= "tHANK YOU FOR YOUR PATIENCE"
|
||||
|
||||
custom_font()
|
||||
startcoroutine(create_board)
|
||||
@@ -95,9 +105,15 @@ function state_loading()
|
||||
|
||||
local function _draw()
|
||||
cls()
|
||||
|
||||
board:draw_bg()
|
||||
draw_tiles(board)
|
||||
|
||||
local l = print(message, 0, -100)
|
||||
print(messages_str, messages_x, 50, 7)
|
||||
print(spinner[t()\.25%4+1], 120, 120)
|
||||
if not loaded then
|
||||
print(messages_str, messages_x, 50, 7, 0)
|
||||
-- print(spinner[t()\.25%4+1], 120, 120)
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user