generated from mwc/project_game
I will finish the rest of the project at home
This commit is contained in:
10
catcher.py
10
catcher.py
@@ -8,7 +8,7 @@ class CatcherPiece:
|
||||
|
||||
def play_turn(self, game):
|
||||
fruit = game.get_agent_by_name("fruit")
|
||||
if new_position == fruit.position:
|
||||
if self.position == fruit.position:
|
||||
game.state['Score'] += 1
|
||||
|
||||
class Catcher:
|
||||
@@ -36,6 +36,14 @@ class Catcher:
|
||||
if x + self.width < width:
|
||||
self.position = (x+1, y)
|
||||
self.update_piece_positions()
|
||||
self.checkforfruitcollision(game)
|
||||
|
||||
def checkforfruitcollision(self, game):
|
||||
for piece in self.pieces:
|
||||
if piece.collision(game):
|
||||
game.remove_agent(fruit)
|
||||
game.state['Score'] += 1
|
||||
|
||||
|
||||
def create_pieces(self, game):
|
||||
x, y = self.position
|
||||
|
||||
Reference in New Issue
Block a user