[Edu-sig] some turtle questions

kirby urner kirby.urner at gmail.com
Tue Jan 26 01:10:32 EST 2010


Hi Brian --

If you wanna go to a lot of work, but not a huge amount, write wrapper class
for the Standard Library turtle that intercepts its commands and updates an
on-board data structure, representing pixels x pixels, specifying self
position, keep color info stashed per each one.  That's a lot of data,
depending on screen resolution.  Consider a thick line option if you have
one, make your turtle "wide body".  Or stay with thin.

So then if you go turtle.forward(10) you will send it to your self-made
forward method.  Stop and smell the pixels, see what color was stashed
there, either by another turtle (! -- shared data structure) or by this
turtle, or maybe it's still the default untrammeled color.

You can add new methods, like "glide" or "explode" that translate to the
underlying turtle somehow -- use your imagination.

Kirby



On Sun, Jan 24, 2010 at 7:29 AM, Brian Blais <bblais at bryant.edu> wrote:

> Hello,
>
> I am trying to think of things to do with the turtle module with my
> students, and I have some ideas where I am not sure whether the turtle
> module can do it.
>
> 1) is there a way to determine the current screen pixel color?  I am
> thinking about having the turtle go forward until it reaches an object, say
> a red circle.  I can probably do this by making circle objects (drawn with
> turtles themselves) which know their own position, and check against this
> info.  But I thought it might be useful also for the turtle to know.
>
> 2) is there a way to put a limit on the extent the turtle can travel?  it
> seems I can keep moving off of the screen.  Is there a way to make it so
> that a forward(50) command, at the edge, either raises an exception (at the
> wall) or simply doesn't move the turtle because of the limit?
>
>
> thanks!
>
>
> bb
>
>  --
> Brian Blais
> bblais at bryant.edu
> http://web.bryant.edu/~bblais
> http://bblais.blogspot.com/
>
>
>
>
> _______________________________________________
> Edu-sig mailing list
> Edu-sig at python.org
> http://mail.python.org/mailman/listinfo/edu-sig
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100125/187b3582/attachment-0001.html>


More information about the Python-list mailing list