ball
Define the football used in the game
Ball Objects
class Ball()
Implement the football used in the game
__init__
| __init__(pos, sound=True)
Initialize the Football
Attributes:
pos
Point - the initial position of the ball
draw
| draw(win, cam, debug=False)
Draw the football
Attributes:
win
pygame.display - Window on which to drawdebug
bool - If enabled, show the square used to approximate the ball as well as a red border whenever the ball is not free
reset
| reset(pos)
Reset the ball
Attributes:
pos
Point - the initial position of the ball
goal_check
| goal_check(stats)
Check if a goal is scored
Attributes:
stats
Stats - Keep track of game statistics for the pause menu
update_stats
| update_stats(stats, player=None, goal=None, side=None)
Sync ball statistics with the global variables
Attributes:
player
Agent - Player that received the ballgoal
bool - True if a goal is scoredside
int - id of the team which conceded the goal
Activates when a player receives the ball or during a goal attempt
- Possession: +1 if same team pass is recorded
- Pass: +1 to 'succ' if same team pass is recorded +1 to 'fail' if diff team pass is recorded
- Shot: +1 to 'succ' if a goal is scored +1 to 'fail' if goal is not scored (out of bounds) / keeper stops the ball Does not apply if player shoots towards his own goal
ball_player_collision
| ball_player_collision(team, stats)
Check if the ball has been captured by a player
Attributes:
team
Team - The team for which to checkstats
Stats - Keep track of game statistics for the pause menu
check_capture
| check_capture(team1, team2, stats)
If the ball is not free, move the ball along with the player rather than on it's own
Attributes:
team1
Team - Team facing rightteam2
Team - Team facing leftstats
Stats - Keep track of game statistics for the pause menu
update
| update(team1, team2, action1, action2, stats)
Update the ball's (in-game) state according to specified action
Attributes:
team1
Team - Team facing rightteam2
Team - Team facing leftaction1
list - Actions of team 1action2
list - Actions of team 2stats
Stats - Keep track of game statistics for the pause menu
Calls check_capture()
and goal_check()