fix: tractor does not explode after seeing dynia anymore
This commit is contained in:
parent
c341c02249
commit
eb34cbfab3
@ -1 +0,0 @@
|
||||
,adam,adam-thinkpad,12.05.2024 17:16,file:///home/adam/.config/libreoffice/4;
|
@ -20,7 +20,7 @@ class Tile(pygame.sprite.Sprite):
|
||||
vegetables = tractor_kb.query(pl.Expr("warzywo(Nazwa_warzywa)"))
|
||||
random_vegetable = vegetables[random.randint(0, len(vegetables)-1)]['Nazwa_warzywa']
|
||||
|
||||
if random_vegetable in {'cebula','pietruszka','bób'}:
|
||||
if random_vegetable in {'cebula','pietruszka','bób', 'dynia'}:
|
||||
random_vegetable = 'marchew'
|
||||
|
||||
self.set_type(random_vegetable)
|
||||
|
@ -110,6 +110,31 @@ class Tractor(pygame.sprite.Sprite):
|
||||
self.rect.x += TILE_SIZE
|
||||
# self.log_info()
|
||||
|
||||
def move_rotating(self):
|
||||
if self.direction == "north":
|
||||
if self.rect.y > 0:
|
||||
self.rect.y -= TILE_SIZE
|
||||
else:
|
||||
self.rotate('left')
|
||||
self.rect.x -= TILE_SIZE
|
||||
elif self.direction == "south":
|
||||
if self.rect.y < 15 * TILE_SIZE:
|
||||
self.rect.y += TILE_SIZE
|
||||
else:
|
||||
self.rotate('left')
|
||||
self.rect.x += TILE_SIZE
|
||||
elif self.direction == "west":
|
||||
if self.rect.x > 0:
|
||||
self.rect.x -= TILE_SIZE
|
||||
else:
|
||||
self.rotate('left')
|
||||
self.rect.y += TILE_SIZE
|
||||
elif self.direction == "east":
|
||||
if self.rect.x < 15 * TILE_SIZE:
|
||||
self.rect.x += TILE_SIZE
|
||||
else:
|
||||
self.rotate('left')
|
||||
self.rect.y -= TILE_SIZE
|
||||
|
||||
def update(self):
|
||||
# A STAR:
|
||||
@ -129,11 +154,11 @@ class Tractor(pygame.sprite.Sprite):
|
||||
action = self.make_decision()
|
||||
self.prev_action = action
|
||||
if self.prev_action is not None and self.prev_action != 'move':
|
||||
self.move()
|
||||
self.move_rotating()
|
||||
self.prev_action = 'move'
|
||||
match (action):
|
||||
case ('move'):
|
||||
self.move()
|
||||
self.move_rotating()
|
||||
case ('harvest'):
|
||||
self.get_current_tile().set_type('grass')
|
||||
case ('water'):
|
||||
@ -151,7 +176,7 @@ class Tractor(pygame.sprite.Sprite):
|
||||
case ('plant(cukinia)'):
|
||||
self.get_current_tile().set_type('cukinia')
|
||||
case ('plant(dynia)'):
|
||||
self.get_current_tile().set_type('dynia')
|
||||
self.get_current_tile().set_type('fasola')
|
||||
case ('plant(fasola)'):
|
||||
self.get_current_tile().set_type('fasola')
|
||||
case ('plant(groch)'):
|
||||
@ -192,7 +217,6 @@ class Tractor(pygame.sprite.Sprite):
|
||||
print(action)
|
||||
return
|
||||
|
||||
|
||||
def log_info(self):
|
||||
# print on what tile type the tractor is on
|
||||
x = self.rect.x // TILE_SIZE
|
||||
|
Loading…
Reference in New Issue
Block a user