|
|
|
@ -44,7 +44,8 @@ class IsometricGame: |
|
|
|
self.menu = Menu(self.canvas, tearoff=0) |
|
|
|
self.menu = Menu(self.canvas, tearoff=0) |
|
|
|
self.window.bind('<KeyRelease>', self.on_key_press) |
|
|
|
self.window.bind('<KeyRelease>', self.on_key_press) |
|
|
|
self.canvas.bind('<Button-1>', self.on_canvas_click) |
|
|
|
self.canvas.bind('<Button-1>', self.on_canvas_click) |
|
|
|
self.canvas.bind('<Button-3>', self.on_canvas_rclick) |
|
|
|
self.canvas.bind('<Button-3>', self.on_canvas_right_click) |
|
|
|
|
|
|
|
self.canvas.bind('<Double-Button-3>', self.on_canvas_double_right_click) |
|
|
|
self.canvas.bind('<Motion>', self.calculate_coordinates) |
|
|
|
self.canvas.bind('<Motion>', self.calculate_coordinates) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -238,7 +239,20 @@ class IsometricGame: |
|
|
|
self.draw_battlefield() |
|
|
|
self.draw_battlefield() |
|
|
|
self.draw_units() |
|
|
|
self.draw_units() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def on_canvas_right_click(self, event): |
|
|
|
|
|
|
|
# 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 0 <= cell_x < self.width and 0 <= cell_y < self.height: |
|
|
|
|
|
|
|
self.knight.move_to((cell_x, cell_y)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def on_canvas_double_right_click(self, event): |
|
|
|
|
|
|
|
# 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="darkblue")) |
|
|
|
|
|
|
|
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): |
|
|
|
def set_tile(self, name, pos): |
|
|
|
# Handle option 1 selection |
|
|
|
# Handle option 1 selection |
|
|
|
@ -250,15 +264,6 @@ class IsometricGame: |
|
|
|
self.draw_battlefield() |
|
|
|
self.draw_battlefield() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def on_canvas_rclick(self, event): |
|
|
|
|
|
|
|
# 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): |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
if 0 <= cell_x < self.width and 0 <= cell_y < self.height: |
|
|
|
|
|
|
|
self.knight.run_to((cell_x, cell_y)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def run(self): |
|
|
|
def run(self): |
|
|
|
self.draw_battlefield() |
|
|
|
self.draw_battlefield() |
|
|
|
self.update() |
|
|
|
self.update() |
|
|
|
|