Retrogamecoding(.org) > Examples
Simple turtle library for EGSL
Cybermonkey:
Sorry, but due to security reasons I removed the links to the images. As Mopz said, maybe you'll find another hoster for images (flickr?)
Tomaaz:
Yes, I need to find something or... maybe you could change the limit of attachments from 2 to 3? :) One archive with all files needed to run an example and two screenshots would be enough. ;)
Tomaaz:
I've added some features to make the library more kids-friendly (after all, I've written it for my son). There are two new functions for colour. They accept 17 colour names (white, black, green, red, blue, yellow, grey, purple, aqua, teal, olive, maroon, navy, magenta, lightblue, lightgrey, darkgrey).
setcolour("[colour name]") - set the colour for drawing to "colour name"
setbgcolour("[colour name]") - clears the screen and set the background colour to"colour name"
For more colours you can still use EGSL functions.
There is also a new fill() function that fills the area with a currently set colour.
Here is a small example (see the screenshot):
--- Code: ---require "turtle"
openwindow (640, 550, 0, "Example of turtle graphics")
function koch(x, t)
if t > 0 then
t=t-1
x=x/3
koch(x, t)
turnleft(60)
koch(x, t)
turnright(120)
koch(x, t)
turnleft(60)
koch(x, t)
else
forward(3*x)
end
end
setredraw(0)
setbgcolor("red")
setcolor("yellow")
goxy (100, 150)
turnright(90)
for x = 1, 3 do
koch(150, 5)
turnright(120)
end
goxy (250, 237)
for x = 1, 3 do
koch(50, 4)
turnright(120)
end
setcolor("white")
circle (325, 275, 200)
redraw()
setredraw(1)
goxy (200, 200)
setcolor("purple")
fill()
goxy (320, 275)
setcolor("olive")
fill()
goxy (10, 10)
setcolor("teal")
fill()
inkey()
--- End code ---
Source codes and an updated configuration file for Geany are attached.
Aurel:
Hi Tomek
I am playing with this Turtle functions in my interpreter and i looking into
your koch curve example ...
how big is variable t
because inside if / end if you have
t=t-1 but i don't see where is t set to value
any help maybe ?
Cybermonkey:
t is part of the function call. So if it's
--- Code: ---koch(150, 5)
--- End code ---
then t=5.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version