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
|
startx = startx or 0
|
||||||
fillp(0b0101101001011010)
|
fillp(0b0101101001011010)
|
||||||
|
|
||||||
local color = 4
|
local color = 1
|
||||||
-- vertical lines
|
-- vertical lines
|
||||||
local t = t()+10
|
local t = t()+10
|
||||||
for i=startx-1,127,11 do
|
for i=startx-1,127,11 do
|
||||||
|
@ -28,16 +28,4 @@ function draw_animated_bg(startx)
|
||||||
i,
|
i,
|
||||||
color)
|
color)
|
||||||
end
|
end
|
||||||
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)
|
|
16
board.lua
16
board.lua
|
@ -2,7 +2,7 @@ local Board = {}
|
||||||
function Board.new()
|
function Board.new()
|
||||||
local debug = false
|
local debug = false
|
||||||
|
|
||||||
local width = 6
|
local width = 10
|
||||||
local tile_width = 10
|
local tile_width = 10
|
||||||
local padding = 1
|
local padding = 1
|
||||||
local tiles = {}
|
local tiles = {}
|
||||||
|
@ -401,13 +401,6 @@ function Board.new()
|
||||||
return locked[idx]
|
return locked[idx]
|
||||||
end,
|
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)
|
draw_bg_tile = function(self, k)
|
||||||
local w = tile_width
|
local w = tile_width
|
||||||
local x,y = self:draw_coords(k)
|
local x,y = self:draw_coords(k)
|
||||||
|
@ -416,7 +409,6 @@ function Board.new()
|
||||||
end,
|
end,
|
||||||
|
|
||||||
draw = function(self)
|
draw = function(self)
|
||||||
self:draw_bg()
|
|
||||||
local w = tile_width
|
local w = tile_width
|
||||||
for k,v in ipairs(tiles) do
|
for k,v in ipairs(tiles) do
|
||||||
self:draw_tile(k)
|
self:draw_tile(k)
|
||||||
|
@ -428,14 +420,14 @@ function Board.new()
|
||||||
local v = tiles[idx]
|
local v = tiles[idx]
|
||||||
if v > 0 then
|
if v > 0 then
|
||||||
local x,y = self:draw_coords(idx)
|
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 color == 1 then fillp(▒) else fillp(█) end
|
||||||
if self:is_locked(idx) then
|
if self:is_locked(idx) then
|
||||||
rectfill2(x, y, w, w, color)
|
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
|
else
|
||||||
roundedrect(x, y, w, w, color)
|
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
|
end
|
||||||
else
|
else
|
||||||
fillp(█)
|
fillp(█)
|
||||||
|
|
4
main.lua
4
main.lua
|
@ -104,8 +104,8 @@ end
|
||||||
local create = true
|
local create = true
|
||||||
|
|
||||||
function _init()
|
function _init()
|
||||||
pal({[0]=0,128,132,7,136,8,14,137,9,10,131,3,11,1,140,12},1)
|
-- 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
|
-- poke(0x5f2e,1) --to keep colors
|
||||||
|
|
||||||
printh(" ")
|
printh(" ")
|
||||||
printh("*************")
|
printh("*************")
|
||||||
|
|
|
@ -50,16 +50,16 @@ function state_game()
|
||||||
palt(0,false)
|
palt(0,false)
|
||||||
palt(5,true)
|
palt(5,true)
|
||||||
local x,y
|
local x,y
|
||||||
if clue.type == "row" then
|
if clue.type == "row" then
|
||||||
x,y = board:draw_coords((clue.pos-1) * board:get_size()+1)
|
x,y = board:draw_coords((clue.pos-1) * board:get_size()+1)
|
||||||
x=0
|
x=-32
|
||||||
spr(19, x+clue.t%144, y+1+sin(t())*2)
|
spr(19, x+clue.t%144, y+1+sin(t())*2)
|
||||||
else -- col
|
else -- col
|
||||||
x,y = board:draw_coords(clue.pos)
|
x,y = board:draw_coords(clue.pos)
|
||||||
spr(19, x+2+sin(t())*2, y+clue.t%144)
|
y=-32
|
||||||
y=0
|
spr(19, x+2+sin(t())*2, y+clue.t%144)
|
||||||
end
|
end
|
||||||
pset(x, y, 5)
|
pset(x, y, 5)
|
||||||
clue.t += 1
|
clue.t += 1
|
||||||
end
|
end
|
||||||
palt()
|
palt()
|
||||||
|
|
|
@ -24,7 +24,11 @@ function state_loading()
|
||||||
local messages_str = ""
|
local messages_str = ""
|
||||||
local messages_x = 128
|
local messages_x = 128
|
||||||
local loaded = false
|
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 create_board = cocreate(function()
|
||||||
local start = time()
|
local start = time()
|
||||||
|
@ -38,19 +42,23 @@ function state_loading()
|
||||||
|
|
||||||
-- Remove tiles that can be removed
|
-- Remove tiles that can be removed
|
||||||
local previous = {board:get_tiles_copy()} -- initial state
|
local previous = {board:get_tiles_copy()} -- initial state
|
||||||
local size = board:get_size()*board:get_size()
|
done = {}
|
||||||
while true do
|
while true do
|
||||||
|
|
||||||
board:set_tiles(previous[#previous])
|
board:set_tiles(previous[#previous])
|
||||||
-- remove a random tile
|
-- remove a random tile
|
||||||
repeat
|
repeat
|
||||||
removing_tile += 1
|
removing_tile += 1
|
||||||
|
if removing_tile > size then
|
||||||
|
removing_tile = 1
|
||||||
|
end
|
||||||
until removing_tile == size or board:get_tiles_copy()[removing_tile] ~= 0
|
until removing_tile == size or board:get_tiles_copy()[removing_tile] ~= 0
|
||||||
if removing_tile == size then
|
if removing_tile == og_rt then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
board:fill(removing_tile, 0)
|
board:fill(removing_tile, 0)
|
||||||
|
add(done, removing_tile)
|
||||||
add(previous, board:get_tiles_copy())
|
add(previous, board:get_tiles_copy())
|
||||||
|
|
||||||
-- try to solve the board
|
-- try to solve the board
|
||||||
|
@ -86,7 +94,7 @@ function state_loading()
|
||||||
local w = board:get_size()
|
local w = board:get_size()
|
||||||
local tiles = board:get_tiles_copy()
|
local tiles = board:get_tiles_copy()
|
||||||
for k,v in ipairs(tiles) do
|
for k,v in ipairs(tiles) do
|
||||||
if k < removing_tile then
|
if v==0 or contains(done, k) then
|
||||||
board:draw_tile(k)
|
board:draw_tile(k)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -129,11 +137,11 @@ function state_loading()
|
||||||
local l = print(message, 0, -100)
|
local l = print(message, 0, -100)
|
||||||
local y = 118+(removing_tile/s)*100/8
|
local y = 118+(removing_tile/s)*100/8
|
||||||
local ci = removing_tile\20+1
|
local ci = removing_tile\20+1
|
||||||
if not loaded then
|
-- if not loaded then
|
||||||
rectfill2(0,y-2,127,10,0)
|
-- rectfill2(0,y-2,127,10,0)
|
||||||
print(messages_str, messages_x, y, 3, 0)
|
-- print(messages_str, messages_x, y, 3, 0)
|
||||||
-- print(spinner[t()\.25%4+1], 120, 120)
|
-- -- print(spinner[t()\.25%4+1], 120, 120)
|
||||||
end
|
-- end
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user