Lab Assignment 10
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Kevin Bennett

Lab 10

The first task for this lab was to add the line style "broken" to the forward method of the interpreter. I basically copied and pasted the initial code from the jitter method and followed the instructions for the actual moving around and drawing stuff part of it. The one exception was that I changed the part of the code:# Go to (xm + jx, ym + jy)

  1. Pick the pen up
  2. Go to (xm + jx, ym + jy)
    turtle.goto( xm + jx, ym + jy )
    turtle.goto( xm + kx, ym + ky )

If I left it as jx and jy for the second pair, it doesn't "break" because it is drawing from the same place.
That was an easy fix, however, and with little pain, I ended up with this picture:

The second task was to create a dashed line style.
Like in the other styles, I assigned the beginning and end points to (x0, y0) and (xf, yf).
Then, inside a for loop in range int( distance/( self.dashLength*2 ) ), I just had the turtle go forward, then pick it-
self up and go forward again. Once it was done, I had it pick up, go to the end point, and put down.
My test code was accidentally written over, but I recreated it with incorrect colors and positioning, but the code is basically the same.

  • No labels