Code:
SUB Drawtowers (discnum%, playit%, move&)
'draw the towers (poles) and the discs
'discnum=number of discs in the game, playit=play move, movenum=move number
'first the tips of each pole only
VIEW PRINT
'print over any raised disks (above the poles) first
COLOR 1: LOCATE 5, 8: PRINT STRING$(21, 219);
LOCATE 5, 30: PRINT STRING$(21, 219): LOCATE 5, 52: PRINT STRING$(21, 219)
'Poles only need to be drawn at start of game
IF move& = 0 THEN
COLOR 0 'poles are black
'The body of each pole is displayed when
'an empty discs is displayed. (which is everywhere a pole length is visible)
LOCATE 7, 18: PRINT CHR$(219)
LOCATE 7, 40: PRINT CHR$(219)
LOCATE 7, 62: PRINT CHR$(219)
' now show the base holding up all three poles
LOCATE 18, 6: PRINT STRING$(69, 223)
COLOR 15
LOCATE 18, 17: PRINT "ONE"; : LOCATE 18, 39: PRINT "TWO": LOCATE 18, 60: PRINT "THREE"
END IF
'
IF discnum% = 0 THEN discnum% = 10 'initial screen will show ten disks
IF move& = 0 THEN 'it's the start of a new game, initialize the second
'and third pole arrays to their start-up values
j% = 6 ' j% is the number of the disc's color (how intuitive eh?)
k% = 2 ' k% is the width of each disc
IF discnum% < 10 THEN
temp% = discnum%: j% = 15: k% = 20
FOR i% = 9 TO 0 STEP -1
IF discnum% > 0 THEN
pole1(i%, 0) = j%
pole1(i%, 1) = k%
discnum% = discnum% - 1
ELSE
pole1(i%, 0) = -1
pole1(i%, 1) = 20
END IF ' discnum% > 0
j% = j% - 1
k% = k% - 2
' not really set up for this IF discnum% < 7 THEN k% = k% - 4 ELSE k% = k% - 2 ''new today *******
NEXT i%
discnum% = temp%
END IF
'old one works for ten disks only
IF discnum% = 10 THEN
FOR i% = 0 TO 9
pole1(i%, 0) = j%
pole1(i%, 1) = k%
j% = j% + 1
k% = k% + 2
NEXT i%
END IF 'discnum% = 10
FOR i% = 0 TO 9
pole2(i%, 0) = -1 'no color
pole2(i%, 1) = 20 'maximum width value
NEXT i%
FOR i% = 0 TO 9
pole3(i%, 0) = -1
pole3(i%, 1) = 20
'empty slots must have largest width value to allow
NEXT i% 'complete erasing when large discs are moved.
END IF
'draw the discs - first pole1
FOR i% = 9 TO 0 STEP -1
size% = pole1(i%, 1) / 2 - 1 'this is the width indicator printed on each disc
LOCATE i% + 8, INT(18 - pole1(i%, 1) / 2)
IF pole1(i%, 0) > -1 THEN 'there is a disc at this location at this pole
j% = pole1(i%, 0)'get the color for this disc
COLOR j%: PRINT STRING$(pole1(i%, 1) + 1, 219); 'show disc with ASCII chr$ 219
'the +1 is for the width of the pole! (which is covered by the disk here)
' i% can't be used in this next line - it always shows the bottom disc
'regardless of size as 9, next up is 8, etc. (their position in the array)
COLOR 15, j%: LOCATE , 18: PRINT USING "#"; size%; : COLOR 15, 1
ELSE
'no disc on this position so color it with background color
j% = 1
COLOR j%: PRINT STRING$(pole1(i%, 1) / 2, 219); 'show empty disc with ASCII chr$ 219
'in background color.+1 is the width of the pole! (which is NOT covered by the disk here)
COLOR 0: PRINT CHR$(219); 'draw the pole
COLOR j%: PRINT STRING$(pole1(i%, 1) / 2, 219)'the other half of the empty disc
END IF
NEXT i%
'
'now pole2
FOR i% = 9 TO 0 STEP -1
size% = pole2(i%, 1) / 2 - 1 'this is the width indicator printed on each disc
LOCATE i% + 8, INT(40 - pole2(i%, 1) / 2)
IF pole2(i%, 0) > -1 THEN 'there is a disc at this location at this pole
j% = pole2(i%, 0)'get the color for this disc
COLOR j%: PRINT STRING$(pole2(i%, 1) + 1, 219); 'show disc with ASCII chr$ 219
'the +1 is for the width of the pole! (which is covered by the disk here)
COLOR 15, j%: LOCATE , 40: PRINT USING "#"; size%; : COLOR 15, 1
ELSE
'no disc on this position so color it with background color
j% = 1
COLOR j%: PRINT STRING$(pole2(i%, 1) / 2, 219); 'show empty disc with ASCII chr$ 219
'in background color.+1 is the width of the pole! (which is NOT covered by the disk here)
COLOR 0: PRINT CHR$(219); 'draw the pole
COLOR j%: PRINT STRING$(pole2(i%, 1) / 2, 219)'the other half of the empty disc
END IF
NEXT i%
'
'and pole3 here
FOR i% = 9 TO 0 STEP -1
size% = pole3(i%, 1) / 2 - 1 'this is the width indicator printed on each disc
LOCATE i% + 8, INT(62 - pole3(i%, 1) / 2)
IF pole3(i%, 0) > -1 THEN 'there is a disc at this location at this pole
j% = pole3(i%, 0)'get the color for this disc
COLOR j%: PRINT STRING$(pole3(i%, 1) + 1, 219); 'show disc with ASCII chr$ 219
'the +1 is for the width of the pole! (which is covered by the disk here)
COLOR 15, j%: LOCATE , 62: PRINT USING "#"; size%; : COLOR 15, 1
ELSE
'no disc on this position so color it with background color
j% = 1
COLOR j%: PRINT STRING$(pole3(i%, 1) / 2, 219); 'show empty disc with ASCII chr$ 219
'in background color.+1 is the width of the pole! (which is NOT covered by the disk here)
COLOR 0: PRINT CHR$(219); 'draw the pole
COLOR j%: PRINT STRING$(pole3(i%, 1) / 2, 219); 'the other half of the empty disc
END IF
NEXT i%
'
COLOR 15, 1'restore bright white foreground
VIEW PRINT 20 TO 24
END SUB
I couldn't get a screenshot to show the colors, so a couple suggestions: