add life preview before buying
This commit is contained in:
parent
1a92ebe2aa
commit
1790929b89
|
@ -248,42 +248,10 @@ end
|
|||
function drawGame()
|
||||
map(0,0,30,17)
|
||||
p:draw()
|
||||
|
||||
for i,v in pairs(coins) do
|
||||
v:draw()
|
||||
end
|
||||
|
||||
-- Life
|
||||
spr(83,0,0)
|
||||
local color=11 -- green
|
||||
if life < 25 then
|
||||
color=6 -- red
|
||||
elseif life < 50 then
|
||||
color=9 -- orange
|
||||
end
|
||||
-- from x=11 to 106
|
||||
local lifeLimit=(106-11)*life/100+11
|
||||
for i=lifeLimit,106 do
|
||||
pix(i,1,0)
|
||||
pix(i,2,0)
|
||||
pix(i,3,0)
|
||||
pix(i,4,0)
|
||||
pix(i,5,0)
|
||||
pix(i,6,0)
|
||||
end
|
||||
for i=11,lifeLimit do
|
||||
pix(i,1,color)
|
||||
pix(i,2,color)
|
||||
pix(i,3,color)
|
||||
pix(i,4,color)
|
||||
pix(i,5,color)
|
||||
pix(i,6,color)
|
||||
end
|
||||
spr(85,10,0,0)
|
||||
for i=18,100,8 do
|
||||
spr(86,i,0,0)
|
||||
end
|
||||
spr(85,100,0,0,1,1)
|
||||
drawLife(0,0,0)
|
||||
|
||||
-- Coins / market
|
||||
local coinsOff=110
|
||||
|
@ -299,6 +267,51 @@ function drawGame()
|
|||
print(valueYellow,222,2,14)
|
||||
end
|
||||
|
||||
function drawLife(x,y,next)
|
||||
spr(83,x,y,0)
|
||||
local color=11 -- green
|
||||
if life < 25 then
|
||||
color=6 -- red
|
||||
elseif life < 50 then
|
||||
color=9 -- orange
|
||||
end
|
||||
local xmin=11
|
||||
local xmax=107
|
||||
local lifeLimit=(xmax-xmin)*life/100+xmin
|
||||
for i=lifeLimit,xmax do
|
||||
pix(x+i,y+1,0)
|
||||
pix(x+i,y+2,0)
|
||||
pix(x+i,y+3,0)
|
||||
pix(x+i,y+4,0)
|
||||
pix(x+i,y+5,0)
|
||||
pix(x+i,y+6,0)
|
||||
end
|
||||
if t%60 > 30 then
|
||||
local potential=math.min(xmax,lifeLimit+next)
|
||||
for i=lifeLimit,potential do
|
||||
pix(x+i,y+1,8)
|
||||
pix(x+i,y+2,8)
|
||||
pix(x+i,y+3,8)
|
||||
pix(x+i,y+4,8)
|
||||
pix(x+i,y+5,8)
|
||||
pix(x+i,y+6,8)
|
||||
end
|
||||
end
|
||||
for i=xmin,lifeLimit do
|
||||
pix(x+i,y+1,color)
|
||||
pix(x+i,y+2,color)
|
||||
pix(x+i,y+3,color)
|
||||
pix(x+i,y+4,color)
|
||||
pix(x+i,y+5,color)
|
||||
pix(x+i,y+6,color)
|
||||
end
|
||||
spr(85,x+10,y,0)
|
||||
for i=18,100,8 do
|
||||
spr(86,x+i,y,0)
|
||||
end
|
||||
spr(85,x+100,y,0,1,1)
|
||||
end
|
||||
|
||||
function drawMarket()
|
||||
-- Background
|
||||
xOff=2
|
||||
|
@ -347,22 +360,31 @@ function drawMarket()
|
|||
print("Done",20*s,12*s+2)
|
||||
|
||||
-- Selection
|
||||
local next=0
|
||||
if marketSelection == MarketOptions.blue then
|
||||
spr(97,19*s,4*s+1,0)
|
||||
spr(97,22*s,4*s+1,0,1,1)
|
||||
next=math.floor(coinBlue*valueBlue)
|
||||
elseif marketSelection == MarketOptions.red then
|
||||
spr(97,19*s,6*s+1,0)
|
||||
spr(97,22*s,6*s+1,0,1,1)
|
||||
next=math.floor(coinRed*valueRed)
|
||||
elseif marketSelection == MarketOptions.yellow then
|
||||
spr(97,19*s,8*s+1,0)
|
||||
spr(97,22*s,8*s+1,0,1,1)
|
||||
next=math.floor(coinYellow*valueYellow)
|
||||
elseif marketSelection == MarketOptions.all then
|
||||
spr(97,18*s,10*s+1,0)
|
||||
spr(97,24*s,10*s+1,0,1,1)
|
||||
next=math.floor(coinBlue*valueBlue)
|
||||
next=next+math.floor(coinRed*valueRed)
|
||||
next=next+math.floor(coinYellow*valueYellow)
|
||||
elseif marketSelection == MarketOptions.done then
|
||||
spr(97,19*s,12*s+1,0)
|
||||
spr(97,23*s,12*s+1,0,1,1)
|
||||
end
|
||||
|
||||
drawLife(4*s,12*s,next)
|
||||
end
|
||||
|
||||
function draw(state)
|
||||
|
|
Loading…
Reference in a new issue