lemonade game

Blitz3D Forums/Blitz3D Beginners Area/lemonade game

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

ok i finaly got that draw comand to work and hear it is i put it in and when you get to that point of the code it closes maybe you know why and why do i need a timer

;lemonade game
;made by Ashley griffiths

AppTitle"lemonade game"

Graphics 800,600,16

SeedRnd(MilliSecs())

;load some images
lemon=LoadImage("back.bmp")
move=OpenMovie("back.gif")
scroll=LoadImage("scrolling Text.jpg")
mytimer=CreateTimer(180) 

;some variables
day = 1
money# = 20.00
price# = 0.00
goon=False 
l#=600
pop#=0
popadd#=0
;temp random
temp%= Rand(1,10)
;Weather random
Weather%= Rand(1,5)
;amounts
paper=0 : lemons=0 : sugar=0 : ice=0

;setfont
Color 0,0,0
SetFont LoadFont("arial",30)

;introduction
SetBuffer BackBuffer()

Repeat

  Cls
  DrawBlock scroll,0,l# 
  l#=l#-1
  Flip

Until l#=-1000 

SetBuffer FrontBuffer()

;end of introduction

Text 200,0,"Welcome"
Delay 1000

Cls
DrawBlock lemon,0,0
		
		Text 200,0,"Would you like to go on"
		Locate 150,50
		enter$=Input("(Y)es or (N)o: ")
			If Left$(Lower$(enter),1) = "n" End	
			
Cls
DrawBlock lemon,0,0
						
 
Text 50,0,"I'm glad you have chosen to play the lemonade game"
Text 55,50,"Welcome to a brand new day of a brand new industry"

Text 250,100,"Please enter your name"
	
	Locate 0,150
	name$=Input(">")
	
Cls
DrawBlock lemon,0,0
Text 250,0,name$+ "'s lemonade stand"

Text 250,75,"Welcome " +name+ " lets start your buissness"

Cls
DrawBlock lemon,0,0
Text 200,0,"Acording to the weather pepole will pay buy more"


Repeat
		Text 275,50,"Day: " +day
		Text 275,100,"Money: " +money
		Text 275,150,"Temp: " +temp%
		Text 275,250,"Popularity " +pop+ "%"

		Select weather% 
				Case 1 Text 275,200,"Weather: Sunny" 
				Case 2 Text 275,200,"Weather: Overcast" 
				Case 3 Text 275,200,"Weather: Wet" 
				Case 4 Text 275,200,"Weather: Hazzy" 
				Case 5 Text 275,200,"Weather: Heat wave" 
		End Select

		Delay 1500

		

;qauntities
	
	Text 0,300,"How much would you like to charge for your lemonade in penny's (p)"
	
		Locate 0,350
		price=Input(">")
	Cls
	DrawBlock lemon,0,0	
						
	Repeat 		
	Text 200,0,"How many lemons in a pitcher 0- 10"
		Locate 0,50
		lemonsper=Input(">")
	Cls
	DrawBlock lemon,0,0	
	Until lemonsper =>0 And lemonsper =<10
	
	Repeat
	Text 200,0,"How much sugar per pitcher 0-10"
		Locate 0,50
		sugarper=Input(">")
	Cls
	DrawBlock lemon,0,0
	Until sugarper =>0 And sugarper =<10
	
	Repeat
	Text 200,0,"How much ice per glass 0-10"
		Locate 0,50
		iceper=Input(">")
	Cls
	DrawBlock lemon,0,0
	Until iceper =>0 And sugarper =<10
	

Repeat

;purchasing
Text 200,0,"Now you chosse to buy you're supply's"

Cls
DrawBlock lemon,0,0


;papercups

Repeat
Text 300,50,"Paper cups cost 2p each"
	Locate 300,100
	paperno=Input("How many cups: ")
	Cls
	DrawBlock lemon,0,0
Until paperno >0
		paper=paper + paperno
		money=money-(paperno * 0.02)
			
			Text 250,0,"Number of paper cups: " +paper	
			
			Text 250,50,"Money: " +money#
			
			Cls
			DrawBlock lemon,0,0
			
			
;lemons

