|
|
|
@ -14,7 +14,8 @@ class MiceMaze(controls.KeyBindings): |
|
|
|
self.audio = True |
|
|
|
self.audio = True |
|
|
|
self.cell_size = 40 |
|
|
|
self.cell_size = 40 |
|
|
|
self.full_screen = False |
|
|
|
self.full_screen = False |
|
|
|
self.engine = engine.GameWindow(self.map.width, self.map.height, self.cell_size, "Mice!", key_callback=self.key_pressed) |
|
|
|
self.engine = engine.GameWindow(self.map.width, self.map.height, |
|
|
|
|
|
|
|
self.cell_size, "Mice!", key_callback=(self.key_pressed, self.key_released)) |
|
|
|
self.pointer = (random.randint(1, self.map.width-2), random.randint(1, self.map.height-2)) |
|
|
|
self.pointer = (random.randint(1, self.map.width-2), random.randint(1, self.map.height-2)) |
|
|
|
self.scroll_cursor() |
|
|
|
self.scroll_cursor() |
|
|
|
self.points = 0 |
|
|
|
self.points = 0 |
|
|
|
@ -106,6 +107,7 @@ class MiceMaze(controls.KeyBindings): |
|
|
|
unit.collisions() |
|
|
|
unit.collisions() |
|
|
|
unit.draw() |
|
|
|
unit.draw() |
|
|
|
self.engine.update_status(f"Mice: {len(self.units)} - Points: {self.points}") |
|
|
|
self.engine.update_status(f"Mice: {len(self.units)} - Points: {self.points}") |
|
|
|
|
|
|
|
self.scroll() |
|
|
|
self.engine.new_cycle(50, self.update_maze) |
|
|
|
self.engine.new_cycle(50, self.update_maze) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -155,14 +157,15 @@ class MiceMaze(controls.KeyBindings): |
|
|
|
|
|
|
|
|
|
|
|
def start_scrolling(self, direction): |
|
|
|
def start_scrolling(self, direction): |
|
|
|
self.scrolling_direction = direction |
|
|
|
self.scrolling_direction = direction |
|
|
|
self.scrolling = True |
|
|
|
if not self.scrolling: |
|
|
|
self.scroll() |
|
|
|
self.scrolling = 1 |
|
|
|
|
|
|
|
|
|
|
|
def stop_scrolling(self): |
|
|
|
def stop_scrolling(self): |
|
|
|
self.scrolling = False |
|
|
|
self.scrolling = 0 |
|
|
|
|
|
|
|
|
|
|
|
def scroll(self): |
|
|
|
def scroll(self): |
|
|
|
if self.scrolling: |
|
|
|
if self.scrolling: |
|
|
|
|
|
|
|
if not self.scrolling % 5: |
|
|
|
if self.scrolling_direction == "Up": |
|
|
|
if self.scrolling_direction == "Up": |
|
|
|
self.scroll_cursor(y=-1) |
|
|
|
self.scroll_cursor(y=-1) |
|
|
|
elif self.scrolling_direction == "Down": |
|
|
|
elif self.scrolling_direction == "Down": |
|
|
|
@ -171,7 +174,7 @@ class MiceMaze(controls.KeyBindings): |
|
|
|
self.scroll_cursor(x=-1) |
|
|
|
self.scroll_cursor(x=-1) |
|
|
|
elif self.scrolling_direction == "Right": |
|
|
|
elif self.scrolling_direction == "Right": |
|
|
|
self.scroll_cursor(x=1) |
|
|
|
self.scroll_cursor(x=1) |
|
|
|
self.engine.new_cycle(100, self.scroll) |
|
|
|
self.scrolling += 1 |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
if __name__ == "__main__": |
|
|
|
|
|
|
|
|
|
|
|
|