Automated Drawing

Jim Hurley jhurley0305 at sbcglobal.net
Sat May 9 18:22:14 EDT 2015


> 
> Message: 8
> Date: Sat, 09 May 2015 19:59:15 +0300
> From: Richmond <richmondmathewson at gmail.com>
> To: How to use LiveCode <use-livecode at lists.runrev.com>
> Subject: Re: Automated Drawing
> Message-ID: <554E3CE3.2030507 at gmail.com>
> Content-Type: text/plain; charset=utf-8; format=flowed
> 
> On 09/05/15 16:52, Richmond wrote:
>> On 21/03/15 18:17, Jim Hurley wrote:
>>> Richmond,
>>> 
>>> I wrote this Turtle Graphics library in the dark ages of RR, before 
>>> ?sum? became a reserved word.
>>> 
>>> So, comment out the ?sum? handler in the stack script.
>>> 
>>> Jim
>>> 
>> 
>> Having copied your stack script across into my stack I am stuck with 2 
>> problems:
>> 
>> 1. How to make the line to show as 'pd' [penDown] doesn't seem to work.
>> 
>> 2. How to exchange your graphic "turtleGraphic" for an img.
>> 
>> In all other respects the thing is super!
>> 
>> Richmond.
> 
> Actually my "big" problem at the moment is, with this script:
> 
> on right dangl
>   rt dangl
> end right
> 
> on rt dangl
>   subtract dangl from angl
>   drawTurtle
> end rt
> 
> on drawTurtle
>   myWait waitTime
>   if noDraw then exit drawturtle
>   put 5 into distance
>   put round(x0 +x)&comma& round(-y+y0) & return into gPoints
>   put distance * cos(radPerDeg * angl) into dx
>   put dx into fld "dx"
>   put distance * sin(radPerDeg * angl) into dy
>   put dy into fld "dy"
>   put round(x+x0+dx)&comma&round(-y+y0-dy) after gPoints
>   set points of graphic "turtleGraphic" to gPoints
>   set the angle of img "turt" to ((the angle of img "turt") - angl)
> end drawTurtle
> 
> with the graphic "turtleGraphic" and the img "turt" initially pointing 
> in the same direction,
> why they don't go on pointing in the same direction everytime I send 
> "right 45" via the message box?
> 
> Richmond.
> *********************************************


Hi Richmond,
  
I suspect the problem your are having is that the turtle has to initiated before he will respond.

Try this script in a button as see if it draw a line, shows the arrow pointing in the direction of the next move and then repeats.
The result  should be a square 100 units on a side.

on mouseUp
   startTurtle
   showturtle
   repeat 4 times
      fd 100
      lt 90
      wait 50  ticks
   end repeat
   choose the browse tool
end mouseUp

Jim





More information about the use-livecode mailing list