Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TurtleArt/taturtle.py
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2012-11-01 13:42:52 (GMT)
committer Walter Bender <walter.bender@gmail.com>2012-11-01 13:42:52 (GMT)
commit0f1d1747978c7c9c230b8f6bb13b72f787f15acb (patch)
tree6d60f1bb66a758e01f2daf555328aa2f47b187a3 /TurtleArt/taturtle.py
parentdbe1bce2281f1b1e295b8002f003cdcfce5603a6 (diff)
use float to store internal turtle position and heading
Diffstat (limited to 'TurtleArt/taturtle.py')
-rw-r--r--TurtleArt/taturtle.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/TurtleArt/taturtle.py b/TurtleArt/taturtle.py
index c70f379..e3d6e39 100644
--- a/TurtleArt/taturtle.py
+++ b/TurtleArt/taturtle.py
@@ -112,14 +112,14 @@ class Turtle:
def __init__(self, turtles, key, turtle_colors=None):
""" The turtle is not a block, just a sprite with an orientation """
- self.x = 0
- self.y = 0
+ self.x = 0.0
+ self.y = 0.0
self.hidden = False
self.shapes = []
self.custom_shapes = False
self.type = 'turtle'
self.name = key
- self.heading = 0
+ self.heading = 0.0
self.pen_shade = 50
self.pen_color = 0
self.pen_gray = 100
@@ -190,7 +190,7 @@ class Turtle:
if n != 1:
debug_output("%d images passed to set_shapes: ignoring" % (n),
self.tw.running_sugar)
- if self.heading == 0: # rotate the shapes
+ if self.heading == 0.0: # rotate the shapes
images = []
w, h = shapes[0].get_width(), shapes[0].get_height()
nw = nh = int(sqrt(w * w + h * h))
@@ -265,18 +265,16 @@ class Turtle:
self.move((self.x, self.y))
self.set_heading(self.heading)
if self.label_block is not None:
- self.label_block.spr.move((self.x + self.label_xy[0],
- self.y + self.label_xy[1]))
self.label_block.spr.set_layer(TURTLE_LAYER + 1)
def move(self, pos):
""" Move the turtle. """
- self.x, self.y = int(pos[0]), int(pos[1])
+ self.x, self.y = pos[0], pos[1]
if not self.hidden and self.spr is not None:
- self.spr.move(pos)
+ self.spr.move((int(pos[0]), int(pos[1])))
if self.label_block is not None:
- self.label_block.spr.move((pos[0] + self.label_xy[0],
- pos[1] + self.label_xy[1]))
+ self.label_block.spr.move((int(pos[0] + self.label_xy[0]),
+ int(pos[1] + self.label_xy[1])))
return(self.x, self.y)
def get_name(self):