diff --git a/tractor.py b/tractor.py index 6716e0c..8ba6bc4 100644 --- a/tractor.py +++ b/tractor.py @@ -17,16 +17,19 @@ from colors import * from sprites import * class Tractor(pygame.sprite.Sprite): - def __init__(self, field): + def __init__(self, field, position): super(Tractor, self).__init__() self.surf = pygame.Surface((WIDTH, HEIGHT)) self.surf = tractor_img_0 - self.position = field.position + self.position = position + self.field = field self.rect = self.surf.get_rect( topleft=((MARGIN + WIDTH) * self.position[0] + MARGIN, (MARGIN + HEIGHT) * self.position[1] + MARGIN)) self.direction = [1, 0] + self.field[self.position[0]][self.position[1]].tractor_there = True def move(self): + self.field[self.position[0]][self.position[1]].tractor_there = False self.rect.move_ip(self.direction[0]*(WIDTH + MARGIN), self.direction[1]*(HEIGHT + MARGIN)) self.position[0] += self.direction[0] self.position[1] += self.direction[1] @@ -48,7 +51,9 @@ class Tractor(pygame.sprite.Sprite): if self.rect.right > SCREEN_WIDTH-MARGIN: self.rect.right = SCREEN_WIDTH-MARGIN + self.field[self.position[0]][self.position[1]].tractor_there = True + def rotate_right(self): if self.direction == [1, 0]: self.direction = [0, 1]