Rotating an arrow construct. BBCSDL

Discussions related to graphics (2D and 3D), animation and games programming
Post Reply
mikeg
Posts: 65
Joined: Sat 23 Jun 2018, 19:52

Rotating an arrow construct. BBCSDL

Post by mikeg » Fri 07 Feb 2020, 14:47

This includes a turtle tool that allows fine rotation controls and positioning
If you watch the arrow spin long enough you may become brain washed. (I am not serious)

(By the way, this turtle tool has been advanced from the older version: PROCt("a",r) :REM this is your angle
* the command "a" is a specific angle. So if you want 90' then you basically type: PROCt("a",90)
* the difference is that it is 90 degrees from home position at 0 degrees. And 0 degrees is map wise EAST ward bound.
* my interpretation may be wrong, but it seems to be right

HEY GUYS !! If you want to try your hand at making complex things rotate, lets try some graphics stuff !!

I would like to see something from everyone including Richard if he wants to post a example. :)

Code: Select all

REM and the answer is >>>>> 
REM Copy and paste in BBCSDL and run :
MODE 8
GCOL 15
r=1:REM this is your rotation
REPEAT
PROCt("m",500)
PROCt("a",r) :REM this is your angle
PROCt("d",1)
PROCt("c",15)
PROCt("f",25)
PROCt("r",90)
PROCt("f",5)
PROCt("l",135)
PROCt("f",25)
PROCt("l",90)
PROCt("f",25)
PROCt("l",135)
PROCt("f",5)
PROCt("r",90)
PROCt("f",25)
PROCt("l",90)
PROCt("f",10)
PROCt("f",10)
PROCt("f",5)
WAIT 10
r+=1:IF r>360 THEN r=0
CLG
UNTIL FALSE
END
DEFPROCt(mess$,amt%)
PRIVATE angle,x%,y%,pen$,dracol%,sz%
IF sz%<1 THEN sz=1
GCOL dracol%
IF pen$="" THEN pen$="down"
IF mess$="a" THEN angle=amt%
IF mess$= "r" THEN angle=angle - amt%
IF mess$= "l" THEN angle=angle + amt%
IF mess$= "f" THEN VDU 23,23,sz%|:PROC_turtle(amt%,angle,pen$,x%,y%)
IF mess$= "u" THEN pen$="up"
IF mess$= "d" THEN pen$="down"
IF mess$= "p" THEN FILL x%,y%
IF mess$= "c" THEN IF amt%=16 THEN amt%=0
IF mess$= "c" THEN GCOL amt%:dracol%=amt%
IF mess$= "s" THEN sz%=amt%
VDU 23,23,sz%|
IF mess$= "m" THEN
x%=amt%:y%=amt%
pen$="move"
ENDIF
PROC_turtle(0,angle,pen$,x%,y%)
ENDPROC
DEFPROC_turtle(coun%,angle,pen$,RETURN x%,RETURN y%)
PRIVATE sx%,sy%
IF pen$="move" THEN sx%=x%:sy%=y%
IF pen$="up" OR pen$="down" THEN
sx%+=coun%*COS(RAD(angle))
sy%+=coun%*SIN(RAD(angle))
IF pen$="down" THEN LINE x%,y%,sx%,sy%
ENDIF
x%=sx%:y%=sy%
ENDPROC
Focus is on code subject. Feel free to judge the quality of my work.

RichardRussell
Posts: 132
Joined: Tue 15 Oct 2019, 09:10

Re: Rotating an arrow construct. BBCSDL

Post by RichardRussell » Mon 17 Feb 2020, 12:39

mikeg wrote:
Fri 07 Feb 2020, 14:47

Code: Select all

PRIVATE angle,x%,y%,pen$,dracol%,sz%
Forcing the coordinates to be integers (x% and y%) causes a build-up of errors, since at every step a rounding error of up to 0.5 pixels may be introduced. Your program works considerably better if all the percent signs (%) are deleted!
My posts are moderated; if you are seeing this it has already been approved. If you have a comment about the style or tone of the message please report it to the moderators by clicking the exclamation mark icon rather than complaining on the public forum.

mikeg
Posts: 65
Joined: Sat 23 Jun 2018, 19:52

Re: Rotating an arrow construct. BBCSDL

Post by mikeg » Mon 17 Feb 2020, 23:31

considerably better if all the percent signs (%) are deleted!
Fixed and the arrow actually rotates better visually. Thanks Richard.

Code: Select all

      REM and the answer is >>>>>
      REM Copy and paste in BBCSDL and run :
      MODE 8
      GCOL 15
      r=1:REM this is your rotation
      REPEAT
        PROCt("m",500)
        PROCt("a",r) :REM this is your angle
        PROCt("d",1)
        PROCt("c",15)
        PROCt("f",25)
        PROCt("r",90)
        PROCt("f",5)
        PROCt("l",135)
        PROCt("f",25)
        PROCt("l",90)
        PROCt("f",25)
        PROCt("l",135)
        PROCt("f",5)
        PROCt("r",90)
        PROCt("f",25)
        PROCt("l",90)
        PROCt("f",10)
        PROCt("f",10)
        PROCt("f",5)
        WAIT 10
        r+=1:IF r>360 THEN r=0
        CLG
      UNTIL FALSE
      END
      DEFPROCt(mess$,amt)
      PRIVATE angle,x,y,pen$,dracol,sz
      IF sz<1 THEN sz=1
      GCOL dracol
      IF pen$="" THEN pen$="down"
      IF mess$="a" THEN angle=amt
      IF mess$= "r" THEN angle=angle - amt
      IF mess$= "l" THEN angle=angle + amt
      IF mess$= "f" THEN VDU 23,23,sz|:PROC_turtle(amt,angle,pen$,x,y)
      IF mess$= "u" THEN pen$="up"
      IF mess$= "d" THEN pen$="down"
      IF mess$= "p" THEN FILL x,y
      IF mess$= "c" THEN IF amt=16 THEN amt=0
      IF mess$= "c" THEN GCOL amt:dracol=amt
      IF mess$= "s" THEN sz=amt
      VDU 23,23,sz|
      IF mess$= "m" THEN
        x=amt:y=amt
        pen$="move"
      ENDIF
      PROC_turtle(0,angle,pen$,x,y)
      ENDPROC
      DEFPROC_turtle(coun,angle,pen$,RETURN x,RETURN y)
      PRIVATE sx,sy

      IF pen$="move" THEN sx=x:sy=y
      IF pen$="up" OR pen$="down" THEN
        sx+=coun*COS(RAD(angle))
        sy+=coun*SIN(RAD(angle))
        IF pen$="down" THEN LINE x,y,sx,sy
      ENDIF
      x=sx:y=sy
      ENDPROC
Focus is on code subject. Feel free to judge the quality of my work.

Post Reply