diff --git a/main.py b/main.py index b801d5c..144a459 100644 --- a/main.py +++ b/main.py @@ -45,6 +45,7 @@ class IsometricGame: self.window.bind('', self.on_key_press) self.canvas.bind('', self.on_canvas_click) self.canvas.bind('', self.on_canvas_rclick) + self.canvas.bind('', self.on_canvas_double_rclick) self.canvas.bind('', self.calculate_coordinates) @@ -238,7 +239,15 @@ class IsometricGame: self.draw_battlefield() self.draw_units() - + def on_canvas_double_rclick(self, event): + print("Double right click") + # calculate the clicked cell's coordinates + cell_x, cell_y = self.inv_iso_transform(event.x, event.y) + self.effects.append(OrderClick(self.iso_transform(cell_x, cell_y),color="lightblue")) + if self.knight.target == (cell_x, cell_y) and self.knight.state == "Run": + return + if 0 <= cell_x < self.width and 0 <= cell_y < self.height: + self.knight.run_to((cell_x, cell_y)) def set_tile(self, name, pos): # Handle option 1 selection @@ -257,7 +266,7 @@ class IsometricGame: if self.knight.target == (cell_x, cell_y): return if 0 <= cell_x < self.width and 0 <= cell_y < self.height: - self.knight.run_to((cell_x, cell_y)) + self.knight.move_to((cell_x, cell_y)) def run(self): self.draw_battlefield()