BBC BASIC for Windows
Programming >> Graphics and Games >> Puppet Master animation using HEX (faster?)
http://bb4w.conforums.com/index.cgi?board=graphics&action=display&num=1462418672

Puppet Master animation using HEX (faster?)
Post by michael on May 5th, 2016, 03:24am

The data statements are generated by a Utility Program I made. (So no more pen and paper)
I am not sure if hexadecimal adds to the speed.. But here it is:
You can increase the speed but you must make sure that it slows down near destination points.. ( I will work on that tomorrow and make the speed adjustable )
Code:
 REM SET MODE TO 8 USING VDU
      VDU 23,22,900;900;8,15,16,1 :REM max width is 1920 and 1440 height
      REM SET LINE THICKNESS TO 3
      REM VDU 23,23,3|
      xx%=0:yy%=0:h%=100:v%=100:sw%=0:s%=0
      continue$="":pass%=0
      f$=""
      REM OFF
      GCOL 1

      REPEAT
        DATA  &14C,&296, &1C8,&2E6, &2A6,&356, &340,&3AC, &392,&3F6, &392,&3F6
        DATA  &3CC,&470, &414,&4DA, &494,&528, &516,&4E6, &564,&47A, &564,&47A
        DATA  &58C,&432, &5AC,&3E8, &58A,&34E, &558,&306, &4FC,&2D6, &4FC,&2D6
        DATA  &4A2,&2A0, &456,&256, &422,&20E, &3C0,&1E4, &35E,&1D0, &35E,&1D0
        DATA  &2DE,&1A2, &24A,&19E, &1CA,&1A6, &158,&1EA, 3000,3000
        READ h%,v%
        IF h%=3000 THEN RESTORE:READ h%,v%:f$="NO"
        REPEAT
          IF xx%<h% THEN xx%=xx%+1
          IF yy%<v% THEN yy%=yy%+1
          IF xx%>h% THEN xx%=xx%-1
          IF yy%>v% THEN yy%=yy%-1
          CLG
          * REFRESH OFF
          CIRCLE FILL xx%,yy%,30
          MOVE 100,100:PRINT xx%
          MOVE 100,70:PRINT yy%
          CIRCLE FILL 500,500,50
          * REFRESH
          IF xx%=h% THEN s%=1
          IF yy%=v% THEN sw%=1
          IF sw%=1 AND s%=1 THEN pass%=1
        UNTIL pass%=1
        pass%=0:s%=0:sw%=0
      UNTIL continue$="done"
      END
  

You will need to make a folder named \Hexdata
before you use this program
The BBC generated file is HEX.BBC
let me know if there is any issues..
(closing the window will also close the file and end the program so you don't really need to use the middle mouse button)
Code:
      REM       width;height;charwidth,charheight,number of colors,character set
      x=0:y=0:b=0:px=0:py=0:nx=0:ny=0:coun%=0
      VDU 23,22,900;900;8,15,16,1 :REM max width is 1920 and 1440 height
      status$=""
      REM Turn off the text cursor _
      OFF
      VDU 5 : REM Treat text as graphics (transparent background)
      REM Here is where you would make your center image or image that you will make animation around
      ON CLOSE PROCclose
      A=OPENOUT(@usr$+"\Hexdata\HEX.BBC")
      PRINT#A,"DATA "
      PROCcolor("f",200,200,200)
      MOVE 1,1000:PRINT" Left mouse button = plot a destination"
      MOVE 1,950:PRINT" Right mouse button = Save current plot to file"
      MOVE 1,900:PRINT" Middle mouse button = close file and end"
      CIRCLE FILL 500,500,50
      REM Here is where the locator is
      REPEAT
        PROCmoubox
      UNTIL b=2
      PROCclose
      END
      DEF PROCclose
      PRINT#A, "3000,3000"
      CLOSE#A
      QUIT
      ENDPROC
      REM ***************End of INPUT routine ************
      DEF PROCmoubox
      REM MOUSE b-- 1-rightbttn  2-mid bttn  4-left bttn
      WAIT 1
      MOUSE x,y,b
      * REFRESH OFF
      IF b=4 THEN PROCpr(10,605,15,"X : &"+STR$~(x)+" Y : &"+STR$~(y)+" ",100,100,200):PROCcolor("f",100,100,100):CIRCLE FILL x,y,20:nx=x:by=y
      * REFRESH
      IF px<nx OR px>nx OR py<ny OR py>ny THEN
        IF b=1 AND coun%<5 THEN PRINT#A,"&"+STR$~(x)+",&"+STR$~(y)+",":px=nx:py=ny:coun%=coun%+1
      ELSE
        IF b=1 AND coun%=5 THEN PRINT#A,"&"+STR$~(x)+",&"+STR$~(y)+CHR$(10):px=nx:py=ny:coun%=0:PRINT#A,"DATA "
  
      ENDIF
      ENDPROC
      REM ***********************this is my super custom text box tool ***********************
      REM X,Y,text color,boarder color,message,r,g,b
      REM ************************************************************************
      DEF PROCpr(X,Y,C,msg$,r,g,b)
      initialx%=LEN(msg$)
      COLOUR 0,r,g,b
      GCOL 0
      LET tx= X+initialx%+25
      LET ty= Y:reduction%=0
      reduction%=initialx%/2
      reduction%=reduction%*6
      IF initialx%<20 THEN reduction%=reduction%/2
      initialx%=initialx%*22-reduction%
      FOR fill=12 TO 48
        LINE X-3,Y+20-fill,X+initialx%+8,Y+20-fill
      NEXT fill
      COLOUR 0,0,0,0
      GCOL 0
      MOVE tx,ty
      PRINT msg$
      MOVE 0,0 REM hide that thing
      ENDPROC
      REM ******************this is a custom Foreground and Background control tool (too much?) *****************
      REM color "F"or"B", r,g,b
      DEF PROCcolor(fb$,r%,g%,b%)
      IF fb$="f" OR fb$="F" THEN COLOUR 0,r%,g%,b% : GCOL 0
      IF fb$="b" OR fb$="B" THEN COLOUR 1,r%,g%,b% : GCOL 128+1
      ENDPROC