Exemplo n.º 1
0
 def draw_score(self):
     size = 50
     xcoord = self.surface.get_width() - uaio.get_width(
         str(self.ball.right_score), size)
     uaio.draw_string(str(self.ball.left_score), self.surface, (0, 0), size)
     uaio.draw_string(str(self.ball.right_score), self.surface, (xcoord, 0),
                      size)
Exemplo n.º 2
0
def main():

    # create window
    pygame.init()
    surfaceX=800
    surfaceY=800
    surface = pygame.display.set_mode((surfaceX, surfaceY), 0, 0)
    pygame.display.set_caption('Hacker!!!')
    
    # display instructions
    textX=0;
    textY=0;
    instructions = ['A group of possible passwords will be displayed.','You must guess the password. You have at most 4 guesses.','If you are incorrect you will be told how many letters in','your guess were exactly the correct location of the password.']
    height=uaio.get_height('Test.')
    for  instruction in instructions:
        uaio.draw_string(instruction, surface, (textX, textY))
        textY = textY + height     
    
    # display words
    words = ['PROVIDE', 'SETTING', 'CANTINA', 'CUTTING', 'HUNTERS', 'SURVIVE', 'HEARING', 'HUNTING', 'REALIZE', 'NOTHING', 'OVERLAP', 'FINDING', 'PUTTING']
    answer = 'SURVIVE' 
    for  word in words:
        uaio.draw_string(word, surface, (textX, textY))
        textY = textY + height

   
    
    #check answer 
    numberGuesses = 4 
    guess = uaio.input_string('Enter Password (' + str(numberGuesses) + ' guesses remaining)>', surface, (textX, textY))
    textY = textY + height
    
    while numberGuesses > 0:
        if guess == answer:
            numberGuesses = 0
        else:
            numberGuesses = numberGuesses - 1
            if numberGuesses > 0:
                uaio.draw_string('Password Incorrect', surface, (textX, textY))
                textY = textY + height            
                guess = uaio.input_string('Enter Password (' + str(numberGuesses) + ' guesses remaining)>', surface, (textX, textY))
                textY = textY + height
            
    
    #display result
    if  guess == answer:
        uaio.draw_string('User login successful', surface, (textX, textY))
    else:
        uaio.draw_string('User login unsuccessful', surface, (textX, textY))
    
    
    textY = surfaceY - height
    uaio.input_string('Press enter to exit', surface, (textX, textY))
    
    # end game
    pygame.quit()
Exemplo n.º 3
0
def displayResult(surface, location, win):
    #display result
    height = uaio.get_height("Test.")
    if win:
        uaio.draw_string('User login successful', surface, location)
    else:
        uaio.draw_string('User login unsuccessful', surface, location)
    surfaceHeight = pygame.Surface.get_height(surface)
    location[1] = surfaceHeight - height
    uaio.input_string('Press enter to exit', surface, location)
    endGame()
Exemplo n.º 4
0
def displayWords(surface, location):
    # display words
    words = [
        'PROVIDE', 'SETTING', 'CANTINA', 'CUTTING', 'HUNTERS', 'SURVIVE',
        'HEARING', 'HUNTING', 'REALIZE', 'NOTHING', 'OVERLAP', 'FINDING',
        'PUTTING'
    ]
    height = uaio.get_height('TEST')
    for word in words:
        uaio.draw_string(word, surface, location)
        location[1] = location[1] + height
    return location
Exemplo n.º 5
0
def displayInstructions(surface, location):
    # display instructions
    instructions = [
        'A group of possible passwords will be displayed.',
        'You must guess the password. You have at most 4 guesses.',
        'If you are incorrect you will be told how many letters in',
        'your guess were exactly the correct location of the password.'
    ]
    height = uaio.get_height('Test.')
    for instruction in instructions:
        uaio.draw_string(instruction, surface, location)
        location[1] = location[1] + height
    return location
