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)
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)