Lecture Date: Friday, January 23
Today, we are going to move a bit quick, but mainly so you can see a quick overview of a lot of concepts.
First, you need to get everything setup to go!
Open Eclipse. Remember, it MUST NOT be removed from the folder it came in, thoguh the whole folder may be moved.
If it asks you about a workspace, pick the folder where you’d like all the files we write this semester to be located.
In the welcome page there’s a button labeled Workbench on the right. Click it.
Select File → New → Java Project (you might need to select just Project and then select Java Project on the next screen)
Type the project name as TurtleDemo (or something else if you want; I’ll assume TurtleDemo)
Leave everything else in its default state and press the Finish button
If it asks about the Java perspective check remember my decision and click Yes
Click the little plus sign next to the project name:
You should now see a folder called src; we’ll be putting files in that.
Open your operating system’s file viewer to where you downloaded the .java files
Drag Turtle.java and World.java from your file viewer onto the src folder icon in Eclipse. If it asks, chose copy rather than link. You should now see something like the following:
If you do not, click + icons and/or drag files around until you do.
Select File → New → Class
Type Demo1 in the Name field and check the box next to public static void main(String args), then click Finish
1 2 3 4 5 6 7 8 9 10 11 12 13 14
The API (i.e. things you can tell this stuff to do)
Things you can tell a world
|Makes a new 600-by-600 pixel world|
|Makes a new w-by-h pixel world with a red background|
|Erases all turtle trails|
|Saves the current image in your project folder (path/to/your/eclipse/workspace/TurtleDemo/someImageName.png)|
Things you can tell a turtle
|Makes a new turtle in the center of the world|
|Makes a new turtle at the specified point of the world|
|t moves forward 100 pixels|
|t moves backward 83 pixels|
|t rotates to its left (counter-clockwise) 47°|
|t rotates to its right (clockwise) 306°|
|t becomes a red turtle.|
|t stops leaving trails as it moves.|
|t becomes a very large turtle|
|trails t leaves are now 20-pixels wide|
|t draws a picture about 30 pixels wide where it is standing|
There are a few other methods too, like
t.putPenDown() and get methods for most of the set methods.