Ejemplo n.º 1
0
def gameOver(gameScene, land_1, land_2, spriteBird, upPipeCollided):
    global collision_func
    land_1.stop()
    land_2.stop()

    removeMovePipeFunc(gameScene)
    removeCalScoreFunc(gameScene)
    removeBirdTouchHandler(gameScene)
    if upPipeCollided and collision_func:
        gameScene.unschedule(collision_func)
        spriteBird.stop()
        import game_controller
        game_controller.backToMainMenu()
Ejemplo n.º 2
0
def gameOver(gameScene, land_1, land_2, spriteBird, upPipeCollided):
    #游戏结束,记录本局结果
    global update
    if not update:
        updateGameResult()
        update = True

    global collision_func
    land_1.stop()
    land_2.stop()

    removeMovePipeFunc(gameScene)
    removeCalScoreFunc(gameScene)
    removeBirdTouchHandler(gameScene)
    if upPipeCollided and collision_func:
        gameScene.unschedule(collision_func)
        spriteBird.stop()
        import game_controller
        game_controller.backToMainMenu()
Ejemplo n.º 3
0
def fix_game_result(data):
    #从服务器获取到排名,执行相关操作
    data = data['re_game_result']
    data = data.strip()
    dataList = data.split('\t')
    if len(dataList) != 4:
        print("Error: result data has error")
    bestScore = dataList[0]
    bestTime = dataList[1]
    defeat = dataList[2]
    myRank = dataList[3]
    from pipe import g_score
    import game_controller
    game_controller.setResult(str(g_score), str(bestScore), str(myRank),
                              str(defeat))
    #从服务器收到游戏结果后,显示游戏结果
    import game_controller
    game_controller.backToMainMenu()
    print "receive game rank:  ", data
Ejemplo n.º 4
0
def gameOver(gameScene, land_1, land_2, spriteBird, upPipeCollided):
    global collision_func
    land_1.stop()
    land_2.stop()
    import game_controller
    import pipe
    liveTime = time.time() - game_controller.startTime
    global isSend
    if not isSend:
        game_controller.sendResult(pipe.g_score, liveTime)
        user = game_controller.User
        output = open('./score/' + user + '_score.txt', 'a+')
        output.writelines([str(pipe.g_score), '\n', str(liveTime), '\n'])
        output.close()
        isSend = True
    print liveTime
    removeMovePipeFunc(gameScene)
    removeCalScoreFunc(gameScene)
    removeBirdTouchHandler(gameScene)
    if upPipeCollided and collision_func:
        gameScene.unschedule(collision_func)
        spriteBird.stop()
        import game_controller
        game_controller.backToMainMenu()
Ejemplo n.º 5
0
def gameOver(gameScene, land_1, land_2, spriteBird, upPipeCollided):
    global collision_func
    land_1.stop()
    land_2.stop()
    removeMovePipeFunc(gameScene)
    removeCalScoreFunc(gameScene)
    removeBirdTouchHandler(gameScene)
    if upPipeCollided and collision_func:
        gameScene.unschedule(collision_func)
        spriteBird.stop()
        # ###### yyy add 12/15/17
        import game_controller
        import pipe
        # print game_controller.getUserName(),pipe.getGameScore()
        scoreInformation = {
            'userName': game_controller.getUserName(),
            'difficulty': game_controller.getDifficulty(),
            'score': pipe.getGameScore()
        }
        storeScoreInClient(scoreInformation)
        sendScoreToServer(scoreInformation)
        # 向服务器发送请求成绩数据
        # sendScoreRequesttoServer()
        # ######
        game_controller.appendScore()
        game_controller.backToMainMenu()


# json file format:
# [
#     {
#         "userName": "******",
#         "scores": [
#             {
#                 "difficulty": 0,
#                 "scores": [
#                     1
#                 ]
#             },
#             {
#                 "difficulty": 1,
#                 "scores": [
#                     1
#                 ]
#             },
#             {
#                 "difficulty": 2,
#                 "scores": [
#                     1
#                 ]
#             }
#         ]
#     },
#     {
#         "userName": "******",
#         "scores": [
#             {
#                 "difficulty": 0,
#                 "scores": [
#                     1
#                 ]
#             },
#             {
#                 "difficulty": 1,
#                 "scores": [
#                     1
#                 ]
#             },
#             {
#                 "difficulty": 2,
#                 "scores": [
#                     1
#                 ]
#             }
#         ]
#     }
# ]