Ejemplo n.º 1
0
        currentFood = myFood.getFoodXY()

        #If the snake eats the food
        if currentFood == currentSnakeHead:
            mySoundMgr.playEat()
            mySnake.moveSnake(newD, True)
            myFood.moveFood(mySnake.getBodylist())
            myStage.updateScore(1)
        else:
            mySnake.moveSnake(newD, False)

        #If the snake eats itself or hits the bounds(if BOUNDS on)
        if mySnake.isGameOver():
            onOverScreen = True
            mySoundMgr.stopBackground()
            mySoundMgr.playCollide()
        elif myStage.isGameWon():  #If the player has scored winning points
            onWonScreen = True
            mySoundMgr.stopBackground()
            mySoundMgr.playWinning()
        else:
            myStage.refreshStage()
            myFood.renderFood()
            mySnake.renderSnake()

    if onOverScreen == True:
        myStage.gameOver()
    if onWonScreen == True:
        myStage.gameWon()
    display.flip()
    sleepDuration = max(