| |
StarSqueakTurtle
category: StarSqueak-Kernel
superclass: Object
subclasses: AntColonyTurtle DiffusionTurtle SlimeMoldTurtle TermiteTurtle TreeTurtle
I represent a "creature" that can move about on the surface of a StarSqueak world. I have a position and a heading (direction), and respond commands such as "turnRight:" and "forward:" by turning or moving. I also have an imaginary pen that can draw a trail as I move. In StarSqueak, turtles are born with random positions and headings.
Here are some expressions to try in a workspace:
w _ StarSqueakMorph new openInWorld. "make an empty world"
w makeTurtles: 100. "create 100 turtles"
w turtlesDo: [:t | t forward: 1]. "tell all turtles to take a step"
w turtlesDo: [:t | t goto: 50@50]. "tell all turtles to go to 50@50"
w turtlesDo: [:t | t forward: 10]. "tell all turtles to take 10 steps"
Structure:
world StarSqueakMorph the world that owns this turtle
who integer unique id
x number x position in world
y number y position in world
wrapX float private; used for wrapping in x
wrapY float private; used for wrapping in y
headingRadians float heading in radians
color color turtle color and its pen color
penDown boolean true if drawing a pen trail
nextTurtle StarSqueaktTurtle private; used to make linked list of turtles




|
|