diff options
author | Walter Bender <walter@sugarlabs.org> | 2013-06-25 14:27:51 (GMT) |
---|---|---|
committer | Walter Bender <walter@sugarlabs.org> | 2013-06-25 14:27:51 (GMT) |
commit | 186cf0130bde035a9b5362df040bb812061cfc85 (patch) | |
tree | 96c2e39f28b99d90126710a32e912d94f269eac5 | |
parent | 040275d412029fe5dcde82cd9b6ada041db43248 (diff) |
more refactoring
-rw-r--r-- | TurtleArt/tabasics.py | 14 | ||||
-rw-r--r-- | TurtleArt/tacollaboration.py | 13 | ||||
-rw-r--r-- | TurtleArt/talogo.py | 1 | ||||
-rw-r--r-- | TurtleArt/taturtle.py | 189 | ||||
-rw-r--r-- | TurtleArt/tawindow.py | 71 | ||||
-rw-r--r-- | plugins/turtle_blocks_extras/turtle_blocks_extras.py | 13 |
6 files changed, 154 insertions, 147 deletions
diff --git a/TurtleArt/tabasics.py b/TurtleArt/tabasics.py index 0d05f19..c060d9d 100644 --- a/TurtleArt/tabasics.py +++ b/TurtleArt/tabasics.py @@ -217,7 +217,7 @@ degrees)')) 'setxy2', 2, lambda self, x, y: primitive_dictionary['move']( - self.tw.turtles.get_active_turtle().set_xy, x, y)) + self.tw.turtles.get_active_turtle().set_xy, (x, y))) define_logo_function('tasetxy', 'to tasetxy :x :y\nsetxy :x :y\nend\n') primitive_dictionary['set'] = self._prim_set @@ -295,7 +295,7 @@ turtle (can be used in place of a number block)'), 'setxy', 2, lambda self, x, y: primitive_dictionary['move']( - self.tw.turtles.get_active_turtle().set_xy, x, y, + self.tw.turtles.get_active_turtle().set_xy, (x, y), pendown=False)) define_logo_function('tasetxypenup', 'to tasetxypenup :x :y\npenup\n\ setxy :x :y\npendown\nend\n') @@ -1115,6 +1115,11 @@ variable')) def _prim_move(self, cmd, value1, value2=None, pendown=True, reverse=False): ''' Turtle moves by method specified in value1 ''' + pos = None + if isinstance(value1, (tuple, list)): + pos = value1 + value1 = pos[0] + value2 = pos[1] if not _num_type(value1): raise logoerror("#notanumber") if value2 is None: @@ -1125,7 +1130,10 @@ variable')) else: if not _num_type(value2): raise logoerror("#notanumber") - cmd(float(value1), float(value2), pendown=pendown) + if pos is not None: + cmd((float(value1), float(value2)), pendown=pendown) + else: + cmd(float(value1), float(value2), pendown=pendown) if self.tw.lc.update_values: self.tw.lc.update_label_value( 'xcor', diff --git a/TurtleArt/tacollaboration.py b/TurtleArt/tacollaboration.py index 85b54f0..965e2c1 100644 --- a/TurtleArt/tacollaboration.py +++ b/TurtleArt/tacollaboration.py @@ -322,9 +322,9 @@ class Collaboration(): file_name = base64_to_image(data, tmp_path) pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(file_name, width, height) - x, y = self._tw.turtles.turtle_to_screen_coordinates(x, y) - self._tw.turtles.get_active_turtle().draw_pixbuf(pixbuf, a, b, x, y, w, h, - file_name, False) + pos = self._tw.turtles.turtle_to_screen_coordinates((x, y)) + self._tw.turtles.get_active_turtle().draw_pixbuf( + pixbuf, a, b, pos[0], pos[1], w, h, file_name, False) def _move_forward(self, payload): if len(payload) > 0: @@ -396,7 +396,6 @@ class Collaboration(): self._tw.turtles.get_active_turtle().set_pen_state(x, False) def _fill_polygon(self, payload): - # TODO: FIXME if len(payload) > 0: [nick, poly_points] = data_from_string(payload) shared_poly_points = [] @@ -404,7 +403,11 @@ class Collaboration(): shared_poly_points.append( (self._tw.turtles.turtle_to_screen_coordinates (poly_points[i][0], poly_points[i][1]))) - self._tw.turtles.get_active_turtle().fill_polygon(shared_poly_points) + if nick != self._tw.nick: + self._tw.turtles.set_turtle(nick) + self._tw.turtles.get_active_turtle().set_poly_points( + shared_poly_points) + self._tw.turtles.get_active_turtle().stop_fill(False) def _speak(self, payload): if len(payload) > 0: diff --git a/TurtleArt/talogo.py b/TurtleArt/talogo.py index b8ee4dc..fd2751e 100644 --- a/TurtleArt/talogo.py +++ b/TurtleArt/talogo.py @@ -599,6 +599,7 @@ class LogoCode: from tagplay import stop_media stop_media(self) self.tw.canvas.clearscreen() + self.tw.turtles.reset_turtles() self.scale = DEFAULT_SCALE self.hidden_turtle = None self.start_time = time() diff --git a/TurtleArt/taturtle.py b/TurtleArt/taturtle.py index b6e2e68..e95556a 100644 --- a/TurtleArt/taturtle.py +++ b/TurtleArt/taturtle.py @@ -119,15 +119,15 @@ class Turtles: ["#008000", "#00A000"]) return(self._default_pixbufs) - def turtle_to_screen_coordinates(self, x, y): + def turtle_to_screen_coordinates(self, pos): ''' The origin of turtle coordinates is the center of the screen ''' - return self.width / 2.0 + x, self.invert_y_coordinate(y) + return [self.width / 2.0 + pos[0], self._invert_y_coordinate(pos[1])] - def screen_to_turtle_coordinates(self, x, y): + def screen_to_turtle_coordinates(self, pos): ''' The origin of the screen coordinates is the upper left corner ''' - return x - self.width / 2.0, self.invert_y_coordinate(y) + return [pos[0] - self.width / 2.0, self._invert_y_coordinate(pos[1])] - def invert_y_coordinate(self, y): + def _invert_y_coordinate(self, y): ''' Positive y goes up in turtle coordinates, down in sceeen coordinates ''' return self.height / 2.0 - y @@ -155,7 +155,7 @@ class Turtles: # if it is a new turtle, start it in the center of the screen self._active_turtle = self.get_turtle(turtle_name, True, colors) self._active_turtle.set_heading(0.0, False) - self._active_turtle.set_xy(0.0, 0.0, False, pendown=False) + self._active_turtle.set_xy((0.0, 0.0), False, pendown=False) self._active_turtle.set_pen_state(True) elif colors is not None: self._active_turtle = self.get_turtle(turtle_name, False) @@ -163,7 +163,6 @@ class Turtles: else: self._active_turtle = self.get_turtle(turtle_name, False) self._active_turtle.show() - tx, ty = self._active_turtle.get_xy() self._active_turtle.set_color(share=False) self._active_turtle.set_gray(share=False) self._active_turtle.set_shade(share=False) @@ -448,7 +447,7 @@ class Turtle: shared_poly_points = [] for p in self.poly_points: shared_poly_points.append( - (self.turtles.screen_to_turtle_coordinates(p[0], p[1]))) + (self.turtles.screen_to_turtle_coordinates(p))) event = 'F|%s' % (data_to_string( [self.turtles.turtle_window.nick, shared_poly_points])) self.turtles.turtle_window.send_event(event) @@ -471,28 +470,27 @@ class Turtle: self.label_block.spr.set_layer(TURTLE_LAYER + 1) def move_turtle(self, pos=None): + ''' Move the turtle's position ''' if pos is None: - x, y = self.get_xy() - else: - x, y = pos[0], pos[1] + pos = self.get_xy() - self.x, self.y = x, y - self.move((x, y)) + self.x, self.y = pos[0], pos[1] + self.move(pos) def move(self, pos): + ''' Move the turtle's sprite ''' # self.x, self.y = pos[0], pos[1] - x, y = self.turtles.turtle_to_screen_coordinates(pos[0], pos[1]) + pos = self.turtles.turtle_to_screen_coordinates(pos) if self.turtles.turtle_window.interactive_mode: - x -= self.spr.rect.width / 2.0 - y -= self.spr.rect.height / 2.0 + pos[0] -= int(self.spr.rect.width / 2.0) + pos[1] -= int(self.spr.rect.height / 2.0) - if not self.hidden and self.spr is not None: - self.spr.move((int(x), int(y))) - if self.label_block is not None: - self.label_block.spr.move((int(x + self.label_xy[0]), - int(y + self.label_xy[1]))) - return(self.x, self.y) + if not self.hidden and self.spr is not None: + self.spr.move(pos) + if self.label_block is not None: + self.label_block.spr.move((pos[0] + self.label_xy[0], + pos[1] + self.label_xy[1])) def right(self, degrees, share=True): ''' Rotate turtle clockwise ''' @@ -509,6 +507,21 @@ class Turtle: round_int(self.heading)])) self.turtles.turtle_window.send_event(event) + def _draw_line(self, old, new, pendown): + if self.pen_state and pendown: + self.turtles.turtle_window.canvas.set_rgb( + self.turtles.turtle_window.canvas.fgrgb[0] / 255., + self.turtles.turtle_window.canvas.fgrgb[1] / 255., + self.turtles.turtle_window.canvas.fgrgb[2] / 255.) + pos1 = self.turtles.turtle_to_screen_coordinates(old) + pos2 = self.turtles.turtle_to_screen_coordinates(new) + self.turtles.turtle_window.canvas.draw_line(pos1[0], pos1[1], + pos2[0], pos2[1]) + if self.pen_fill: + if self.poly_points == []: + self.poly_points.append(('move', pos1[0], pos1[1])) + self.poly_points.append(('line', pos2[0], pos2[1])) + def forward(self, distance, share=True): scaled_distance = distance * self.turtles.turtle_window.coord_scale @@ -517,26 +530,16 @@ class Turtle: self.turtles.turtle_window.canvas.fgrgb[1] / 255., self.turtles.turtle_window.canvas.fgrgb[2] / 255.) - oldx, oldy = self.get_xy() + old = self.get_xy() try: - xcor = oldx + scaled_distance * sin(self.heading * DEGTOR) - ycor = oldy + scaled_distance * cos(self.heading * DEGTOR) + xcor = old[0] + scaled_distance * sin(self.heading * DEGTOR) + ycor = old[1] + scaled_distance * cos(self.heading * DEGTOR) except (TypeError, ValueError): debug_output('bad value sent to %s' % (__name__), self.turtles.turtle_window.running_sugar) return - if self.pen_state: - x1, y1 = self.turtles.turtle_to_screen_coordinates(oldx, oldy) - x2, y2 = self.turtles.turtle_to_screen_coordinates(xcor, ycor) - self.turtles.turtle_window.canvas.draw_line(x1, y1, x2, y2) - if self.pen_fill: - if self.poly_points == []: - x, y = self.turtles.turtle_to_screen_coordinates(oldx, oldy) - self.poly_points.append(('move', x, y)) - x, y = self.turtles.turtle_to_screen_coordinates(xcor, ycor) - self.poly_points.append(('line', x, y)) - + self._draw_line(old, (xcor, ycor), True) self.move_turtle((xcor, ycor)) if self.turtles.turtle_window.sharing() and share: @@ -544,31 +547,18 @@ class Turtle: int(distance)])) self.turtles.turtle_window.send_event(event) - def set_xy(self, x, y, share=True, pendown=True): - oldx, oldy = self.get_xy() + def set_xy(self, pos, share=True, pendown=True): + old = self.get_xy() + try: - xcor = x * self.turtles.turtle_window.coord_scale - ycor = y * self.turtles.turtle_window.coord_scale + xcor = pos[0] * self.turtles.turtle_window.coord_scale + ycor = pos[1] * self.turtles.turtle_window.coord_scale except (TypeError, ValueError): debug_output('bad value sent to %s' % (__name__), self.turtles.turtle_window.running_sugar) return - if self.pen_state and pendown: - self.turtles.turtle_window.canvas.set_rgb( - self.turtles.turtle_window.canvas.fgrgb[0] / 255., - self.turtles.turtle_window.canvas.fgrgb[1] / 255., - self.turtles.turtle_window.canvas.fgrgb[2] / 255.) - x1, y1 = self.turtles.turtle_to_screen_coordinates(oldx, oldy) - x2, y2 = self.turtles.turtle_to_screen_coordinates(xcor, ycor) - self.turtles.turtle_window.canvas.draw_line(x1, y1, x2, y2) - if self.pen_fill: - if self.poly_points == []: - x, y = self.turtles.turtle_to_screen_coordinates(oldx, oldy) - self.poly_points.append(('move', x, y)) - x, y = self.turtles.turtle_to_screen_coordinates(xcor, ycor) - self.poly_points.append(('line', x, y)) - + self._draw_line(old, (xcor, ycor), pendown) self.move_turtle((xcor, ycor)) if self.turtles.turtle_window.sharing() and share: @@ -585,15 +575,15 @@ class Turtle: self.turtles.turtle_window.canvas.fgrgb[2] / 255.) try: if a < 0: - xcor, ycor = self.larc(-a, r) + pos = self.larc(-a, r) else: - xcor, ycor = self.rarc(a, r) + pos = self.rarc(a, r) except (TypeError, ValueError): debug_output('bad value sent to %s' % (__name__), self.turtles.turtle_window.running_sugar) return - self.move_turtle((xcor, ycor)) + self.move_turtle(pos) if self.turtles.turtle_window.sharing() and share: event = 'a|%s' % (data_to_string([self.turtles.turtle_window.nick, @@ -606,24 +596,24 @@ class Turtle: if r < 0: r = -r a = -a - xcor, ycor = self.get_xy() - cx = xcor + r * cos(self.heading * DEGTOR) - cy = ycor - r * sin(self.heading * DEGTOR) + pos = self.get_xy() + cx = pos[0] + r * cos(self.heading * DEGTOR) + cy = pos[1] - r * sin(self.heading * DEGTOR) if self.pen_state: - x, y = self.turtles.turtle_to_screen_coordinates(cx, cy) - self.turtles.turtle_window.canvas.rarc(x, y, r, a, self.heading) + npos = self.turtles.turtle_to_screen_coordinates((cx, cy)) + self.turtles.turtle_window.canvas.rarc(npos[0], npos[1], r, a, + self.heading) - if self.pen_fill: - x, y = self.turtles.turtle_to_screen_coordinates(x, y) - if self.poly_points == []: - self.poly_points.append(('move', x, y)) - self.poly_points.append(('rarc', x, y, r, - (self.heading - 180) * DEGTOR, - (self.heading - 180 + a) * DEGTOR)) + if self.pen_fill: + if self.poly_points == []: + self.poly_points.append(('move', npos[0], npos[1])) + self.poly_points.append(('rarc', npos[0], npos[1], r, + (self.heading - 180) * DEGTOR, + (self.heading - 180 + a) * DEGTOR)) self.right(a, False) - return cx - r * cos(self.heading * DEGTOR), \ - cy + r * sin(self.heading * DEGTOR) + return [cx - r * cos(self.heading * DEGTOR), + cy + r * sin(self.heading * DEGTOR)] def larc(self, a, r): ''' draw a counter-clockwise arc ''' @@ -631,24 +621,24 @@ class Turtle: if r < 0: r = -r a = -a - xcor, ycor = self.get_xy() - cx = xcor - r * cos(self.heading * DEGTOR) - cy = ycor + r * sin(self.heading * DEGTOR) + pos = self.get_xy() + cx = pos[0] - r * cos(self.heading * DEGTOR) + cy = pos[1] + r * sin(self.heading * DEGTOR) if self.pen_state: - x, y = self.turtles.turtle_to_screen_coordinates(cx, cy) - self.turtles.turtle_window.canvas.larc(x, y, r, a, self.heading) + npos = self.turtles.turtle_to_screen_coordinates((cx, cy)) + self.turtles.turtle_window.canvas.larc(npos[0], npos[1], r, a, + self.heading) - if self.pen_fill: - x, y = self.turtles.turtle_to_screen_coordinates(x, y) - if self.poly_points == []: - self.poly_points.append(('move', x, y)) - self.poly_points.append(('larc', x, y, r, - (self.heading) * DEGTOR, - (self.heading - a) * DEGTOR)) + if self.pen_fill: + if self.poly_points == []: + self.poly_points.append(('move', npos[0], npos[1])) + self.poly_points.append(('larc', npos[0], npos[1], r, + (self.heading) * DEGTOR, + (self.heading - a) * DEGTOR)) self.right(-a, False) - return cx + r * cos(self.heading * DEGTOR), \ - cy - r * sin(self.heading * DEGTOR) + return [cx + r * cos(self.heading * DEGTOR), + cy - r * sin(self.heading * DEGTOR)] def draw_pixbuf(self, pixbuf, a, b, x, y, w, h, path, share=True): ''' Draw a pixbuf ''' @@ -670,11 +660,12 @@ class Turtle: height = pixbuf.get_height() width = pixbuf.get_width() - x, y = self.screen_to_turtle_coordinates(x, y) + pos = self.screen_to_turtle_coordinates((x, y)) event = 'P|%s' % (data_to_string([self.turtles.turtle_window.nick, [round_int(a), round_int(b), - round_int(x), round_int(y), + round_int(pos[0]), + round_int(pos[1]), round_int(w), round_int(h), round_int(width), round_int(height), @@ -700,33 +691,33 @@ class Turtle: return self.name def get_xy(self): - return(self.x, self.y) + return [self.x, self.y] def get_heading(self): - return(self.heading) + return self.heading def get_color(self): - return(self.pen_color) + return self.pen_color def get_gray(self): - return(self.pen_gray) + return self.pen_gray def get_shade(self): - return(self.pen_shade) + return self.pen_shade def get_pen_size(self): - return(self.pen_size) + return self.pen_size def get_pen_state(self): - return(self.pen_state) + return self.pen_state def get_fill(self): - return(self.pen_fill) + return self.pen_fill def get_poly_points(self): - return(self.poly_points) + return self.poly_points def get_pixel(self): x, y = self.get_xy() - x, y = self.turtle_to_screen_coordinates(x, y) - return self.turtles.turtle_window.canvas.get_pixel(x, y) + pos = self.turtle_to_screen_coordinates((x, y)) + return self.turtles.turtle_window.canvas.get_pixel(pos[0], pos[1]) diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py index e4c2873..fe10a9b 100644 --- a/TurtleArt/tawindow.py +++ b/TurtleArt/tawindow.py @@ -2434,14 +2434,15 @@ before making changes to your Turtle Blocks program')) self._adjust_dock_positions(c) def _turtle_pressed(self, x, y): - x, y = self.turtles.screen_to_turtle_coordinates(x, y) print 'xy', x, y - (tx, ty) = self.selected_turtle.get_xy() - print 'txy', tx, ty + pos = self.selected_turtle.get_xy() + tpos = self.turtles.turtle_to_screen_coordinates(pos) + print 'txy', tpos[0], tpos[1] w = self.selected_turtle.spr.rect.width / 2 h = self.selected_turtle.spr.rect.height / 2 - dx = x - tx - w - dy = y - ty - h + print 'wh', w, h + dx = x - tpos[0] # - w + dy = y - tpos[1] # - h print 'dxy', dx, dy # if x, y is near the edge, rotate if not hasattr(self.lc, 'value_blocks'): @@ -2456,8 +2457,8 @@ before making changes to your Turtle Blocks program')) - atan2(dy, dx) / DEGTOR, 0) else: - print 'move', x - tx, y - ty - self.drag_turtle = ('move', x - tx, y - ty) + print 'move', x - tpos[0], y - tpos[1] + self.drag_turtle = ('move', x - tpos[0], y - tpos[1]) def _move_cb(self, win, event): x, y = xy(event) @@ -2510,28 +2511,29 @@ before making changes to your Turtle Blocks program')) # First, check to see if we are dragging or rotating a turtle. if self.selected_turtle is not None: dtype, dragx, dragy = self.drag_turtle - (sx, sy) = self.selected_turtle.get_xy() + spos = self.selected_turtle.get_xy() # self.set_turtle(self.selected_turtle.get_name()) self.update_counter += 1 if dtype == 'move': - dx = x - dragx - sx + self.selected_turtle.spr.rect.width / 2 - dy = y - dragy - sy + self.selected_turtle.spr.rect.height / 2 + dx = x - dragx - spos[0] + \ + self.selected_turtle.spr.rect.width / 2 + dy = y - dragy - spos[1] + \ + self.selected_turtle.spr.rect.height / 2 self.selected_turtle.spr.set_layer(TOP_LAYER) - tx, ty = self.turtles.screen_to_turtle_coordinates(sx + dx, - sy + dy) - debug_output('DRAG %f, %f' % (tx, ty), self.running_sugar) - if self.turtles.get_active_turtle().get_pen_state(): - self.turtles.get_active_turtle().set_pen_state(False) - self.turtles.get_active_turtle().set_xy(tx, ty, share=False) - self.turtles.get_active_turtle().set_pen_state(True) + pos = self.turtles.screen_to_turtle_coordinates( + (spos[0] + dx, spos[1] + dy)) + if self.selected_turtle.get_pen_state(): + self.selected_turtle.set_pen_state(False) + self.selected_turtle.set_xy(pos, share=False) + self.selected_turtle.set_pen_state(True) else: - self.turtles.get_active_turtle().set_xy(tx, ty, share=False) + self.selected_turtle.set_xy(pos, share=False) if self.update_counter % 5: self.lc.update_label_value( - 'xcor', self.turtles.get_active_turtle().get_xy()[0] / + 'xcor', self.selected_turtle.get_xy()[0] / self.coord_scale) self.lc.update_label_value( - 'ycor', self.turtles.get_active_turtle().get_xy()[1] / + 'ycor', self.selected.get_xy()[1] / self.coord_scale) else: dx = x - sx - self.selected_turtle.spr.rect.width / 2 @@ -2541,7 +2543,7 @@ before making changes to your Turtle Blocks program')) share=False) if self.update_counter % 5: self.lc.update_label_value( - 'heading', self.turtles.get_active_turtle().get_heading()) + 'heading', self.selected_turtle.get_heading()) if self.update_counter % 20: self.display_coordinates() self.turtle_movement_to_share = self.selected_turtle @@ -2698,11 +2700,11 @@ before making changes to your Turtle Blocks program')) # We may have been moving the turtle if self.selected_turtle is not None: - (tx, ty) = self.selected_turtle.get_xy() + tpos = self.selected_turtle.get_xy() k = self.turtles.get_turtle_key(self.selected_turtle) # Remove turtles by dragging them onto the trash palette. - if self._in_the_trash(tx, ty): + if self._in_the_trash(tpos[0], tpos[1]): # If it is the default turtle, just recenter it. if k == self.turtles.get_default_turtle_name(): self._move_turtle(0, 0) @@ -3568,12 +3570,12 @@ before making changes to your Turtle Blocks program')) x = 0 y = 0 else: - x, y = self.turtles.get_active_turtle().get_xy() - x += dx - y += dy + pos = self.turtles.get_active_turtle().get_xy() + x = pos[0] + dx + y = pos[1] + dy self.turtles.set_active_turtle( self.turtles.spr_to_turtle(self.selected_spr)) - self.turtles.get_active_turtle().move_turtle(x, y) + self.turtles.get_active_turtle().move_turtle((x, y)) self.display_coordinates() self.selected_turtle = None @@ -3739,8 +3741,8 @@ before making changes to your Turtle Blocks program')) if add_new_block: # add a new block for this code at turtle position - (tx, ty) = self.turtles.get_active_turtle().get_xy() - self._new_block('userdefined', tx, ty) + pos = self.turtles.get_active_turtle().get_xy() + self._new_block('userdefined', pos[0], pos[1]) self.myblock[self.block_list.list.index(self.drag_group[0])] =\ self.python_code self.set_userdefined(self.drag_group[0]) @@ -4140,9 +4142,10 @@ before making changes to your Turtle Blocks program')) def load_start(self, ta_file=None): ''' Start a new project with a 'start' brick ''' if ta_file is None: - self.process_data([[0, "start", PALETTE_WIDTH + 20, - self.toolbar_offset + PALETTE_HEIGHT + 20, - [None, None]]]) + self.process_data( + [[0, "start", PALETTE_WIDTH + 20, + self.toolbar_offset + PALETTE_HEIGHT + 20 + ICON_SIZE, + [None, None]]]) else: self.process_data(data_from_file(ta_file)) @@ -4217,11 +4220,11 @@ before making changes to your Turtle Blocks program')) # Save default turtle as 'Yertle' if turtle == self.nick: turtle = DEFAULT_TURTLE - x, y = self.turtles.get_active_turtle().get_xy() + pos = self.turtles.get_active_turtle().get_xy() data.append( (-1, ['turtle', turtle], - x, y, + pos[0], pos[1], self.turtles.get_active_turtle().get_heading(), self.turtles.get_active_turtle().get_color(), self.turtles.get_active_turtle().get_shade(), diff --git a/plugins/turtle_blocks_extras/turtle_blocks_extras.py b/plugins/turtle_blocks_extras/turtle_blocks_extras.py index b9b359e..a272ec8 100644 --- a/plugins/turtle_blocks_extras/turtle_blocks_extras.py +++ b/plugins/turtle_blocks_extras/turtle_blocks_extras.py @@ -1465,14 +1465,14 @@ Journal objects')) # Place the block at the active turtle (x, y) and move the turtle # into position to place the next block in the stack. # TODO: Add expandable argument - x, y = self.tw.turtles.get_active_turtle().get_xy() + pos = self.tw.turtles.get_active_turtle().get_xy() if isinstance(blkname, list): name = blkname[0] if len(blkname) > 1: value = blkname[1:] - dy = int(self._find_block(name, x, y, value)) + dy = int(self._find_block(name, pos[0], pos[1], value)) else: - dy = int(self._find_block(name, x, y)) + dy = int(self._find_block(name, pos[0], pos[1])) else: name = blkname if name == 'delete': @@ -1482,11 +1482,12 @@ Journal objects')) blk.spr.hide() dy = 0 else: - dy = int(self._find_block(name, x, y)) + dy = int(self._find_block(name, pos[0], pos[1])) # Reposition turtle to end of flow - self.tw.turtles.get_active_turtle().get_xy()[1] -= dy - self.tw.turtles.get_active_turtle().move_turtle() + pos = self.tw.turtles.get_active_turtle().get_xy() + pos[1] -= dy + self.tw.turtles.get_active_turtle().move_turtle(pos) def _make_block(self, name, x, y, defaults): if defaults is None: |