Folks,
I've just started playing with Greenfoot as part of a project to develop programming teaching at my daughter's local school. I'm a C++ programmer (20 years) with enough Java to get by with, and many years ago I used to help teach LOGO to primary kids; Greenfoot looks like the modern way to do the same, and I'm really looking forward to getting the school using it.
I was playing with the Turtle scenario and found that some of the subclasses (e.g. SquareTurtle) were moving but not plotting any lines. I've also been playing with my own FractalTurtle (see below) and found the same thing.
The problem seems to arise because move() and turn() in Turtle have a 'double' parameter, while in Actor they are 'int'. So if (as in SquareTurtle) they are called with an 'int' the Turtle versions are bypassed and the non-plotting Actor versions are called. If you change the SquareTurtle code to explicitly use doubles (e.g. move(50.0); turn(90.0); ) then it works fine. This is Linux (Debian Squeeze) with Java 6.
For your amusement, here's my FractalTurtle code... It's interesting the difference between the iterative step-at-a-time mode of programming that the act() model enforces vs. the conventional procedural model that it needed for recursion which we used to teach in LOGO - I've ended up making it spin round just to give act() something to do!
Thanks and best wishes
Paul
------
import greenfoot.*; // (World, Actor, GreenfootImage, and Greenfoot) /** * Turtle using recursion to draw a fractal tree * * @author Paul Clark * @version 0.1 */ public class FractalTurtle extends Turtle { public FractalTurtle() { } public void act() { draw(6); turn(15.0); } public void draw(double depth) { // Bottom out if (depth == 0) return; // Draw two-branched tree and recurse penDown(); move(depth*15); turn(30.0); draw(depth-1); turn(-60.0); draw(depth-1); turn(30.0); // Return to start penUp(); move(-depth*15); } }