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