Outline for December 2, 2024
Reading: none
Due: Homework 5, due December 6; Completed project, due December 12
All work except the completed project must be submitted by 11:59pm on December 6. Anything submitted after that will not be graded.
- Writing a program with objects [war.py]
- Turtle graphics
- What turtle is; import turtle
- Drawing a figure: a box with a hat [tbox.py]
- Set up the window to draw in: Screen()
- Create the turtle: Turtle()
- Cursor for drawing
- Move cursor: forward, backward(), left(), right()
- Wait for the window to close: mainloop()
- Titles, background, and such [tfancybox.py]
- Window
- Color of the window background: background()
- Title of the window: title()
- Turtle, more properly called “pen”
- Shape of the turtle: shape()
- Speed of the drawing: speed()
- Color of the drawn line: color()
- Thickness of the line (pixels): pensize()
- Hide the turtle: hideturtle()
- Plotting points and graphing
- Drawing lines: penup(), pendown()
- Move turtle: setpos()
- Write text: write()
- Draw a dot at the current position: dot() [tchaosdots.py]
- Draw a line from the current position to another: goto() [tchaosline.py]
- Curves in turtle
- Drawing parts of a circle [tcircle.py]
- Drawing a curve [tcurve.py]
- Turtle race [turtlerace.py]
- Create turtles
- Create goals
- Create die
- Program structure:
- Check to see if either turtle has reached its goal; if so, that turtle wins
- If not, ask the player whose turn it is to roll the die (ie, press ENTER)
- Select random number from die list
- Advance turtle appropriately (multiply by LENGTH_OF_STEP)
- Loop until someone wins
A very good tutorial (and the turtle race) is https://realpython.com/beginners-guide-python-turtle