Exemple #1
0
def main():
    # Create window
    window_width = 500
    window_height = 400
    window = uagame.Window('Remember The Word', window_width, window_height)

    # display logo
    draw_logo(window)

    # display instructions
    text_size = 24
    text_color = 'white'
    draw_instructions(window, text_size, text_color)

    # present words: orange, chair, mouse, sandwich
    # sample correct answer from choices; randomize presentation order
    word_names = ['chair', 'orange', 'mouse', 'sandwich']
    correct_answer = random.choice(word_names)
    random.shuffle(word_names)
    draw_words(window, text_size, text_color, word_names)

    # prompt user for input
    guess = get_guess(window, text_size, text_color, correct_answer[0])

    # display feedback
    draw_feedback(window, text_size, text_color, guess, correct_answer)

    # terminate program
    window.close()
Exemple #2
0
def create_window():
    # Create a Window object and return it
    title = 'Graphics Example 3'
    width = 500
    height = 400
    window = uagame.Window(title, width, height)
    window.set_auto_update(False)
    return window
Exemple #3
0
def main():

    # create window
    screen_width = 600
    screen_height = 600
    window = uagame.Window('Word Puzzle', screen_width, screen_height)
    # display instructions
    window.set_font_size(24)
    window.set_font_color('white')
    instructions = [
        'I am tinking of a secerct word.',
        'Try and guess the word. You can guess one letter',
        'at a time. Each time you guess I will show you',
        'which letters have been coreectly guessed and which',
        'letters are still missing. You will have 4 guesses to',
        'guess all the letter. Good luck!'
    ]

    x = 0
    y = 0
    for line in instructions:
        window.draw_string(line, x, y)
        font_height = window.get_font_height()
        y = y + font_height

    # create a list of words to be used
    Words_list = [
        'apple', 'banana', 'watermelon', 'kiwi', 'pineapple', 'mango'
    ]
    word = random.choice(Words_list)
    # alternative way is to use random.randint(1, (len(Words_liost)-1)
    selected_word = word[1:]
    window.draw_string('The answer so far is _' + selected_word, x, y)

    # prompt user to guess the letter

    y = y + font_height
    guess = window.input_string('Guess a letter: ', x, y)

    # Provide Feedback
    # can also use guess == word[:1]
    if guess == word[0]:

        y = y + font_height
        window.draw_string('Good Job! You found the word ' + word + '!', x, y)
    else:

        y = y + font_height
        window.draw_string(
            'Not quite, the correct word was ' + word +
            '. Better luck next time', x, y)

    # prompt user to exit program
    y = y + font_height
    window.input_string('Press enter to end the game.', x, y)
    window.close()
Exemple #4
0
def create_window():
    # Create a window

    # return: a new uagame.Window object

    screen_width = 600
    screen_height = 600
    title = 'Word Puzzle'
    window = uagame.Window(title, screen_width, screen_height)
    return window
def create_window():
    # Create a window
    # return: a new uagame.Window object    
    screen_width = 500
    screen_height = 400
    window = uagame.Window("Word Puzzle 3", screen_width, screen_height)
    text_size = 20
    text_color = 'white'
    window.set_font_size(text_size)
    window.set_font_color(text_color)    
    return window
Exemple #6
0
def generateWindowProperties(gameWindowHeight, gameWindowWidth):
    # Create game window that is gameWindowHeight pixels by gameWindowWidth pixels
    gameWindow = uagame.Window('Hacking', gameWindowHeight, gameWindowWidth)

    # Set other window properties
    gameWindow.set_font_name('couriernew')  # Set font as courier new
    gameWindow.set_font_size(18)  # Set font size as 18
    gameWindow.set_font_color('green')  # Set font color as green
    gameWindow.set_bg_color('black')  # Set background color as black
    stringHeight = gameWindow.get_font_height()  # Get height of 18 point font

    # Generate list of window properties
    windowProperties = [gameWindow, stringHeight]

    return (gameWindow, stringHeight)
def main():

    # Create window
    width = 650
    height = 650
    window = uagame.Window('Planetary Model', width, height)
    window.set_auto_update(False)

    # Create game
    game = Game(window)

    # Play game
    game.play_game()

    # Close Window
    window.close()
def main():

    window = uagame.Window('Remember the Word', 500, 400)
    # display icon
    window.set_font_size(50)
    window.set_font_color('red')
    window.set_bg_color('blue')
    icon_width = window.get_string_width('UA')
    surface_width = window.get_width()
    icon_height = window.get_font_height()
    x_coord_icon = surface_width - icon_width
    surface_height = window.get_height()
    y_coord_icon = surface_height - icon_height
    window.draw_string('UA', x_coord_icon, y_coord_icon)
    window.input_string('Press enter to end game', 0, 0)
    window.close()
Exemple #9
0
def main():

   # Create window
   width = 500
   height = 500
   window = uagame.Window('Move Test', width, height)
   window.set_auto_update(False)

   # Create game
   game = Game(window)

   # Play game
   game.play_game()

   # Close Window
   window.close()
Exemple #10
0
def main():

    # Create window
    width = 800
    height = 500
    window = uagame.Window('Pong', width, height)
    window.set_auto_update(False)
    window.set_font_size(100)

    # Create game
    game = Game(window)

    # Play game
    game.play_game()

    # Close Window
    window.close()
Exemple #11
0
def main():
    window = uagame.Window('Remember the Word', 500, 400)
    # display icon
    icon_string = 'UA'

    window.set_font_size(50)
    window.set_font_color('red')
    window.set_bg_color('blue')
    icon_width = window.get_string_width(icon_string)
    surface_width = window.get_width()
    x_coord_icon = surface_width - icon_width

    icon_height = window.get_font_height()
    surface_height = window.get_height()
    y_coord_icon = surface_height - icon_height

    window.draw_string('UA', x_coord_icon, y_coord_icon)
    window.close()
Exemple #12
0
    def __init__(self):
        # Create window with fixed height of 500px, fixed width of 400px
        self.gameWindow = uagame.Window('Poke the Dots', 500, 400)
        self._adjustWindowProperties()

        # Define game properties
        self._closeButtonSelected = False  # Define the default close button object
        self._gameClock = pygame.time.Clock()  # Create the clock
        self._score = 0  # Initialize game _score to be zero
        self._frameRate = 90  # Higher frame rate is faster game, vice versa
        self._collision = False  # Define the default object to determine if dots have come into contact

        # Define dot properties
        self.smallDotColor = 'red'  # Dot color
        self.smallDotRadius = 30  # Dot radius in px
        self.smallDotCenter = [50, 75]  # Where the small dot will be spawned
        self.smallDotVelocity = [1, 2]  # The velocity [xVelocity, yVelocity]
        self.bigDotColor = 'blue'  # Dot color
        self.bigDotRadius = 40  # Dot radius in px
        self.bigDotCenter = [200, 100]  # Where the big dot will be spawned
        self.bigDotVelocity = [2, 1]  # The velocity [xVelocity, yVelocity]

        # Create the dots
        self.smallDot = Dot(self.smallDotColor, self.smallDotCenter,
                            self.smallDotRadius, self.smallDotVelocity,
                            self.gameWindow)
        self.bigDot = Dot(self.bigDotColor, self.bigDotCenter,
                          self.bigDotRadius, self.bigDotVelocity,
                          self.gameWindow)

        # Randomize the dots' positions
        self.smallDot.randomizeDotPosition()
        self.bigDot.randomizeDotPosition()

        # Play the game
        self.playGame()

        return (None)