colour(blue)
put "Welcome to the game Dice"
colour(black)
procedure die1
drawbox(300,50,200,150,7)
drawfilloval(250,100,10,10,7)
end die1
procedure die2
drawbox(300,50,200,150,7)
drawfilloval(285,135,10,10,7)
drawfilloval(215,65,10,10,7)
end die2
procedure die3
drawbox(300,50,200,150,7)
drawfilloval(285,135,10,10,7)
drawfilloval(215,65,10,10,7)
drawfilloval(250,100,10,10,7)
end die3
procedure die4
drawbox(300,50,200,150,7)
drawfilloval(285,135,10,10,7)
drawfilloval(215,65,10,10,7)
drawfilloval(285,65,10,10,7)
drawfilloval(215,135,10,10,7)
end die4
procedure die5
drawbox(300,50,200,150,7)
drawfilloval(285,135,10,10,7)
drawfilloval(215,65,10,10,7)
drawfilloval(285,65,10,10,7)
drawfilloval(215,135,10,10,7)
drawfilloval(250,100,10,10,7)
end die5
procedure die6
drawbox(300,50,200,150,7)
drawfilloval(285,135,10,10,7)
drawfilloval(215,65,10,10,7)
drawfilloval(285,65,10,10,7)
drawfilloval(215,135,10,10,7)
drawfilloval(215,100,10,10,7)
drawfilloval(285,100,10,10,7)
end die6
procedure d1
drawbox(480,50,380,150,7)
drawfilloval(430,100,10,10,7)
end d1
procedure d2
drawbox(480,50,380,150,7)
drawfilloval(465,135,10,10,7)
drawfilloval(395,65,10,10,7)
end d2
procedure d3
drawbox(480,50,380,150,7)
drawfilloval(465,135,10,10,7)
drawfilloval(395,65,10,10,7)
drawfilloval(430,100,10,10,7)
end d3
procedure d4
drawbox(480,50,380,150,7)
drawfilloval(465,135,10,10,7)
drawfilloval(395,65,10,10,7)
drawfilloval(465,65,10,10,7)
drawfilloval(395,135,10,10,7)
end d4
procedure d5
drawbox(480,50,380,150,7)
drawfilloval(465,135,10,10,7)
drawfilloval(395,65,10,10,7)
drawfilloval(465,65,10,10,7)
drawfilloval(395,135,10,10,7)
drawfilloval(430,100,10,10,7)
end d5
procedure d6
drawbox(480,50,380,150,7)
drawfilloval(465,135,10,10,7)
drawfilloval(395,65,10,10,7)
drawfilloval(465,65,10,10,7)
drawfilloval(395,135,10,10,7)
drawfilloval(395,100,10,10,7)
drawfilloval(465,100,10,10,7)
end d6
var answer:string
put "Would you like to roll the dice?(y/n)"
get answer
if answer="y" then
var die : array 1 .. 6 of procedure dice
die (1) := die1
die (2) := die2
die (3) := die3
die (4) := die4
die (5) := die5
die (6) := die6
die (Rand.Int (1, 6))
var d : array 1..6 of procedure dice
d(1):= d1
d(2):= d2
d(3):= d3
d(4):= d4
d(5):= d5
d(6):= d6
d (Rand.Int (1, 6))
var diee,dce,di2,total,num1,num2:int
put"Enter the number of the first die you have rolled:"
get diee
case diee of
label 1 : put "You have rolled a 1"
label 2: put " You have rolled a 2"
label 3 :put "You have rolled a 3"
label 4 : put "You have rolled a 4"
label 5: put "You have rolled a 5"
label 6 :put "You have rolled a 6"
end case
put "Enter the number of the second die you rolled:"
get dce
case dce of
label 1 : put "You have rolled a 1"
label 2: put " You have rolled a 2"
label 3 :put "You have rolled a 3"
label 4 : put "You have rolled a 4"
label 5: put "You have rolled a 5"
label 6 :put "You have rolled a 6"
end case
if diee=1 then
num1:=1
elsif
diee=2 then
num1:=2
elsif
diee=3 then
num1:=3
elsif
diee=2 then
num1:=2
elsif
diee=3 then
num1:=3
elsif
diee=4 then
num1:=4
elsif
diee=5 then
num1:=5
elsif
diee=6 then
num1:=6
end if
if dce=1 then
num2:=1
elsif
dce=2 then
num2:=2
elsif
dce=3 then
num2:=3
elsif
dce=2 then
num2:=2
elsif
dce=3 then
num2:=3
elsif
dce=4 then
num2:=4
elsif
dce=5 then
num2:=5
elsif
dce=6 then
num2:=6
end if
total:=num1+num2
put "The total of the two dice equals:"
put total
if total= 7 then
put "You Win!"
elsif
total =11 then
put "You Win!"
elsif
total = 2 then
put "You Lose!"
elsif total =3 then
put "You Lose!"
if total =12 then
put "You Lose!"
else
put "you must match your point value"
end if
end if
end if
|