This classroom project teaches the students to tell time–assuming that there will still be a need for this archaic skill in the era of digital watches.
The student is confronted with a series of clock faces, with the hands at randomly-selected positions. The complexity of the time indicated by the clock depends on the difficulty index, which is set at the beginning of the session.
Somewhere backstage, a time bomb reads 5 seconds, and counting. Fortunately, the counting is not in real time, as this is a rather slow-running program. Every time the student gives the time correctly, one second is added to the bomb’s life; on the other hand, the apocalypse is brought closer by one second when a wrong answer is given. If the detonation time is expanded to 10 seconds, the bomb is considered to be de-fused; if it gets down to 0, then…
The success and failure messages, given in lines 2010 and 2110, are models of economy.
Editors Comments
As I mentioned above, this is a slow-running program, although Mr. Shideler has taken advantage of a few programming techniques to reduce the delay. One clever stratagem is to store the clock face, once it has been generated, as A$, so that a simple “PRINT A$” rapidly fills the screen with the numbers and index marks of the clock. The hands, of course, have to be put in separately, as they must appear in various positions.
Another wise move is to identify the hour hand with an inverse “S”, so that even the youngest (or the oldest) eyes will have no difficulty telling the two hands apart.
I have a couple of questions and comments, however. First, I don’t see the need for the long delay at line 3. Second, the subroutine at 3000 is a real time-killer, and the students would appreciate some sort of courtesy message, like “Don’t go ‘wa-a-ay!” to warn them that they haven’t been deserted. Third, since the clock face is good forever, once it has been generated, it would be helpful to make provision for another run without having to go through the wait all over again. And fourth, isn’t A$ SAVEd along with the rest of the program? Couldn’t the delay be avoided entirely by having the program automatically GOTO 10?
Come to think of it, it would probably be even better (safer, anyway) to store the clock face in a PRINT statement, by the technique presented in the forewords to BASIL’s COMPENDIUM, Chapters 8 and 9 (SyncWare News, Vol. III number 6 and Vol. IV number 1).
Time Bomb Listing
1 REM "TIME BOMB"
2 PRINT "TIME BOMB"
3 PAUSE 600
4 CLS
5 FAST
6 GOSUB 3000
8 SLOW
9 CLS
10 PRINT "YOU HAVE FIVE SECOND
S TO DEFUSE A BOMB. YOU WILL BE
SHOWN A SERIES OF CLOCK FACE
S SHOWING TIMES PICKED AT RAND
OM. IF YOU ENTER THE CORRECT TI
ME YOU ARE GIVEN AN EXTRA SECON
D. IF YOU ENTER THE WRONG TIME
IT COSTS YOU A SECOND. IF TH
E COUNT REACHES ZERO THE BOM
B EXPLODES. IF THE COUNT REACHES
10 YOU DEFUSE THE BOMB. DO
NOT ENTER A COLON TO ENTER THE
TIME. 1:30 IS ENTERED AS 130. S
ELECT LEVEL(1-5)"
20 INPUT LEVEL
30 LET COUNT=5
40 LET T=INT (RND*12)+1
50 LET T$=STR$ T
60 GOTO (90 AND LEVEL=1)+(100 A
ND LEVEL=2)+(110 AND LEVEL=3)+(1
20 AND LEVEL=4)+(130 AND LEVEL=
5)
90 LET T$=T$+"00"
95 GOTO 140
100 LET T=INT (RND*2)*30
102 LET S$=STR$ T
105 LET T$=T$+(S$ AND LEN S$=2)
+(("0"+S$) AND LEN S$=1)
106 GOTO 140
110 LET T=INT (RND*4)*15
115 LET S$=STR$ T
116 LET T$=T$+(S$ AND LEN S$=2)
+(("0"+S$) AND LEN S$=1)
117 GOTO 140
120 LET T=INT (RND*12)*5
125 LET S$=STR$ T
126 LET T$=T$+(S$ AND LEN S$=2)
+(("0"+S$) AND LEN S$=1)
127 GOTO 140
130 LET T=INT (RND*60)
135 LET S$=STR$ T
136 LET T$=T$+(S$ AND LEN S$=2)
+(("0"+S$) AND LEN S$=1)
140 CLS
150 PRINT AT 0,0;A$
210 LET H=2*INT ((VAL T$)/100)
215 LET M$=T$(LEN T$-1 TO )
220 IF VAL M$>15 THEN LET H=H+1
230 IF VAL M$>45 THEN LET H=H+1
240 LET L=VAL M$/30*PI
250 LET D=33+14*SIN L
260 LET E=22+14*COS L
270 GOSUB 1000
280 LET G=H/12*PI
290 LET D=33+10*SIN G
300 LET E=22+10*COS G
310 GOSUB 1000
315 LET D=INT (D/2)
320 LET E=INT ((43-E)/2)
325 PRINT AT E,D;"▒"
330 PRINT AT 0,25;COUNT
340 INPUT R$
350 IF R$<>T$ THEN GOTO 385
355 PRINT AT 21,0;R$;" IS CORRE
CT"
360 LET COUNT=COUNT+1
370 IF COUNT=10 THEN GOTO 2000
380 GOTO 410
385 PRINT AT 21,0;"WRONG, CORRE
CT TIME: ";T$
390 LET COUNT=COUNT-1
400 IF COUNT=0 THEN GOTO 2100
410 GOTO 40
1000 REM DRAW
1010 LET X=33
1020 LET Y=22
1050 LET A=X-D
1060 LET B=Y-E
1070 LET C=(A AND ABS A>=ABS B)+
(B AND ABS B>ABS A)
1080 IF C=0 THEN LET C=0.1
1090 FOR F=0 TO C STEP SGN C
1100 PLOT X+A/C*-F,Y+B/C*-F
1110 NEXT F
1120 RETURN
2000 CLS
2010 PRINT "YOU DID IT";"▒▒▒▒▒▒▒▒
▒▒";
2020 GOTO 2010
2100 CLS
2110 PRINT "BOOM";"▒▒▒▒";
2120 GOTO 2110
3000 REM SET UP CLOCK FACE
3010 FOR D=1 TO 12
3020 PRINT AT 10-8*COS (D/6*PI),
16+8*SIN (D/6*PI);D
3030 NEXT D
3040 FOR I=1 TO 60
3050 PLOT 33+20*SIN (I/30*PI),22
+20*COS (I/30*PI)
3060 NEXT I
3070 DIM A$(704)
3080 LET X=1
3090 LET L=PEEK 16396+256*PEEK 1
6397+1
3100 FOR L=L TO L+725
3110 IF PEEK L=118 THEN G[illegible]
0
3120 LET A$(X)=CHR$ PEEK L
3130 LET X=X+1
3140 NEXT L
3150 RETURN
Media
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.