add buy options
This commit is contained in:
		
							parent
							
								
									31c887c1e8
								
							
						
					
					
						commit
						2f63914951
					
				
					 1 changed files with 64 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -19,6 +19,8 @@ coinRed=0
 | 
			
		|||
valueRed=1.0
 | 
			
		||||
coinYellow=0
 | 
			
		||||
valueYellow=1.0
 | 
			
		||||
MarketOptions = { blue=0, red=1, yellow=2, all=3, done=4 }
 | 
			
		||||
marketSelection = MarketOptions.blue
 | 
			
		||||
 | 
			
		||||
solids={}
 | 
			
		||||
do 
 | 
			
		||||
| 
						 | 
				
			
			@ -179,11 +181,12 @@ function drawGame()
 | 
			
		|||
	print("x"..coinYellow,coinsOff+50+s,2)
 | 
			
		||||
	-- spr(84,190,0)
 | 
			
		||||
	print(valueBlue,190,2,8)
 | 
			
		||||
	print(valueRed,206,2,6)
 | 
			
		||||
	print(valueRed,206,2,12)
 | 
			
		||||
	print(valueYellow,222,2,14)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function drawMarket()
 | 
			
		||||
	-- Background
 | 
			
		||||
	xOff=2
 | 
			
		||||
	yOff=2
 | 
			
		||||
	for i=xOff+1, mw-2-xOff do
 | 
			
		||||
| 
						 | 
				
			
			@ -204,12 +207,48 @@ function drawMarket()
 | 
			
		|||
		end
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	-- Coins
 | 
			
		||||
	spr(80,4*s,4*s,0)
 | 
			
		||||
	print("x "..coinBlue,5*s+4,4*s+2)
 | 
			
		||||
	print("x"..coinBlue,5*s+4,4*s+2)
 | 
			
		||||
	print("x"..valueBlue,8*s+4,4*s+2,8)
 | 
			
		||||
	print("= "..math.floor(coinBlue*valueBlue),12*s,4*s+2)
 | 
			
		||||
	spr(83,15*s,4*s,0)
 | 
			
		||||
	print("Buy",20*s,4*s+2)
 | 
			
		||||
 | 
			
		||||
	spr(81,4*s,6*s,0)
 | 
			
		||||
	print("x "..coinRed,5*s+4,6*s+2)
 | 
			
		||||
	print("x"..coinRed,5*s+4,6*s+2)
 | 
			
		||||
	print("x"..valueRed,8*s+4,6*s+2,12)
 | 
			
		||||
	print("= "..math.floor(coinBlue*valueBlue),12*s,6*s+2)
 | 
			
		||||
	spr(83,15*s,6*s,0)
 | 
			
		||||
	print("Buy",20*s,6*s+2)
 | 
			
		||||
 | 
			
		||||
	spr(82,4*s,8*s,0)
 | 
			
		||||
	print("x "..coinYellow,5*s+4,8*s+2)
 | 
			
		||||
	print("x"..coinYellow,5*s+4,8*s+2)
 | 
			
		||||
	print("x"..valueYellow,8*s+4,8*s+2,14)
 | 
			
		||||
	print("= "..math.floor(coinBlue*valueBlue),12*s,8*s+2)
 | 
			
		||||
	spr(83,15*s,8*s,0)
 | 
			
		||||
	print("Buy",20*s,8*s+2)
 | 
			
		||||
 | 
			
		||||
	print("Buy all",19*s,10*s+2)
 | 
			
		||||
	print("Done",20*s,12*s+2)
 | 
			
		||||
 | 
			
		||||
	-- Selection
 | 
			
		||||
	if marketSelection == MarketOptions.blue then
 | 
			
		||||
		spr(97,19*s,4*s+1,0)
 | 
			
		||||
		spr(97,22*s,4*s+1,0,1,1)
 | 
			
		||||
	elseif marketSelection == MarketOptions.red then
 | 
			
		||||
		spr(97,19*s,6*s+1,0)
 | 
			
		||||
		spr(97,22*s,6*s+1,0,1,1)
 | 
			
		||||
	elseif marketSelection == MarketOptions.yellow then
 | 
			
		||||
		spr(97,19*s,8*s+1,0)
 | 
			
		||||
		spr(97,22*s,8*s+1,0,1,1)
 | 
			
		||||
	elseif marketSelection == MarketOptions.all then
 | 
			
		||||
		spr(97,18*s,10*s+1,0)
 | 
			
		||||
		spr(97,24*s,10*s+1,0,1,1)
 | 
			
		||||
	elseif marketSelection == MarketOptions.done then
 | 
			
		||||
		spr(97,19*s,12*s+1,0)
 | 
			
		||||
		spr(97,23*s,12*s+1,0,1,1)
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function draw(state)
 | 
			
		||||
| 
						 | 
				
			
			@ -233,9 +272,7 @@ function update(state)
 | 
			
		|||
	elseif currentState == GameState.game then
 | 
			
		||||
		updateGame()
 | 
			
		||||
	elseif currentState == GameState.market then
 | 
			
		||||
		if btnp(4) then -- A (Z key)
 | 
			
		||||
			currentState = GameState.game
 | 
			
		||||
		end
 | 
			
		||||
		updateMarket()
 | 
			
		||||
	elseif currentState == GameState.gameover then
 | 
			
		||||
		if btnp(4) then -- A (Z key)
 | 
			
		||||
			currentState = GameState.start
 | 
			
		||||
| 
						 | 
				
			
			@ -259,6 +296,24 @@ function updateGame()
 | 
			
		|||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function updateMarket()
 | 
			
		||||
	if btnp(0) then -- Up
 | 
			
		||||
		if marketSelection ~= MarketOptions.blue then
 | 
			
		||||
			marketSelection = marketSelection - 1
 | 
			
		||||
		end
 | 
			
		||||
	elseif btnp(1) then -- Down
 | 
			
		||||
		if marketSelection ~= MarketOptions.done then
 | 
			
		||||
			marketSelection = marketSelection + 1
 | 
			
		||||
		end
 | 
			
		||||
	elseif btnp(4) then -- A (Z key)
 | 
			
		||||
		if marketSelection == MarketOptions.done then
 | 
			
		||||
			currentState = GameState.game
 | 
			
		||||
		end
 | 
			
		||||
	elseif btnp(5) then -- B (X key)
 | 
			
		||||
		currentState = GameState.game
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
p=Player
 | 
			
		||||
function TIC()
 | 
			
		||||
	update(currentState)
 | 
			
		||||
| 
						 | 
				
			
			@ -281,6 +336,8 @@ end
 | 
			
		|||
-- 084:000008880000880000880000008eeeee08ee00008ee666608666006680000000
 | 
			
		||||
-- 085:0333333333000000300000003000000030000000300000003300000003333333
 | 
			
		||||
-- 086:3333333300000000000000000000000000000000000000000000000033333333
 | 
			
		||||
-- 096:7773377777733377777333373333333333333333777333377773337777733777
 | 
			
		||||
-- 097:0006660000660000066000000660000006600000066000000066000000066600
 | 
			
		||||
-- </TILES>
 | 
			
		||||
 | 
			
		||||
-- <SPRITES>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue