Advertisement
Guest User

Main class for swift pong

a guest
Mar 2nd, 2013
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. '''
  2. Class file for pong game   (Swift Pong)
  3. '''
  4. #!/usr/bin/python
  5. import string
  6.  
  7. class Pong:
  8.     def __init__(self):
  9.         # Scores of the player and the AI
  10.         self.p1_score = 0
  11.         self.ai_score = 0
  12.    
  13.         # The next three variables deal with the width and color of the net
  14.         self.lineColor = (255,255,255)
  15.         self.net1 = (450,0)
  16.         self.net2 = (450,900)
  17.         self.netWidth = 4
  18.    
  19.    
  20.     def score_change(self, change):
  21.         if not change:
  22.             self.ai_score += 1    # if p1 didn't score, increase ai total
  23.         else:
  24.             self.p1_score += 1    # if ai didn't score, increase p1 total
  25.            
  26.  
  27.     # if return 0 then ai wins, 1, then p1 wins, else then it returns 2
  28.     def check_win(self):
  29.         if self.ai_score == 11:
  30.             return 0
  31.         elif self.p1_score == 11:
  32.             return 1
  33.         else:
  34.             return 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement