Retrogamecoding(.org) > Examples

Simple turtle library for EGSL

<< < (4/4)

Aurel:
Thanks Cyb

i see ,so it is 5....but my main problem is how to avoid recursion calls.
is that possible  ::)

Cybermonkey:
I don't know. It is actually a recursive function so it will become hard to do it in another way.

Tomaaz:

--- Quote from: Aurel on September 25, 2014, 10:05:47 pm ---i see ,so it is 5....but my main problem is how to avoid recursion calls.
is that possible  ::)

--- End quote ---

That's an interesting question. I think you could draw Koch Curve using nested loops, but you would have to manually change the code (the number of loops) to see less/more detailed curve. With recursion all you have to do is to change the value of t (bigger - more details, smaller - less details). Without recursion you would have to manually place t nested loops in your code. But I might be wrong...

The question is - why you don't want to use recursion? Like I said - it might be possible to draw Koch Curve without recursion, but I'm 100% sure the code would be much more complicated.

Aurel:
Answer is simple i don't have built-in any shape of subroutines or functions in my
primitive interpreter so i cannot use recursion on that way.
Yes i agree ..recusive calls is the best way to do the job.
I only have currently built in turtle functions TR,TL,MF,MB...
and if you look in bp.org you will see my examples...

Aurel:
here is one strange modification

--- Code: ---'TURTLE GRAPHICS
defn tx,ty
defn tr
defn tl,level
defn m,s
defn i,t,n
wform 10,100,600,600,#SYS,0,"TURTLE-> StarKoch"
wcolor 0,0,0
'start position
set tx = TURTLEX(300), ty=TURTLEY(240)
set s=12
txcolor 0,220,220
'initial turn to 90 deg LEFT
set tr=TURNR(80),m = moveF(s)
'F LFLF RFLF RFLF RFR F
for n,1,12
'set tr=turnR(120)
For i,1,10

'----------------
set tr=TURNL(60),m = moveF(s), tr = turnL(60),m = moveF(s)
set tr=turnR(120),m = moveF(s),tr = turnL(60),m = moveF(s)
set tr=turnR(120),m = moveF(s),tr = turnL(60),m = moveF(s)
set tr=turnR(120),m = moveF(s),tr=turnL(90),m = moveF(s)

 '-------------------------------------
Next i
set tr=turnR(120)
Next n
wtext 40,2,"TURTLE -> StarKoch"

--- End code ---

Navigation

[0] Message Index

[*] Previous page

Go to full version