Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- Class file for pong game (Swift Pong)
- '''
- #!/usr/bin/python
- import string
- class Pong:
- def __init__(self):
- # Scores of the player and the AI
- self.p1_score = 0
- self.ai_score = 0
- # The next three variables deal with the width and color of the net
- self.lineColor = (255,255,255)
- self.net1 = (450,0)
- self.net2 = (450,900)
- self.netWidth = 4
- def score_change(self, change):
- if not change:
- self.ai_score += 1 # if p1 didn't score, increase ai total
- else:
- self.p1_score += 1 # if ai didn't score, increase p1 total
- # if return 0 then ai wins, 1, then p1 wins, else then it returns 2
- def check_win(self):
- if self.ai_score == 11:
- return 0
- elif self.p1_score == 11:
- return 1
- else:
- return 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement