'=========================================================================== ' Subject: BOUNCING/ROTATING TRIANGLE Date: 04-30-96 (06:30) ' Author: Cam Spowart Code: QB, QBasic, PDS ' Origin: slyboots@supernet.ab.ca Packet: GRAPHICS.ABC '=========================================================================== DECLARE SUB grid () timesvar = 1.5 beg: CLS RANDOMIZE TIMER xinc = .1 RANDOMIZE TIMER yinc = .1 RANDOMIZE TIMER neg = INT(RND * 2) RANDOMIZE TIMER neg1 = INT(RND * 2) IF neg = 0 THEN xinc = xinc IF neg = 1 THEN xinc = xinc * -1 IF neg1 = 0 THEN yinc = yinc IF neg1 = 1 THEN yinc = yinc * -1 SCREEN 12 RANDOMIZE TIMER xcoor = RND * 640 RANDOMIZE TIMER yCoor = RND * 480 x1Coor = xcoor + 100 y1Coor = yCoor x2Coor = xcoor + 50 y2Coor = yCoor - 74 DO grid KEY(1) ON KEY(10) ON ON KEY(1) GOSUB revamp ON KEY(10) GOSUB show LINE (xOld, yOld)-(x1Old, y1Old), 0 LINE (x1Old, y1Old)-(x2Old, y2Old), 0 LINE (x2Old, y2Old)-(xOld, yOld), 0 xcoor = xcoor + xinc yCoor = yCoor + yinc x1Coor = x1Coor + xinc y1Coor = y1Coor + timesvar * yinc x2Coor = x2Coor + timesvar * xinc y2Coor = y2Coor + timesvar * yinc clr = INT(RND * 15) + 1 LINE (xcoor, yCoor)-(x1Coor, y1Coor), clr LINE (x1Coor, y1Coor)-(x2Coor, y2Coor), clr LINE (x2Coor, y2Coor)-(xcoor, yCoor), clr xOld = xcoor x1Old = x1Coor x2Old = x2Coor yOld = yCoor y1Old = y1Coor y2Old = y2Coor IF xcoor > 720 OR xcoor < 0 THEN GOSUB changex IF yCoor > 348 OR yCoor < 0 THEN GOSUB changey getback: LOOP UNTIL INKEY$ = " " CLS END changex: xinc = xinc * -1 RETURN getback changey: yinc = yinc * -1 RETURN getback revamp: CLS GOTO beg show: LOCATE 11, 10: PRINT "Bouncing, moving, rotating, blinking triangles (tm)" LOCATE 12, 25: PRINT "by Cam Spowart (1995)" LOCATE 13, 15: PRINT "Hit space to exit, F1 to redraw, and F10 to see this" DO WHILE INKEY$ = "": LOOP GOTO beg SUB grid xcircle = RND * 640 ycircle = RND * 480 radius = RND * 20 seveneightnine = 7 PSET (xcircle, ycircle), seveneightnine 'CIRCLE (xcircle, ycircle), radius, clr 'FOR xJump = 0 TO 640 STEP 64 'clr = 4 'LINE (xJump, 0)-(xJump, 480), clr 'NEXT xJump 'FOR yJump = 0 TO 480 STEP 64 'clr = 4 'LINE (0, yJump)-(640, yJump), clr 'NEXT yJump END SUB