ruch_traktor_bfs #12

Merged
s481834 merged 2 commits from ruch_traktor_bfs into BFS 2024-04-12 20:44:17 +02:00
Showing only changes of commit 18d2fdbb49 - Show all commits

View File

@ -1,3 +1,4 @@
import time
import pygame
import random
import displayControler as dCon
@ -41,6 +42,7 @@ class Tractor:
}
self.direction = direction_map[self.direction]
self.current_tractor_image = self.tractor_images[self.direction]
self.draw_tractor()
def turn_right(self):
# zmiana kierunku w prawo
@ -52,6 +54,7 @@ class Tractor:
}
self.direction = direction_map[self.direction]
self.current_tractor_image = self.tractor_images[self.direction]
self.draw_tractor()
def move_forward(self, pole):
next_slot_coordinates = None
@ -71,6 +74,7 @@ class Tractor:
# sprawdzenie czy następny slot jest dobry
if next_slot_coordinates and pole.is_valid_move(next_slot_coordinates):
next_slot = pole.get_slot_from_cord(next_slot_coordinates)
self.slot.redraw_image()
self.slot = next_slot
self.draw_tractor()
@ -78,6 +82,7 @@ class Tractor:
# losowanie skrętu
turn_direction = random.choice([self.turn_left, self.turn_right])
turn_direction()
time.sleep(0.5)
# wykonanie ruchu do przodu z uwzględnieniem aktualnej orientacji
self.move_forward(pole)