### Author Topic: Moving letters in a circle (kind off)  (Read 769 times)

0 Members and 1 Guest are viewing this topic.

#### SkulleateR

• CPC6128
• Posts: 262
• Country:
• Liked: 144
• Likes Given: 77
##### Moving letters in a circle (kind off)
« on: 19:31, 02 January 20 »
I´m just doing some experiments here for future projects with Loco Basic.

Wrote a quick simple code to let the word "HELLO" circle around the screen. I think it´s fast enough for my needs but are there any optimisations there ?

Or maybe other solutions ?

#### ComSoft6128

• ..................................
• Supporter
• 6128 Plus
• Posts: 2.006
• Country:
• CPC THEN CPC NOW
• Liked: 2145
• Likes Given: 4291
##### Re: Moving letters in a circle (kind off)
« Reply #1 on: 19:45, 02 January 20 »
There might be some pointers in video 11 of this thread:

http://www.cpcwiki.eu/forum/applications/small-pd-graphic-display-files/25/

#### SkulleateR

• CPC6128
• Posts: 262
• Country:
• Liked: 144
• Likes Given: 77
##### Re: Moving letters in a circle (kind off)
« Reply #2 on: 20:25, 02 January 20 »
Hmmm, thx but not really ...

This is how far I am right now ...

https://youtu.be/LzO6O0QZmyE

#### AMSDOS

• Supporter
• 6128 Plus
• Posts: 3.939
• Country:
• Liked: 1157
• Likes Given: 1924
##### Re: Moving letters in a circle (kind off)
« Reply #3 on: 00:41, 03 January 20 »
Mine is more like a Diamond, feeding ' HELLO      ' using LOCATE and PRINT MID\$ around in a Diamond Like Shape, the Spaces between HELLO are important in this case based on the position held, so if it were shorted to 10 Characters instead of 12 and the 12 adjusted to 10 then HELLO would be jumping 2 positions in the Diamond shape.

Code: [Select]
`100 MODE 0:a\$=" HELLO      "110 x=9:y=9:d1=1:d2=1120 p=1:p2=1:c=1130 a\$=a\$+MID\$(a\$,1,1):a\$=RIGHT\$(a\$,LEN(a\$)-1)140 WHILE c<>12150   LOCATE x+d1,y+d2160   PRINT MID\$(a\$,p2,1);170   x=x+d1:y=y+d2180   IF x=12 THEN d1=-1 ELSE IF x=6 THEN d1=1190   IF y=15 THEN d2=-1 ELSE IF y=9 THEN d2=1200   p2=p2+1:IF p2=12 THEN p2=1210 WEND220 IF c=12 THEN c=1230 GOTO 130`

* Using the old Amstrad Languages    * with the Firmware
* I also like to problem solve code in BASIC    * And type-in Type-Ins!

Home Computing Weekly Programs
Popular Computing Weekly Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

#### AMSDOS

• Supporter
• 6128 Plus
• Posts: 3.939
• Country:
• Liked: 1157
• Likes Given: 1924
##### Re: Moving letters in a circle (kind off)
« Reply #4 on: 03:31, 03 January 20 »
This might be more to your liking, it creates a Text Coordinate based Circle with a Radius of 2, I had to then find out how to Draw each point, a Circle with a Radius of 2 Draws a Circle with 16 points, so Dividing 360/16 gave me 22.5. The message then becomes 16 characters long, which I filled with Hash Characters.
Earlier, in my Diamond example I'd realised my initial c Loop isn't incrementing c at all and Line 130 isn't really doing anything as well as Lines 220-230 because it's stuck in an Infinite Loop, so removing those won't change anything.
The problem with these Circle examples is when the radius changes, the steps between each point changes and then the Length of the Message needs to change.

My first example uses a Radius of 2 which produces a Squarish circle using 16 points, so my String Message is 16 points long and is adjusted accordingly in Line 160. The steps for this becomes 360/16 = 22.5 and incremented in line 1010. The radius of 2 is set on Line 1020.

