-- title: The Right Coin -- author: Fabien Freling, Pascal Batty -- desc: Ludum Dare 44 -- script: lua t=0 s=8 -- sprite/cell size w=240 mw=w/s h=136 mh=h/s GameState = { start=0, game=1, gameover=2, market=3 } currentState = GameState.game coinBlue=0 coinRed=0 coinYellow=0 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) spr(84,64,0) end function drawMarket() xOff=2 yOff=2 for i=xOff+1, mw-2-xOff do spr(64,i*s,yOff*s,0,1,0,1) spr(64,i*s,(mh-1-yOff)*s,0,1,2,1) end for j=yOff+1, mh-2-xOff do spr(64,xOff*s,j*s,0,1,0,0) spr(64,(mw-1-xOff)*s,j*s,0,1,1,0) end spr(65,xOff*s,yOff*s,0,1,0,1) spr(65,(mw-1-xOff)*s,yOff*s,0,1,0,2) spr(65,(mw-1-xOff)*s,(mh-1-yOff)*s,0,1,0,3) spr(65,xOff*s,(mh-1-yOff)*s,0,1,0,0) for i=xOff+1, mw-2-xOff do for j=yOff+1, mh-2-xOff do spr(66,i*s,j*s,0,1,0,1) end end spr(80,4*s,4*s,0) print("x "..coinBlue,5*s+4,4*s+2) spr(81,4*s,6*s,0) print("x "..coinRed,5*s+4,6*s+2) spr(82,4*s,8*s,0) print("x "..coinYellow,5*s+4,8*s+2) 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() update(currentState) draw(currentState) t=t+1 end -- -- 064:03aaaa3703aaaa3703aa3a3703aaaa3703aaaa3703aaaa3703a3aa3703aaaa37 -- 065:03aaaa3703aa3a3303aaaaaa03aaaaaa03aaaa3a033aaaaa0033333300000000 -- 066:7777777777777777777777777777777777777777777777777777777777777777 -- 080:0088880008822880082882800828828008288280082882800882288000888800 -- 081:00cccc000cc66cc00c6cc6c00c6cc6c00c6cc6c00c6cc6c00cc66cc000cccc00 -- 082:00eeee000ee99ee00e9ee9e00e9ee9e00e9ee9e00e9ee9e00ee99ee000eeee00 -- 083:0660066066666666666666666666666666666666066666600066660000066000 -- 084:000008880000880000880000008eeeee08ee00008ee666608666006680000000 -- -- -- 000:00000000ffffffff00000000ffffffff -- 001:0123456789abcdeffedcba9876543210 -- 002:0123456789abcdef0123456789abcdef -- -- -- 000:000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000304000000000 -- -- -- 000:140c1c44243430346d4e4a4e854c30346524d04648757161597dced27d2c8595a16daa2cd2aa996dc2cadad45edeeed6 --