BBC BASIC for Windows
Programming >> Graphics and Games >> simple vector roll
http://bb4w.conforums.com/index.cgi?board=graphics&action=display&num=1464643307

simple vector roll
Post by RockOve on May 30th, 2016, 9:21pm

This is fun:

Code:
      rem VDU 23,22,width;height;charx,chary,ncols,charset
      vdu 23,22,1125;750;32,32,16,0:rem nikon d3300 size ratio (x=y * 1.5)
      origin 1125,750:rem center poiter moved to center of the screen
      r=100:d=0:rem radius set to 100:degree angle is set to zero
      x1=0:x2=0:x3=0:x4=0:rem cordinates for lines set to zero
      y1=0:y2=0:y3=0:y4=0
      oldd=0:oldr=0:rem variables used to detect any change of the mouse
      :
      :print "Move mouse up/down right/left"
      repeat
        mouse mx,my,mb:rem reads mouse
        r=my:d=mx
        if oldd<>d or oldr<>r then
          gcol 0:rem graphic pen colour
          proc_lines(x1,x2,x3,x4,y1,y2,y3,y4):rem procedure is made at the bottom
        endif
        :
        x1=cos(rad(d+((360/4)*1)))*r
        x2=cos(rad(d+((360/4)*2)))*r
        x3=cos(rad(d+((360/4)*3)))*r
        x4=cos(rad(d+((360/4)*4)))*r
        :
        y1=sin(rad(d+((360/4)*1)))*r
        y2=sin(rad(d+((360/4)*2)))*r
        y3=sin(rad(d+((360/4)*3)))*r
        y4=sin(rad(d+((360/4)*4)))*r
        :
        gcol 15:rem graphic pen colour
        proc_lines(x1,x2,x3,x4,y1,y2,y3,y4)
        oldd=d:rem to remember
        oldr=r
      endif
      until false
      :
      def proc_lines(x1,x2,x3,x4,y1,y2,y3,y4)
      line x1+10,y1+10,x2-10,y2-10
      line x2+10,y2+10,x3-10,y3-10
      line x3+10,y3+10,x4-10,y4-10
      line x4+10,y4+10,x1-10,y1-10
      line 0,0,x1,y1
      endproc