From fbe6a7e386e36f8926d5c473e06c63c848ad3886 Mon Sep 17 00:00:00 2001 From: tafit0902 Date: Sun, 14 Apr 2024 00:13:27 +0200 Subject: [PATCH] poprawa obrotu traktora --- App.py | 2 +- Tractor.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/App.py b/App.py index 4a92366..9ae7626 100644 --- a/App.py +++ b/App.py @@ -41,7 +41,7 @@ def init_demo(): #Demo purpose bfsRoot.reverse() print(bfsRoot) # ui.render_text(string_to_print="traktor porusza się ścieżką bfs") - traktor.move_by_root(bfsRoot, pole, traktor.irrigateSlot) + traktor.move_by_root(bfsRoot, pole, [traktor.irrigateSlot]) start_flag=False # demo_move() old_info=get_info(old_info) diff --git a/Tractor.py b/Tractor.py index 0e8aa5a..8cbee1f 100644 --- a/Tractor.py +++ b/Tractor.py @@ -207,15 +207,18 @@ class Tractor: for event in pygame.event.get(): if event.type == pygame.QUIT: quit() - def move_by_root(self, root, pole, action): + def move_by_root(self, root, pole, actions = None): for move in root: + self.slot.redraw_image() if move == 'forward': self.move_forward(pole) if move == 'right': self.turn_right() if move == 'left': self.turn_left() - action() + for a in actions: + a() + self.clock.tick(3) #to tak zrobiłam już na później, może się przyda