On 25 September 2013 21:51, Danny Staple <notifications@github.com> wrote:

> In turtlepower/bouncing_turtle.py:
>
> > +
> > +    def make_line_bodies(self):
> > +        """Create a line for the turtles to interact with"""
> > +        self.static_body = pm.Body()
> > +        self.static_lines = [
> > +            pm.Segment(self.static_body, (-299.0, -250.0),
> > +                       (299.0, -259.0), 0.0),
> > +            pm.Segment(self.static_body,
> > +                       (299.0, -259.0), (299.0, 250.0), 0.0),
> > +            pm.Segment(self.static_body,
> > +                       (-299.0, -250.0), (-299.0, 250.0), 0.0)
> > +        ]
> > +        for line in self.static_lines:
> > +            line.elasticity = 0.95
> > +        self.world.space.add(self.static_lines)
> > +
>
> A Line drawn call back may be neater than my current attempt - I've been
> playing with this in a local branch - just adding segments when the turtle
> is moved if the pen is down.
> However- a few gotcha's here:
>
>    - Lots of line segments are bad
>    - Trapped bouncing turtles will eventually miss a collision and break
>    the simulation
>    - Lines are drawn as a turtle moves- which creates lots of tiny lines
>    - especially at the top of a bounce curve.
>
> This does still sound kind of cool - but at a first shot it is a lot
> harder in principle.
> Perhaps I can push the branch - you can play with it and see what I got.
>

That would be cool

I see the problem with many segments. Perhaps we can extend an existing
one? So while a turtle hasn't changed direction, keep extending that one
segment? Or kill the old and add a new one that's a bit longer?

There's an interesting reverse problem as well - imagine a game of snakes
where the tail of a line disappears after a bit?

I suspect the Segment management will need to be a bit higher level that
the individual line segments.

Fun :)

Oh, btw, I implemented that extra callback wrapper as _do_callback in head,
fyi


-- 
Simon