def event_moved(self): """ Called when an object coordinate has changed """ if not self._coord is None: coord = "%s %s" % (self._coord[0], self._coord[1]) self.owner.transport.send(mf(10, coord=coord))
def msg_received(self, m): if m.id == 6: self.world_size = Coord(*[int(x) for x in m.size.split("x")]) if m.id == 10: self.coord = Coord(*[int(x) for x in m.coord.split(" ")]) self.react_move = True if self.react_move and not(self.world_size is None): moves = { str(Coord(0,0)): Coord(self.world_size[0], 0), str(Coord(self.world_size[0], 0)): Coord(0, self.world_size[1]), str(Coord(self.world_size[0], self.world_size[1])): Coord(-20, 0), str(Coord(0, self.world_size[1])): Coord(0, -20) } if str(self.coord) in moves.keys(): self.transport.send(mf(8, coord=moves[str(self.coord)])) self.react_move = False