WAZ MADE A GAME!

Blitz3D Forums/Blitz3D Beginners Area/WAZ MADE A 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.

Yes, SSS is right. You don't want to halt the program execution just to wait for the user to press a specific key.

I wrote up a version of the code that implements all the things I consider hallmarks of professionalyl written code. Hopefully this will give you a jump start on writing clean code and more complex programs. :-)

AppTitle "Dice Roll"

SeedRnd MilliSecs()  

NewRoll = True

Repeat

	If NewRoll = True

		Computer_Die = Rand(1, 6)

	    Print "The computer rolled " + Str$(Computer_Die) + "."
		Print "Press space to roll your die!"

		NewRoll = False

	EndIf	
		
	If KeyHit(57)
		
		Player_Die = Rand(1, 6)
		
		Print "You rolled a " + Str$(Player_Die) + "."
		
		If Player_Die < Computer_Die 
			Print "Computer WINS!"
		Else
			If Player_Die > Computer_Die 
				Print "You WON!"
			Else
				Print "It's a DRAW!"
			EndIf
		EndIf

		Print ""
		
		NewRoll = True
		
	EndIf
	
Until KeyHit(1)