Tweaked rendering
This commit is contained in:
parent
529703b7e4
commit
6f54ba9477
14
board.lua
14
board.lua
|
@ -4,7 +4,6 @@ function Board.new()
|
|||
|
||||
local width = 10
|
||||
local tile_width = 10
|
||||
local margin = 4
|
||||
local padding = 1
|
||||
local tiles = {}
|
||||
local locked = {} -- list of indexes
|
||||
|
@ -46,9 +45,10 @@ function Board.new()
|
|||
end,
|
||||
|
||||
draw_coords = function(self, x, y)
|
||||
local margin = (128 - (tile_width + padding) * width) / 2- padding
|
||||
if not y then x, y = self:idx_xy(x) end
|
||||
return margin + (x-1)*tile_width + (x-1)*(padding+1),
|
||||
margin + (y-1)*tile_width + (y-1)*(padding+1)
|
||||
return margin + (x-1)*tile_width + (x-1)*padding,
|
||||
margin + (y-1)*tile_width + (y-1)*padding
|
||||
end,
|
||||
|
||||
get_size = function(self)
|
||||
|
@ -425,10 +425,12 @@ function Board.new()
|
|||
local x,y = self:draw_coords(idx)
|
||||
local color = v == BLUE and 12 or 8
|
||||
if color == 1 then fillp(▒) else fillp(█) end
|
||||
rectfill2(x, y, w, w, color)
|
||||
if self:is_locked(idx) then
|
||||
line(x, y+w, x+w, y+w, v == BLUE and 6 or 14)
|
||||
line(x+w, y, x+w, y+w, v == BLUE and 6 or 14)
|
||||
rectfill2(x, y, w, w, color)
|
||||
line(x, y+w-1, x+w-1, y+w-1, v == BLUE and 13 or 2)
|
||||
line(x+w-1, y, x+w-1, y+w-1, v == BLUE and 13 or 2)
|
||||
else
|
||||
roundedrect(x, y, w, w, color)
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
|
8
main.lua
8
main.lua
|
@ -59,7 +59,13 @@ function slice(tbl, first, last, step)
|
|||
end
|
||||
|
||||
function rectfill2(x, y, w, h, col)
|
||||
rectfill(x, y, x+w, y+h, col)
|
||||
rectfill(x, y, x+w-1, y+h-1, col)
|
||||
end
|
||||
|
||||
function roundedrect(x, y, w, h, col)
|
||||
rectfill2(x,y,w,h,0)
|
||||
rectfill2(x+1, y, w-2, h, col)
|
||||
rectfill2(x, y+1, w, h-2, col)
|
||||
end
|
||||
|
||||
function rect2(x, y, w, h, col)
|
||||
|
|
|
@ -9,7 +9,7 @@ function state_menu()
|
|||
|
||||
local buttons = {
|
||||
make_button({x=10, y=10, w=30, text="play", data={i=1},
|
||||
on_click=function() set_state(states.game) end,
|
||||
on_click=function() set_state(states.loading) end,
|
||||
on_hover=function(btn) btn.color = 7 selected = 1 end,
|
||||
on_draw=on_btn_draw}),
|
||||
make_button({x=10, y=20, w=30, text="rules", data={i=2},
|
||||
|
@ -42,6 +42,7 @@ function state_menu()
|
|||
end,
|
||||
|
||||
_draw = function()
|
||||
cls()
|
||||
for k,button in ipairs(buttons) do
|
||||
button:draw(selected == k)
|
||||
end
|
||||
|
|
|
@ -33,6 +33,7 @@ function state_rules()
|
|||
end,
|
||||
|
||||
_draw=function()
|
||||
cls()
|
||||
custom_font()
|
||||
|
||||
print("1) yOU CAN'T HAVE MORE THAN\n TWO (2) CONSECUTIVE TILES\n OF THE SAME COLOR", 2,2, 7)
|
||||
|
|
Loading…
Reference in New Issue
Block a user