예제 #1
0
def MainMenu():
    renderer.erase()
    row = 0
    selectedRow = 0
    printMenu(row)
    input = GameEngine.InputHandler()
    dbgText = GameEngine.RenderObject()
    logoDrawer = GameEngine.RenderObject()
    border = GameEngine.RenderObject()
    box = GameEngine.RenderObject()
    copyrightText = "© 2019 Kelompok KebalSP - LD01 -  BINUS University @Bandung"
    copyrightDrawer = GameEngine.RenderObject()
    border.drawBorder()
    while(True):
        box.drawRect(54, 15, 12, 5, GameEngine.WR)
        border.drawBorder(GameEngine.WR)
        for yPos, lines in enumerate(title):
            logoDrawer.drawObject((renderer.xBorder//2) - 25, 5+yPos, lines, GameEngine.WR)
        copyrightDrawer.drawObject((renderer.xBorder//2) - len(copyrightText)//2, renderer.yBorder-2, copyrightText )
        key = input.getInput()
        if key == curses.KEY_UP and row > 0:
            row -= 1
        elif key == curses.KEY_DOWN and row < len(menuSelection)-1:
            row += 1
        elif key == curses.KEY_ENTER or key in [10, 13]:

            break
        printMenu(row)

    return row
예제 #2
0
def GameOver(score):
    renderer.erase()
    border = GameEngine.RenderObject()
    GameOver = GameEngine.RenderObject()
    yourName = GameEngine.InputHandler()
    border.drawBorder()
    scoreStr = "SCORE : {}".format(score)
    GameOver.drawObject((renderer.xBorder//2) - len("Game Over!")//2, renderer.yBorder//2, "Game Over!")
    GameOver.drawObject((renderer.xBorder // 2) - len(scoreStr) // 2, (renderer.yBorder // 2)+1, scoreStr)
    GameOver.drawObject((renderer.xBorder // 2) - len("Your Name:") // 2, (renderer.yBorder // 2) + 2, "Your Name: ")
    curses.echo()
    curses.curs_set(1)
    name = yourName.getStringInput(((renderer.xBorder // 2) + len("Your Name:")//2) + 1 ,  (renderer.yBorder // 2) + 2)
    curses.curs_set(0)
    curses.noecho()

    FileHandler.saveScore(name.decode("utf-8"), score)
    time.sleep(5)
    Leaderboard()
예제 #3
0
def Game():
    renderer.erase()
    Hangman = GameEngine.RenderObject()
    Answer = GameEngine.RenderObject()
    border = GameEngine.RenderObject()
    input = GameEngine.InputHandler()
    health = GameEngine.RenderObject()
    debugObj = GameEngine.RenderObject()
    hangmanState = GameEngine.RenderObject()
    GameObject = GameHandler.Game()
    score = GameEngine.RenderObject()
    hangmanBox = GameEngine.RenderObject()
    lose = False
    while(lose == False):
        currentWord = FileHandler.getWord()
        GameObject.setCurrentWord(currentWord)
        UnansweredWord = GameObject.unanswered
        spaceIndex = [i for i, x in enumerate(GameObject.wordList) if x == " "]
        for l in spaceIndex:
            UnansweredWord[l] = " "

        while(GameObject.checkifAnswerCorrect() == False):
            border.drawBorder(GameEngine.WR)
            if cheat == True:
                cheatStr = "word: {}"
                score.drawObject(1, 1, cheatStr.format(GameObject.word), GameEngine.WR)
            HighscoreStr = "SCORE : " + str(GameObject.score)
            UnansweredStr = " ".join(UnansweredWord)
            hangmanArt = GameObject.hangman[GameObject.hangmanState].splitlines()
            for yPos, lines in enumerate(hangmanArt):
                Hangman.drawObject(15, (renderer.yBorder//2) - 4 + yPos, lines, GameEngine.WR)
            hangmanBox.drawRect(28, (renderer.yBorder//2)-4 , 12, 10)
            score.drawObject(renderer.xBorder//2 - len(HighscoreStr)//2, 1, HighscoreStr, GameEngine.WR)
            #health.drawObject(2,2, str(GameObject.health), GameEngine.WR)
            #hangmanState.drawObject(2,3, str(GameObject.hangmanState), GameEngine.WR) #DEBUG
            Answer.drawObject((renderer.xBorder // 2), (renderer.yBorder // 2) - 5, UnansweredStr.upper(), GameEngine.WR)
            renderer.refresh()
            ans = chr(input.getInput())
            #index = GameObject.wordList.index(ans)
            index = [i for i, x in enumerate(GameObject.wordList) if x == ans]
            if index == []:
                GameObject.damagePlayer()
            for j in index:
                UnansweredWord[j] = ans
                GameObject.score += len(ans) * 10
            #debugObj.drawObject(2, 5, str(UnansweredWord), GameEngine.WR)
            renderer.refresh()
            renderer.updateFrame()
            if (GameObject.health == 0):
                border.drawBorder(GameEngine.WR)
                HighscoreStr = "SCORE : " + str(GameObject.score)
                UnansweredStr = " ".join(GameObject.word)
                hangmanArt = GameObject.hangman[GameObject.hangmanState].splitlines()
                for yPos, lines in enumerate(hangmanArt):
                    Hangman.drawObject(15, (renderer.yBorder // 2) - 4 + yPos, lines, GameEngine.WR)
                hangmanBox.drawRect(28, (renderer.yBorder // 2) - 4, 12, 10)
                score.drawObject(renderer.xBorder // 2 - len(HighscoreStr) // 2, 1, HighscoreStr, GameEngine.WR)
                Answer.drawObject((renderer.xBorder // 2), (renderer.yBorder // 2) - 5, UnansweredStr.upper(),
                                  GameEngine.WR)
                renderer.refresh()
                renderer.updateFrame()
                time.sleep(5)
                return GameObject.score


        GameObject.score += 100