Fixed new board state

This commit is contained in:
Simon Cambier 2022-09-24 16:07:41 +02:00
parent 31f6b7c3e3
commit 02fbe198d4

View File

@ -1,5 +1,8 @@
function state_loading() function state_loading()
local board = Board.new() local board
local size
local og_rt
local removing_tile
local spinner = split"-,\\,|,/" local spinner = split"-,\\,|,/"
local loading_messages = { local loading_messages = {
@ -26,11 +29,8 @@ function state_loading()
local loaded = false local loaded = false
local done = {} local done = {}
local size = board:get_size()*board:get_size() local create_board = function()
local og_rt = rnd(size)\1+1 -- original removing tile printh("creating")
local removing_tile = og_rt
local create_board = cocreate(function()
local start = time() local start = time()
repeat repeat
board:reset() board:reset()
@ -88,7 +88,7 @@ function state_loading()
printh(count(board:get_tiles_copy(), 0).." zeroes") printh(count(board:get_tiles_copy(), 0).." zeroes")
loaded = true loaded = true
end) end
local function draw_tiles(board) local function draw_tiles(board)
local w = board:get_size() local w = board:get_size()
@ -101,8 +101,15 @@ function state_loading()
end end
local function _enter() local function _enter()
printh("enter loading")
board = Board:new()
size = board:get_size()*board:get_size()
og_rt = rnd(size)\1+1 -- original removing tile
removing_tile = og_rt
amplitude = 64 amplitude = 64
loaded = false loaded = false
done = {}
local copy_messages = copy(loading_messages) local copy_messages = copy(loading_messages)
messages_str = "" messages_str = ""
@ -114,7 +121,7 @@ function state_loading()
end end
messages_str ..= "tHANK YOU FOR YOUR PATIENCE" messages_str ..= "tHANK YOU FOR YOUR PATIENCE"
startcoroutine(create_board) startcoroutine(cocreate(create_board))
end end
local function _update() local function _update()