Exemplo n.º 6
0
def checkAnswer(surface, location):
    #check answer
    numberGuesses = 4
    words = [
        'PROVIDE', 'SETTING', 'CANTINA', 'CUTTING', 'HUNTERS', 'SURVIVE',
        'HEARING', 'HUNTING', 'REALIZE', 'NOTHING', 'OVERLAP', 'FINDING',
        'PUTTING'
    ]
    answerPosition = random.randint(0, len(words) - 1)
    answer = words[answerPosition]
    print(answer)
    height = uaio.get_height('TEST')

    while numberGuesses > 0:
        guess = promptForGuess(surface, numberGuesses, location)
        location[1] = location[1] + height
        correctLetters = 0  #the number of correct letters in the guess
        indexRange = min(len(answer), len(guess))
        for index in range(indexRange):
            if guess[index] == answer[index]:
                correctLetters = correctLetters + 1

        if correctLetters == len(
                answer):  #player guesses all the correct letters
            numberGuesses = 0
        else:
            numberGuesses = numberGuesses - 1
            if numberGuesses > 0:
                uaio.draw_string('Password Incorrect', surface, location)
                location[1] = location[1] + height
                uaio.draw_string(
                    str(correctLetters) + '/' + str(len(answer)) + ' correct.',
                    surface, location)
                location[1] = location[1] + height

    return correctLetters == len(
        answer)  #this statement evalutes to either true or false
Exemplo n.º 7
0
def main():

    # create window
    pygame.init()
    surfaceSize = (800, 800)
    surfaceX = 1000
    surfaceY = 800
    surface = pygame.display.set_mode(surfaceSize, 0, 0)
    pygame.display.set_caption('Hacker!!!')

    words = [
        'PROVIDE', 'SETTING', 'CANTINA', 'CUTTING', 'HUNTERS', 'SURVIVE',
        'HEARING', 'HUNTING', 'REALIZE', 'NOTHING', 'OVERLAP', 'FINDING',
        'PUTTING'
    ]
    answer = 'SURVIVE'

    # display instructions
    textX = 0
    textY = 0
    height = uaio.get_height(
        'A group of possible passwords will be displayed.')
    uaio.draw_string('A group of possible passwords will be displayed.',
                     surface, (textX, textY))
    textY = textY + height
    uaio.draw_string(
        'You must guess the password. You have at most 4 guesses.', surface,
        (textX, textY))
    textY = textY + height
    uaio.draw_string(
        'If you are incorrect you will be told how many letters in', surface,
        (textX, textY))
    textY = textY + height
    uaio.draw_string(
        'your guess were exactly the correct location of the password.',
        surface, (textX, textY))
    textY = textY + height

    # display words
    uaio.draw_string('PROVIDE', surface, (textX, textY))
    textY = textY + height
    uaio.draw_string('SETTING', surface, (textX, textY))
    textY = textY + height
    uaio.draw_string('CANTINA', surface, (textX, textY))
    textY = textY + height
    uaio.draw_string('CUTTING', surface, (textX, textY))
    textY = textY + height
    uaio.draw_string('HUNTERS', surface, (textX, textY))
    textY = textY + height
    uaio.draw_string('SURVIVE', surface, (textX, textY))
    textY = textY + height
    uaio.draw_string('HEARING', surface, (textX, textY))
    textY = textY + height
    uaio.draw_string('HUNTING', surface, (textX, textY))
    textY = textY + height
    uaio.draw_string('REALIZE', surface, (textX, textY))
    textY = textY + height
    uaio.draw_string('NOTHING', surface, (textX, textY))
    textY = textY + height
    uaio.draw_string('OVERLAP', surface, (textX, textY))
    textY = textY + height
    uaio.draw_string('FINDING', surface, (textX, textY))
    textY = textY + height
    uaio.draw_string('PUTTING', surface, (textX, textY))
    textY = textY + height

    guess = uaio.input_string('Enter Password>', surface, (textX, textY))
    textY = textY + height

    #check answer and display result
    if guess == answer:
        uaio.draw_string('User login successful', surface, (textX, textY))
    else:
        uaio.draw_string('User login unsuccessful', surface, (textX, textY))

    textY = surfaceY - height
    uaio.input_string('Press enter to exit', surface, (textX, textY))

    # end game
    pygame.quit()
Exemplo n.º 8
0
 def draw_score(self):
    score=pygame.time.get_ticks()//1000
    score_width=uaio.get_width(str(score),70)
    window_width=self.surface.get_width()
    x=window_width-score_width
    uaio.draw_string(str(score),self.surface,(x,0),70)