Sunday, September 25, 2011

FREEBASIC BREAKOUT SOURCE CODES !!
















'Recoded From K.R. Sloan, Jr. GWBASIC Spinout.
'GWBASIC version uses Screen 1 ( 320 x 200 Resolution - CGA Graphics )
'FreeBASIC Version uses Screen 19 ( 800 x 600 Resolution 256K colors to 256 attributes or direct color )

REM ibm pc spinout
REM K.R. Sloan, Jr.
REM 1 January 1982
Screen 19 ' ( 800x 600)
DIM BALL(100)
DIM PADDLE(300)
DIM BRICK(20, 4)
RANDOMIZE (VAL(RIGHT$(TIME$, 2)))
' KEY OFF: PLAY "mb"
LOUD = 0
'BRUNO$ = "l16o2b-o3cl8ddc+16do2fp1"
T = 24: B = 580: L = 20: R = 770 ' T=8 B=188 L = 8 R = 308
BH = 20: BW = (R - L) / 20 ' BH = 8: BW = (R - L) / 20
BT = T + (BH * 4): BB = BT + (BH * 4) ' BT = T + (BH * 4): BB = BT + (BH * 4)
CLS:COLOR 6
'BLOAD"BREAKFB.PIC"
160 LOCATE 32, 10: PRINT "Choose a key to move the paddle right";
170 R$ = INKEY$: IF R$ = "" GOTO 170
LOCATE 32, 10: PRINT "Choose a key to move the paddle left ";
190 L$ = INKEY$: IF L$ = "" GOTO 190
IF R$ = L$ GOTO 160
LOCATE 32, 10: PRINT "Choose a key to serve ";
220 S$ = INKEY$: IF S$ = "" GOTO 220
IF (R$ = S$) OR (L$ = S$) GOTO 160
LOCATE 32, 10: PRINT "Choose a key to turn noise on/off ";
250 N$ = INKEY$: IF N$ = "" GOTO 250
IF (R$ = N$) OR (L$ = N$) OR (S$ = N$) GOTO 160
270 LOCATE 32, 10: INPUT ; "How good are you at this game (1-10)"; SKILL
IF SKILL < 1 GOTO 270
IF SKILL > 10 GOTO 270
SKILL = SKILL / 10
MAXVX = 6 + (4 * SKILL): MAXVY = MAXVX
G = SKILL / 5
' DEF SEG = 0: EQUIPMENT% = PEEK(&H410): POKE &H410, EQUIPMENT% - &H10
SCREEN 19: COLOR 1, 0: CLS
LINE (0, 0)-(799, 599), 0, BF
FOR BY = 0 TO 3
FOR BX = 0 TO 19 '19
BRICK(1 + BX, 1 + BY) = 10 + 50 * BY
LINE (L + 2 + (BW * BX), BT + 2 + (BH * BY))-STEP(BW - 4, BH - 4), 2 + INT(BY / 2), BF
NEXT BX, BY
SCORE = 0
LINE (L, T)-(R, T)
LINE -(R, B)
LINE -(L, B)
LINE -(L, T)
X = 160: Y = 10
LASTD$ = ""
CIRCLE (X,Y),5,4
PAINT (X,Y),4,4
GET (X - 5, Y - 5)-(X + 5, Y + 5), BALL
CIRCLE (X,Y),5,0:PAINT (X,Y),0,0
PL = 120: PR = 170: PY = B - 20
LINE (PL, PY)-(PR, PY+10), 1, BF
GET (PL, PY)-(PR, PY+10), PADDLE
REM main loop
'IF LOUD = 1 THEN PLAY BRUNO$
COLOR 7
FOR SHOT = 1 TO 4
LOCATE 1, 1
PRINT USING "#####"; SCORE;
LOCATE 1, 20
PRINT USING "Ball # "; SHOT;
LOCATE 1, 40
PRINT "K.R.Sloan,Jr. 1st Jan 1982 , JALI Software 2011";
IF X > R THEN X = R
IF X < L THEN X = L
IF Y < T THEN Y = T
IF Y > B THEN Y = B
'PUT (X - 2, Y - 2), BALL
X = L + RND(X) * (R - L)
Y = B - 10
PUT (X - 2, Y - 2), BALL
VX = 6 * RND(1) - 3
VY = -5 - 2 * RND(1)
SPIN = 0
FAST = 1 + SKILL
720 GOSUB 1410 'MOVE PADDLE
IF D$ <> S$ GOTO 720
740 OX = X: OY = Y: OBX = BX: OBY = BY
OVX = VX: OVY = VY
VX = OVX - (SPIN * OVY * .05): VY = OVY + (SPIN * OVX * .05) + G
SPIN = SPIN * .9999
IF VX > MAXVX THEN VX = MAXVX
IF VY > MAXVY THEN VY = MAXVY
IF VX < -MAXVX THEN VX = -MAXVX
IF VY < -MAXVY THEN VY = -MAXVY
X = X + VX: Y = Y + VY
BX = INT((X - L) / BW)
IF BX > 19 THEN BX = 19
IF BX < 0 THEN BX = 0
BY = INT((Y - BT) / BH)
IF BY > 3 GOTO 1050
IF BY < 0 GOTO 1050
IF BRICK(1 + BX, 1 + BY) <= 0 GOTO 1050
IF BY > 1 GOTO 890
VY = VY * FAST
890 IF (OBX <> BX) THEN VX = -VX
IF (OBY <> BY) THEN VY = -VY
SCORE = SCORE + BRICK(1 + BX, 1 + BY)
' SOUND 440, 2 * LOUD
PUT (OX - 2, OY - 2), BALL, XOR
LINE (L + 2 + (BW * BX), BT + 2 + (BH * BY))-STEP(BW - 4, BH - 4), 0, BF
PUT (OX - 2, OY - 2), BALL, XOR
BRICK(1 + BX, 1 + BY) = -BRICK(1 + BX, 1 + BY)
IF SCORE < 6800 GOTO 1050
LOCATE 1, 1
PRINT USING "#####"; SCORE;
FOR FLASH = 1 TO 8
COLOR FLASH, .5 + RND(FLASH)
' PLAY "mfaemb"
NEXT FLASH
GOTO 1340
1050 IF X <= L THEN X = L + L - X: VX = -VX: VY = VY + SPIN: 'SOUND 600, 2 * LOUD
IF X >= R THEN X = R + R - X: VX = -VX: VY = VY - SPIN: 'SOUND 1200, 2 * LOUD
IF Y <= T THEN Y = T + T - Y: VY = -VY: VX = VX - SPIN: 'SOUND 880, 2 * LOUD
IF Y >= B GOTO 1310
IF (Y < PY) OR (OY > PY) THEN GOTO 1270
IF ((PL - 2) < X) AND (X < (PR + 2)) GOTO 1130
IF ((PL - 2) < OX) AND (OX < (PR + 2)) GOTO 1130
GOTO 1270
1130 Y = PY + PY - Y
' SOUND 300, 5 * LOUD
IF (RND(1) * 2) > SKILL GOTO 1210
BX = INT(RND(1) * 19.99): BY = INT(RND(1) * 3.99):
IF BRICK(1 + BX, 1 + BY) > 0 GOTO 1210
BRICK(1 + BX, 1 + BY) = -BRICK(1 + BX, 1 + BY)
LINE (L + 2 + (BW * BX), BT + 2 + (BH * BY))-STEP(BW - 4, BH - 4), 2 + INT(BY / 2), BF
SCORE = SCORE - BRICK(1 + BX, 1 + BY)
1210 LOCATE 1, 1
PRINT SCORE;
VY = -VY
MISS = (X - (PL + PR) / 2) / (PL - PR)
VX = VX + VY * MISS * SKILL * 5
SPIN = (SPIN * SKILL) + MISS * SKILL
1270 PUT (X - 2, Y - 2), BALL, XOR
PUT (OX - 2, OY - 2), BALL, XOR

Start = TIMER
DO
LOOP UNTIL TIMER > Start + .05

GOSUB 1410 'move paddle
GOTO 740
1310 REM lost ball
' IF LOUD = 1 THEN SOUND 200, 20
NEXT SHOT
1340 REM End of Game
' DEF SEG = 0: POKE &H410, 125: WIDTH 40: WIDTH 80: SCREEN 0, 0, 0
'WIDTH 80: SCREEN 0, 0, 0
LOCATE 12, 20
PRINT "Do you want to play another game? ";
1370 D$ = INKEY$
IF D$ = "y" THEN RUN"BRKFB.EXE"
IF D$ = "n" THEN STOP
GOTO 1370
1410 REM move paddle routine
OPL = PL
1430 D$ = INKEY$
IF D$ = CHR$(27) THEN END
IF D$ = N$ THEN LOUD = -1 * LOUD + 1
IF D$ = L$ THEN PL = PL - 5: GOTO 1430
IF D$ = R$ THEN PL = PL + 5: GOTO 1430
IF PL < L THEN PL = L
IF PL > (R - 50) THEN PL = R - 50
IF OPL = PL THEN RETURN
PR = PL + 50
PUT (OPL, PY), PADDLE, XOR
PUT (PL, PY), PADDLE, XOR
RETURN

No comments: