BYOB Project: BYOB Turtles

Students will implement simple turtle graphics in BYOB to draw various shapes based on keys pressed by the user.

  1. Overview

Turtle graphics (see date back to the 1960s as a simple way to create shapes using a basic programming language. The concept was based on turtle robots, which have existed since the 1940s and are the basis of such modern devices as the automated vacuum cleaner Roomba. One of the most widely known turtle graphics implementations is the programming language Logo (see which is in many ways a spiritual predecessor to BYOB. In a turtle graphics system, the cursor (or turtle) has only four basic operations: move, turn, put pen down, and pick pen up. Despite having only these possibilities, very complex images can be created in a turtle graphics system (examples at

  1. Details
  2. Behavior

You will implement a simple turtle graphics program in BYOB. The program should have a single sprite (the “turtle”) that performs different actions depending on the keys pressed by the user. There are three types of commands: movement, pen, and drawing. The commands you must implemented are given in the table on page X. Do not attempt to correct for shapes being drawn on top of each other or the turtle running off the edge of the stage. You should pretend that all actions take place in a clear part of the stage and sufficiently far away from an edge to fit the shape. However, for commands that draw multiple shapes, the shapes must be clearly distinguishable and must not overlap.

  1. Implementation Details

Pressing any key should result in the complete command being executed, and all commands should work regardless of the state of the turtle or the order of the commands given. Specifically, all shapes should appear correct no matter what shapes have been drawn before.

You are free to implement your scripts in any way you like, but you must use the following constructs somewhere in your program:

  • A loop
  • A variable
  • An arithmetic operation
  1. Grading Scheme/Rubric

Functional Correctness (Behavior)
Movement commands work correctly / 2 points
Pen commands work correctly / 2 points
Simple drawing commands work correctly / 10 points (2 points each)
Complex drawing commands work correctly / 12 points (3 points each)
Total / 26 points
Technical Correctness (Implementation)
Uses at least one loop / 1 point
Uses at least one variable / 1 point
Uses at least one arithmetic operation / 1 point
Commands function independently / 1 point
Total / 4 points
Overall Total / 30 points
  1. Required Commands

When this key is pressed: / Perform this action:
Movement commands
Left arrow / Move the turtle one step left
Right arrow / Move the turtle one step right
Up arrow / Move the turtle one step up
Down arrow / Move the turtle one step down
Space bar / Move the turtle to the center of the stage and face it to the right (direction = 90)
Pen commands
Q / Change the pen color to red
W / Change the pen color to green
E / Change the pen color to blue
Simple drawing commands
A / Draw a square
S / Draw an equilateral triangle
D / Draw a five-pointed star
F / Draw your first and last initials (e.g. BW)
X / Clear all drawing on the stage
Complex drawing commands
H / Draw a square, then a star, then a triangle
J / Ask for a number, then draw the given number of stars
K / Ask for a size, then draw a triangle with the given side length
L / Ask for a size and a number, then draw the given number of squares with the given side length

Page 1 of 2Project created by Brett Wortzman