Changing Screen After hitting specific score

222
November 27, 2017, at 9:25 PM

I'm trying to change my Game screen into the Game Over Screen once one player hits a score of 3. In my pong file, I have the following. Gameover_state is a global variable.

def main():
while running:
    #Code and event based things 
    #if the score reaches 3, then the game is over
    if player_paddle.score == 3 or ai_paddle.score == 3:
        gameover_state = True

In my screens file which controls how screens change to another, I have this in my Gamestate screen:

class GameScene(SceneBase):
    def __init__(self):
        SceneBase.__init__(self)

    def ProcessInput(self, events, pressed_keys):
        for event in events:
            if event.type == pygame.KEYDOWN and event.key == pygame.K_RETURN:
                # Move to the next scene when the user pressed Enter 
                self.SwitchToScene(GameOverScene())
            if event.type == pygame.KEYUP:
                print("You are hitting up!") 
                print(self.next)

    def Update(self):
        #pongtry4.main()

        if pongtry4.gameover_state == True:
            self.SwitchToScene(GameOverScene())
        pongtry4.main()
    def Render(self, screen):
        # The game scene is just a blank blue screen 
        #screen.fill((0, 0, 255))
        pass

I've tried debugging and my gameover_state eventually returns true after either ai or player gets 3. However, the gamestate doesn't change properly to the game over screen. Is the problem the order of how I call pongtry4.main() or something else? Thanks.

Rent Charter Buses Company
READ ALSO
My Sql Query to copy value inside a column

My Sql Query to copy value inside a column

i have a problem with create a sql queryi have this situation

195
Can't add nodes to galera mariadb 10.1 cluster

Can't add nodes to galera mariadb 10.1 cluster

I'm trying to setup a galera MariaDB 101 cluster on Centos 7

216
Division Operation: How can i use select statement to produce result given in description?

Division Operation: How can i use select statement to produce result given in description?

Question: identify all clients who have viewed all properties with three rooms

152