bradgrantham-apple2e/COLORBOUNCESOUND.A

39 lines
1.7 KiB
Plaintext
Raw Normal View History

60 Y = 5: REM SET STARTING POSITION OF UP-AND-DOWN VARIABLE
240 REM SET S TO ADDRESS OF SPEAKER
260 S = - 16336
280 REM SET TEXT MODE
300 TEXT : HOME
310 PRINT "TO SELECT A COLOR FOR"
320 PRINT "THE BOUNCING BALL, FIRST TYPE"
330 PRINT "IN ANY NUMBER FROM 1 TO 15."
340 PRINT "THEN PRESS THE KEY LABELLED RETURN.": PRINT
350 INPUT "WHAT COLOR WOULD YOU LIKE THE BALL TO BE (1-15)?";HUE$
352 REM IS ENTRY A NUMBER?
354 HUE = VAL (HUE$): REM VALUE OF HUE$ BECOMES NUMERIC VARIABLE
356 IF HUE > 999999 OR HUE < .01 THEN GOTO 300: REM INPUT MESSAGE WILL REAPPEAR
358 HUE$ = STR$ (HUE): REM HUE CHANGED BACK INTO STRING HUE$
370 REM IS HUE OF BALL IN RANGE?
380 IF HUE > 0 AND HUE < 16 THEN 400
390 HOME : PRINT "THAT WASN'T BETWEEN 1 AND 15!": PRINT
395 GOTO 310
400 GR : REM SET COLOR GRAPHICS AREA
420 HOME : REM CLEAR TEXT AREA
440 X = 0: REM SET STARTING POSITION OF BACK-AND-FORTH VARIABLE
460 Y = 5: REM SET STARTING POSITION OF UP-AND-DOWN VARIABLE
480 XV = 2: REM SET X VELOCITY
500 YV = 1: REM SET Y VELOCITY
520 REM CALCULATE NEW POSITION
540 NX = X + XV:NY = Y + YV
560 REM IF BALL EXCEEDS SCREEN EDGE, THEN BOUNCE
580 IF NX > 39 THEN NX = 39:XV = - XV: FOR B = 1 TO 5:BOUNCE = PEEK (S) + PEEK (S) + PEEK (S): NEXT B
600 IF NX < 0 THEN NX = 0:XV = - XV: FOR B = 1 TO 5:BOUNCE = PEEK (S) + PEEK (S) + PEEK (S): NEXT B
620 IF NY > 39 THEN NY = 39:YV = - YV: FOR B = 1 TO 5:BOUNCE = PEEK ( S) + PEEK (S) + PEEK (S): NEXT B
640 IF NY < 0 THEN NY = 0:YV = - YV: FOR B = 1 TO 5:BOUNCE = PEEK (S) + PEEK (S) + PEEK (S): NEXT B
660 REM PLOT NEW POSITION
680 COLOR= HUE: PLOT NX,NY
700 REM ERASE OLD POSITION
720 COLOR= 0: PLOT X,Y
740 REM SAVE CURRENT POSITION
760 X = NX:Y = NY
780 GOTO 540