Merge remote-tracking branch 'origin/master'
# Conflicts: # src/constants.py
This commit is contained in:
commit
e66690e37d
@ -8,6 +8,7 @@ class Constants:
|
||||
LEFT = [-1, 0]
|
||||
ROTATE_RIGHT = "rotate_right"
|
||||
ROTATE_LEFT = "rotate_left"
|
||||
TURN_AROUND = 'turn_around'
|
||||
|
||||
# Technical terms
|
||||
|
||||
|
@ -70,6 +70,30 @@ class Tractor(Sprite):
|
||||
|
||||
pygame.time.wait(self.settings.freeze_time) # bez tego sie kreci jak hot-wheels
|
||||
|
||||
def turn_around(self):
|
||||
if self.curr_direction == C.UP:
|
||||
self.curr_direction = C.DOWN
|
||||
self.image = pygame.transform.scale(
|
||||
pygame.image.load('assets/images/tractor/tractor-transparent-down.png'),
|
||||
(self.settings.tile_size, self.settings.tile_size))
|
||||
elif self.curr_direction == C.LEFT:
|
||||
self.curr_direction = C.RIGHT
|
||||
self.image = pygame.transform.scale(
|
||||
pygame.image.load('assets/images/tractor/tractor-transparent-right.png'),
|
||||
(self.settings.tile_size, self.settings.tile_size))
|
||||
elif self.curr_direction == C.DOWN:
|
||||
self.curr_direction = C.UP
|
||||
self.image = pygame.transform.scale(
|
||||
pygame.image.load('assets/images/tractor/tractor-transparent-up.png'),
|
||||
(self.settings.tile_size, self.settings.tile_size))
|
||||
elif self.curr_direction == C.RIGHT:
|
||||
self.curr_direction = C.LEFT
|
||||
self.image = pygame.transform.scale(
|
||||
pygame.image.load('assets/images/tractor/tractor-transparent-left.png'),
|
||||
(self.settings.tile_size, self.settings.tile_size))
|
||||
|
||||
pygame.time.wait(self.settings.freeze_time) # bez tego sie kreci jak hot-wheels
|
||||
|
||||
def move(self):
|
||||
self.rect.x += self.curr_direction[0] * self.settings.tractor_speed
|
||||
self.rect.y -= self.curr_direction[1] * self.settings.tractor_speed
|
||||
@ -139,6 +163,8 @@ class Tractor(Sprite):
|
||||
self.turn_right()
|
||||
elif action == C.ROTATE_LEFT:
|
||||
self.turn_left()
|
||||
elif action == C.TURN_AROUND:
|
||||
self.turn_around()
|
||||
elif action == C.MOVE:
|
||||
self.move()
|
||||
|
||||
|
@ -48,6 +48,10 @@ class Node:
|
||||
temp_direction = [temp_direction[1], -temp_direction[0]]
|
||||
action_list.append((C.ROTATE_RIGHT, ((x, y), temp_direction)))
|
||||
|
||||
temp_direction = self.agent_direction
|
||||
temp_direction = [-temp_direction[0], -temp_direction[1]]
|
||||
action_list.append((C.TURN_AROUND, ((x, y), temp_direction)))
|
||||
|
||||
if self.agent_direction == C.RIGHT and x < 9:
|
||||
action_list.append((C.MOVE, ((x + 1, y), self.agent_direction)))
|
||||
elif self.agent_direction == C.LEFT and x > 0:
|
||||
|
Loading…
Reference in New Issue
Block a user