function state_game() local board local selected_id = 1 local timer_clue = 0 local clues = {} local function show_clues() local issues = board:get_issues(true) clues = {} for issue in all(issues) do local type, err, row, pos, other = unpack(issue) printh(type .. " " .. err .. " " .. pos) add(clues, {type=type, pos=pos, t=0}) if err == "identical" then add(clues, {type=type, pos=other, t=0}) end end end local function draw_selected_tile() local x, y = board:draw_coords(selected_id) local w = board:get_tile_width() -- fillp(▒) rect2(x-1, y-1, w+1, w+1, 6) line() fillp(█) end local function _enter(_board) board = _board -- lock the initial tiles board:lock_tiles() end local function _leave() -- stopcoroutine(show_clues) end local function _draw() cls() local x,y = board:draw_coords(1) draw_animated_bg(x) board:draw() draw_selected_tile() -- draw clues for clue in all(clues) do palt(0,false) palt(5,true) local x,y if clue.type == "row" then x,y = board:draw_coords((clue.pos-1) * board:get_size()+1) x=0 spr(19, x+clue.t%144, y+1+sin(t())*2) else -- col x,y = board:draw_coords(clue.pos) spr(19, x+2+sin(t())*2, y+clue.t%144) y=0 end pset(x, y, 5) clue.t += 1 end palt() end local function _update() local size = board:get_size() local x, y = board:idx_xy(selected_id) if btnp(UP) then y -= 1 elseif btnp(DOWN) then y += 1 elseif btnp(LEFT) then x -= 1 elseif btnp(RIGHT) then x += 1 end if btnp(BTN_O) then board:try_flip_tile(selected_id) show_clues() end if (x<1) x=size if (x>size) x=1 if (y<1) y=size if (y>size) y=1 selected_id = board:xy_idx(x, y) end return { _enter = _enter, _update = _update, _draw = _draw, _leave = _leave } end