Exemple #1
0
 def __init__(self, leftGoal):
     if leftGoal:
         posX = - 1.5
     else:
         posX = FIELD_LENGTH + 1.5
     posY = FIELD_WIDTH/2
     PitchObject.__init__(self, COLOR_GOAL, posX, posY, GRAPH_GOAL_SIZE)
     PitchObject.update(self)
Exemple #2
0
    def __init__(self, playerRole, team, ball):
        self.team = team
        self.ball = ball

        self.perX = playerRole[0]
        self.perY = playerRole[1]

        self.defaultPosX = self.perX * FIELD_LENGTH / 2
        self.defaultPosY = self.perY * FIELD_WIDTH

        PitchObject.__init__(self, COLOR_ORANGE, self.defaultPosX, self.defaultPosY, STRAT_HOME_POS_SIZE)
Exemple #3
0
 def move(self):
     """
     Ensures the player does not move faster the its maximum speed and updates the player position
     """
     # if self.hasBall:
     #     if math.sqrt(self.velY**2 + self.velX**2) > (float(4)/5 * self.maxSpeed):
     #         self.velX = float(4)/5 * self.maxSpeed * self.velX/math.sqrt(self.velY**2 + self.velX**2)
     #         self.velY = float(4)/5 * self.maxSpeed * self.velY/math.sqrt(self.velY**2 + self.velX**2)
     if math.sqrt(self.velY ** 2 + self.velX ** 2) > self.maxSpeed:
         self.velX = self.maxSpeed * self.velX / math.sqrt(self.velY ** 2 + self.velX ** 2)
         self.velY = self.maxSpeed * self.velY / math.sqrt(self.velY ** 2 + self.velX ** 2)
     PitchObject.move(self)
Exemple #4
0
    def __init__(self, possessionController, scoreController, leftGoal, rightGoal):
        PitchObject.__init__(self, COLOR_BALL, self.getStartingPosX(), self.getStartingPosY(), GRAPH_BALL_SIZE)
        self.image.set_alpha(255)

        self.possessionController = possessionController
        self.scoreController = scoreController
        self.leftGoal = leftGoal
        self.rightGoal = rightGoal

        self.possessor = None
        self.prevPossessor = None
        self.isLoose = True
        self.target = None
        self.shot = False
        self.outOfPlay = "Kickoff"
Exemple #5
0
 def move(self):
     """ Rolls the ball according to its own velocity or its possessor's, and applies friction coefficient"""
     # if there is a player controlling the ball, the ball should move with that player
     if self.possessor is not None:
         # Put the ball in front of the player
         self.posX = self.possessor.posX
         self.posY = self.possessor.posY
         self.velX = self.possessor.velX
         self.velY = self.possessor.velY
         # I don't really like calling PitchObject.move() twice in one turn, but it puts the ball where I want it
         PitchObject.move(self)
     else:
         speed = (math.sqrt(self.velX**2 + self.velY**2))
         if speed > 0:
             self.velX -= self.velX * MECH_GRASS_FRICTION
             self.velY -= self.velY * MECH_GRASS_FRICTION
     PitchObject.move(self)
Exemple #6
0
    def __init__(self, color, posX, posY, size):

        self.shootingRange = ATTR_SHOOTING_RANGE
        self.hasBall = False
        self.isOffsides = False
        self.covering = []
        self.blocking = []
        self.marking = None
        self.blockedBy = []
        self.coveredBy = []

        self.recovering = 0  # If the player has recently lost the ball, they are recovering and cannot touch the ball

        self.chargeToBall = False
        self.maxSpeed = float(ATTR_PLAYER_SPEED)
        self.acceleration = float(ATTR_PLAYER_ACCEL)

        PitchObject.__init__(self, color, posX, posY, size)
Exemple #7
0
 def update(self):
     self.move()
     PitchObject.update(self)
Exemple #8
0
 def update(self, players):
     """ method called by matchturn using existing pygame.sprite implementation"""
     self.move()
     self.checkOutOfBounds()
     PitchObject.update(self)
     self.evaluateControl(players)
Exemple #9
0
 def update(self):
     if self.recovering:
         self.recovering -= 1
     self.move()
     PitchObject.update(self)
Exemple #10
0
 def getDistanceToGoalline(self, attacking):
     return PitchObject.getDistanceToGoalline(self, attacking, self.team.isDefendingLeft)