Updated rendering
This commit is contained in:
parent
d75277a29d
commit
f7fdea4268
16
bg.lua
16
bg.lua
|
@ -3,7 +3,7 @@ function draw_animated_bg(startx)
|
|||
startx = startx or 0
|
||||
fillp(0b0101101001011010)
|
||||
|
||||
local color = 4
|
||||
local color = 1
|
||||
-- vertical lines
|
||||
local t = t()+10
|
||||
for i=startx-1,127,11 do
|
||||
|
@ -28,16 +28,4 @@ function draw_animated_bg(startx)
|
|||
i,
|
||||
color)
|
||||
end
|
||||
end
|
||||
|
||||
local players = {
|
||||
{name="alice", hp=5},
|
||||
{name="anemone", hp=10},
|
||||
}
|
||||
local current_player = players[2]
|
||||
|
||||
for player in all(players) do
|
||||
printh("Hello, my name is "..player.name.."and my hp is"..player.hp)
|
||||
end
|
||||
|
||||
printh("The active player is "..current_player.name)
|
||||
end
|
16
board.lua
16
board.lua
|
@ -2,7 +2,7 @@ local Board = {}
|
|||
function Board.new()
|
||||
local debug = false
|
||||
|
||||
local width = 6
|
||||
local width = 10
|
||||
local tile_width = 10
|
||||
local padding = 1
|
||||
local tiles = {}
|
||||
|
@ -401,13 +401,6 @@ function Board.new()
|
|||
return locked[idx]
|
||||
end,
|
||||
|
||||
draw_bg = function(self)
|
||||
fillp()
|
||||
for k,v in ipairs(tiles) do
|
||||
self:draw_bg_tile(k)
|
||||
end
|
||||
end,
|
||||
|
||||
draw_bg_tile = function(self, k)
|
||||
local w = tile_width
|
||||
local x,y = self:draw_coords(k)
|
||||
|
@ -416,7 +409,6 @@ function Board.new()
|
|||
end,
|
||||
|
||||
draw = function(self)
|
||||
self:draw_bg()
|
||||
local w = tile_width
|
||||
for k,v in ipairs(tiles) do
|
||||
self:draw_tile(k)
|
||||
|
@ -428,14 +420,14 @@ function Board.new()
|
|||
local v = tiles[idx]
|
||||
if v > 0 then
|
||||
local x,y = self:draw_coords(idx)
|
||||
local color = v == BLUE and 8 or 14
|
||||
local color = v == BLUE and 12 or 8
|
||||
if color == 1 then fillp(▒) else fillp(█) end
|
||||
if self:is_locked(idx) then
|
||||
rectfill2(x, y, w, w, color)
|
||||
line(x, y+w-1, x+w-1, y+w-1, color-1)
|
||||
line(x+w-1, y, x+w-1, y+w-1, color-1)
|
||||
else
|
||||
roundedrect(x, y, w, w, color)
|
||||
line(x+1, y+w-1, x+w-2, y+w-1, color+1)
|
||||
line(x+w-1, y+1, x+w-1, y+w-2, color+1)
|
||||
end
|
||||
else
|
||||
fillp(█)
|
||||
|
|
4
main.lua
4
main.lua
|
@ -104,8 +104,8 @@ end
|
|||
local create = true
|
||||
|
||||
function _init()
|
||||
pal({[0]=0,128,132,7,136,8,14,137,9,10,131,3,11,1,140,12},1)
|
||||
poke(0x5f2e,1) --to keep colors
|
||||
-- pal({[0]=0,128,132,7,136,8,14,137,9,10,131,3,11,1,140,12},1)
|
||||
-- poke(0x5f2e,1) --to keep colors
|
||||
|
||||
printh(" ")
|
||||
printh("*************")
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue
Block a user