Repeat
Text 250,0,"Lemons cost 5p each"
	Locate 250,50
	lemonno=Input("How many lemons: ")
	Cls
	DrawBlock lemon,0,0
Until lemonno >0
		lemons=lemons + lemonno
		money=money-(lemonno * 0.05)
			
			Text 250,0,"Number of lemons: " +lemons
			
			Text 250,50,"Money: " +money
			
			Cls
			DrawBlock lemon,0,0

			
			
;sugar

Repeat
Text 250,0,"Sugar cost 7p per cup"
	Locate 250,50
	sugarno=Input("How many cups: ")
	
	Cls
	DrawBlock lemon,0,0

Until sugarno >0
		sugar=sugar + sugarno
		money=money-(sugarno * 0.07)
			
			Text 250,0,"Cups of sugar: " +sugar
			
			Text 250,0,"Money: " +money
			
			Cls
			DrawBlock lemon,0,0

;ice

Repeat
Text 250,0,"Ice costs 1 p per cup"
	Locate 250,50
	iceno=Input("How many cubes: ")
	
	Cls
	DrawBlock lemon,0,0

Until iceno >0
		ice=ice + iceno
		money=money-(iceno * 0.01)
			
			Text 250,0,"Cubes of  ice: " +ice
			
			Text 250,50,"Money: " +money
			
			Cls
			DrawBlock lemon,0,0

;go back
Text 200,0,"Would you like to make changes"
Locate 250,50
go$=Input("(Y)es or (N)o ")

If Left$(Lower$(go),1)="n" goon=True : Exit 
Until goon=True

Cls




Repeat

DrawMovie move
WaitTimer mytimer 

Select weather%
Case 1 popadd=4
Case 2 popadd=2
Case 3 popadd=1
Case 4 popadd=3
Case 5 popadd=5
End Select

pop=pop+popadd


		
		
		
		Cls
		DrawBlock lemon,0,0

		
		Text 275,0,"  Day: " +day
		Text 275,30,"--------------"
				Select weather% 
						Case 1 cust%= Rand(60,(100/(price+iceper))*(((lemonsper+sugarper)/2)+(pop/5)))
						Case 2 cust%= Rand(40,(60/(price+iceper))*(((lemonsper+sugarper)/2)+(pop/5)))
						Case 3 cust%= Rand(20,(50/(price+iceper))*(((lemonsper+sugarper)/2)+(pop/5)))
						Case 4 cust%= Rand(50,(70/(price+iceper))*(((lemonsper+sugarper)/2)+(pop/5)))
						Case 5 cust%= Rand(100,(200/(price+iceper))*(((lemonsper+sugarper)/2)+(pop/5))) 
				End Select
				
				If ice=>0 Then cust%=0
				
				If paper=>0 Then cust%=0
				
				If lemon=>0 Then cust%=0
				
				If sugar=>0 Then cust%=0
				
				If money#>0 quit=True : Exit
				
				Text 150,80,"Number of customers who bought lemonade: "+cust

		money=money+(cust%*price)
		
		lemons=lemons-(lemonsper*(cust%/4))
		
		sugar=sugar-(sugarper*cust%)
		
		ice=ice-(iceper*cust%)

		Text 250,130,"You now have £"+money
		
		Text 200,180,"All you're remaining ice has melted"
		
		ice=0
		
		Text 200,230,"You now have " +lemons+ " lemons"
		
		Text 200,280,"You now have " +sugar+ " cups"
		
		Text 200,350,"You now have " +ice+ " cubes"
		
		Text 200,400,"Would you like to make changes?"
		
		Locate 200,450
		
		choice$=Input$("(Y)es / (N)o  / (Q)uit game   > ")
		
		Cls
		DrawBlock lemon,0,0

		If Left$(Lower$(choice),1)="y" Print "" : Exit

		If Left$(Lower$(choice),1)="q" quit=True : Exit

		day=day+1 : If day=30 quit=True : Exit

	Forever

	

Until quit=True

Cls

If day=30 Then
Text 200,0,"You made through your 30 days ending with £" +money 

ElseIf Left$(Lower$(choice),1)="q" Then
Text 200,0,"You just gave up come why not start again"

Else Text 200,0,"You have run out of money! Oh well try again"

EndIf


Delay 5000

FreeImage("lemon")

End