master
Fabien Freling 2019-04-28 10:36:01 +02:00
parent 045f985cd2
commit 0419311f63
1 changed files with 52 additions and 6 deletions

View File

@ -12,6 +12,7 @@ mh=h/s
GameState = { start=0, game=1, gameover=2, market=3 }
currentState = GameState.game
life=100
coinBlue=0
coinRed=0
coinYellow=0
@ -132,6 +133,38 @@ function drawGame()
p:direct()
p:update()
p:draw()
-- 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)
end
function drawMarket()
@ -181,12 +214,7 @@ function update(state)
currentState = GameState.game
end
elseif currentState == GameState.game then
if btnp(4) then -- A (Z key)
currentState = GameState.market
end
if btnp(5) then -- B (X key)
currentState = GameState.gameover
end
updateGame()
elseif currentState == GameState.market then
if btnp(4) then -- A (Z key)
currentState = GameState.game
@ -198,6 +226,22 @@ function update(state)
end
end
function updateGame()
if life == 0 then
currentState = GameState.gameover
return
end
if t%10 ==0 then
life=life-1
end
if btnp(4) then -- A (Z key)
currentState = GameState.market
end
if btnp(5) then -- B (X key)
currentState = GameState.gameover
end
end
p=Player
function TIC()
update(currentState)
@ -218,6 +262,8 @@ end
-- 082:00eeee000ee99ee00e9ee9e00e9ee9e00e9ee9e00e9ee9e00ee99ee000eeee00
-- 083:0660066066666666666666666666666666666666066666600066660000066000
-- 084:000008880000880000880000008eeeee08ee00008ee666608666006680000000
-- 085:0333333333000000300000003000000030000000300000003300000003333333
-- 086:3333333300000000000000000000000000000000000000000000000033333333
-- </TILES>
-- <SPRITES>