% die
var die : array 1 .. 6 of int
% attack/defend variables
var attackDie : int
var defendDie : int
var counter1 : int := 0
var attack : array 1 .. 3 of int := init (0, 0, 0)
var defend : array 1 .. 2 of int := init (0, 0)
% mouse variables
var mouseX, mouseY, onOff : int
var void : string (1)
% dice pictures
drawfillbox (220, 200, 270, 250, brightred) % 1 dice
drawfilloval (245, 225, 5, 5, white) % middle circle
drawfillbox (290, 200, 340, 250, brightred) % 2 dice
drawfilloval (331, 210, 5, 5, white) % top left circle
drawfilloval (300, 240, 5, 5, white) % bottom left circle
drawfillbox (360, 200, 410, 250, brightred) % 3 dice
drawfilloval (370, 240, 5, 5, white) % top left circle
drawfilloval (401, 210, 5, 5, white) % bottom right circle
drawfilloval (385, 225, 5, 5, white) % middle circle
drawfillbox (430, 200, 480, 250, brightred)
drawfilloval (440, 240, 5, 5, white)
drawfilloval (440, 210, 5, 5, white)
drawfilloval (471, 240, 5, 5, white)
drawfilloval (471, 210, 5, 5, white)
drawfillbox (500, 200, 550, 250, brightred)
drawfilloval (510, 240, 5, 5, white)
drawfilloval (510, 210, 5, 5, white)
drawfilloval (541, 240, 5, 5, white)
drawfilloval (541, 210, 5, 5, white)
drawfilloval (525, 225, 5, 5, white)
drawfillbox (570, 200, 620, 250, brightred)
drawfilloval (580, 240, 5, 5, white)
drawfilloval (580, 210, 5, 5, white)
drawfilloval (611, 240, 5, 5, white)
drawfilloval (611, 210, 5, 5, white)
drawfilloval (580, 225, 5, 5, white)
drawfilloval (611, 225, 5, 5, white)
die (1) := Pic.New (220, 200, 270, 250)
die (2) := Pic.New (290, 200, 340, 250)
die (3) := Pic.New (360, 200, 410, 250)
die (4) := Pic.New (430, 200, 480, 250)
die (5) := Pic.New (500, 200, 550, 250)
die (6) := Pic.New (570, 200, 620, 250)
% dice procedures
proc decide
locate (8, 2)
put "Attacker: "
locate (14, 2)
put "Defender: "
if attack (1) = 1 then
Pic.Draw (die (1), 50, 200, picCopy)
elsif attack (1) = 2 then
Pic.Draw (die (2), 110, 200, picCopy)
elsif attack (1) = 3 then
Pic.Draw (die (3), 170, 200, picCopy)
elsif attack (1) = 4 then
Pic.Draw (die (4), 230, 200, picCopy)
elsif attack (1) = 5 then
Pic.Draw (die (5), 300, 200, picCopy)
elsif attack (1) = 6 then
Pic.Draw (die (6), 360, 200, picCopy)
end if
if attack (2) = 1 then
Pic.Draw (die (1), 50, 200, picCopy)
elsif attack (2) = 2 then
Pic.Draw (die (2), 110, 200, picCopy)
elsif attack (2) = 3 then
Pic.Draw (die (3), 170, 200, picCopy)
elsif attack (2) = 4 then
Pic.Draw (die (4), 230, 200, picCopy)
elsif attack (2) = 5 then
Pic.Draw (die (5), 300, 200, picCopy)
elsif attack (2) = 6 then
Pic.Draw (die (6), 360, 200, picCopy)
end if
if attack (3) = 1 then
Pic.Draw (die (1), 50, 200, picCopy)
elsif attack (3) = 2 then
Pic.Draw (die (2), 110, 200, picCopy)
elsif attack (3) = 3 then
Pic.Draw (die (3), 170, 200, picCopy)
elsif attack (3) = 4 then
Pic.Draw (die (4), 230, 200, picCopy)
elsif attack (3) = 5 then
Pic.Draw (die (5), 300, 200, picCopy)
elsif attack (3) = 6 then
Pic.Draw (die (6), 360, 200, picCopy)
end if
if defend (1) = 1 then
Pic.Draw (die (1), 50, 100, picCopy)
elsif defend (1) = 2 then
Pic.Draw (die (2), 110, 100, picCopy)
elsif defend (1) = 3 then
Pic.Draw (die (3), 170, 100, picCopy)
elsif defend (1) = 4 then
Pic.Draw (die (4), 230, 100, picCopy)
elsif defend (1) = 5 then
Pic.Draw (die (5), 300, 100, picCopy)
elsif defend (1) = 6 then
Pic.Draw (die (6), 360, 100, picCopy)
end if
if defend (2) = 1 then
Pic.Draw (die (1), 50, 100, picCopy)
elsif defend (2) = 2 then
Pic.Draw (die (2), 110, 100, picCopy)
elsif defend (2) = 3 then
Pic.Draw (die (3), 170, 100, picCopy)
elsif defend (2) = 4 then
Pic.Draw (die (4), 230, 100, picCopy)
elsif defend (2) = 5 then
Pic.Draw (die (5), 300, 100, picCopy)
elsif defend (2) = 6 then
Pic.Draw (die (6), 360, 100, picCopy)
end if
end decide
% misc procedures
proc processingBar
for counter : 1 .. 190 by 5
drawfillbox (220, 35, 220 + counter, 30, brightred)
delay (25)
end for
end processingBar
proc logo
drawfillbox (0, 300, maxx, maxy, brightred)
locatexy (220, 351)
put "EHS Risk Roller by EHSoft"
for counter : 0 .. 21 by 2
drawbox (2 + counter, 299 + counter, maxx - counter, maxy - counter, brightred)
end for
for counter : 1 .. 20 by 2
drawbox (2 + counter, 299 + counter, maxx - counter, maxy - counter, white)
end for
end logo
proc bodyBack
drawfillbox (5, 292, maxx - 5, 5, white)
end bodyBack
proc numberDiceAttack
% attacker
drawfillbox (220, 200, 270, 250, brightred) % 1 dice
drawfilloval (245, 225, 5, 5, white) % middle circle
drawfillbox (290, 200, 340, 250, brightred) % 2 dice
drawfilloval (331, 210, 5, 5, white) % top left circle
drawfilloval (300, 240, 5, 5, white) % bottom left circle
drawfillbox (360, 200, 410, 250, brightred) % 3 dice
drawfilloval (370, 240, 5, 5, white) % top left circle
drawfilloval (401, 210, 5, 5, white) % bottom right circle
drawfilloval (385, 225, 5, 5, white) % middle circle
end numberDiceAttack
proc numberDiceDefend
% defender
drawfillbox (220, 85, 270, 135, brightred) % 1 dice
drawfilloval (245, 110, 5, 5, white) % middle circle
drawfillbox (290, 85, 340, 135, brightred) % 2 dice
drawfilloval (331, 95, 5, 5, white) % top left circle
drawfilloval (300, 125, 5, 5, white) % bottom left circle
end numberDiceDefend
proc whiteColumn
drawfillbox (634, 287, 631, 5, white)
end whiteColumn
setscreen ("nocursor")
colorback (brightred)
color (white)
cls
logo
bodyBack
loop
numberDiceAttack
locate (8, 2)
put " How many dice is the attacker using?"
whiteColumn
loop
mousewhere (mouseX, mouseY, onOff)
if onOff = 1 then
if mouseX > 220 and mouseX < 270 and mouseY > 200 and mouseY < 250 then
attackDie := 1
exit
elsif mouseX > 290 and mouseX < 340 and mouseY > 200 and mouseY < 250 then
attackDie := 2
exit
elsif mouseX > 360 and mouseX < 410 and mouseY > 200 and mouseY < 250 then
attackDie := 3
exit
end if
end if
end loop
locate (9, 2)
put " ::", attackDie, "::"
numberDiceDefend
locate (15, 2)
put " How many dice is the defender using?"
whiteColumn
loop
mousewhere (mouseX, mouseY, onOff)
if onOff = 1 then
if mouseX > 220 and mouseX < 270 and mouseY > 85 and mouseY < 135 then
defendDie := 1
exit
elsif mouseX > 290 and mouseX < 340 and mouseY > 85 and mouseY < 135 then
defendDie := 2
exit
end if
end if
end loop
locate (16, 2)
put " ::", defendDie, "::"
whiteColumn
locate (22, 2)
put " Processing..."
whiteColumn
processingBar
delay (500)
bodyBack
if attackDie = 1 and defendDie = 1 then
randint (attack (1), 1, 6)
randint (defend (1), 1, 6)
decide
elsif attackDie = 1 and defendDie = 2 then
randint (attack (1), 1, 6)
randint (defend (1), 1, 6)
randint (defend (2), 1, 6)
decide
elsif attackDie = 2 and defendDie = 1 then
randint (attack (1), 1, 6)
randint (attack (2), 1, 6)
randint (defend (1), 1, 6)
decide
elsif attackDie = 2 and defendDie = 2 then
randint (attack (1), 1, 6)
randint (attack (2), 1, 6)
randint (defend (1), 1, 6)
randint (defend (2), 1, 6)
decide
elsif attackDie = 3 and defendDie = 1 then
randint (attack (1), 1, 6)
randint (attack (2), 1, 6)
randint (attack (3), 1, 6)
randint (defend (1), 1, 6)
decide
elsif attackDie = 3 and defendDie = 2 then
randint (attack (1), 1, 6)
randint (attack (2), 1, 6)
randint (attack (3), 1, 6)
randint (defend (1), 1, 6)
randint (defend (2), 1, 6)
decide
end if
attack (1) := 0
attack (2) := 0
attack (3) := 0
defend (1) := 0
defend (2) := 0
loop
mousewhere (mouseX, mouseY, onOff)
if onOff = 1 then
if mouseX > 0 and mouseY > 0 then
exit
end if
end if
end loop
bodyBack
end loop
|