'Rope Version 2 SCREEN 12 ' Setup & initialise variables ' ============================ CONST w = 640, h = 480 ' screen dimensions CONST pi = 3.141592 CONST ropex = w / 2, ropey = h / 2 CONST ropemid = 90 ' middle point of swing (try 270!) CONST ropebend = 370 ' increase to reduce amount of bend angle = ropemid + 5: ropedir = 1 ropespd = 2.3 ' ropes speed ropeacc = .1 ' ropes acceleration DIM s(359), c(359) ' lookup tables for sin/cos values FOR d = 0 TO 359 s(d) = SIN(d * (pi / 180)) c(d) = COS(d * (pi / 180)) NEXT d ' Main loop ' ========= DO ropecolor = 14: GOSUB drawrope ' draw rope as yellow WAIT &H3DA, 8 ' wait for screen refresh ropecolor = 0: GOSUB drawrope ' draw rope as black (erase) LOOP UNTIL INKEY$ = CHR$(27) ' exit if ESC pressed END ' Update and draw the rope ' ======================== drawrope: IF ropecolor = 0 THEN GOTO skipupdate IF ropedir = 1 THEN IF angle < ropemid THEN ropespd = ropespd + ropeacc ELSE ropespd = ropespd - ropeacc ELSE IF angle < ropemid THEN ropespd = ropespd - ropeacc ELSE ropespd = ropespd + ropeacc END IF angle = angle + ropespd * ropedir IF ropespd < .1 THEN ropedir = -ropedir: ropespd = 0 skipupdate: FOR rad = 10 TO 232 STEP 7 bend = (angle - ropemid) / ropebend ang = angle + bend * rad CIRCLE (ropex + c(ang) * rad, ropey + s(ang) * rad), 4, ropecolor NEXT rad RETURN '================================================================== ' 270 These indicate the directions the rope will be ' Ý pointing depending on the value of 'angle' ' 180--+--0/360 ' / Ý \ EG: If angle=45 then rope points down & right ' 135 90 45