Page 161 - Learn to Program - Basic-256
P. 161
Chapter 10: Functions and Subroutines – Reusing Code. Page 145
18 end
19
20 subroutine drawdie(x,y,n)
21 # draw 70x70 with dots 10x10 pixels
22 # set x,y for top left and n for number of dots
23 color black
24 rect x,y,70,70
25 color white
26 # top row
27 if n <> 1 then rect x + 10, y + 10, 10, 10
28 if n = 6 then rect x + 30, y + 10, 10, 10
29 if n >= 4 and n <= 6 then rect x + 50, y + 10,
10, 10
30 # middle
31 if n = 1 or n = 3 or n = 5 then rect x + 30, y +
30, 10, 10
32 # bottom row
33 if n >= 4 and n <= 6 then rect x + 10, y + 50,
10, 10
34 if n <> 1 then rect x + 50, y + 50, 10, 10
35 if n = 6 then rect x + 30, y + 50, 10, 10
36 end subroutine
Program 69: Big Program - Roll Two Dice Graphically
© 2019 James M. Reneau (CC BY-NC-SA 3.0 US)

