Class Trtl

java.lang.Object
  extended by greenfoot.Actor
      extended by Trtl

public class Trtl
extends greenfoot.Actor

A basic turtle.

Version:
1.0.2
Author:
Poul Henriksen, procedural(static) version by Ian Barland.

Field Summary
 double direction
          The direction the turtle is facing.
 
Constructor Summary
protected Trtl()
           
 
Method Summary
protected  void addedToWorld(greenfoot.World world)
          A hook called when this Trtl is added to a World.
static
<T extends greenfoot.Actor>
T
addToWorld(T a)
           
static Trtl makeTrtl()
          Create a new Trtl.
static void move(Trtl _this, double distance)
          Moves the Trtl the given distance.
static void penDown(Trtl _this)
          Puts the pen down.
static void penUp(Trtl _this)
          Takes the pen up.
static void radiate(Trtl t, int sz)
           
static void setColor(Trtl _this, java.lang.String newColor)
          Set the color of the pen.
 void setLocation(int x, int y)
          Set the location of the turtle.
protected static void setLocation(Trtl _this, double x, double y)
          Set the location of the Trtl _this.
static void triangle(Trtl t, int sz)
           
static void turn(Trtl _this, double degrees)
          Turns a turtle.
 
Methods inherited from class greenfoot.Actor
act, getImage, getIntersectingObjects, getNeighbours, getObjectsAtOffset, getObjectsInRange, getOneIntersectingObject, getOneObjectAtOffset, getRotation, getWorld, getX, getY, intersects, move, setImage, setImage, setRotation, turn, turnTowards
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

direction

public double direction
The direction the turtle is facing.

Constructor Detail

Trtl

protected Trtl()
Method Detail

addedToWorld

protected void addedToWorld(greenfoot.World world)
A hook called when this Trtl is added to a World.

Overrides:
addedToWorld in class greenfoot.Actor

addToWorld

public static <T extends greenfoot.Actor> T addToWorld(T a)

makeTrtl

public static Trtl makeTrtl()
Create a new Trtl.

Returns:
a new Trtl.

move

public static void move(Trtl _this,
                        double distance)
Moves the Trtl the given distance.

Parameters:
_this - The Trtl to be moved.
distance - The number of pixels to move the turtle in the direction it's facing.

penDown

public static void penDown(Trtl _this)
Puts the pen down.

Parameters:
_this - The Trtl whose pen is to be lowered.

penUp

public static void penUp(Trtl _this)
Takes the pen up.

Parameters:
_this - The Trtl whose pen is to be lifted.

radiate

public static void radiate(Trtl t,
                           int sz)

setColor

public static void setColor(Trtl _this,
                            java.lang.String newColor)
Set the color of the pen.

Parameters:
_this - The Trtl whose pen-color is being set.
newColor - The name of the color to use; accepted colours are: "red", "black", "blue", "yellow", "green", "magenta", "white"

setLocation

public void setLocation(int x,
                        int y)
Set the location of the turtle. We must override setLocation(int,int) so we can interactively move objects. Not procedural, since it's called by the Greenfoot environment.

Overrides:
setLocation in class greenfoot.Actor

setLocation

protected static void setLocation(Trtl _this,
                                  double x,
                                  double y)
Set the location of the Trtl _this.

See Also:
setLocation(int,int)

triangle

public static void triangle(Trtl t,
                            int sz)

turn

public static void turn(Trtl _this,
                        double degrees)
Turns a turtle.

Parameters:
_this - The Trtl to be turned.
degrees - How many degrees clockwise to turn the turtle.