from math import * from chiplotle import * class turtle: rotation = 0 myXY = (0,0) def rotate(self, angle): self.rotation += angle def rotate_2d(self, xy,angle): nx = xy[0]*cos(radians(angle)) - xy[1]*sin(radians(angle)) ny = xy[0]*sin(radians(angle)) + xy[1]*cos(radians(angle)) return (int(nx), int(ny)) def go(self, distance): print self.myXY dest = self.rotate_2d((0, distance), self.rotation) self.myXY = (self.myXY[0] + dest[0], self.myXY[1] + dest[1]) self.plotter.pen_down(self.myXY) def pen_up(self, xy): print xy self.plotter.pen_up(xy) self.myXY = xy def right(self, distance): print self.myXY dest = self.rotate_2d((distance,0), self.rotation) self.myXY = (self.myXY[0] + dest[0], self.myXY[1] + dest[1]) self.plotter.pen_down(self.myXY) def left(self, distance): self.right(0-distance) def back(self, distance): self.go(0-distance) def __init__(self): self.plotter = instantiate_plotters( )[0] self.plotter.select_pen(3)