Code: [Select]
`100 MODE 0110 DEG120 a\$=CHR\$(127)+"HELLO"+STRING\$(10,127)130 p=1:p2=1:a=0:c=0140 WHILE 1150   GOSUB 1000160   p2=p2+1:IF p2=16 THEN p2=1170 WEND1000 WHILE c=a1010    a=a+22.51020    x=10-2*COS(a):y=10-2*SIN(a)1030    LOCATE x,y:PRINT MID\$(a\$,p2,1);1040 WEND1050 c=a1060 RETURN`

The second example I've altered the Radius to 5, so it looks more like a Circle, initially I had an odd looking Circle, which I fixed when I set 'a' and 'c' to 0 in line 130, the string size in 120 has been altered to 28 characters, which is the number of points used when a Circle with a Radius of 5 is created and apart from that the other change is the Length of the message in Line 160 to reflect the length of the message and the Radius itself in line 1020 becomes 5 instead of 2.

Code: [Select]
`100 MODE 0110 DEG120 a\$=CHR\$(127)+"HELLO"+STRING\$(22,127)130 p=1:p2=1:a=0:c=0140 WHILE 1150   GOSUB 1000160   p2=p2+1:IF p2=28 THEN p2=1170 WEND1000 WHILE c=a1010    a=a+12.85714291020    x=10-5*COS(a):y=10-5*SIN(a)1030    LOCATE x,y:PRINT MID\$(a\$,p2,1);1040 WEND1050 c=a1060 RETURN`

EDIT:In my last example with the Circle becomming larger, the whole drawing process slows down and it's only really necessary to Move the Hello Message along with the 1st character of the Hash, so here's an alternative which Draws the Circle initially (along with HELLO in it) and then works out where it has to move to.

Code: [Select]
`100 MODE 0110 DEG120 a\$=CHR\$(127)+"HELLO"+STRING\$(22,127)130 p=1:p2=1:a=0:c=0:c2=1:f=1140 FOR p2=1 TO 28:GOSUB 1000:NEXT p2150 a=0:c=0:c2=1:p2=1:f=1160 WHILE 1170   GOSUB 1000180   p2=p2+1:IF p2=28 THEN p2=1:f=1190   IF p2>7 THEN f=0200 WEND1000 WHILE c<>c21010    a=a+12.8571429:c=c+11020    x=10-5*COS(a):y=10-5*SIN(a)1030    IF f=1 THEN LOCATE x,y:PRINT MID\$(a\$,p2,1);1040 WEND1050 c=01060 RETURN`

EDIT2:And if you don't like the Message moving backwards, it can be made to move Forwards like this:

Code: [Select]
`100 MODE 0110 DEG120 a\$=CHR\$(127)+"HELLO"+STRING\$(22,127)130 a=0:c=0:c2=1:f=1140 FOR p=1 TO 28:GOSUB 1000:NEXT p150 a=0:c=0:c2=1:p=2:f=1160 WHILE 1170   GOSUB 1000180   p=p+1:IF p=28 THEN p=1:f=1190   IF p>7 THEN f=0200 WEND1000 WHILE c<>c21010    a=a-12.8571429:c=c+11020    x=10+5*COS(a):y=10+5*SIN(a)1030    IF f=1 THEN LOCATE x,y:PRINT MID\$(a\$,p,1);1040 WEND1050 c=01060 RETURN`
« Last Edit: 04:55, 03 January 20 by AMSDOS »
* Using the old Amstrad Languages    * with the Firmware
* I also like to problem solve code in BASIC    * And type-in Type-Ins!

Home Computing Weekly Programs
Popular Computing Weekly Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

#### SkulleateR

• CPC6128
• Posts: 262
• Country:
• Liked: 144
• Likes Given: 77
##### Re: Moving letters in a circle (kind off)
« Reply #5 on: 00:10, 04 January 20 »
Thx there are some nice ideas in your listings, maybe i'll do a mix of graphics and text based code, have to try around a little