'=========================================================================== ' Subject: BOUNCING LINES Date: 05-24-97 (15:20) ' Author: Daniel Davies Code: QB, QBasic, PDS ' Origin: ia53@rapid.co.uk Packet: GRAPHICS.ABC '=========================================================================== 'Bouncing lines by Daniel Davies 'if you use this routine in a program please give me some credit. 'Copyright (C) UK 1996 Daniel Davies 'e-mail me at :- ia53@rapid.co.uk DIM SHARED FlineX1%(1 TO 10): DIM SHARED FlineY1%(1 TO 10) DIM SHARED FlineX2%(1 TO 10): DIM SHARED FlineY2%(1 TO 10) DIM SHARED FlineX3%(1 TO 10): DIM SHARED FlineY3%(1 TO 10) DIM SHARED FlineX4%(1 TO 10): DIM SHARED FlineY4%(1 TO 10) DIM SHARED FlineX5%(1 TO 10): DIM SHARED FlineY5%(1 TO 10) RANDOMIZE TIMER FlineX1%(1) = INT(RND * 320): FlineY1%(1) = INT(RND * 200) FlineX2%(1) = INT(RND * 320): FlineY2%(1) = INT(RND * 200) FlineX3%(1) = INT(RND * 320): FlineY3%(1) = INT(RND * 200) FlineX4%(1) = INT(RND * 320): FlineY4%(1) = INT(RND * 200) FlineX5%(1) = INT(RND * 320): FlineY5%(1) = INT(RND * 200) xmod1% = -2: ymod1% = 2 xmod2% = 2: ymod2% = -2 xmod3% = -2: ymod3% = -2 xmod4% = 2: ymod4% = 2 xmod5% = -2: ymod5% = 3 SCREEN 7, 0, 1, 0 starttime! = TIMER DO IF FlineX1%(1) > 319 THEN xmod1% = -2 IF FlineX1%(1) < 0 THEN xmod1% = 2 IF FlineY1%(1) > 199 THEN ymod1% = -2 IF FlineY1%(1) < 0 THEN ymod1% = 2 IF FlineX2%(1) > 319 THEN xmod2% = -2 IF FlineX2%(1) < 0 THEN xmod2% = 2 IF FlineY2%(1) > 199 THEN ymod2% = -2 IF FlineY2%(1) < 0 THEN ymod2% = 2 IF FlineX3%(1) > 319 THEN xmod3% = -2 IF FlineX3%(1) < 0 THEN xmod3% = 2 IF FlineY3%(1) > 199 THEN ymod3% = -2 IF FlineY3%(1) < 0 THEN ymod3% = 2 IF FlineX4%(1) > 319 THEN xmod4% = -2 IF FlineX4%(1) < 0 THEN xmod4% = 2 IF FlineY4%(1) > 199 THEN ymod4% = -2 IF FlineY4%(1) < 0 THEN ymod4% = 2 IF FlineX5%(1) > 319 THEN xmod5% = -2 IF FlineX5%(1) < 0 THEN xmod5% = 2 IF FlineY5%(1) > 199 THEN ymod5% = -3 IF FlineY5%(1) < 0 THEN ymod5% = 3 FlineX1%(1) = FlineX1%(1) + xmod1%: FlineY1%(1) = FlineY1%(1) + ymod1% FlineX2%(1) = FlineX2%(1) + xmod2%: FlineY2%(1) = FlineY2%(1) + ymod2% FlineX3%(1) = FlineX3%(1) + xmod3%: FlineY3%(1) = FlineY3%(1) + ymod3% FlineX4%(1) = FlineX4%(1) + xmod4%: FlineY4%(1) = FlineY4%(1) + ymod4% FlineX5%(1) = FlineX5%(1) + xmod5%: FlineY5%(1) = FlineY5%(1) + ymod5% FOR x% = 10 TO 2 STEP -1 FlineX1%(x%) = FlineX1%(x% - 1): FlineY1%(x%) = FlineY1%(x% - 1) FlineX2%(x%) = FlineX2%(x% - 1): FlineY2%(x%) = FlineY2%(x% - 1) FlineX3%(x%) = FlineX3%(x% - 1): FlineY3%(x%) = FlineY3%(x% - 1) FlineX4%(x%) = FlineX4%(x% - 1): FlineY4%(x%) = FlineY4%(x% - 1) FlineX5%(x%) = FlineX5%(x% - 1): FlineY5%(x%) = FlineY5%(x% - 1) NEXT x% FOR x% = 10 TO 4 STEP -2 c% = 7 IF x% = 8 THEN c% = 8 IF x% >= 9 THEN c% = 0 LINE (FlineX1%(x%), FlineY1%(x%))-(FlineX2%(x%), FlineY2%(x%)), c% LINE (FlineX1%(x%), FlineY1%(x%))-(FlineX3%(x%), FlineY3%(x%)), c% LINE (FlineX3%(x%), FlineY3%(x%))-(FlineX4%(x%), FlineY4%(x%)), c% LINE (FlineX4%(x%), FlineY4%(x%))-(FlineX5%(x%), FlineY5%(x%)), c% LINE (FlineX5%(x%), FlineY5%(x%))-(FlineX2%(x%), FlineY2%(x%)), c% NEXT x% LINE (FlineX1%(1), FlineY1%(1))-(FlineX2%(1), FlineY2%(1)), 15 LINE (FlineX1%(1), FlineY1%(1))-(FlineX3%(1), FlineY3%(1)), 15 LINE (FlineX3%(1), FlineY3%(1))-(FlineX4%(1), FlineY4%(1)), 15 LINE (FlineX4%(1), FlineY4%(1))-(FlineX5%(1), FlineY5%(1)), 15 LINE (FlineX5%(1), FlineY5%(1))-(FlineX2%(1), FlineY2%(1)), 15 'UnRemark the next five lines to display the frame rate the animation 'is running at. 'IF q% MOD 30 = 29 THEN 'LOCATE 1, 1 'PRINT (INT(q% / (TIMER - starttime!))); "FPS " 'END IF 'q% = q% + 1 PCOPY 1, 0 LOOP WHILE INKEY$ = ""