Craps

Vb.Net

Public Domain

written in small basic, a simple game of craps. a work in progress

Download (right click, save as, rename as appropriate)

Embed

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
bankroll:
TextWindow.Write("How Much Do You Have: ")
cash = TextWindow.ReadNumber()
bet()

Sub bet
If(cash = 0)Then
TextWindow.WriteLine("You are Bankrupt")
TextWindow.PauseWithoutMessage()
Program.End()
Endif
TextWindow.Write("Bet How Much: ")
PlacedBet = TextWindow.ReadNumber()
If(PlacedBet > cash)Then
TextWindow.WriteLine("You have insufficient cash")
bet()
endif
d1 = Math.GetRandomNumber(6)
d2 = Math.GetRandomNumber(6)
diceroll = d1 + d2
TextWindow.WriteLine("Rolling Dice...")
If diceroll = 7 Or diceroll = 11 then
  Won()
Else
  Lost()
EndIf
EndSub

Sub Won
TextWindow.Write("You Rolled " + diceroll)
TextWindow.WriteLine(" and won!")
cash = cash + PlacedBet*5
TextWindow.WriteLine("You now have $" + cash)
bet()
EndSub

Sub Lost
TextWindow.Write("You Rolled " + diceroll)
TextWindow.WriteLine(" and lost!")
cash = cash - PlacedBet
TextWindow.WriteLine("You now have $" + cash)
bet()
EndSub