Improve speed in turtle
@@ -86,22 +86,20 @@ class Turtle(object):
self.__turtle__.forward(d)
return
- if self.__speed__ != 10:
i = 0
+ all = 0
while i < abs(d):
+ _d = self.__speed__
+ if all+_d >= abs(d):
+ self.__turtle__.forward(d-all)
+ break
+
if d < 0:
- self.__turtle__.forward(-1)
- else:
- self.__turtle__.forward(1)
- i += 1
- else:
- i = 0
- while i < abs(d/2):
- if d < 0:
- self.__turtle__.forward(-2)
+ self.__turtle__.forward(-_d)
else:
- self.__turtle__.forward(2)
- i += 1
+ self.__turtle__.forward(_d)
+ i += _d
+ all += _d
def back(self, d):
self.forward(-d)
