Updated rendering

This commit is contained in:
2022-07-08 22:47:26 +02:00
parent d75277a29d
commit f7fdea4268
5 changed files with 35 additions and 47 deletions
+10 -10
View File
@@ -50,16 +50,16 @@ function state_game()
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)
if clue.type == "row" then
x,y = board:draw_coords((clue.pos-1) * board:get_size()+1)
x=-32
spr(19, x+clue.t%144, y+1+sin(t())*2)
else -- col
x,y = board:draw_coords(clue.pos)
y=-32
spr(19, x+2+sin(t())*2, y+clue.t%144)
end
pset(x, y, 5)
clue.t += 1
end
palt()
+17 -9
View File
@@ -24,7 +24,11 @@ function state_loading()
local messages_str = ""
local messages_x = 128
local loaded = false
local removing_tile = 0
local done = {}
local size = board:get_size()*board:get_size()
local og_rt = rnd(size)\1+1 -- original removing tile
local removing_tile = og_rt
local create_board = cocreate(function()
local start = time()
@@ -38,19 +42,23 @@ function state_loading()
-- Remove tiles that can be removed
local previous = {board:get_tiles_copy()} -- initial state
local size = board:get_size()*board:get_size()
done = {}
while true do
board:set_tiles(previous[#previous])
-- remove a random tile
repeat
removing_tile += 1
if removing_tile > size then
removing_tile = 1
end
until removing_tile == size or board:get_tiles_copy()[removing_tile] ~= 0
if removing_tile == size then
if removing_tile == og_rt then
break
end
board:fill(removing_tile, 0)
add(done, removing_tile)
add(previous, board:get_tiles_copy())
-- try to solve the board
@@ -86,7 +94,7 @@ function state_loading()
local w = board:get_size()
local tiles = board:get_tiles_copy()
for k,v in ipairs(tiles) do
if k < removing_tile then
if v==0 or contains(done, k) then
board:draw_tile(k)
end
end
@@ -129,11 +137,11 @@ function state_loading()
local l = print(message, 0, -100)
local y = 118+(removing_tile/s)*100/8
local ci = removing_tile\20+1
if not loaded then
rectfill2(0,y-2,127,10,0)
print(messages_str, messages_x, y, 3, 0)
-- print(spinner[t()\.25%4+1], 120, 120)
end
-- if not loaded then
-- rectfill2(0,y-2,127,10,0)
-- print(messages_str, messages_x, y, 3, 0)
-- -- print(spinner[t()\.25%4+1], 120, 120)
-- end
end
return {