Add market border

master
Fabien Freling 2019-04-27 15:32:42 +02:00
parent bb4612ca83
commit c52143c0b2
1 changed files with 77 additions and 19 deletions

View File

@ -4,31 +4,89 @@
-- script: lua
t=0
x=96
y=24
w=240
h=136
GameState = { start=0, game=1, gameover=2, market=3 }
currentState = GameState.start
function drawStart()
cls(13)
print("The Right Coin",80,36)
print("Press Z to start",75,96)
end
function drawGameOver()
cls(1)
print("You died",80,36,6)
print("Press Z",75,96,15)
end
function drawGame()
cls(0)
end
function drawMarket()
s=8 -- sprite size
xOff=s*2
yOff=s*2
for i=xOff+s, w-(2*s)-xOff, s do
spr(64,i,yOff,0,1,0,1)
spr(64,i,h-s-yOff,0,1,0,1)
end
for j=yOff+s, h-(2*s)-xOff, s do
spr(64,xOff,j,0,1,0,0)
spr(64,w-s-xOff,j,0,1,0,0)
end
spr(65,xOff,yOff,0,1,0,1)
spr(65,w-8-xOff,yOff,0,1,0,2)
spr(65,w-8-xOff,h-8-yOff,0,1,0,3)
spr(65,xOff,h-8-yOff,0,1,0,0)
end
function draw(state)
if currentState == GameState.start then
drawStart()
elseif currentState == GameState.game then
drawGame()
elseif currentState == GameState.market then
drawMarket()
elseif currentState == GameState.gameover then
drawGameOver()
end
end
function update(state)
if currentState == GameState.start then
if btnp(4) then -- A (Z key)
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
elseif currentState == GameState.market then
if btnp(4) then -- A (Z key)
currentState = GameState.game
end
elseif currentState == GameState.gameover then
if btnp(4) then -- A (Z key)
currentState = GameState.start
end
end
end
function TIC()
if btn(0) then y=y-1 end
if btn(1) then y=y+1 end
if btn(2) then x=x-1 end
if btn(3) then x=x+1 end
cls(13)
spr(1+t%60//30*2,x,y,14,3,0,0,2,2)
print("HELLO WORLD!",84,84)
update(currentState)
draw(currentState)
t=t+1
end
-- <TILES>
-- 001:efffffffff222222f8888888f8222222f8fffffff8ff0ffff8ff0ffff8ff0fff
-- 002:fffffeee2222ffee88880fee22280feefff80fff0ff80f0f0ff80f0f0ff80f0f
-- 003:efffffffff222222f8888888f8222222f8fffffff8fffffff8ff0ffff8ff0fff
-- 004:fffffeee2222ffee88880fee22280feefff80ffffff80f0f0ff80f0f0ff80f0f
-- 017:f8fffffff8888888f888f888f8888ffff8888888f2222222ff000fffefffffef
-- 018:fff800ff88880ffef8880fee88880fee88880fee2222ffee000ffeeeffffeeee
-- 019:f8fffffff8888888f888f888f8888ffff8888888f2222222ff000fffefffffef
-- 020:fff800ff88880ffef8880fee88880fee88880fee2222ffee000ffeeeffffeeee
-- 064:03aaaa3003aaaa3003aa3a3003aaaa3003aaaa3003aaaa3003a3aa3003aaaa30
-- 065:03aaaa3003aa3a3303aaaaaa03aaaaaa03aaaa3a033aaaaa0033333300000000
-- </TILES>
-- <WAVES>