class GameSpace: #Set up gamespace def setup(self): pygame.init() self.size=self.width,self.height=1250,600 self.black=0,0,0 self.player1=None self.player2=None self.b_run = 1 self.puck=Puck(self) self.p1score=0 self.p2score=0 self.scoretimer=SCORE_TIME+1 #determines how long to show score message self.win=0 #indicates if a player has won self.winscore=7 #score needed to win #Add player 1 to game def addPlayer1(self): self.player1=Player(self,1) #Add player 2 to game def addPlayer2(self): self.player2=Player(self,2) #Increase score after a goal def updateScore(self,p1,p2): self.p1score+=p1 self.p2score+=p2 print "P1: "+str(self.p1score)+" P2: "+str(self.p2score) self.scoretimer=0 if self.p1score==self.winscore: self.win=1 elif self.p2score==self.winscore: self.win=2 self.puck.reset() #Iterate - tick game objects def gameLoop(self, p1data, p2data): self.scoretimer+=1 if self.player1!=None: self.player1.tick(p1data) if self.player2!=None: self.player2.tick(p2data) self.puck.tick()