'=========================================================================== ' Subject: PAC-MAN SCREEN SAVER Date: 03-02-96 (00:00) ' Author: Chad Beck Code: QB, QBasic, PDS ' Origin: Kevin Smith Packet: GRAPHICS.ABC '=========================================================================== ' > Here's...my PacMan Screen Saver.... ' I love it! ' > Anyone have any suggestions as to how I could make it any better? ' Yep. This could still be much improved, but it's a start (>15K 'smaller than the original). Hopefully you'll find it easier to read and 'modify too. Enjoy! ' ****************************************************************** ' ** KEVIN SMITH ******** PACMAN.BAS ********* JAN 14, 1996 ** ' ****************************************************************** ' ** PURPOSE: TO CREATE A PAC-MAN SCREEN SAVER THAT WILL GO IN ** ' ** ALL FOUR DIRECTIONS INSTEAD OF ONLY ONE USING ** ' ** DATA FILES INSTEAD OF REDRAWING ALL THE GRAPHICS ** ' ** EACH TIME THE PROGRAM IS RUN. ** ' ****************************************************************** ' Optimized by CHuRL 3-2-96 DEFINT A-Z 'Use integers only CONST ArraySize = 242, NumGraphics = 21 CONST Delay = 700 'Set the delay once CONST True = -1, False = NOT True DIM Graphic(0 TO ArraySize * NumGraphics) SCREEN 7 CLS RANDOMIZE TIMER 'GOSUB MakeData '!!! DEF SEG = VARSEG(Graphic(0)) ON ERROR GOTO MakeData BLOAD "Pacman.DAT", VARPTR(Graphic(0)) ON ERROR GOTO 0 'I promise it won't crash ' from here on... Direction = 1 X = 160 Y = 100 DO IF Turns > NumTurns THEN Turns = 0 Direction = INT(RND * 4) NumTurns = INT(RND * 7) + 2 END IF SELECT CASE Direction CASE 0: GOSUB Right CASE 1: GOSUB Left CASE 2: GOSUB Down: Y = 199 - Y - 19 CASE ELSE: GOSUB Up END SELECT Turns = Turns + 1 LOOP UNTIL INKEY$ = CHR$(27) 'Continue until ESC pressed SCREEN 0 WIDTH 80 END Right: FOR Frame = 0 TO 6 PUT (X, Y), Graphic(Frame * ArraySize), PSET FOR Stall = 0 TO Delay: NEXT IF X < 295 THEN X = X + 1 NEXT FOR Frame = 6 TO 0 STEP -1 PUT (X, Y), Graphic(Frame * ArraySize), PSET FOR Stall = 0 TO Delay: NEXT IF X < 295 THEN X = X + 1 NEXT IF X = 295 THEN NumTurns = 0 RETURN Left: FOR Frame = 7 TO 13 PUT (X, Y), Graphic(Frame * ArraySize), PSET FOR Stall = 0 TO Delay: NEXT IF X > 0 THEN X = X - 1 NEXT FOR Frame = 13 TO 7 STEP -1 PUT (X, Y), Graphic(Frame * ArraySize), PSET FOR Stall = 0 TO Delay: NEXT IF X > 0 THEN X = X - 1 NEXT IF X = 0 THEN NumTurns = 0 RETURN Down: Y = 199 - Y - 19 '19 = graphic height WINDOW (0, 0)-(319, 199) 'Inverse coordinates Up: FOR Frame = 14 TO 20 PUT (X, Y), Graphic(Frame * ArraySize), PSET FOR Stall = 0 TO Delay: NEXT IF Y > 0 THEN Y = Y - 1 NEXT FOR Frame = 20 TO 14 STEP -1 PUT (X, Y), Graphic(Frame * ArraySize), PSET FOR Stall = 0 TO Delay: NEXT IF Y > 0 THEN Y = Y - 1 NEXT IF Y = 0 THEN NumTurns = 0 WINDOW SCREEN (0, 0)-(319, 199) 'Return to normal RETURN MakeData: 'Right Pac-People 'SCREEN 7, , 1, 0 '!!! FOR X = 1 TO 10 CIRCLE (20, 20), X, 14 CIRCLE (21, 20), X, 14 NEXT X LINE (20, 14)-STEP(2, 1), 0, BF 'Sketch the eye GOSUB SaveGraphic LINE (20, 20)-(31, 20), 0 GOSUB SaveGraphic LINE (20, 20)-(31, 19), 0 LINE (20, 20)-(31, 21), 0 GOSUB SaveGraphic LINE (20, 20)-(31, 18), 0 LINE (20, 20)-(31, 22), 0 GOSUB SaveGraphic LINE (20, 20)-(31, 17), 0 LINE (20, 20)-(31, 23), 0 GOSUB SaveGraphic LINE (20, 20)-(31, 16), 0 LINE (20, 20)-(31, 24), 0 GOSUB SaveGraphic LINE (20, 20)-(31, 15), 0 LINE (20, 20)-(31, 25), 0 GOSUB SaveGraphic 'Left Pac-People FOR X = 0 TO 10 CIRCLE (20, 20), X, 14 CIRCLE (21, 20), X, 14 NEXT X LINE (20, 14)-STEP(2, 1), 0, BF 'Sketch the eye GOSUB SaveGraphic LINE (20, 20)-(10, 20), 0 GOSUB SaveGraphic LINE (20, 20)-(10, 19), 0 LINE (20, 20)-(10, 21), 0 GOSUB SaveGraphic LINE (20, 20)-(10, 18), 0 LINE (20, 20)-(10, 22), 0 GOSUB SaveGraphic LINE (20, 20)-(10, 17), 0 LINE (20, 20)-(10, 23), 0 GOSUB SaveGraphic LINE (20, 20)-(10, 16), 0 LINE (20, 20)-(10, 24), 0 GOSUB SaveGraphic LINE (20, 20)-(10, 15), 0 LINE (20, 20)-(10, 25), 0 GOSUB SaveGraphic 'Up Pac-People FOR X = 1 TO 10 CIRCLE (20, 20), X, 14 CIRCLE (21, 20), X, 14 NEXT X LINE (14, 19)-STEP(1, 2), 0, BF 'Sketch the eye GOSUB SaveGraphic LINE (20, 20)-(20, 10), 0 GOSUB SaveGraphic LINE (20, 20)-(19, 10), 0 LINE (20, 20)-(21, 10), 0 GOSUB SaveGraphic LINE (20, 20)-(18, 10), 0 LINE (20, 20)-(22, 10), 0 GOSUB SaveGraphic LINE (20, 20)-(17, 10), 0 LINE (20, 20)-(23, 10), 0 GOSUB SaveGraphic LINE (20, 20)-(16, 10), 0 LINE (20, 20)-(24, 10), 0 GOSUB SaveGraphic LINE (20, 20)-(15, 10), 0 LINE (20, 20)-(25, 10), 0 GOSUB SaveGraphic 'SCREEN 7, , 0 '!!! 'RETURN '!!! SCREEN 0 WIDTH 80 PRINT "CREATING DATA FILE... PLEASE WAIT" DEF SEG = VARSEG(Graphic(0)) BSAVE "Pacman.DAT", VARPTR(Graphic(0)), ArraySize * NumGraphics * 2 PRINT "DATA FILE CREATED. YOU MAY NOW RUN THIS PROGRAM AGAIN." END SaveGraphic: GET (9, 11)-(32, 29), Graphic(Offset) Offset = Offset + ArraySize RETURN