Esempio n. 1
0
def keep_score():
    round_display = gamebox.from_text(550,
                                      20,
                                      "Round: " + str(round_num),
                                      'Arial',
                                      20,
                                      'white',
                                      bold=True)
    score_board = gamebox.from_text(50,
                                    20,
                                    "Score: " + str(score),
                                    "Arial",
                                    20,
                                    'white',
                                    bold=True)
    lives = gamebox.from_text(275,
                              20,
                              "Lives left: " + str(live_count),
                              "Arial",
                              20,
                              "cyan",
                              bold=True)
    camera.draw(round_display)
    camera.draw(score_board)
    camera.draw(lives)
Esempio n. 2
0
def loading_screen(keys):
    """

    :param keys: keys used to start the game
    :return: once the keys are hit, the player gets transferred to the intro screen
    """
    global ticks
    global background_number
    ticks += 1
    camera.clear("Black")
    background_intro = gamebox.from_image(camera.x, camera.y, """http://www.desktopimages.org/pictures/2014/0522/1/video-games-mario-bowser-princess-peach-goomba-wallpaper-455562.jpg""")
    background_intro.scale_by(1.2)
    text = "Press SPACE BAR to Begin"
    loading_screen_text = gamebox.from_text(400, 320, text, 60, "white", bold=False)
    game_name = "Mario's Quest"
    name_text = "Michael Masner(mm6md) and Joel Tavarez(jt3bk)"
    game_title = gamebox.from_text(400, 230, game_name, 85, "white", italic=True, bold=True)
    names = gamebox.from_text(400, 450, name_text, 45, "cyan", bold=False)
    camera.draw(background_intro)
    camera.draw(game_title)
    camera.draw(loading_screen_text)
    camera.draw(names)

    if pygame.K_SPACE in keys:
        background_number += 1
Esempio n. 3
0
def tick(keys):
    """
    this is the main function
    :param keys: keys used throughout the entire game
    :return: runs the entire game
    """
    global level
    global ticks
    global lvl1_enemies
    global score
    ticks += 1
    if level == 1:
        level1(keys)
    elif level == 2:
        level2(keys)
    elif level == 3:
        level3(keys)
    elif level == 4:
        camera.draw(winner_track)
        win = gamebox.from_text(camera.x, camera.y-50, "YOU WIN!", 80, "cyan", italic=True, bold=True)
        win_2 = gamebox.from_text(camera.x, camera.y+20, "PRINCESS PEACH IS SAVED!!!!", 60, "cyan", italic=True,
                                  bold=True)
        play_again = gamebox.from_text(camera.x, camera.y + 80, "Press Space to Play Again", 60, "cyan", italic=True,
                                       bold=True)
        camera.draw(play_again)
        camera.draw(win)
        camera.draw(win_2)
        if pygame.K_SPACE in keys:
            level -= 3

    camera.display()
Esempio n. 4
0
def end_game(type):
    if type == 0:
        camera.clear("black")
        end_screen = gamebox.from_text(
            400, 200, "Player 2 survived longer!!... game over!!", "Arial", 40,
            "red")
        camera.draw(end_screen)
    if type == 1:
        camera.clear("black")
        end_screen = gamebox.from_text(
            400, 200, "Player 1 survived longer!!... game over!!", "Arial", 40,
            "red")
        camera.draw(end_screen)
    if type == 2:
        camera.clear("black")
        end_screen = gamebox.from_text(
            400, 200, "You are the largest orb on screen... Player 1 wins!!",
            "Arial", 30, "green")
        camera.draw(end_screen)
    if type == 3:
        camera.clear("black")
        end_screen = gamebox.from_text(
            400, 200, "You are the largest orb on screen... Player 2 wins!!",
            "Arial", 30, "green")
        camera.draw(end_screen)
Esempio n. 5
0
def end_frame(player_have_lost):
    text1 = my_font.render(player_have_lost + " has lost!", True, (0, 200, 0))
    while True:
        init_screen.fill(white)
        init_screen.blit(text1, [50, 200])
        mode1 = gamebox.from_image(200, 300, 'button.png')
        mode1.scale_by(0.4)
        mode2 = gamebox.from_image(600, 300, 'button.png')
        mode2.scale_by(0.4)
        camera.draw(mode1)
        camera.draw(
            gamebox.from_text(200, 300, "Start Over", 25, 'black', True))
        camera.draw(mode2)
        camera.draw(
            gamebox.from_text(600, 300, "End the Game", 25, 'black', True))
        pygame.display.flip()
        break
    while True:
        event = pygame.event.wait()
        if event.type == pygame.MOUSEBUTTONDOWN:
            if mode1.x - mode1.width / 2 < camera.mousex < mode1.x + mode1.width / 2:
                if mode1.y - mode1.height / 2 < camera.mousey < mode1.y + mode1.height / 2:
                    start_frame()
            if mode2.x - mode2.width / 2 < camera.mousex < mode2.x + mode2.width / 2:
                if mode2.y - mode2.height / 2 < camera.mousey < mode2.y + mode2.height / 2:
                    sys.exit()
Esempio n. 6
0
def splash(keys):
    global screen, ticks
    #camera.clear('cyan')
    back = gamebox.from_image(50, 100, 'stars.png')
    back.scale_by(1.5)
    camera.draw(back)

    text = gamebox.from_text(400, 100, "Battle for Planet Wassel", "Arial", 50,
                             'white')
    names = gamebox.from_text(400, 100, "By Alex Wassel", "Arial", 20, 'white')
    names.top = text.bottom
    camera.draw(text)
    camera.draw(names)
    directions = gamebox.from_text(
        400, 300,
        "Player 1: use W to move your spaceship up and S to move it down. Use the Space Bar to shoot.",
        "Arial", 17, 'white')
    directions1 = gamebox.from_text(
        400, 300,
        "Player 2: use the Up and Down arrow keys to move your spaceship. Use the comma key to shoot.",
        "Arial", 17, 'white')
    directions2 = gamebox.from_text(400, 300, "Press SPACE to start", "Arial",
                                    20, 'yellow')
    camera.draw(directions)
    directions1.top = directions.bottom
    directions2.top = directions1.bottom
    camera.draw(directions1)
    camera.draw(directions2)

    if pygame.K_SPACE in keys:
        screen = False
    camera.display()
Esempio n. 7
0
def endgame_screen():
    global level
    global score
    welcome_message = gamebox.from_text(camera.x, camera.y - 250, fontsize=36, text="Game Over!", color="white")
    begin_message = gamebox.from_text(camera.x, camera.y - 200, fontsize=36, text="Your score was: "+str(score), color="white")
    camera.draw(welcome_message)
    camera.draw(begin_message)
Esempio n. 8
0
def splash(keys):
    '''
    start screen
    '''
    global show_splash
    camera.draw(splash_background)
    camera.draw(
        gamebox.from_text(camera.x,
                          camera.y - 90,
                          'Worm',
                          'Arial',
                          100,
                          'white',
                          bold=True))
    camera.draw(
        gamebox.from_text(camera.x, camera.y - 20,
                          'An Luong (aml4dy) & Samantha Garcia (smg2jj)',
                          'Arial', 30, 'white'))
    camera.draw(
        gamebox.from_text(camera.x, camera.y + 20,
                          'use up/down/right/left keys to move the worm',
                          "Arial", 25, 'white'))
    camera.draw(
        gamebox.from_text(camera.x, camera.y + 50,
                          'collect apples to grow, avoid birds to keep lives',
                          'Arial', 25, 'white'))
    camera.draw(
        gamebox.from_text(camera.x, camera.y + 80,
                          'press space bar to continue', 'Arial', 25, 'white'))

    if pygame.K_SPACE in keys:
        show_splash = False
    camera.display()
Esempio n. 9
0
def draw(keys, adversary):
    '''
    draws everything: the scenary, the field, the emblems, the gloves, the ball.
    '''
    global game_mode
    for box in Scenary(adversary)[0:5]:
        camera.draw(box)
    camera.draw(
        gamebox.from_text(300,
                          50,
                          Scenary(adversary)[6] + str(other_score),
                          50,
                          "white",
                          bold=True))
    camera.draw(
        gamebox.from_text(500, 50, Scenary(adversary)[5], 50, "red",
                          bold=True))
    camera.draw(gamebox.from_text(700, 50, str(round(timer)), 40, "red"))
    arr1 = [pygame.K_RIGHT, pygame.K_LEFT, pygame.K_DOWN, pygame.K_UP]
    arr2 = [pygame.K_d, pygame.K_a, pygame.K_s, pygame.K_w]
    move_gloves(gloves1, keys, arr1)
    move_ball()
    camera.draw(gloves1)
    if glove_on:
        camera.draw(gloves2)
        move_gloves(gloves2, keys, arr2)
    if not game_on:
        camera.draw(
            gamebox.from_text(400, 300, 'Press spacebar to start', 50, 'red'))
    camera.draw(ball)
Esempio n. 10
0
def startframe(keys):
    '''
    Draw title screen
    '''
    global game_started
    global tick_count

    if keys:
        game_started = True
    keys.clear()

    to_draw = []  # contains everything drawed in this frame
    title_box = gamebox.from_text(300, 30, 'Hey', 80, 'red', True)
    to_draw.append(title_box)
    ypos = 200
    for line in instructions.split('\n'):
        to_draw.append(gamebox.from_text(300, ypos, line, 30, 'red'))
        ypos += 20
    for sr in title_snake:
        sr.image = images_sr[tick_count // 2 % len(images_sr)]
        sr.move_speed()
        to_draw.append(sr)
        if sr.x > 800 and sr.speedx > 0:
            sr.x = 0
        elif sr.x < 0 and sr.speedx < 0:
            sr.x = 800
    to_draw.append(s_right)
    tick_count += 1

    for box in to_draw:
        camera.draw(box)
def tick_options(keys):
    global control_count, option_count, sound_count
    camera.clear("sky blue")
    if pygame.K_q in keys:
        quit()
    opt1 = gamebox.from_text(683, 200, "press 't' for controller controls", "Cambria", 40, "red")
    opt2 = gamebox.from_text(683, 500, "press 's' for sound controls", "Cambria", 40, "red")
    pic1 = gamebox.from_image(683, 350, "https://d30y9cdsu7xlg0.cloudfront.net/png/195040-200.png")
    pic2 = gamebox.from_image(683, 650, "http://images.clipartpanda.com/music-note-transparent-background-RTAR6agTL.png")
    back = gamebox.from_text(125, 50, "press 'b' for back", "Cambria", 30, "red")
    pic1.size = 200, 220
    pic2.size = 200, 220
    camera.draw(opt1)
    camera.draw(opt2)
    camera.draw(pic1)
    camera.draw(pic2)
    camera.draw(back)
    if pygame.K_t in keys:
        control_count += 1
    if pygame.K_s in keys:
        sound_count += 1
    if control_count != 0:
        control(keys)
    if pygame.K_b in keys:
        option_count = 0
    if option_count == 0:
        title(keys)
    if sound_count != 0:
        set_all_volume(keys)
    if control_count == 0 and sound_count == 0:
        camera.display()
Esempio n. 12
0
def splash(keys):
    global show_splash, ticks
    camera.clear('red')
    text = gamebox.from_text(camera.x, camera.y, "ACID RAIN RUN", "Arial", 20,
                             'black')
    camera.draw(text)
    directions = gamebox.from_text(camera.x, camera.y,
                                   "Press space to continue", "Arial", 10,
                                   'black')
    controls = gamebox.from_text(
        camera.x, camera.y,
        'Up arrow to jump; Right arrow to run forward; Left to run backward',
        'Arial', 10, 'black')
    instructions = gamebox.from_text(
        camera.x, camera.y,
        'Avoid the rain and puddles, keep running and collect coins!', 'Arial',
        10, 'black')
    names = gamebox.from_text(
        camera.x, camera.y,
        'Made by Ian McCray (im3vy) and Lata Goudel (lg3dy)', 'Arial', 10,
        'black')
    instructions.top = text.bottom + 20
    controls.top = instructions.bottom + 10
    directions.top = controls.bottom + 20
    names.top = directions.bottom + 10
    camera.draw(controls)
    camera.draw(directions)
    camera.draw(instructions)
    camera.draw(names)

    if pygame.K_SPACE in keys:
        show_splash = False
    if ticks > 600:
        show_splash = False
    camera.display()
Esempio n. 13
0
def splash(keys):
    global show_splash
    global logo
    camera.clear("light green")
    camera.draw(
        gamebox.from_text(
            camera.x, camera.y - 75,
            "Use keys WASD and the Arrow Keys to control each reptile character.",
            "Arial", 20, "black"))
    camera.draw(
        gamebox.from_text(
            camera.x, camera.y - 100,
            "The person to get the highest time before running out of life wins.",
            "Arial", 20, "black"))
    camera.draw(
        gamebox.from_text(
            camera.x, camera.y - 125,
            "Alexandra Hickman (azh5kn) and Zach Forstot (zf6pd)", "Arial", 20,
            "black"))

    camera.draw(logo)
    # camera.draw(leaves)

    if ticks > 60:
        show_splash = False
    if pygame.K_SPACE in keys:
        show_splash = False
    camera.display()
Esempio n. 14
0
def score_time():
    global scores
    score_box = gamebox.from_text(90, 30, "Planets Hit: " + str(scores), 32,
                                  "white")
    if (ticks_time / 30) > 0:
        seconds = str(int((ticks_time / 30))).zfill(2)
    else:
        seconds = "00"
    if seconds != "00":
        time_box = gamebox.from_text(650, 30, "Time Remaining: " + seconds, 32,
                                     "white")
    elif seconds == "00":
        time_box = gamebox.from_text(650, 30, "Time Remaining: 00", 32,
                                     "white")
        comet.move_speed()
    camera.draw(score_box)
    camera.draw(time_box)
    if len(planets) == 0:
        win_box = gamebox.from_text(400, 300, "THE ASTEROIDS HAVE WON!", 48,
                                    "white")
        camera.draw(win_box)
    elif (seconds == "00") and (len(planets) != 0):
        win_box = gamebox.from_text(400, 300, "THE ASTRONAUTS HAVE WON!", 48,
                                    "white")
        camera.draw(win_box)
Esempio n. 15
0
def respawn():
    global power
    global top
    monkey.x = cam.x - 270
    monkey.y = 300
    power = False
    for t in top:
        #top.append(gamebox.from_color(cam.right + 200, random.randint(0, 600), "black", 30, random.randint(200,400)))
        t.x = random.randint(cam.right + 50, cam.right + 250)
        if top.index(t) % 2 == 0:
            t.y = random.randint(300, 600)
        else:
            t.y = random.randint(0, 300)
    # for t in top:
    #     t.speedx = 0
    #     t.speedy = 0
    now = time.time()
    cam.clear("cyan")
    while time.time() < now + 1:
        cam.draw(gamebox.from_text(cam.x, 300, "3", 50, "red"))
    cam.clear("cyan")
    while time.time() < now + 2:
        cam.draw(gamebox.from_text(cam.x, 300, "2", 50, "red"))
    cam.clear("cyan")
    while time.time() < now + 3:
        cam.draw(gamebox.from_text(cam.x, 300, "1", 50, "red"))
    cam.clear("cyan")
    power = True
Esempio n. 16
0
def tick(keys):
    global game_on
    global p1_score
    global p2_score
    if game_on:
        top_barrier.move_speed()
        bot_barrier.move_speed()

    # ------- INPUT ---------
    if pygame.K_SPACE in keys:
        game_on = True
    '''

    '''
    #top_barrier.move(8,0)
    # Draw all the walls
    for wall in walls:
        camera.draw(wall)

    camera.draw(top_barrier)
    camera.draw(bot_barrier)
    #camera.draw(ball)

    # ---- CHECKING FOR WIN ----
    if p1_score >= 10:
        camera.draw(
            gamebox.from_text(400, 100, "Red Wins!", "Arial", 40, "Red", True))
        gamebox.pause()
    if p2_score >= 10:
        camera.draw(
            gamebox.from_text(400, 100, "Yellow Wins!", "Arial", 40, "Yellow",
                              True))
        gamebox.pause()
    camera.display()
Esempio n. 17
0
def tick(keys):
    # get access to the counter
    global count_tick
    global counter
    if pygame.K_RIGHT in keys:
        character.x += 10
    if pygame.K_LEFT in keys:
        character.x -= 10
    character.yspeed += 1
    character.y = character.y + character.yspeed
    camera.clear("black")
    camera.draw(character)
    camera.draw(ground)
    if character.bottom_touches(ground):
        character.yspeed = 0
        if pygame.K_SPACE in keys:
            character.yspeed = -20
    if character.touches(ground):
        character.move_to_stop_overlapping(ground)
    camera.display()
    count_tick += 1

    for wall in walls:
        if character.bottom_touches(wall):
            character.yspeed = 0
            if pygame.K_SPACE in keys:
                character.yspeed = -22
        if character.touches(wall):
            character.move_to_stop_overlapping(wall)
        camera.draw(wall)
    for coin in coins:
        if character.touches(coin):
            counter += 1
            coins.remove(coin)

        camera.draw(coin)
    camera.draw(
        gamebox.from_text(70,
                          10,
                          "Stars collected: " + str(counter),
                          "Arial",
                          20,
                          "red",
                          italic=True))
    ticks_per_second = 30
    seconds = int(count_tick / ticks_per_second)
    camera.draw(
        gamebox.from_text(700,
                          10,
                          str(seconds) + " out of 30 seconds spent",
                          "Arial",
                          20,
                          "red",
                          italic=True))
    if seconds >= 30:
        gamebox.stop_loop()
        print("You found " + str(counter) + " stars.")

    camera.display()
Esempio n. 18
0
def transition(keys):
    global on_level
    cam.clear("black")
    cam.draw(gamebox.from_text(400, 300, "You are about to fight the boss, good luck", 40, "white"))
    cam.draw(gamebox.from_text(400, 350, "Health packs may spawn if you need aid!", 30, "green"))
    cam.draw(gamebox.from_text(400, 450, "PRESS SPACE TO CONTINUE", 35, "blue"))
    if pygame.K_SPACE in keys:
        on_level = "final"
        keys.remove(pygame.K_SPACE)
Esempio n. 19
0
def draw_scorebox():
    score_box_1 = gamebox.from_text(300, camera.top + 20,
                                    "Player 1 Score: " + str(p1_score), 24,
                                    "white")
    camera.draw(score_box_1)
    score_box_2 = gamebox.from_text(500, camera.top + 20,
                                    "Player 2 Score: " + str(p2_score), 24,
                                    "white")
    camera.draw(score_box_2)
Esempio n. 20
0
def start(keys):

    camera.clear("skyblue")
    camera.draw(gamebox.from_text(500,500,"Our Game", "Futura",20,"black"))
    camera.draw(gamebox.from_text(500,600,"Press SPACE to start", "Futura",20,'black'))

    camera.display()
    if pygame.K_SPACE in keys:
        gamebox.timer_loop(ticks_per_second, tick)
Esempio n. 21
0
def tick(keys):
    global time
    global counter
    global coin_1
    global coin_2
    global coin_3
    global coins
    global score
    counter += 1
    if pygame.K_RIGHT in keys:
        character.x += 5
    if pygame.K_LEFT in keys:
        character.x -= 5
    camera.clear("cyan")
    camera.draw(character)
    camera.draw(ground)
    for coin in coins:
        camera.draw(coin)
        if character.touches(coin):
            coins.remove(coin)
            score += 1
    camera.draw(
        gamebox.from_text(50,
                          100,
                          "Score: " + str(score),
                          "arial",
                          12,
                          "red",
                          bold=True))
    if counter % 20 == 0:
        time += 1
    camera.draw(
        gamebox.from_text(750,
                          100,
                          "Time: " + str(time),
                          "arial",
                          12,
                          "red",
                          bold=True))
    character.yspeed += 1
    character.y = character.y + character.yspeed
    if character.bottom_touches(ground):
        character.yspeed = 0
        if pygame.K_SPACE in keys:
            character.yspeed = -15
    if character.touches(ground):
        character.move_to_stop_overlapping(ground)
    for wall in walls:
        if character.bottom_touches(wall):
            character.yspeed = 0
            if pygame.K_SPACE in keys:
                character.yspeed = -20
        if character.touches(wall):
            character.move_to_stop_overlapping(wall)
        camera.draw(wall)
    camera.display()
Esempio n. 22
0
def read_high_scores():
    file = open("scores.csv")
    line_processed = []
    for line in file:
        line_processed.append(line.strip().split(","))
    for spacing in range(5):
        name_disp = gamebox.from_text(camera.x - 100, camera.y-100+50*spacing, line_processed[spacing][0], 36, "white")
        score_disp = gamebox.from_text(camera.x + 100, camera.y-100+50*spacing, line_processed[spacing][1], 36, "white")
        camera.draw(score_disp)
        camera.draw(name_disp)
Esempio n. 23
0
def tick(keys):
    global time, score

    # clear display
    camera.clear("blue")

    # decrease timer per call of tick
    time -= 1

    # calculate timer
    seconds = str(int((time / ticks_per_second))).zfill(3)

    if pygame.K_RIGHT in keys:
        character.x += 5
    if pygame.K_LEFT in keys:
        character.x -= 5
    character.yspeed += 1
    character.y = character.y + character.yspeed

    for wall in walls:
        if character.bottom_touches(wall):
            character.yspeed = 0
            if pygame.K_SPACE in keys:
                character.yspeed = -15
        # give infinite jumps (flappy bird style)
        # if pygame.K_SPACE in keys:
        #     character.yspeed = -15
        if character.touches(wall):
            character.move_to_stop_overlapping(wall)
        camera.draw(wall)

    for coin in coins:
        if character.touches(coin):
            score += 1
            coins.remove(coin)
        camera.draw(coin)

    # if time % 30 == 0:
    #     coin_x = random.randint(50, 750)
    #     coin_y = random.randint(400, 500)
    #     coins.append(gamebox.from_color(coin_x, coin_y, "yellow", 12, 12))

    # write timer and score to screen
    time_box = gamebox.from_text(650, 30, "Time Remaining: " + seconds,
                                 "arial", 24, "white")
    score_box = gamebox.from_text(75, 30, "Score: " + str(score), "arial", 24,
                                  "white")
    camera.draw(time_box)
    camera.draw(score_box)

    # draw the character
    camera.draw(character)

    # display the screen
    camera.display()
Esempio n. 24
0
def restart(keys):
    '''
    This function is executed whenever the player hits a wall or hits an enemy -- it's basically a "reset".
    :param keys:
    :return:
    '''
    global time
    global level
    global points
    if pygame.K_SPACE in keys:
        gamebox.unpause()
        points = points - 10
        if points < 0:
            camera.clear('black')
            camera.draw(
                gamebox.from_text(camera.left + 400, 200, 'You Lose!', 50,
                                  'white'))
            camera.draw(
                gamebox.from_text(camera.left + 400, 300,
                                  'Quit and reopen the game to play again', 50,
                                  'white'))
        elif level == 1:
            player_sprite[0].x = 320
            player_sprite[0].y = 550
            gamebox.timer_loop(60, tick)
        elif level == 2:
            player_sprite[1].x = 0
            player_sprite[1].y = 420
            enemy_sprite2[0].x = 400
            enemy_sprite2[0].y = 420
            enemy_sprite2[1].x = 400
            enemy_sprite2[1].y = 225
            enemy_sprite2[0].xspeed = -enemy_sprite2[0].xspeed
            enemy_sprite2[1].xspeed = -enemy_sprite2[1].xspeed
            gamebox.timer_loop(60, tick)
        elif level == 3:
            player_sprite[2].x = 10
            player_sprite[2].y = 75
            gamebox.timer_loop(60, tick)
        elif level == 4:
            player_sprite[3].x = 10
            player_sprite[3].y = 300
            gamebox.timer_loop(60, tick)
        elif level == 5:
            camera.clear('black')
            camera.draw(
                gamebox.from_text(
                    400, 300,
                    'You failed to win, quit the game and reopen to try again.',
                    40, 'red'))
            gamebox.stop_loop()

    camera.display()
Esempio n. 25
0
def new_game():
    global game_over
    print('new')
    text = gamebox.from_text(400, 105, 'ASTEROIDS', fontsize=36, color="red")
    text2 = gamebox.from_text(450,
                              105,
                              'game controls:left,right,up,down',
                              fontsize=36,
                              color="red")
    camera.draw(text)
    camera.draw(text2)
    camera.diplay()
Esempio n. 26
0
def splash(keys):
    global show_splash
    camera.clear("blue")
    camera.draw(gamebox.from_text(camera.x,camera.y,"FlappyBird-like game by azh5kn", "Arial",30,"black"))
    camera.draw(gamebox.from_text(camera.x,camera.y+50,"(press space to continue)", "Arial",20,"black"))

    camera.display()

    if ticks > 60:
        show_splash = False
    if pygame.K_SPACE in keys:
        show_splash = False
    camera.display()
Esempio n. 27
0
def splash(keys):
    global show_splash
    camera.clear('grey')
    camera.draw(
        gamebox.from_text(camera.x, camera.y, "Thank You For Choosing FINNAIR",
                          "Arial", 30, "red"))
    camera.draw(
        gamebox.from_text(camera.x, camera.y + 50,
                          "(press space to begin your journey)", "Arial", 15,
                          "white"))
    if pygame.K_SPACE in keys:
        show_splash = False
    camera.display()
Esempio n. 28
0
def end(keys):
    music.stop()
    endgame_music.play()
    endgame = gamebox.from_text(camera.x, camera.y, "Game Over ", "Arial", 70, "Red")
    score_display = gamebox.from_text(camera.x, camera.y + 200, "Your score is " + str(score) + "!", "Arial", 50,
                                      "Yellow")
    time_lasted = gamebox.from_text(camera.x, camera.y + 250,"You survived " + str(int(frame / ticks_per_second)) + " seconds", "Arial", 40,"Yellow")
    camera.clear("black")
    camera.draw(game_over_background)
    camera.draw(endgame)
    camera.draw(score_display)
    camera.draw(time_lasted)
    camera.display()
Esempio n. 29
0
def player_ui():
    global level
    global num_swarmers
    global num_shooters
    score_counter = gamebox.from_text(camera.x+300, camera.y-250, fontsize=36, text="Score: " + str(score),
                                      color="white", bold=True)
    health_counter = gamebox.from_text(camera.x-300, camera.y-250, fontsize=36, text="Health: " + str(health),
                                       color="white", bold=True)
    if num_swarmers == 0 and len(swarmers) == 0 and num_shooters == 0 and len(shooters) == 0 and num_boss == 0 \
            and boss_health == 0:
        level += 1
    camera.draw(score_counter)
    camera.draw(health_counter)
Esempio n. 30
0
def tick(keys):

    global background, playGame, Instructions, highlight, camera
    camera.draw(background)

    if pygame.K_w in keys:
        if background.y == 300:
            highlight = gamebox.from_color(camera.x, 400, "yellow", 300, 5)
    if pygame.K_s in keys:
        if background.y == 300:
            highlight = gamebox.from_color(camera.x, 480, "yellow", 300, 5)
    if pygame.K_b in keys:

        background = gamebox.from_image(400, 300, "background.jpg")
        playGame = gamebox.from_text(camera.x, 370, "Play Game", "Arial", 50,
                                     "WHITE")
        Instructions = gamebox.from_text(camera.x, 450, "Instructions",
                                         "Arial", 50, "WHITE")
        highlight = gamebox.from_color(camera.x, 400, "yellow", 300, 5)
    if pygame.K_RETURN in keys:
        if highlight.y == 480:
            background = gamebox.from_color(0, 0, "black", 0, 0)
            playGame = gamebox.from_color(0, 0, "black", 0, 0)
            Instructions = gamebox.from_color(0, 0, "black", 0, 0)
            highlight = gamebox.from_color(0, 0, "black", 0, 0)
            camera.clear("blacK")
            y = 40
            for line in instructions:
                if y == 440 or y == 480:
                    camera.draw(
                        gamebox.from_text(camera.x, y, line, "Arial", 20,
                                          "green"))
                elif y == 400:
                    camera.draw(
                        gamebox.from_text(camera.x, y, line, "Arial", 20,
                                          "red"))

                else:
                    camera.draw(
                        gamebox.from_text(camera.x, y, line, "Arial", 20,
                                          "white"))
                y += 40
        elif highlight.y == 400:
            gamebox.Camera.is_initialized = False
            import switch
            switch.run_game()

    camera.draw(highlight)
    camera.draw(playGame)
    camera.draw(Instructions)
    camera.display()
Esempio n. 31
0
def splash(keys):
    global show_splash
    camera.clear('black')
    white_house = gamebox.from_image(
        camera.x, camera.bottom - 190,
        "http://www.pngmart.com/files/4/White-House-PNG-HD.png")
    face = gamebox.from_image(830, 240, "http://tinyurl.com/y86pwv9o")
    title = gamebox.from_text(350, 100, "MISSION TRUMP", 'sys', 100, 'white')
    white_house.width = 1000
    camera.draw(white_house)
    camera.draw(face)
    camera.draw(title)
    camera.draw(
        gamebox.from_text(350, 150, "Press SPACE to start", 'sys', 30,
                          'white'))
    camera.draw(gamebox.from_text(100, 170, "Controls:", 'sys', 30, 'white'))
    camera.draw(gamebox.from_text(166, 190, "SPACE - Jump", 'sys', 30,
                                  'white'))
    camera.draw(
        gamebox.from_text(240, 210, "Right and Left Arrows - Move", 'sys', 30,
                          'white'))
    camera.draw(
        gamebox.from_text(855, 90, "- Avoid FAKE NEWS", 'sys', 30, 'red'))
    camera.draw(gamebox.from_text(820, 115, "- Collect $$$", 'sys', 30, 'red'))
    camera.draw(
        gamebox.from_text(camera.left + 170, camera.bottom - 20,
                          "Quang Nguyen", 'sys', 20, 'white'))
    menu_music.play(loops=-1)

    if pygame.K_SPACE in keys:
        show_splash = False
        menu_music.stop()
        background_music.play(loops=-1)
    camera.display()
Esempio n. 32
0
def splash(keys):
    global show_splash
    camera.clear('black')
    camera.draw(
        gamebox.from_text(camera.x, camera.y, "Welcome!", "Arial", 30,
                          "yellow"))
    camera.draw(
        gamebox.from_text(camera.x, camera.y + 50, "(press space to continue)",
                          "Arial", 15, "white"))
    if ticks > 60:
        show_splash = False
    if pygame.K_SPACE in keys:
        show_splash = False
    camera.display()
def tick_creds(keys):
    global credit_count
    cred_char = gamebox.from_text(683, 200,
                                  "A special thanks to the following:  Luther Tychonievich for the gamebox functions", "Cambria", 40, "red")
    back = gamebox.from_text(125, 50, "press 'b' for back", "Cambria", 30, "red")
    camera.clear("sky blue")
    if pygame.K_q in keys:
        quit()
    camera.draw(cred_char)
    camera.draw(back)
    camera.display()
    if pygame.K_b in keys:
        credit_count = 0
    if credit_count == 0:
        title(keys)
def set_all_volume(keys):
    global sound_count, sound_level
    camera.clear("sky blue")
    if pygame.K_q in keys:
        quit()
    toggle_off = gamebox.from_text(683, 200, "To turn off sound, press 'n'", "Cambria", 40, "red")
    back = gamebox.from_text(125, 50, "press 'b' for back", "Cambria", 30, "red")
    if pygame.K_n in keys:
        music1.stop()
        music2_count = 1
    if pygame.K_b in keys:
        sound_count = 0
        title(keys)
    camera.draw(toggle_off)
    camera.draw(back)
    camera.display()
def control(keys):
    global control_count, wasd_count, arrow_keys_count
    camera.clear("sky blue")
    if pygame.K_q in keys:
        quit()
    txt1 = gamebox.from_text(683, 200, "press '1' to make your controls wasd", "Cambria", 40, "red")
    txt2 = gamebox.from_text(683, 400, "press '2' to make your controls the arrow keys", "Cambria", 40, "red")
    back = gamebox.from_text(125, 50, "press 'b' for back", "Cambria", 30, "red")
    camera.draw(txt1)
    camera.draw(txt2)
    camera.draw(back)
    if pygame.K_b in keys:
        control_count = 0
        title(keys)
    if pygame.K_1 in keys:
        global_stage.wasd_count = 1
    if pygame.K_2 in keys:
        global_stage.wasd_count = 0

    camera.display()
Esempio n. 36
0
def tick(keys):

    global hit_interval, hit_moment, hit_check, health, secretformula_check, stick_check,\
        move_check, x, y, stage, face_check, time, seconds, minutes, jf_stage, check, \
        spat_stage, spat_check, bear_stage, circle_stage, x_coord, level

    hud = [gamebox.from_color(character.x, 0, "White", 100000, 120)]
    hit_interval += 1
    character.xspeed = 0
    character.yspeed += 1
    circle_check = 0
    time += 1
    jf_stage += 1/3
    spat_stage += 1/3
    bear_stage += 1/3
    if circle_stage >= 9:
        circle_stage = 8
    if time == 30:
        seconds += 1
        move_check = 0
    if time == 60:
        check = 0
        time = 0
        seconds += 1
    if seconds == 60:
        seconds = 0
        minutes += 1
    if int(seconds) < 10:
        second = '0{}'.format(str(seconds))
    else:
        second = str(seconds)
    if hit_moment + 30 == hit_interval:
        hit_check = 0
    for jellyfish in jf_list:
        if time < 30:
            jellyfish.yspeed = -2
        else:
            jellyfish.yspeed = 2
        jellyfish.y = jellyfish.y + jellyfish.yspeed
    for bear in bear_list:
        if time < 30:
            bear.speedx = -10
        else:
            bear.speedx = 10
        bear.x = bear.x + bear.speedx
    character.y = character.y + character.yspeed


    # ----- GEN ANIMATION -----
    timer = gamebox.from_text(character.x - 225, y/25, "{}".format(str(int(minutes))) + ":{}".format(second), "haettenschweiler", 40, "Black")
    hud.append(timer)
    tie_hud = gamebox.from_image(character.x + 400, y/20 - 20, "tie_hud.png")
    tie_hud.scale_by(0.8)
    hud.append(tie_hud)
    secretformula_hud_file = 'secretformula_check{}'.format(str(secretformula_check)) + ".png"
    secretformula_hud = gamebox.from_image(character.x - 50, y/20 - 5, secretformula_hud_file)
    hud.append(secretformula_hud)
    health_hud_file = 'health_hud_1.png'
    health_hud_a = gamebox.from_image(character.x + 850, y/20 - 8, health_hud_file)
    health_hud_b = gamebox.from_image(character.x + 925, y/20 - 8, health_hud_file)
    health_hud_c = gamebox.from_image(character.x + 1000, y/20 - 8, health_hud_file)
    if health <= 2:
        health_hud_a = gamebox.from_image(character.x + 850, y/20 - 8, 'health_hud_0.png')
    if health <= 1:
        health_hud_b = gamebox.from_image(character.x + 925, y/20 - 8, 'health_hud_0.png')
    if health <= 0:
        health_hud_c = gamebox.from_image(character.x + 1000, y/20 - 8, 'health_hud_0.png')
    hud.append(health_hud_a)
    hud.append(health_hud_b)
    hud.append(health_hud_c)
    stick_hud_file = "stick_check{}".format(str(stick_check)) + ".png"
    stick_hud= gamebox.from_image(character.x - 150, y/20 - 5, stick_hud_file)
    hud.append(stick_hud)
    spat_hud_file = "spat_check{}".format(str(spat_check))+".png"
    spat_hud = gamebox.from_image(character.x - 100, y/20, spat_hud_file)
    hud.append(spat_hud)
    if stage >= 7:
        stage = 1
    if spat_stage >= 4 or bear_stage >= 4:
        spat_stage = 1
        bear_stage = 1
    if int(jf_stage) == 8:
        jf_stage = 1
    sb = 'running_{}'.format(str(int(stage)))+'.png'
    character_an = gamebox.from_image(character.x, character.y - 10, sb)
    character_an.scale_by(.5)
    jf_file = 'jellyfish_{}'.format(str(int(jf_stage)))+'.png'
    jellyfish_an = []
    secretformula_file = 'secretformula_{}'.format(str(int(spat_stage)))+".png"
    secretformula = gamebox.from_image(7500, 700, secretformula_file)
    spat_file = 'spatula_{}'.format(str(int(spat_stage)))+".png"
    spatula = gamebox.from_image(5100, 100, spat_file)
    stick_file = 'stick_{}'.format(str(int(spat_stage)))+".png"
    stick = gamebox.from_image(2100, 100, stick_file)
    circle = gamebox.from_image(character.x, character.y + 30, 'circle_8.png')
    bear_an = []
    seabear_file = 'seabear_{}'.format(str(int(bear_stage)))+".png"
    # ----- DRAW DISTANCE -----
    for bear in bear_list:
        if character.x + 1123 > bear.x and character.x - 300 < bear.x:
            bear_an.append(gamebox.from_image(bear.x, bear.y, seabear_file))
    for seabear in bear_an:
        if time > 30:
            seabear.flip()
    for jellyfish in jf_list:
        if character.x + 1123 > jellyfish.x and character.x - 300 < jellyfish.x:
            jellyfish_an.append(gamebox.from_image(jellyfish.x, jellyfish.y, jf_file))
    if pygame.K_q in keys:
        quit()
    #  ----- WASD INPUT -----
    if character.touches(ground) and stick_check == 1:
        if pygame.K_c in keys:
            circle_check = 1
        else:
            circle_check = 0
    if global_stage.wasd_count != 0:
        if pygame.K_d in keys and circle_check == 0:
            character.xspeed += 9.5
            character.x += 9.5
            for item in hud:
                item.speedx += 9.5
            if face_check == 1:
                character_an.flip()
                face_check = 0
        if pygame.K_a in keys and circle_check == 0:
            character.speedx -= 9.5
            character.x -= 9.5
            for item in hud:
                item.speedx -= 9.5
            if face_check == 0:
                character_an.flip()
                face_check = 1


        # -----WASD COLLISION -----
        for object in jump_list:
            if character.bottom_touches(object):
                if pygame.K_a not in keys and pygame.K_d not in keys:
                    stage = 1
                if pygame.K_a in keys or pygame.K_d in keys and pygame.K_SPACE not in keys:
                    stage += 1/1.3
                character.yspeed = 0
                character.move_to_stop_overlapping(object)
                if pygame.K_SPACE in keys:
                    stage = 5
                    character.yspeed = -16

    #  ----- ARROW INPUT -----
    if global_stage.wasd_count == 0:
        if pygame.K_RIGHT in keys and circle_check == 0:
            character.xspeed += 95
            character.x += 95
            for item in hud:
                item.speedx += 9.5
            if face_check == 1:
                character_an.flip()
                face_check = 0
        if pygame.K_LEFT in keys and circle_check == 0:
            character.speedx -= 9.5
            character.x -= 9.5
            for item in hud:
                item.speedx -= 9.5
            if face_check == 0:
                character_an.flip()
                face_check = 1


        # ----- ARROW COLLISION -----
        for object in jump_list:
            if character.bottom_touches(object):
                if pygame.K_LEFT not in keys and pygame.K_RIGHT not in keys:
                    stage = 1
                if pygame.K_LEFT in keys or pygame.K_RIGHT in keys and pygame.K_SPACE not in keys:
                    stage += 1/1.3
                character.yspeed = 0
                character.move_to_stop_overlapping(object)
                if pygame.K_SPACE in keys:
                    stage = 5
                    character.yspeed = -16
    for w in wall:
        if character.touches(w):
            character.move_to_stop_overlapping(w)
    if character.touches(spatula) and spat_check == 0:
        spat_check = 1
        not_lame.play()
    if character.touches(stick) and stick_check == 0:
        stick_check = 1
        not_lame.play(0)
    if character.touches(secretformula) and secretformula_check == 0:
        secretformula_check = 1
        not_lame.play(0)
    for platform in platforms:
        if character.bottom_touches(platform):
            if pygame.K_DOWN in keys:
                character.y = character.y + y/10


    # ----- DEATH CHECK -----
    for jellyfish in jf_list:
        if character.bottom_touches(jellyfish):
            stage = 2
        if character.top_touches(jellyfish) and hit_check == 0:
            health -= 1
            hit_check = 1
            hit_moment = hit_interval
    for seabear in bear_an:
        if character.touches(seabear) and hit_check == 0 and circle_check == 0:
            health -= 1
            hit_check = 1
            hit_moment = hit_interval
        if circle_check == 1 and character.touches(seabear):
            health += 0
    if health == 0:
        character_an = gamebox.from_image(character.x, character.y, 'crying.png')
        gamebox.pause()


    # ----- DRAWING -----
    camera.clear("Black")
    for entry in background:
        camera.draw(entry)
    camera.draw(ground)
    camera.draw(house)
    for jellyfish in jellyfish_an:
        camera.draw(jellyfish)
    if secretformula_check == 0:
        camera.draw(secretformula)
    if stick_check == 0:
        camera.draw(stick)
    if spat_check == 0:
        camera.draw(spatula)
    for seabear in bear_an:
        camera.draw(seabear)
    if face_check == 1:
        character_an.flip()
    if circle_check == 1:
        camera.draw(circle)
    camera.draw(character_an)
    for entry in hud:
        camera.draw(entry)
    for platform in platforms:
        if character.x + 1300 > platform.x and character.x - 400 < platform.x:
            camera.draw(platform)
    camera.move(character.speedx, 0)
    if health == 0:
        x_coord = character.x
    if stick_check == 1 and spat_check == 1 and secretformula_check == 1 and character.x >= 9400:
        camera.draw(gamebox.from_image(9750, 400,"continue.png"))
        level = 2
    camera.display()
    health = 3
    spat_check = 1
    secretformula_check = 1
    stick_check = 1
Esempio n. 37
0
def tick(keys):
    global score
    global cash
    global wave
    global wave_started
    global tank_count
    global tick_count
    global ticks_per_second
    global timer
    global T
    
    # Count Tick
    if not wave_started:
        tick_count += 1
        if tick_count % ticks_per_second == 0:
            tick_count = 0
            timer -= 1
            
        if timer <= 0:
            enemy_tanks.extend(generate_tanks(tank_count, 600, 800, 0, 600))
            wave_started = True
            
    
    # Draw Objects
    camera.clear("black")
    camera.draw(background)
    
    camera.draw(king)
    
    # Remove Dead Bullets
    for bullet in bullets:
        if not bullet.alive:
            bullets.remove(bullet)
    
    # Move Bullets 
    for bullet in bullets:
        bullet.tick()
        if bullet.touches(king):
            print("King Killed")
            gamebox.pause()
        camera.draw(bullet)
    
    # Check Barriers
    for barrier in barriers:
        barrier.check(bullets)
        barrier.draw(camera)
        
        for etank in enemy_tanks:
            barrier.check_collision(etank)
    
    # Draw Mines
    for mine in mines:
        camera.draw(mine)
    
    kills = 0
    for tank in enemy_tanks:
        if (tank.y > king.y):
            if (tank.facing > 180 - 45):
                tank.turn_right()
        else:
            if (tank.facing < 180 + 45):
                tank.turn_left()
        
        for mine in mines:
            if not mine.live:
                mines.remove(mine)
            elif tank.touches(mine):
                boom = mine.explode()
                booms.append(boom)
        
        for boom in booms:
            if tank.touches(boom):
                if tank in enemy_tanks:
                    enemy_tanks.remove(tank)
                    kills += 1
                    
    cash += int(TANK_VALUE * (kills**2))
    
    for etank in enemy_tanks:

        etank.forward() 
        etank.tick()
        
        bullet = etank.fire_bullet()
        if bullet:
            bullets.append(bullet)
        camera.draw(etank)
    
    # Draw Booms 
    for boom in booms:
        boom.tick()
        camera.draw(boom)
        if not boom.alive:
            booms.remove(boom)
        
    for b in buttons:
        b.draw(camera)
        
    # Buttons
    if camera.mouseclick:
        
        if button_state_machine.has_state():
            s = button_state_machine.state
            mx, my = camera.mousex, camera.mousey
            if s == "BARRIER":
                if cash >= tankstuff.Barrier.price:
                    cash -= tankstuff.Barrier.price
                    barriers.append(tankstuff.Barrier(mx, my, 2, 4))
            elif s == "TURRET":
                pass
            elif s == "MINE":
                # Mine cannot be place touching another mine
                if cash >= tankstuff.Mine.price:
                    new_mine = tankstuff.Mine(mx, my)
                    touching = False
                    for mine in mines:
                        if new_mine.touches(mine):
                            touching = True
                            break
                    if not touching:
                        cash -= tankstuff.Mine.price
                        mines.append(new_mine)
                    
            print(button_state_machine.state)
            button_state_machine.clear_state()
        
        else:
            for b in buttons:
                
                if b.clicked(camera):
                    if b.text == "START":
                        if timer > 0 and not wave_started:
                            timer = 0
                    else:
                        button_state_machine.set_state(b.text)
    
    if not button_state_machine.has_state():
        if pygame.K_m in keys:
            button_state_machine.set_state("MINE")
            
        elif pygame.K_b in keys:
            button_state_machine.set_state("BARRIER")
            
        elif pygame.K_k in keys:
            button_state_machine.set_state("TURRET")
    
    # Wave Compleated
    if len(enemy_tanks) == 0 and wave_started:
        wave += 1
        tank_count += 1
        score += cash
        timer = PRE_WAVE_TIME
        wave_started = False
    
    if button_state_machine.has_state():
        placing_info = gamebox.from_text(650, 10, "PLACING: " + button_state_machine.state, "arial", 
                                         25, "white", True)
        camera.draw(placing_info)
     
    score_text = gamebox.from_text(700, 575, "SCORE: " + str(score), "arial", 20, "white", bold = True)
    cash_text = gamebox.from_text(700, 555, "CASH: " + str(cash), "arial", 20, "white", bold = True)
    wave_text = gamebox.from_text(50, 10, "WAVE: " +  str(wave), "arial", 20, "white", bold = True)
    wave_timer = gamebox.from_text(400, 25, str(timer) if timer != 0 else "WAVE START!", "arial", 40, "white", bold = True)
    camera.draw(score_text)
    camera.draw(cash_text)
    camera.draw(wave_text)
    camera.draw(wave_timer)
    
    # Display
    camera.display()
Esempio n. 38
0
def tick(keys):
    global player_one_frame
    global player_two_frame
    global player_one_has_flag
    global player_two_has_flag
    global player_one_counter
    global player_two_counter
    global game_start
    global game_end
    global direction
    global counter
    global timer
    global monster_frame
    global monster_sheet
    global touched_monster

    if game_start:
        camera.clear("black")
        beginning_title = gamebox.from_text(400, 250, "CAPTURE THE FLAG", "Arial", 46, "white")
        beginning_description = gamebox.from_text(400, 325, "PRESS SPACEBAR TO BEGIN", "Arial", 46, "white")

        camera.draw(beginning_title)
        camera.draw(beginning_description)

        if pygame.K_SPACE in keys:
            game_start = False

    else:
        timer -= 1

        camera.clear("green")

        player_one_frame += 1
        player_two_frame += 1
        counter += 1

        #animate the monster so that he walks in place
        monster_frame +=1

        #adjusts hulks speed here.
        #make the monster move ahead
        monster.y +=20

        if monster.y == 800:
            monster.y = 0

        if monster_frame == 16:
            monster_frame = 12
        if player_one_frame == 12:
            player_one_frame = 8
        if player_two_frame == 8:
            player_two_frame = 4
        if counter % 5 == 0:
            player_one.image = player_one_sheet[player_one_frame+direction*10]
            player_two.image = player_two_sheet[player_two_frame+direction*10]
            #place the monster on screen
            monster.image = monster_sheet[monster_frame + direction*10]

        if pygame.K_RIGHT in keys:
            player_one.x += 10
        if pygame.K_LEFT in keys:
            player_one.x -= 10
        if pygame.K_UP in keys:
            player_one.y -= 10
        if pygame.K_DOWN in keys:
            player_one.y += 10

        if pygame.K_d in keys:
            player_two.x += 10
        if pygame.K_a in keys:
            player_two.x -= 10
        if pygame.K_w in keys:
            player_two.y -= 10
        if pygame.K_s in keys:
            player_two.y += 10


        # detect if player 2 touched monster
        if player_two.touches(monster):
            game_end = True
            touched_monster = 2

        # detect if player 1 touched monster
        if player_one.touches(monster):
            game_end = True
            touched_monster = 1


        for flag in player_one_flag:
            if player_two.touches(flag):
                flag_sound.play()
                player_two_has_flag = True
                player_one_flag.remove(flag)
            camera.draw(flag)
        for flag in player_two_flag:
            if player_one.touches(flag):
                flag_sound.play()
                player_one_has_flag = True
                player_two_flag.remove(flag)
            camera.draw(flag)

        if player_one.touches(player_one_goal) and player_one_has_flag:
            goal_sound.play()
            new_flag = gamebox.from_image(750, 550, "red.png")
            player_two_flag.append(new_flag)
            player_two_flag[0].scale_by(0.15)
            player_one_counter += 1
            player_one_has_flag = False

        if player_two.touches(player_two_goal) and player_two_has_flag:
            goal_sound.play()
            new_flag = gamebox.from_image(50, 50, "blue.png")
            player_one_flag.append(new_flag)
            player_one_flag[0].scale_by(0.15)
            player_two_counter += 1
            player_two_has_flag = False

        player_one_counter_text = gamebox.from_text(75, 75, str(player_one_counter), "Arial", 28, "blue", italic = True)
        player_two_counter_text = gamebox.from_text(775, 575, str(player_two_counter), "Arial", 28, "red", italic = True)
        timer_display = gamebox.from_text(400, 25, str(timer // 30) + " seconds", "Arial", 46, "black")

        camera.draw(player_one)
        camera.draw(player_two)
        #draw the monster on screen
        camera.draw(monster)
        camera.draw(player_one_goal)
        camera.draw(player_two_goal)
        camera.draw(player_one_counter_text)
        camera.draw(player_two_counter_text)
        camera.draw(timer_display)

    if timer == 0:
        game_end = True

    if game_end:
        camera.clear("black")
        game_over_text = gamebox.from_text(400, 250, "GAME OVER", "Arial", 46, "white")
        continue_text = gamebox.from_text(400, 400, "PRESS ENTER TO REPLAY", "Arial", 46, "white")


        # player one had touched monster
        if touched_monster == 1:
            win_text = gamebox.from_text(400, 325, "PLAYER 2 wins as PLAYER 1 was eaten by monster", "Arial", 30, "white")
        # player 2 had touched monster
        elif touched_monster == 2:
            win_text = gamebox.from_text(400, 325, "PLAYER 2 wins as PLAYER 1 was eaten by monster", "Arial", 30, "white")
        elif player_one_counter > player_two_counter:
            win_text = gamebox.from_text(400, 325, "PLAYER 1 WINS WITH " + str(player_one_counter) + " FLAGS", "Arial", 46, "white")
        elif player_two_counter > player_one_counter:
            win_text = gamebox.from_text(400, 325, "PLAYER 2 WINS WITH " + str(player_two_counter) + " FLAGS", "Arial", 46, "white")
        else:
            win_text = gamebox.from_text(400, 325, "TIE", "Arial", 46, "white")

        camera.draw(game_over_text)
        camera.draw(win_text)
        camera.draw(continue_text)

        # reset the numbers
        if pygame.K_RETURN in keys:
            game_end = False
            game_start = True
            timer = 30 * 60
            player_one_counter = 0
            player_two_counter = 0
            touched_monster = 0
            player_one.x = 350
            player_one.y = 300
            player_two.x = 450
            player_two.y = 300

    camera.display()
Esempio n. 39
0
def tick(keys):

    # make things global
    global char_counter
    global enemy_counter

    # character moving left and right
    if pygame.K_RIGHT in keys:
        character.x += 5
    if pygame.K_LEFT in keys:
        character.x -= 5

    # jumping
    if pygame.K_SPACE in keys and character.bottom_touches(ground):
        character.yspeed -= 17

    # gravity
    character.yspeed += 1
    character.y = character.y + character.yspeed

    enemy.yspeed += 1
    enemy.y = enemy.y + enemy.yspeed

    # enemy moves towards you
    if enemy.x > character.x:
        enemy.x -= 3

    else:
        enemy.x += 3

    # stop collisions with ground
    if character.bottom_touches(ground):
        character.yspeed = 0

    if character.touches(ground):
        character.move_to_stop_overlapping(ground)

    if enemy.bottom_touches(ground):
        enemy.yspeed = 0

    if enemy.touches(ground):
        enemy.move_to_stop_overlapping(ground)

    # character jumps on enemy
    if character.bottom_touches(enemy):
        enemy.x = 30
        enemy.y = 50
        enemy.yspeed = 0
        character.yspeed = -7

    # character gets hit on side
    if character.left_touches(enemy) or character.right_touches(enemy):
        enemy.x = 30
        enemy.y = 50
        enemy.yspeed = 0
        lose_health()

    # character touches coin
    if character.left_touches(coin) or character.right_touches(coin):
        coin.x = random.randint(100, 500)
        char_counter += 1

    # enemy touches coin
    if enemy.left_touches(coin) or enemy.right_touches(coin):
        coin.x = random.randint(100, 500)
        enemy_counter += 1


    # draw everything
    camera.clear("cyan")
    camera.draw(character)
    camera.draw(enemy)
    camera.draw(ground)
    camera.draw(coin)


    if health[0] == True:
        camera.draw(health1)
    if health[1] == True:
        camera.draw(health2)
    if health[2] == True:
        camera.draw(health3)

    # create score and draw it
    char_score = gamebox.from_text(700, 50, str(char_counter), "Comic Sans MS", 30, "red")
    enemy_score = gamebox.from_text(500, 50, str(enemy_counter), "Comic Sans MS", 30, "green")
    camera.draw(char_score)
    camera.draw(enemy_score)

    # game over screen
    if health[2] == False and char_counter <= enemy_counter:
        camera.draw(game_over_background)
        camera.draw(game_over_text)
        camera.draw(char_score)
        camera.draw(enemy_score)
        gamebox.pause()

    if health[2] == False and char_counter > enemy_counter:
        camera.draw(game_over_background)
        camera.draw(win_game_over_text)
        camera.draw(char_score)
        camera.draw(enemy_score)
        gamebox.pause()

    camera.display()
Esempio n. 40
0
def sponge_run_function(keys):
    global death_move_check, cockroach_count, hit_moment, hit_interval, hit_check, pizza_health, c_stage, jump_check, time, rock_stage
    platform_object = []
    if pygame.K_q in keys:
        quit()
    platform_object.append(ground)
    for platform in platform_list:
        platform_object.append(gamebox.from_color(platform.x, platform.y + 15, "white", 240, 100))
    hit_interval += 1
    time += 2
    rock.yspeed += 1
    if hit_interval == 2 and global_stage.level == 2 and level_one.spat_check == 1:
        camera.move(-9200, 0)
    if pygame.K_DOWN in keys:
        rock.yspeed += 4
    c_stage += 1/1.7
    if hit_interval == hit_moment + 25:
        hit_check = 0
    if c_stage >= 4:
        c_stage = 1

    if time == 30:
        time = 0
        jump_check = 0
    if rock.bottom_touches(ground):
        rock_stage += 1/1.2
    if int(rock_stage) >= 4:
        rock_stage = 1

    if not rock.bottom_touches(ground):
        rock_stage = 4
    rock.x = rock.x + rock.speedx
    rock.y = rock.y + rock.speedy
    '''
    for platform in platform_object:
        platform.y = platform.y + platform.yspeed
    '''
    # ----- COLLISION ------
    for cockroach in cockroach_list:
        if rock.touches(cockroach) and hit_check == 0:
            hit_moment = hit_interval
            pizza_health -= 1
            hit_check = 1
    if rock.x > 35250:
        quit()
    for platform in platform_object:
        if rock.bottom_touches(platform):
            rock.yspeed = 0
            rock.move_to_stop_overlapping(platform)
            if platform != platform_object[0]:
                platform.y += 100
            if pygame.K_SPACE in keys:
                rock.yspeed = -20
                jump_check = 1

        if rock.right_touches(platform) and hit_check == 0:
            pizza_health -= 1
            hit_check = 1
            hit_moment = hit_interval

    # ----- GEN ANIMATION -----
    if pizza_health > 0:
        health_file = 'pizza_health_{}'.format(pizza_health) + ".png"
    else:
        health_file = 'pizza_health_1.png'
    health_hud = gamebox.from_image(rock.x + 4*x/5, 100, health_file)
    rock_file = 'rock_{}'.format(int(rock_stage)) + '.png'
    rock_an = gamebox.from_image(rock.x, rock.y, rock_file)
    camera.clear("White")
    if hit_check == 1:
        rock_stage = 4
        rock.xspeed = 15
    else:
        rock.xspeed = 25
    for shift in range(3):
        if hit_check == 1 and hit_interval >= hit_moment + shift*4 and hit_interval < hit_moment + (shift+1)*4:
            rock_an.rotate(random.randint(-30, 5))
    # ----- DRAWING ------

    camera.clear("Black")
    if pizza_health > 0:
        for platform in platform_object:
            camera.draw(platform)
        for entry in background:
            camera.draw(entry)
        for entry in house:
            camera.draw(entry)
        camera.draw(customer_house)
        for platform in platform_list:
            camera.draw(platform)
        camera.draw(rock_an)
        camera.move(rock.xspeed, 0)
        for cockroach in cockroach_list:
            if rock.x + 1300 > cockroach.x and rock.x - 300 < cockroach.x:
                camera.draw(cockroach)
        camera.draw(health_hud)
    else:
        rock.xspeed = 0
        if death_move_check == 0:
            camera.move(19440, 0)
            death_move_check = 1
        death_screen = gamebox.from_image(rock.x + 20000, 400, "deathscreen.jpg")
        quit_text = gamebox.from_text(rock.x + 20200, 400, "Press q to quit", "Cambria",100,  "White")
        camera.draw(death_screen)
        camera.draw(quit_text)
    camera.display()
def tick(keys):

    global score
    global sprite_counter

    # move player
    if pygame.K_LEFT in keys:
        player.x -= 10

    if pygame.K_RIGHT in keys:
        player.x += 10

    # shooting bullets
    if pygame.K_SPACE in keys and bullet1.yspeed == 0:
        shoot_bullet(bullet1)
        bullet_sound.play()

    elif pygame.K_SPACE in keys and bullet2.yspeed == 0:
        shoot_bullet(bullet2)
        bullet_sound.play()

    elif pygame.K_SPACE in keys and bullet3.yspeed == 0:
        shoot_bullet(bullet3)
        bullet_sound.play()

    if pygame.K_SPACE in keys:
        keys.remove(pygame.K_SPACE)

    # moving bullets
    bullet1.y -= bullet1.speedy
    bullet2.y -= bullet2.speedy
    bullet3.y -= bullet3.speedy

    # stop bullet off screen
    if bullet1.y < 0:
        bullet1.speedy = 0
    if bullet2.y < 0:
        bullet2.speedy = 0
    if bullet3.y < 0:
        bullet3.speedy = 0

    # create enemies if there aren't any
    while len(enemies) < 3:
        enemies.append(create_enemy())

    # move the enemies
    for enemy in enemies:
        enemy.x += enemy.xspeed

    # reverse enemies if necessary
    for enemy in enemies:
        if enemy.x < 0:
            enemy.xspeed *= -1
        elif enemy.x > 800:
            enemy.xspeed *= -1

    # kill enemies with bullets
    for enemy in enemies:
        for bullet in bullets:
            if enemy.touches(bullet):
                enemy.x = random.randint(0, 800)
                enemy.y = random.randint(0,2) * 75 + 50
                enemy.xspeed = random.randint(3, 10)
                score += 1
                enemy_explosion_sound.play(fade_ms = 100)

    # enemy shoots bullets
    for i in range(len(en_bullets)):
        if en_bullets[i].yspeed == 0:
            enemy_shoot_bullet(enemies[i], en_bullets[i])

    # enemy bullets move
    for bullet in en_bullets:
        bullet.y += bullet.yspeed

    # handle bullets going off the screen
    for bullet in en_bullets:
        if bullet.y > 600:
            bullet.yspeed = 0

    # update the score
    score_display = gamebox.from_text(750, 10, str(score), "Algerian", 12, "yellow")

    # handle animations
    sprite_counter += 1
    if sprite_counter == 6:
        sprite_counter = 0


    player.image = player_animations[sprite_counter]
    for enemy in enemies:
        enemy.image = enemy_animations[sprite_counter]

    # play music
    music_player

    # draw everything
    camera.clear("black")
    camera.draw(player)
    camera.draw(bullet1)
    camera.draw(bullet2)
    camera.draw(bullet3)
    camera.draw(score_display)

    if lives[0] == True:
        camera.draw(life3)
    if lives[1] == True:
        camera.draw(life2)
    if lives[2] == True:
        camera.draw(life1)

    for bullet in en_bullets:
        camera.draw(bullet)

    for enemy in enemies:
        camera.draw(enemy)

    # game over
    for bullet in en_bullets:
        if bullet.touches(player):
            lose_health()
            bullet.yspeed = 0
            lose_life_sound.play()

    if lives[2] == False:
        camera.draw(game_over_background)
        game_over_score = gamebox.from_text(400, 300, "Final Score: " + str(score), "Algerian", 20, "yellow")
        camera.draw(game_over_score)
        death_sound.play()
        music_player.pause()
        gamebox.pause()

    camera.display()
Esempio n. 42
0
def tick(keys):

    global score

    # move player
    if pygame.K_LEFT in keys:
        player.x -= 10

    if pygame.K_RIGHT in keys:
        player.x += 10

    # shooting bullets
    if pygame.K_SPACE in keys and bullet1.yspeed == 0:
        shoot_bullet(bullet1)

    elif pygame.K_SPACE in keys and bullet2.yspeed == 0:
        shoot_bullet(bullet2)

    elif pygame.K_SPACE in keys and bullet3.yspeed == 0:
        shoot_bullet(bullet3)

    if pygame.K_SPACE in keys:
        keys.remove(pygame.K_SPACE)

    # moving bullets
    bullet1.y -= bullet1.speedy
    bullet2.y -= bullet2.speedy
    bullet3.y -= bullet3.speedy

    # stop bullet off screen
    if bullet1.y < 0:
        bullet1.speedy = 0
    if bullet2.y < 0:
        bullet2.speedy = 0
    if bullet3.y < 0:
        bullet3.speedy = 0

    # create enemies if there aren't any
    while len(enemies) < 3:
        enemies.append(create_enemy())

    # move the enemies
    for enemy in enemies:
        enemy.x += enemy.xspeed

    # reverse enemies if necessary
    for enemy in enemies:
        if enemy.x < 0:
            enemy.xspeed *= -1
        elif enemy.x > 800:
            enemy.xspeed *= -1

    # kill enemies with bullets
    for enemy in enemies:
        for bullet in bullets:
            if enemy.touches(bullet):
                enemy.x = random.randint(0, 800)
                enemy.y = random.randint(0,2) * 75 + 50
                enemy.xspeed = random.randint(3, 10)
                score += 1

    # enemy shoots bullets
    for i in range(len(en_bullets)):
        if en_bullets[i].yspeed == 0:
            enemy_shoot_bullet(enemies[i], en_bullets[i])

    # enemy bullets move
    for bullet in en_bullets:
        bullet.y += bullet.yspeed

    # handle bullets going off the screen
    for bullet in en_bullets:
        if bullet.y > 600:
            bullet.yspeed = 0

    # update the score
    score_display = gamebox.from_text(750, 10, str(score), "Arial", 12, "yellow")

    # check for lives


    # draw everything
    camera.clear("black")
    camera.draw(player)
    camera.draw(bullet1)
    camera.draw(bullet2)
    camera.draw(bullet3)
    camera.draw(score_display)

    for bullet in en_bullets:
        camera.draw(bullet)

    for enemy in enemies:
        camera.draw(enemy)

    # game over
    for bullet in en_bullets:
        if bullet.touches(player):
            camera.draw(game_over_background)
            game_over_score = gamebox.from_text(400, 300, "Final Score: " + str(score), "Arial", 20, "yellow")
            camera.draw(game_over_score)
            gamebox.pause()

    camera.display()
Esempio n. 43
0
def tick(keys):
    global start_game
    global game_over
    global fail_over
    b3= gamebox.from_text(400,300,"Welcome to Yeti Jump! Get 10 points to win!", "Arial", 40, 'red', italic=True)
    b4 = gamebox.from_text(400,400, "Press s to start!","Arial", 40, 'red', italic=True)
    camera.draw(b3)
    camera.draw(b4)
    if pygame.K_s in keys:
        start_game = True
    if start_game is True:
        if fail_over is False:
            if game_over is False:
                global counter
                global lives
                global character_score
                if pygame.K_RIGHT in keys:
                    character.x += 10
                if pygame.K_LEFT in keys:
                    character.x -= 10
                character.yspeed += 1
                character.y = character.y + character.yspeed
                camera.clear("cyan")
                camera.draw(b1)
                camera.draw("Lives: " + str(lives), "Arial", 24, "red", 100, 100)

                camera.draw(character)
                if character.y > 600 or 800 >= character.x <= 0:
                    lives -= 1
                    charater_score = 0
                    character.x = walls[-1].x
                    character.y = walls[-1].y
                    camera.draw(character)

                camera.draw("Character Score: "+ str(character_score), "Arial", 24, "red", 100, 30)

                camera.y -= 3
                b1.y = camera.y

                global counter
                counter += 1
                if counter % 50 == 0:
                    new_wall = gamebox.from_color(random.randint(100,700), camera.y-300,  "black", random.randint(100,250), 10)
                    walls.append(new_wall)
                    if character.y >= new_wall.y + 600 or character.x < 0 or character.x > 800     :
                        lives -= 1
                        character.x = walls[-1].x
                        character.y = walls[-1].y
                        camera.draw(character)
                if counter%40 == 0:
                    coins.append(gamebox.from_color(random.randint(100,550),(character.y-200),"yellow",10,10))
                for coin in coins:
                    camera.draw(coin)
                    if character.touches(coin):
                        coins.remove(coin)
                        coin_sound = gamebox.load_sound('http://theodoregray.com/PeriodicTable/Sounds/029.2.wav')
                        musicplayer0=coin_sound.play()
                        character_score += 1
                        camera.draw("Character Score: " + str(character_score), "Arial", 24, "red", 100, 30)

                if counter%45 == 0:
                    enemy.append(gamebox.from_color(random.randint(100,550),(character.y-200),"red",5,5))
                multiplier = 1
                for thing in enemy:
                    thing.x += 10*multiplier
                    if thing.x >500 or thing.x<300:
                        multiplier = multiplier*-1

                    camera.draw(thing)
                    if character.touches(thing):
                        enemy.remove(thing)
                        character_score -= 5
                        lives -= 1
                        camera.draw("Character Score: " + str(character_score), "Arial", 24, "red", 100, 30)

                for wall in walls:
                    if character.bottom_touches(wall):
                        character.yspeed = 0
                        if pygame.K_SPACE in keys:
                            character.yspeed = -20
                    if character.touches(wall):
                        character.move_to_stop_overlapping(wall)
                    camera.draw(wall)


                if lives == 0:
                    fail_over = True
                if character_score is 10:
                    game_over = True



            else:
                camera.clear("white")
                camera.draw("You Win! Snooooow good", "Arial", 30,"red", 400, 300)
                camera.draw("Press q to quit", "Arial", 30, "red", 400, 500)
                if pygame.K_q in keys:
                    gamebox.stop_loop()
        else:
            camera.clear('white')
            camera.draw("Sorry you lost!", "Arial", 30, "red", 400, 250)
            camera.draw("Press q to quit", "Arial", 30, "red", 400, 450)
   
            if pygame.K_q in keys:
                gamebox.stop_loop()
    camera.display()
music2_count = 0
counter = 0
credit_count = 0
play_count = 0
option_count = 0
control_count = 0
sound_count = 0
camera = global_stage.camera
level_1 = 0
level_2 = 0
level_3 = 0
wasd_count = 0
sound_level = 0.5
char1 = gamebox.from_color(10, 10, "red", 50, 5)
char2 = gamebox.from_text(250, 50, "ya Motha", "Cambria", 70, "orange", True, True)
# char3 = gamebox.from_image(100, 100, "http://images6.fanpop.com/
# image/photos/33000000/The-Customer-s-House-krusty-krab-pizza-33032845-512-384.jpg")
char3 = gamebox.from_image(200, 400,
            "http://3219a2.medialib.glogster.com/creeperman913/media"
            "/18/18ee0bb8dd40f9d96af0d3dfd14687f97923fdf2/spongebob.png")
char4 = gamebox.from_text(350, 150, "By Luke and Connor (lsm5fm and cb4wa)", "Cambria", 30, "orange", False, True)
char5 = gamebox.from_text(683, 200, "Press 'P' to Play", "Cambria", 50, "red")
char6 = gamebox.from_text(683, 400, "Press 'O' for Options", "Cambria", 50, "red")
char7 = gamebox.from_text(683, 600, "Press 'C' for Credits", "Cambria", 50, "red")
titlebackground = gamebox.from_image(683, 384, "http://i.imgur.com/liXLthM.png")
titlebackground.size = 1366, 768
pygame.mouse.set_visible(False)


def set_all_volume(keys):
Esempio n. 45
0
# health boxes
health1 = gamebox.from_color(50, 50, "red", 20, 20)
health2 = gamebox.from_color(100, 50, "red", 20, 20)
health3 = gamebox.from_color(150, 50, "red", 20, 20)
health = [True, True, True]

def lose_health():
    for i in range(len(health)):
        if health[i] == True:
            health[i] = False
            break

# game starting screen
game_start_background = gamebox.from_color(400, 300, "black", 800, 600)
game_start_text = gamebox.from_text(400, 300, "Press Space to play!", "Comic Sans MS", 30, "yellow")
game_start_condition = True
def change_game_start():
    return False

# game over screen
game_over_background = gamebox.from_color(400, 300, "black", 800, 600)
game_over_text = gamebox.from_text(400, 300, "You lose!", "Comic Sans MS", 30, "yellow")
win_game_over_text = gamebox.from_text(400, 300, "You win!", "Arial", 30, "yellow")

# enemy
enemy = gamebox.from_color(750, 50, "green", 30, 60)

# ground
ground = gamebox.from_color(-100, 600, "black", 3000, 100)
Esempio n. 46
0
def tick(keys):
    # Game Beginning Screen and Starting the Game
    global game_start, pause, p1_score, yellow_coins, platforms, p1_health, up_last_pressed, was_touching, bar, background1, time

    if game_start is False:
        camera.clear("light blue")
        camera.draw(gamebox.from_text(400, 300, str("PRESS SPACE BAR TO START!"), "Arial", 50, "black", True))
        camera.draw(gamebox.from_text(400, 350, str("Press UP to jump"), "Arial", 30, "black", True))
        camera.display()
        if pygame.K_SPACE in keys:
            game_start = True
    if game_start is True:
        # Player 1 Collisions with objects
        p1.yspeed += 0.5
        p1.y += p1.yspeed
        if pygame.K_UP in keys and not up_last_pressed:
            p1.yspeed = -8
            music_jump1 = gamebox.load_sound("Jump.wav")
            musicplayer3 = music_jump1.play()
            up_last_pressed = True
        if not pygame.K_UP in keys:
            up_last_pressed = False

        nothing_touched = True  # check if nothing is touched
        for platform in platforms:
            if p1.touches(platform):
                if not was_touching:
                    p1_health -= 1
                p1.x += 65
                was_touching = True
                nothing_touched = False
        if nothing_touched:
            was_touching = False

        if p1.x > 200:
            p1.x -= scroll_speed
        if p1.touches(ground):
            was_touching = True
            p1.yspeed = 0
            p1.y -= 100
            p1_health -= 1
            if pygame.K_UP in keys:
                p1.yspeed -= 5
        if p1.touches(ceiling):
            p1.yspeed = 0
            p1.move_to_stop_overlapping(ceiling)
    # Platform Creation and Removal
        platform_creator()
    # Coin Creation and Removal
        y_coins()
    # Health
        if p1_health > 10:
            p1_health = 10
        bar = [gamebox.from_color(900 - (512-chunknum*25), 50, "red", 20, 20) for chunknum in range(p1_health)]
    # Score
        for platform in platforms[1::2]:
            if 200 <= platform.x < 200 + scroll_speed:
                p1_score += 1
    # Background
        background1.x -= scroll_speed
        if background1.x <= -(800 - scroll_speed):
            background1.x = 2400
        background2.x -= scroll_speed
        if background2.x <= -(800 - scroll_speed):
            background2.x = 2400
        time += 1

    # Visuals
        if pause is False:
            camera.clear("light blue")
            camera.draw(ground)
            camera.draw(background1)
            camera.draw(background2)
            for platform in platforms:
                camera.draw(platform)
            camera.draw(gamebox.from_text(50, 50, str(int(p1_score)), "Arial", 30, "brown", True))
            camera.draw(gamebox.from_text(750, 50, str(time//ticks_per_second), "Arial", 30, "black", True))
            camera.draw(black_bar)
            for chunk in bar:
                camera.draw(chunk)
            for yellow_coin in yellow_coins:
                camera.draw(yellow_coin)
            camera.draw(p1)
            camera.display()

    # Game Ending and Restarting
        if p1_health == 0 and pause is False:
            camera.clear("light blue")
            camera.draw(gamebox.from_text(400, 200, str("GAME OVER"), "Arial", 100, "black", True))
            camera.draw(gamebox.from_text(400, 300, str("Score: " + str(int(p1_score))), "Arial", 50, "brown"))
            camera.draw(gamebox.from_text(400, 350, str("You lasted: " + str(time//ticks_per_second) + " seconds"), "Arial", 50, "black"))
            camera.draw(gamebox.from_text(400, 400, str("Play again?"), "Arial", 50, "black"))
            camera.draw(gamebox.from_text(400, 440, str("(press the space bar)"), "Arial", 20, "black"))
            camera.display()
            pause = True                # Freeze the Game Over menu

        if pygame.K_SPACE in keys and pause is True:
            platforms = []
            yellow_coins = []
            p1_health = 10
            p1.y = 50
            p1_score = 0
            time = 0
            game_start = False      # Restart the game
            pause = False           # Unfreeze the game
Esempio n. 47
0
def tick(keys):

    for bluehole in blueholes:
        bluehole.scale_by(1.018)

    global x, score, y, platform_x, time_on, speed, platform_length, platform_end, prev_length, prev_end, prev_x, radius, prev_radius

    if y > 3:
        y =0
    y+=1

    if camera.x % 1000 == 0:
        speed += 4

    score = int(camera.x)
    scoreboard = gamebox.from_text(camera.x+300,50,(str(score)),"Verdana",26,"black")

    camera.x += speed
    alien.x += speed




    if alien.x >= (platform_x - platform_length/2) and alien.x <= (platform_x - platform_length/2):
        time_on += speed
    elif alien.x >= platform_x - platform_length/2:
        time_on = 0


    if len(platforms) < 10:
        prev_length = int(platform_length)
        prev_x = int(platform_x)
        prev_end = int(platform_end)
        prev_radius = radius

        platform_length = int(random.randint(300,600))
        radius = int(platform_length/2)
        platform_x = prev_end + radius + random.randint(25,200)

        platform_end = platform_x + radius


        height = random.randint(300,700)
        platforms.append(gamebox.from_color(platform_x,height,"black",2*radius,30))


    if len(blueholes) < 2:
        bluehole_x = random.randint(camera.x,camera.x+500)
        bluehole_y = random.randint(0,800)

        blueholes.append(gamebox.from_image(bluehole_x,bluehole_y,blue_hole_sheet[y]))








    # GRAVITY
    alien.yspeed += 1.5
    alien.y = alien.y + alien.yspeed




    if pygame.K_s in keys:
        alien.image = "http://people.virginia.edu/~mak2vr/files/alien/alien_top.png"
    elif pygame.K_d in keys:
        alien.image = "http://people.virginia.edu/~mak2vr/files/alien/alien_middle.png"
    elif pygame.K_f in keys:
        alien.image = "http://people.virginia.edu/~mak2vr/files/alien/alien_bottom.png"
    else:
        alien.image = "http://people.virginia.edu/~mak2vr/files/alien/alien.png"

    for platform in platforms:
        if alien.bottom_touches(platform):
            alien.move_to_stop_overlapping(platform)
        if platform.x < (camera.x-1000):
            platforms.remove(platform)
        if alien.touches(platform):
            if pygame.K_SPACE in keys:
                alien.yspeed -= 30


    if pygame.K_RIGHT in keys:
        alien.x += 5
    if pygame.K_LEFT in keys:
        alien.x -= 5
    camera.clear("skyblue")
    camera.draw(alien)
    camera.draw(scoreboard)
    for platform in platforms:
        camera.draw(platform)
    for bluehole in blueholes:
        camera.draw(bluehole)
    camera.display()


    game_over = gamebox.from_text(camera.x,400,"Game Over","Arial",40,"black",True)

    def end():
        gamebox.pause()
        camera.clear("skyblue")
        camera.draw(game_over)
        camera.display()

    for bluehole in blueholes:
        bluehole.image = blue_hole_sheet[y]
        if bluehole.x < (camera.x-500):
            blueholes.remove(bluehole)
        if alien.touches(bluehole):
            end()


    if alien.y >= 800:
        end()
Esempio n. 48
0
 def draw(self, camera):
     camera.draw(self.box)
     if self.text:
         t = gamebox.from_text(self.x, self.y, self.text, 'arial', 10, self.text_color)
         camera.draw(t)