-- title: The Right Coin -- author: Fabien Freling, Pascal Batty -- desc: Ludum Dare 44 -- script: lua t=0 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() update(currentState) draw(currentState) t=t+1 end -- -- 064:03aaaa3003aaaa3003aa3a3003aaaa3003aaaa3003aaaa3003a3aa3003aaaa30 -- 065:03aaaa3003aa3a3303aaaaaa03aaaaaa03aaaa3a033aaaaa0033333300000000 -- -- -- 000:00000000ffffffff00000000ffffffff -- 001:0123456789abcdeffedcba9876543210 -- 002:0123456789abcdef0123456789abcdef -- -- -- 000:000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000304000000000 -- -- -- 000:140c1c44243430346d4e4a4e854c30346524d04648757161597dced27d2c8595a16daa2cd2aa996dc2cadad45edeeed6 --