Zaktualizuj 'tractor.py'
This commit is contained in:
parent
1b88dd6cb9
commit
3067eda937
@ -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,6 +51,8 @@ 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]:
|
||||
|
Loading…
Reference in New Issue
Block a user