Sunday, September 25, 2011

GWBASIC BREAKOUT SOURCE CODES
















10 REM ibm pc spinout
20 REM K.R. Sloan, Jr.
30 REM 1 January 1982
40 DIM BALL(14)
50 DIM PADDLE(9)
60 DIM BRICK(20, 4)
65 RANDOMIZE (VAL(RIGHT$(TIME$, 2)))
70 KEY OFF: PLAY "mb"
80 LOUD = 0
90 BRUNO$ = "l16o2b-o3cl8ddc+16do2fp1"
110 T = 8: B = 188: L = 8: R = 308
120 BH = 8: BW = (R - L) / 20
130 BT = T + (BH * 4): BB = BT + (BH * 4)
135 CLS
140 LOCATE 7, 12: PRINT "Welcome to Spinout";
150 LOCATE 8, 12: PRINT "ArchMach Version 1";
160 LOCATE 12, 1: PRINT "Choose a key to move the paddle right";
170 R$ = INKEY$: IF R$ = "" GOTO 170
180 LOCATE 12, 1: PRINT "Choose a key to move the paddle left ";
190 L$ = INKEY$: IF L$ = "" GOTO 190
200 IF R$ = L$ GOTO 160
210 LOCATE 12, 1: PRINT "Choose a key to serve ";
220 S$ = INKEY$: IF S$ = "" GOTO 220
230 IF (R$ = S$) OR (L$ = S$) GOTO 160
240 LOCATE 12, 1: PRINT "Choose a key to turn noise on/off ";
250 N$ = INKEY$: IF N$ = "" GOTO 250
260 IF (R$ = N$) OR (L$ = N$) OR (S$ = N$) GOTO 160
270 LOCATE 12, 1: INPUT ; "How good are you at this game (1-10)"; SKILL
275 IF SKILL < 1 GOTO 270
276 IF SKILL > 10 GOTO 270
280 SKILL = SKILL / 10
290 MAXVX = 6 + (4 * SKILL): MAXVY = MAXVX
295 G = SKILL / 5
296 DEF SEG = 0: EQUIPMENT% = PEEK(&H410): POKE &H410, EQUIPMENT% - &H10
297 WIDTH 40: WIDTH 80: SCREEN 0, 0, 0: SCREEN 1: COLOR 1, 0: CLS
300 LINE (0, 0)-(319, 199), 0, BF
310 FOR BY = 0 TO 3
320 FOR BX = 0 TO 19
330 BRICK(1 + BX, 1 + BY) = 10 + 50 * BY
340 LINE (L + 2 + (BW * BX), BT + 2 + (BH * BY))-STEP(BW - 4, BH - 4), 2 + INT(BY / 2), BF
350 NEXT BX, BY
360 SCORE = 0
370 LINE (L, T)-(R, T)
380 LINE -(R, B)
390 LINE -(L, B)
400 LINE -(L, T)
410 X = 160: Y = 100
420 LASTD$ = ""
430 FOR I = 1 TO 5
440 FOR J = 1 TO 5
450 IF ((I - 3) * (I - 3)) + ((J - 3) * (J - 3)) < 6.25 THEN PSET (X - 3 + I, Y - 3 + J)
460 NEXT J, I
470 GET (X - 2, Y - 2)-(X + 2, Y + 2), BALL
480 PL = 150: PR = 170: PY = B - 20
490 LINE (PL, PY)-(PR, PY), 1, BF
500 GET (PL, PY)-(PR, PY), PADDLE
510 REM main loop
520 IF LOUD = 1 THEN PLAY BRUNO$
530 FOR SHOT = 1 TO 4
540 LOCATE 25, 1
550 PRINT USING "#####"; SCORE;
560 LOCATE 25, 8
570 PRINT USING "Ball # "; SHOT;
580 LOCATE 25, 18
590 PRINT "K.R.Sloan,Jr. 1Jan82";
600 IF X > R THEN X = R
610 IF X < L THEN X = L
620 IF Y < T THEN Y = T
630 IF Y > B THEN Y = B
640 PUT (X - 2, Y - 2), BALL
650 X = L + RND(X) * (R - L)
660 Y = B - 10
670 PUT (X - 2, Y - 2), BALL
680 VX = 6 * RND(1) - 3
690 VY = -5 - 2 * RND(1)
700 SPIN = 0
710 FAST = 1 + SKILL
720 GOSUB 1410 'MOVE PADDLE
730 IF D$ <> S$ GOTO 720
740 OX = X: OY = Y: OBX = BX: OBY = BY
750 OVX = VX: OVY = VY
760 VX = OVX - (SPIN * OVY * .05): VY = OVY + (SPIN * OVX * .05) + G
761 SPIN = SPIN * .9999
770 IF VX > MAXVX THEN VX = MAXVX
771 IF VY > MAXVY THEN VY = MAXVY
780 IF VX < -MAXVX THEN VX = -MAXVX
781 IF VY < -MAXVY THEN VY = -MAXVY
790 X = X + VX: Y = Y + VY
800 BX = INT((X - L) / BW)
810 IF BX > 19 THEN BX = 19
820 IF BX < 0 THEN BX = 0
830 BY = INT((Y - BT) / BH)
840 IF BY > 3 GOTO 1050
850 IF BY < 0 GOTO 1050
860 IF BRICK(1 + BX, 1 + BY) <= 0 GOTO 1050
870 IF BY > 1 GOTO 890
880 VY = VY * FAST
890 IF (OBX <> BX) THEN VX = -VX
900 IF (OBY <> BY) THEN VY = -VY
910 SCORE = SCORE + BRICK(1 + BX, 1 + BY)
920 SOUND 440, 2 * LOUD
930 PUT (OX - 2, OY - 2), BALL, XOR
940 LINE (L + 2 + (BW * BX), BT + 2 + (BH * BY))-STEP(BW - 4, BH - 4), 0, BF
950 PUT (OX - 2, OY - 2), BALL, XOR
960 BRICK(1 + BX, 1 + BY) = -BRICK(1 + BX, 1 + BY)
970 IF SCORE < 6800 GOTO 1050
972 LOCATE 25, 1
974 PRINT USING "#####"; SCORE;
980 FOR FLASH = 1 TO 8
990 COLOR FLASH, .5 + RND(FLASH)
1000 PLAY "mfaemb"
1010 NEXT FLASH
1040 GOTO 1340
1050 IF X <= L THEN X = L + L - X: VX = -VX: VY = VY + SPIN: SOUND 600, 2 * LOUD
1060 IF X >= R THEN X = R + R - X: VX = -VX: VY = VY - SPIN: SOUND 1200, 2 * LOUD
1070 IF Y <= T THEN Y = T + T - Y: VY = -VY: VX = VX - SPIN: SOUND 880, 2 * LOUD
1080 IF Y >= B GOTO 1310
1090 IF (Y < PY) OR (OY > PY) THEN GOTO 1270
1100 IF ((PL - 2) < X) AND (X < (PR + 2)) GOTO 1130
1110 IF ((PL - 2) < OX) AND (OX < (PR + 2)) GOTO 1130
1120 GOTO 1270
1130 Y = PY + PY - Y
1140 SOUND 300, 5 * LOUD
1150 IF (RND(1) * 2) > SKILL GOTO 1210
1160 BX = INT(RND(1) * 19.99): BY = INT(RND(1) * 3.99):
1170 IF BRICK(1 + BX, 1 + BY) > 0 GOTO 1210
1180 BRICK(1 + BX, 1 + BY) = -BRICK(1 + BX, 1 + BY)
1190 LINE (L + 2 + (BW * BX), BT + 2 + (BH * BY))-STEP(BW - 4, BH - 4), 2 + INT(BY / 2), BF
1200 SCORE = SCORE - BRICK(1 + BX, 1 + BY)
1210 LOCATE 25, 1
1220 PRINT SCORE;
1230 VY = -VY
1240 MISS = (X - (PL + PR) / 2) / (PL - PR)
1250 VX = VX + VY * MISS * SKILL * 5
1260 SPIN = (SPIN * SKILL) + MISS * SKILL
1270 PUT (X - 2, Y - 2), BALL, XOR
1280 PUT (OX - 2, OY - 2), BALL, XOR
1290 GOSUB 1410 'move paddle
1300 GOTO 740
1310 REM lost ball
1320 IF LOUD = 1 THEN SOUND 200, 20
1330 NEXT SHOT
1340 REM End of Game
1341 DEF SEG = 0: POKE &H410, 125: WIDTH 40: WIDTH 80: SCREEN 0, 0, 0
1342 WIDTH 80: SCREEN 0, 0, 0
1350 LOCATE 12, 20
1360 PRINT "Do you want to play another game?\";
1370 D$ = INKEY$
1380 IF D$ = "y" THEN RUN
1390 IF D$ = "n" THEN STOP
1400 GOTO 1370
1410 REM move paddle routine
1420 OPL = PL
1430 D$ = INKEY$
1440 IF D$ = N$ THEN LOUD = -1 * LOUD + 1
1450 IF D$ = L$ THEN PL = PL - 5: GOTO 1430
1460 IF D$ = R$ THEN PL = PL + 5: GOTO 1430
1470 IF PL < L THEN PL = L
1480 IF PL > (R - 20) THEN PL = R - 20
1490 IF OPL = PL THEN RETURN
1500 PR = PL + 20
1510 PUT (OPL, PY), PADDLE, XOR
1520 PUT (PL, PY), PADDLE, XOR
1530 RETURN

1 comment:

Stefan Höltgen said...

Hi,
this is a very old post! I came to your side because someone on Facebook shared this code. I am researching the history of BASIC game programming. Can you tell me where this code originally stems from?
Thanks!
Stefan