/usr/share/doc/basic256/examples/dice/dice.kbs is in basic256 0.9.6.69a-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | # dice.kbs - graphical dice 2009-10-31 j.m.reneau
# doll dice and make a rolling noise while we do it.
clg
cls
# draw initial screen
color black
rect 1,1,graphwidth,graphheight
# Sound file from freesound.org
# contributed by Freegle - Sample 44061
wavplay "dicewood.wav"
for t = 1 to 6
gosub roll
pause rand * .2
next t
print "You Rolled " + total
pause 1 # let the sound finish
end
roll:
color white
for die = 1 to 2
# set x and y to the top corner of the die
gosub setdie
rect x,y,100,100
next die
total = 0
for die = 1 to 2
# set x and y to the top corner of the die
gosub setdie
roll = int(rand * 6) + 1
total = total + roll
if roll = 1 then gosub drawone
if roll = 2 then gosub drawtwo
if roll = 3 then gosub drawthree
if roll = 4 then gosub drawfour
if roll = 5 then gosub drawfive
if roll = 6 then gosub drawsix
next die
refresh
return
setdie:
x = 40
y = 40
if die = 2 then x = 160
if die = 2 then y = 160
if die = 3 then x = 40
if die = 2 then y = 160
if die = 2 then x = 160
if die = 4 then y = 40
return
drawone:
color red
rect x + 40, y + 40, 20, 20
return
drawtwo:
color black
rect x + 10, y + 10, 20, 20
rect x + 70, y + 70, 20, 20
return
drawthree:
gosub drawtwo
gosub drawone
return
drawfour:
gosub drawtwo
color black
rect x + 10, y + 70, 20, 20
rect x + 70, y + 10, 20, 20
return
drawfive:
gosub drawfour
gosub drawone
return
drawsix:
gosub drawfour
color black
rect x + 10, y + 40, 20, 20
rect x + 70, y + 40, 20, 20
return
|