Ejemplo n.º 1
0
def check_explosion():
    global explosion_bool, x_pos, y_pos
    if explosion_bool:
        for i in explosion:
            pew = gamebox.from_image(x_pos, y_pos, i)
            pew.scale_by(0.30)
            camera.draw(pew)
        gamebox.load_sound('sound effects explosion_1.wav').play()
    explosion_bool = False
Ejemplo n.º 2
0
def shoot(keys):
    global shoot_timer
    if pygame.K_SPACE in keys:
        if shoot_timer > 3:
            missiles.append(
                gamebox.from_color(ship.x + 1, ship.y - 25, "red", 7, 7))
            gamebox.load_sound('pew.wav').play()
            shoot_timer = 0
        keys.clear()
    for missile in missiles:
        missile.y -= 22
        camera.draw(missile)
Ejemplo n.º 3
0
def y_coins():
    global p1_score, platforms, yellow_coins, scroll_speed, p1_health, tick_count, tick_count_2
    for platform in platforms[1::2]:
        if 600 <= platform.x < 600 + scroll_speed:
            coin_height = random.randint(150, 450)
            yellow_coin = gamebox.from_image(800, coin_height, "coin_1.png")
            yellow_coins.append(yellow_coin)
            if yellow_coin.touches(platform):
                yellow_coin.move_to_stop_overlapping(platform)
    for yellow_coin in yellow_coins:
        yellow_coin.image = "coin_" + str(tick_count_2 + 1) + ".png"
        yellow_coin.x -= scroll_speed
        if p1.touches(yellow_coin):
            yellow_coins.remove(yellow_coin)
            p1_score += 1
            music0 = gamebox.load_sound("hit_sound.wav")
            musicplayer0 = music0.play()
        if yellow_coin.x < -50:
            yellow_coins.remove(yellow_coin)

        tick_count = (tick_count + 1) % 128
        tick_count_2 = tick_count // 16
Ejemplo n.º 4
0
def y_coins():
    global p1_score, platforms, yellow_coins, scroll_speed, p1_health, tick_count, tick_count_2
    for platform in platforms[1::2]:
        if 600 <= platform.x < 600 + scroll_speed:
            coin_height = random.randint(150, 450)
            yellow_coin = gamebox.from_image(800, coin_height, "coin_1.png")
            yellow_coins.append(yellow_coin)
            if yellow_coin.touches(platform):
                yellow_coin.move_to_stop_overlapping(platform)
    for yellow_coin in yellow_coins:
        yellow_coin.image = "coin_"+str(tick_count_2+1)+".png"
        yellow_coin.x -= scroll_speed
        if p1.touches(yellow_coin):
            yellow_coins.remove(yellow_coin)
            p1_score += 1
            music0 = gamebox.load_sound("hit_sound.wav")
            musicplayer0 = music0.play()
        if yellow_coin.x < -50:
            yellow_coins.remove(yellow_coin)

        tick_count = (tick_count+1) % 128
        tick_count_2 = tick_count//16
Ejemplo n.º 5
0
# Connor Bottcher (cb4wa) Luke Masters (lsm5fm)

import pygame
import gamebox
import global_stage
import level_one
import level_two


music1 = gamebox.load_sound('Spongebob_Uke.wav')
music2 = gamebox.load_sound('Spongebob Pizza song.wav')


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,
Ejemplo n.º 6
0
                           random.randrange(camera.y, camera.bottom),
                           "shell.png"))
for shell in shells:
    shell.scale_by(0.07)
    for x in shells:
        if shell.touches(x):
            shell.move_to_stop_overlapping(x)
    for rock in rocks:
        if shell.touches(rock):
            shell.move_to_stop_overlapping(rock)

bc1 = gamebox.from_image(camera.x, camera.y, "bc1 (1).png")
bc2 = gamebox.from_image(camera.x + 1024, camera.y, "bc2 (1).png")

# #SOUND EFFECTS
bad = gamebox.load_sound("popsound.wav")
bubbles = gamebox.load_sound("badnoise.wav")

youlose = gamebox.from_text(camera.x, camera.y, "Oh No! You lose!", "Arial",
                            50, "white")

x = 0  #grace period


#start screen with instructions
def splash(keys):
    global show_splash, ticks, box

    camera.draw(bc1)
    camera.draw(bc2)
    bc1.x -= 10
Ejemplo n.º 7
0
import pygame
import gamebox
import global_stage
x = 1366
y = 768

#if global_stage.level == 1:

level = global_stage.level
origin_x = 260
origin_y = 543
camera = global_stage.camera
background = []
check = 0
stage = 1
not_lame = gamebox.load_sound('notlame_louder.wav')
hit_check = 0
hit_moment = 0
hit_interval = 0
circle_stage = 1
face_check = 0
time = 0
jump_check = 0
seconds = 0
minutes = 0
jf_stage = 1
spat_stage = 1
secretformula_check = 0
spat_check = 0
stick_check = 0
health = 3
Ejemplo n.º 8
0
    with open("highscores.txt", 'r') as scores:
        max = 0
        for line in scores:
            line = int(line)
            if line > max:
                max = int(line)
        return str(max)


# title and instruction screens
Width, Length = 800, 700
camera = gamebox.Camera(Width, Length)
imageLink = "https://virginia.box.com/shared/static/"  # used to shorten code in the future

# music
music = gamebox.load_sound(imageLink + "cb5aac92sf9r1zm9ztmb5vxu7g19s4pa")
musicplayer3 = music.play(-1)

# loading screens
splashscreen1 = gamebox.load_sprite_sheet(
    imageLink + "v661x3zpy4fge6wi8ubbinp3ey0r4495", 1, 16)
splashscreen1dummy = gamebox.from_color(camera.x, camera.y, 'black', 800, 700)
splashscreen2 = gamebox.load_sprite_sheet(
    imageLink + "g7wvy29g47qjgkrdobmiqctyuhxnjtil", 1, 16)
splashscreen2dummy = gamebox.from_color(camera.x, camera.y, 'black', 800, 700)

# conditions that control appearance of menus and other items
game_on = False
g_on = False

# used for animation of ship sprites
Ejemplo n.º 9
0
p2north = True
p2south = False
p2east = False
p2west = False

## CREATING WALLS/BOUNDARIES FOR GAME

walls = [
    gamebox.from_color(100, 400, "green", 5, 600),
    gamebox.from_color(700, 400, "green", 5, 600),
    gamebox.from_color(400, 100, "green", 605, 5),
    gamebox.from_color(400, 599, "green", 600, 5)
]

## DEFINING SOUND VARAIBLES FOR GAME
backgroundsound = gamebox.load_sound('Tron.wav')
explosionsound = gamebox.load_sound('Explosion 1.wav')
coinsound = gamebox.load_sound('Coin.wav')
restartsound = gamebox.load_sound('Restart.wav')

## DEFINING COINS LIST AND VARAIBLES
coinsprite = gamebox.load_sprite_sheet("Coin.png", 1, 1)
coins = [gamebox.from_image(400, random.randint(120, 580), coinsprite[0])]
coins[0].scale_by(0.5)

## ------------------------------------------ CODE --------------------------------------------


def tick(keys):
    ## GLOBAL VARIABLES
    global scoreplayer1, scoreplayer2, agreed, countup, p1north, p1west, p1east, p1south, \
Ejemplo n.º 10
0
character_score = 0
character_health = 100
computer_score = 0
computer_health = 100
game_on = False

camera = gamebox.Camera(800, 600)
backsheet = gamebox.load_sprite_sheet(
    "http://openbookproject.net/thinkcs/python/english3e/_images/background.png",
    1, 1)
sheet = gamebox.load_sprite_sheet(
    "http://openbookproject.net/thinkcs/python/english3e/_images/duke_spritesheet.png",
    1, 10)
sheet2 = gamebox.load_sprite_sheet("http://i.stack.imgur.com/WRTsK.png", 1, 8)
coin_sound = gamebox.load_sound("coin.wav")
scream_sound = gamebox.load_sound("scream1.wav")
frame = 0
frame2 = 0
counter = 0
counter2 = 0
back = gamebox.from_image(400, 300, backsheet[0])
character = gamebox.from_image(200, 200, sheet[frame])
computer = gamebox.from_image(500, 500, sheet2[frame2])
coin = gamebox.from_color(random.randint(200, 500), random.randint(200, 500),
                          "yellow", 20, 20)
text = gamebox.from_text(400, 290, "Go to 10 to win!!!", "Courier New", 17,
                         "white", True)

ground = gamebox.from_color(-100, 600, "black", 3000, 150)
character.yspeed = 0
Ejemplo n.º 11
0
    gamebox.from_image(2200, 90, "http://www.gdunlimited.net/resources/image/4946/leprechauns-gold-coin-new/gallery_19500_228_193.png"),
    gamebox.from_image(2700, 570, "http://www.gdunlimited.net/resources/image/4946/leprechauns-gold-coin-new/gallery_19500_228_193.png"),
    gamebox.from_image(3000, 1, "http://www.gdunlimited.net/resources/image/4946/leprechauns-gold-coin-new/gallery_19500_228_193.png"),
    gamebox.from_image(3290, 70, "http://www.gdunlimited.net/resources/image/4946/leprechauns-gold-coin-new/gallery_19500_228_193.png"),
    gamebox.from_image(3400, 70, "http://www.gdunlimited.net/resources/image/4946/leprechauns-gold-coin-new/gallery_19500_228_193.png"),
    gamebox.from_image(2920, 300, "http://www.gdunlimited.net/resources/image/4946/leprechauns-gold-coin-new/gallery_19500_228_193.png"),
    gamebox.from_image(4100, 80, "http://www.gdunlimited.net/resources/image/4946/leprechauns-gold-coin-new/gallery_19500_228_193.png"),
    gamebox.from_image(5700, 5, "http://www.gdunlimited.net/resources/image/4946/leprechauns-gold-coin-new/gallery_19500_228_193.png"),
    gamebox.from_image(5500, 5, "http://www.gdunlimited.net/resources/image/4946/leprechauns-gold-coin-new/gallery_19500_228_193.png"),
    gamebox.from_image(3900, -55, "http://www.gdunlimited.net/resources/image/4946/leprechauns-gold-coin-new/gallery_19500_228_193.png"),
    gamebox.from_image(3800, -85, "http://www.gdunlimited.net/resources/image/4946/leprechauns-gold-coin-new/gallery_19500_228_193.png"),
    gamebox.from_image(5700, 5, "http://www.gdunlimited.net/resources/image/4946/leprechauns-gold-coin-new/gallery_19500_228_193.png"),
    gamebox.from_image(5600, 5, "http://www.gdunlimited.net/resources/image/4946/leprechauns-gold-coin-new/gallery_19500_228_193.png")
]

coin_sound=gamebox.load_sound("https://www.freesound.org/people/bradwesson/sounds/135936/135936__bradwesson__collectcoin.wav")
gameOver_sound=gamebox.load_sound("256091__soundeffectspodcast-com__game-over-voice-2b.wav")
win_sound=gamebox.load_sound("Short_triumphal_fanfare-John_Stracke-815794903.wav")
game_start=False
game_over=False
coin_count=0
timer=0

def tick(keys):
    global game_start
    global coin_count
    global frame
    global counter
    global game_over
    global timer
Ejemplo n.º 12
0
def tick(keys):
    global bullets_l
    global bullets_r
    global character
    global character_speed
    global clicked_home
    global clicked_instructions
    global clicked_leaderboard
    global clicked_skulls
    global coin_sheet
    global coins_towards_reload_increase
    global counter_coins
    global counter_enemy
    global counter_space
    global counter_side
    global counter_air
    global curr_pos
    global difficulty_increasing
    global enemies
    global enemy_explosions
    global enemy_spawn_rate
    global explosion_length
    global falling
    global falling_coin_rate
    global heal
    global run_home
    global kills
    global life
    global line_read
    global loading_1
    global orientation
    global records_coins
    global reload
    global reload_time
    global run_home
    global run_instructions
    global run_leaderboards
    global run_skulls
    global tic_cnt
    global velocity
    global score
    global shot_direction
    global waterfall_rotation

    guidelines = [
        gamebox.from_color(100, 300, 'white', 1, 600),
        gamebox.from_color(200, 300, 'white', 1, 600),
        gamebox.from_color(300, 300, 'white', 1, 600),
        gamebox.from_color(400, 300, 'white', 1, 600),
        gamebox.from_color(500, 300, 'white', 1, 600),
        gamebox.from_color(600, 300, 'white', 1, 600),
        gamebox.from_color(700, 300, 'white', 1, 600),
        gamebox.from_color(800, 300, 'white', 1, 600),
        gamebox.from_color(900, 300, 'white', 1, 600),
        gamebox.from_color(500, 100, 'white', 1000, 1),
        gamebox.from_color(500, 200, 'white', 1000, 1),
        gamebox.from_color(500, 300, 'white', 1000, 1),
        gamebox.from_color(500, 400, 'white', 1000, 1),
        gamebox.from_color(500, 500, 'white', 1000, 1),
    ]

    score_rec_disp = open('scoreboard.txt', 'r')
    line_read = score_rec_disp.readline().split(',')
    score_rec_disp.close()
    for string_score in range(len(line_read)):
        line_read[string_score] = int(line_read[string_score])
    line_read = sorted(line_read)
    line_read.reverse()

    camera.draw(gamebox.from_image(500, 300, 'loading_bg.png'))

    # clicked test
    # #####################################################################
    #sets up clicks
    # SHOWS LEADERBOARDS
    if 440 < camera.mousex < 560 and 380 < camera.mousey < 540 and camera.mouseclick and run_skulls is False and run_leaderboards is False:
        clicked_leaderboard = True
        clicked_home = False
        camera.clear('black')
    # PLAYS GAME
    if ((316 < camera.mousex < 622 and 267 < camera.mousey < 332) or
        (622 < camera.x < 685 and 235 < camera.y < 365)) and camera.mouseclick:
        clicked_skulls = True
        clicked_leaderboard = False
        clicked_home = False

    #changes lighting of play game arrow
    if (316 < camera.mousex < 622
            and 267 < camera.mousey < 332) or (622 < camera.x < 685
                                               and 235 < camera.y < 365):
        loading_1[3] = gamebox.from_image(500, 300, arrow_sheet[1])
    else:
        loading_1[3] = gamebox.from_image(500, 300, arrow_sheet[0])

    #changes lighting of instructions arrow
    if (316 < camera.mousex < 622
            and 17 < camera.mousey < 182) or (622 < camera.x < 685
                                              and 85 < camera.y < 185):
        loading_1[4] = gamebox.from_image(500, 150, inst_button_sheet[1])
    else:
        loading_1[4] = gamebox.from_image(500, 150, inst_button_sheet[0])

    # HOME BUTTON
    if (run_leaderboards or run_instructions) and run_skulls is False and (
            camera.mousex >= 936 and camera.mousey >= 536
            and camera.mouseclick):
        clicked_home = True
        clicked_leaderboard = False
        clicked_instructions = False

    #sets up click for instructions
    if (
        (316 < camera.mousex < 622 and 17 < camera.mousey < 182) or
        (622 < camera.x < 685 and 235 < camera.y < 365)
    ) and camera.mouseclick and run_skulls is False and run_instructions is False:
        clicked_instructions = True
        clicked_home = False

# #####################################################################
#uses clicks to set up runs
    if clicked_leaderboard:
        run_leaderboards = True
        run_home = False
    elif clicked_leaderboard is False:
        run_leaderboards = False

    if clicked_skulls:
        run_skulls = True

    if clicked_home:
        run_home = True
    elif clicked_home is False:
        run_home is False

    if clicked_instructions:
        run_instructions = True
        run_home = False
    elif clicked_instructions is False:
        run_instructions = False

#runs leaderboards based upon above
    if run_leaderboards:
        counter_coins += 1
        falling_coin_rate += 1
        if counter_coins == 2:
            waterfall_rotation += 1
            counter_coins = 0
        if waterfall_rotation == 28:
            waterfall_rotation = 0
        if falling_coin_rate == 5:
            falling_coin_rate = 0
            records_coins.append(
                gamebox.from_image(random.randint(15, 985), 15,
                                   coin_sheet[1 + waterfall_rotation]))
        for record_coin in records_coins:
            record_coin.y += 2
            record_coin = gamebox.from_image(
                record_coin.x, record_coin.y,
                coin_sheet[1 + waterfall_rotation])
            if record_coin.y > 610:
                del records_coins[0]
            camera.draw(record_coin)
        camera.draw(gamebox.from_image(968, 568, 'home_button.png'))
        camera.draw(
            gamebox.from_text(500,
                              50,
                              'HIGH SCORES',
                              'Arial',
                              100,
                              'gold',
                              bold=True,
                              italic=True))
        if len(line_read) < 5:
            top_five = len(line_read)
        else:
            top_five = 5

            for b in range(5, 10):
                sum_2 = 150 + 100 * (b - 5)
                camera.draw(
                    gamebox.from_text(766,
                                      sum_2,
                                      str(line_read[b]),
                                      'Arial',
                                      100,
                                      'white',
                                      bold=False))
                camera.draw(
                    gamebox.from_text(623, sum_2,
                                      str(b + 1) + '.  ', 'Arial', 80,
                                      'black'))

        for a in range(0, top_five):
            sum = 150 + 100 * a
            if a < 3:
                camera.draw(
                    gamebox.from_text(350,
                                      sum,
                                      str(line_read[a]),
                                      'Arial',
                                      100,
                                      'gold',
                                      bold=True,
                                      italic=True))
                camera.draw(
                    gamebox.from_text(220, sum,
                                      str(a + 1) + '.  ', 'Arial', 80, 'red'))
            else:
                camera.draw(
                    gamebox.from_text(333,
                                      sum,
                                      str(line_read[a]),
                                      'Arial',
                                      100,
                                      'white',
                                      bold=False))
                camera.draw(
                    gamebox.from_text(220, sum,
                                      str(a + 1) + '.  ', 'Arial', 80,
                                      'black'))

#runs home based upon above
    if run_home:
        for parts in loading_1:
            camera.draw(parts)

    # for guides in guidelines:
    #     camera.draw(guides)

#runs instructions
    if run_instructions:
        #camera.clear('black')
        camera.draw(gamebox.from_image(968, 568, 'home_button.png'))
        camera.draw(
            gamebox.from_text(
                500, 100,
                'Hello! This is __ created by Andrew Walsh and Kevin Naddoni. Objectives and controls are listed below.',
                'Arial', 20, 'white', False, False))
        camera.draw(
            gamebox.from_text(
                500, 150,
                'On the homepage, click on the Trophy to see the Top Scores!',
                'Arial', 20, 'white'))
        camera.draw(
            gamebox.from_text(200, 200, 'Objectives:', 'Arial', 20, 'white',
                              True, False))
        camera.draw(
            gamebox.from_text(500, 250, 'Collect as many coins as possible!',
                              'Arial', 20, 'white', False, False))
        camera.draw(
            gamebox.from_text(
                500, 300,
                'Enemies will hurt you if you touch them. Shoot them down with your laser pistol!',
                'Arial', 20, 'white', False, False))
        camera.draw(
            gamebox.from_text(
                500, 350, 'Play until you reach the top of the leaderboards!',
                'Arial', 20, 'white', False, False))
        camera.draw(
            gamebox.from_text(200, 400, 'Controls:', 'Arial', 20, 'white',
                              True, False))
        camera.draw(
            gamebox.from_text(500, 450,
                              'Use arrow keys (←,→,↓,↑) to travel the map',
                              'Arial', 20, 'white', False, False))
        camera.draw(
            gamebox.from_text(500, 500,
                              'Press the spacebar to shoot at enemies',
                              'Arial', 20, 'white', False, False))


# ############################################################################################################################
    if run_skulls:
        coin_sound = gamebox.load_sound('coin_sound.wav')
        gun_sound = gamebox.load_sound('gun_sound.wav')
        enemy_death_sound = gamebox.load_sound('enemy_death_sound.wav')
        game_over_sound = gamebox.load_sound('game_over.wav')
        for varb in range(len(tic_cnt)):
            tic_cnt[varb] += 1

        if pygame.K_p in keys:
            gamebox.pause()

        background = gamebox.from_image(500, 300, 'background_image.jpg')
        background.size = 1000, 700
        camera.draw(background)

        #                            x center//y center//colour//width//height
        walls = [
            gamebox.from_image(500, 595, 'platform_block.png'),
            gamebox.from_image(75, 500, 'platform_block.png'),
            gamebox.from_image(400, 380, 'platform_block.png'),
            gamebox.from_image(290, 440, 'platform_block.png'),
            gamebox.from_image(600, 398, 'platform_block.png'),
            gamebox.from_image(900, 320, 'platform_block.png'),
            gamebox.from_image(750, 540, 'platform_block.png'),
            gamebox.from_image(160, 340, 'platform_block.png'),
            gamebox.from_image(860, 480, 'platform_block.png'),
            gamebox.from_image(765, 440, 'platform_block.png'),
            gamebox.from_image(450, 500, 'platform_block.png'),
            gamebox.from_image(30, 260, 'platform_block.png'),
            gamebox.from_image(250, 150, 'platform_block.png'),
            gamebox.from_image(450, 150, 'platform_block.png'),
            gamebox.from_image(100, 205, 'platform_block.png'),
            gamebox.from_image(650, 260, 'platform_block.png'),
            gamebox.from_image(550, 205, 'platform_block.png'),
        ]

        walls[0].size = 1000, 10
        walls[1].size = 200, 10
        walls[2].size = 50, 10
        walls[3].size = 50, 10
        walls[4].size = 200, 10
        walls[5].size = 250, 10
        walls[6].size = 160, 10
        walls[7].size = 200, 10
        walls[8].size = 50, 10
        walls[9].size = 50, 10
        walls[10].size = 180, 10
        walls[11].size = 60, 10
        walls[12].size = 130, 10
        walls[13].size = 130, 10
        walls[14].size = 20, 10
        walls[15].size = 100, 10
        walls[16].size = 20, 10
        sides = [
            gamebox.from_color(1, 300, 'black', 2, 600),
            gamebox.from_color(999, 300, 'black', 2, 600)
        ]

        #    Variables

        invincibility = False
        coin_life_span = (60) * 6
        character_speed = 4
        enemy_speed = 2
        heal_power = 25
        jump_power = -15
        sprite_speed = 8
        # Number of seconds it takes for a new enemy to spawn
        coin_spawn_rate = (60) * 5
        # ####### Increasing Difficulty #########################

        coins_to_hasten_reload = 8
        reload_reduction = 4
        coins_to_increase_enemy_spawn_rate = 6
        amount_spawn_rate_increases = 30
        coins_to_heal = 10

        # Sets the speed that the animation changes
        if tic_cnt[1] % sprite_speed == 0:
            tic_cnt[1] = 0
            counter_space += 1
            counter_side += 1
            counter_enemy += 1
            counter_coins += 1

        if counter_enemy == 3:
            counter_enemy = 0
        if counter_space == 6:
            counter_space = 0
        if counter_side == 5:
            counter_side = 0
        if counter_coins == 28:
            counter_coins = 0

    # Creates 'Gravity'
        velocity += 1
        character.y += velocity

        # **Sets boundaries of the screen

        if character.x > 1000:
            character.x = 1000
        if character.x < 0:
            character.x = 0
        if character.y < 30:
            character.y = 30
        if character.y > 590:
            character.y = 590

    # Test for falling
        if curr_pos != character.y:
            falling = True
        else:
            falling = False
        curr_pos = character.y

        # Create Enemies

        tic_cnt[2] += 1
        if tic_cnt[2] >= enemy_spawn_rate:
            enemies.append(
                gamebox.from_image(random.randint(10, 990), 30,
                                   enemy_sheet[counter_enemy]))
            tic_cnt[2] = 0

    # ############################ SHOOTING ###########################################################

        if reload > 0:
            reload -= 1
        if reload == 0:
            if pygame.K_SPACE in keys:
                if orientation == 'L':
                    bullets_l.append(
                        gamebox.from_image(character.x, character.y,
                                           'bullet_l.png'))
                    gun_sound.play()
                    reload = reload_time
                else:
                    bullets_r.append(
                        gamebox.from_image(character.x, character.y,
                                           'bullet_r.png'))
                    gun_sound.play()
                    reload = reload_time

        for c in range(len(bullets_l)):
            bullets_l[c].x -= 5
        for d in range(len(bullets_r)):
            bullets_r[d].x += 5

        for p in range(len(explosion_length)):
            explosion_length[p] += 1
            if explosion_length[p] == 15:
                del enemy_explosions[p]
                del explosion_length[p]

        for bullet_l in bullets_l:
            for side in sides:
                if bullet_l.touches(side):
                    bullets_l.remove(bullet_l)
            for wall in walls:
                if bullet_l.touches(wall):
                    bullets_l.remove(bullet_l)
            for enemy in enemies:
                if bullet_l.touches(enemy):
                    enemy_explosions.append(
                        gamebox.from_image(enemy.x, enemy.y, 'explosion.png'))
                    explosion_length.append(0)
                    enemies.remove(enemy)
                    enemy_death_sound.play()
                    kills += 1
                    if bullet_l in bullets_l:
                        bullets_l.remove(bullet_l)
            if life != 0:
                camera.draw(bullet_l)

        for bullet_r in bullets_r:
            for side in sides:
                if bullet_r.touches(side):
                    bullets_r.remove(bullet_r)
            for wall in walls:
                if bullet_r.touches(wall):
                    bullets_r.remove(bullet_r)
            for enemy in enemies:
                if bullet_r.touches(enemy):
                    enemy_explosions.append(
                        gamebox.from_image(enemy.x, enemy.y, 'explosion.png'))
                    explosion_length.append(0)
                    enemies.remove(enemy)
                    enemy_death_sound.play()
                    kills += 1
                    if bullet_r in bullets_r:
                        bullets_r.remove(bullet_r)
            if life != 0:
                camera.draw(bullet_r)

        if orientation == 'L':
            shot_direction = -5
        else:
            shot_direction = 5

    # ############################ SHOOTING ###########################################################

        if pygame.K_RIGHT in keys:
            if character.x <= 988:
                character.x += 1
                if pygame.K_SPACE not in keys or falling:
                    character.x += character_speed
            orientation = 'R'

        if pygame.K_LEFT in keys:
            if character.x >= 12:
                character.x -= 1
                if pygame.K_SPACE not in keys or falling:
                    character.x -= character_speed
            orientation = 'L'

        if pygame.K_SPACE in keys and pygame.K_RIGHT not in keys and pygame.K_LEFT not in keys and not falling:
            character = gamebox.from_image(character.x, character.y, sheet[19])

        elif pygame.K_SPACE in keys and (pygame.K_RIGHT in keys
                                         or pygame.K_LEFT
                                         in keys) and not falling:
            character = gamebox.from_image(character.x, character.y,
                                           sheet[16 + counter_space])
        elif pygame.K_SPACE not in keys and (pygame.K_RIGHT in keys
                                             or pygame.K_LEFT
                                             in keys) and not falling:
            character = gamebox.from_image(character.x, character.y,
                                           sheet[8 + counter_side])
        else:
            character = gamebox.from_image(character.x, character.y,
                                           sheet[1 + counter_space])

    # ############# Health ################################################
        for hurt in enemies:
            if character.touches(hurt):
                #if life > 0:
                life -= 5
        if life == 0:

            if invincibility == False:
                gamebox.pause()
            game_over_sound.play()

            # score_rec_disp = open('scoreboard.txt', 'r')
            # line_read = score_rec_disp.readline().split(',')
            # score_rec_disp.close()

            score_clearing = open('scoreboard.txt', 'w')
            score_clearing.write('')
            score_clearing.close()

            # for string_score in range(len(line_read)):
            #     line_read[string_score] = int(line_read[string_score])

            line_read.append(score)
            line_read = sorted(line_read)
            line_read.reverse()
            score_recording = open('scoreboard.txt', 'a')
            for number_of_scores in range(len(line_read)):
                if number_of_scores == 0:
                    score_recording.write(str(line_read[number_of_scores]))
                else:
                    score_recording.write(',' +
                                          str(line_read[number_of_scores]))
            score_recording.close()
            score_display = gamebox.from_text(500,
                                              300,
                                              'Your final score is: ' +
                                              str(score),
                                              'Arial',
                                              90,
                                              'red',
                                              italic=True,
                                              bold=True)
            camera.draw(score_display)

        health = gamebox.from_image(500, 15, 'health_bar.png')
        no_health = gamebox.from_image(500, 15, 'no_health_bar.png')
        health.size = life, 30
        no_health.size = 500, 30

        if heal == coins_to_heal and life < 500:
            heal = 0
            life += heal_power
    # ############# Health ################################################

    # ############# ENEMY #################################################
        for enemy in enemies:
            if enemy.x < character.x:
                enemy.x += enemy_speed
            elif enemy.x > character.x:
                enemy.x -= enemy_speed
            if enemy.y < character.y:
                enemy.y += enemy_speed
            elif enemy.y > character.y:
                enemy.y -= enemy_speed
    # ############# ENEMY #################################################

    # ############ Coins ##################################################
        tic_cnt[3] += 1
        if tic_cnt[3] == coin_spawn_rate:
            coins.append(
                gamebox.from_image(random.randint(15, 985), 15,
                                   coin_sheet[1 + counter_coins]))

            coin_timer.append(coin_life_span)
            tic_cnt[3] = 0
        for coin in coins:
            coin.y += 5
            coin_timer[coins.index(coin)] -= 1
            if coin.touches(character):
                coin_sound.play()
                score += 1
                heal += 1
                coin_timer.remove(coin_timer[coins.index(coin)])
                coins.remove(coin)
                coins_towards_reload_increase += 1
                difficulty_increasing += 1
            for time_left in coin_timer:
                if time_left == 0:
                    coins.remove(coins[coin_timer.index(time_left)])
                    coin_timer.remove(time_left)
            coin = gamebox.from_image(coin.x, coin.y,
                                      coin_sheet[counter_coins])
            if life != 0:
                camera.draw(coin)
        score_display = gamebox.from_text(20,
                                          15,
                                          str(score),
                                          'Arial',
                                          20,
                                          'yellow',
                                          italic=True,
                                          bold=True)
        health_display = gamebox.from_text(500,
                                           15,
                                           str(life),
                                           'Arial',
                                           20,
                                           'white',
                                           italic=True,
                                           bold=True)
        kills_display = gamebox.from_text(20,
                                          40,
                                          str(kills),
                                          'Arial',
                                          20,
                                          'red',
                                          italic=True,
                                          bold=True)

        if coins_towards_reload_increase == coins_to_hasten_reload and (
                reload_time - reload_reduction) >= 0:
            reload_time -= reload_reduction
            coins_towards_reload_increase = 0

        if difficulty_increasing == coins_to_increase_enemy_spawn_rate and enemy_spawn_rate > amount_spawn_rate_increases:
            enemy_spawn_rate -= amount_spawn_rate_increases
            difficulty_increasing = 0
    # ############ Coins ##################################################

    # **// Creates Jumping // Stops Sprite Overlapping
        for wall in walls:
            if character.bottom_touches(wall):
                velocity = 0
                if pygame.K_UP in keys:
                    velocity = jump_power
            for koin in coins:
                # koin.scale_by(0.2)
                if koin.bottom_touches(wall):
                    koin.move_to_stop_overlapping(wall)
            if character.touches(wall):
                character.move_to_stop_overlapping(wall)
            if life != 0:
                camera.draw(wall)

        if orientation == 'L':
            character == character.flip()

    # General Drawing area
        if life != 0:
            camera.draw(score_display)
            camera.draw(kills_display)
            camera.draw(character)
            camera.draw(no_health)
            camera.draw(health)
            camera.draw(health_display)
            for evil in enemies:
                evil = gamebox.from_image(evil.x, evil.y,
                                          enemy_sheet[counter_enemy])
                camera.draw(evil)
            for z in range(len(sides)):
                camera.draw(sides[z])
            for things in enemy_explosions:
                camera.draw(things)

        #camera.display()
    camera.display()
Ejemplo n.º 13
0
character = gamebox.from_image(200, 200, sheet[frame])
#character = gamebox.from_image(100, 200, "game_man.png")
character.yspeed = 0
walls = [
    gamebox.from_color(300, 500, "black", 10, 100),
    gamebox.from_color(600, 500, "black", 10, 100)
]
coins = [
    gamebox.from_image(400, 450, "new_coin.png"),
    gamebox.from_image(200, 450, "new_coin.png")
]
ground = gamebox.from_color(-100, 600, "green", 300000000, 100)
time = 0
counter = 0
score = 0
jump_sound = gamebox.load_sound("jump.wav")
coin_sound = gamebox.load_sound("coin.wav")


def tick(keys):
    global counter
    global frame
    global direction
    global time
    global score
    if counter < 60:
        counter += 1
        camera.clear("blue")
        camera.draw(
            gamebox.from_text(camera.x, 100, "Get Ready...", "Arial", 40,
                              "Orange", True))
Ejemplo n.º 14
0
# jl9pg,sx4pa
import pygame
import gamebox
camera = gamebox.Camera(800,600)

p_width = 10
p_height = 80
ball_velocity = 15
player_speed = 14
p1_score = 0
p2_score = 0
game_on = False

ticker = 0

paddle_sound = gamebox.load_sound("paddle.wav")
wall_sound = gamebox.load_sound("wall.wav")
background_music = gamebox.load_sound("http://upload.wikimedia.org/wikipedia/commons/a/aa/AcousticShuffle.ogg")

walls = [
    gamebox.from_color(400, 600, "green", 1000, 20),
    gamebox.from_color(400, 0, "green", 1000, 20),
]

p1 = gamebox.from_color(20, 400, "red", 15, 100)
p2 = gamebox.from_color(780, 400, "yellow", 15, 100)
ball = gamebox.from_color(400,300, "green", 20, 20)

ball.xspeed = ball_velocity
ball.yspeed = ball_velocity
Ejemplo n.º 15
0
weight_item_caught = speed + 5
counter = 5
counter_up = 0
level = 1
shop_list = []
shop_price = []
money_goal = [
    1000, 2200, 3600, 5400, 7500, 10000, 12500, 17000, 21500, 26000, 30000,
    45000
]
scene = 0  # scene index: 0 = starting scene 1 = game rule scene 2 = game scene 3 = shop scene 4 = you die
index = 0
chains = []
popped_up_word_counterdown = 16
shop_selection = 0
sound = gamebox.load_sound("mining_music.wav")
sound.play()
#sound = gamebox.load_sound("fishing_poll.wav")
#sound.play()
# item references
item_caught = gamebox.from_color(500, 100, "black", 1, 1)
picture_list = [
    "picture/gold_small.png", "picture/gold_middle.png",
    "picture/gold_big.png", "picture/rock_small.png", "picture/rock_big.png",
    "picture/dimaond.png", "picture/mystery_bag.png", "picture/background.png",
    "picture/background2.png", "picture/machine.png",
    "picture/Starting screen.png", "picture/shop.png", "picture/intro.png"
]

item_picture_list = [
    "picture/gold samd.png", "picture/polisher.png", "picture/lamp.png",
Ejemplo n.º 16
0
    gamebox.from_image(500, 71, 'large_log.png'),
    gamebox.from_image(666.66, 71, 'short_log.png'),
]
for log in logs6:
    log.scale_by(1.7)

logs7 = [
    gamebox.from_image(125, 41, 'short_log.png'),
    gamebox.from_image(250, 41, 'short_log.png'),
    gamebox.from_image(375, 41, 'short_log.png'),
    gamebox.from_image(500, 41, 'short_log.png'),
]
for log in logs7:
    log.scale_by(1.7)

run_over_sound = gamebox.load_sound("sound-frogger-squash.wav")
drown_sound = gamebox.load_sound("sound-frogger-plunk.wav")

character = gamebox.from_image(250, 490, 'frog_still.png')
character.scale_by(2)
character.last_move = 0
character.lives = 3
timer = 1200


def tick(keys):
    global ticks
    global timer
    ticks += 1
    timer -= 1
Ejemplo n.º 17
0
# Alex Hicks (awh4kc)

import pygame
import gamebox
import random

flap_sound = gamebox.load_sound(
    "https://dl.dropboxusercontent.com/u/20875109/flappybirdsounds/sfx_wing.ogg"
)
die_sound = gamebox.load_sound(
    "https://dl.dropboxusercontent.com/u/20875109/flappybirdsounds/sfx_die.ogg"
)
score_sound = gamebox.load_sound(
    "https://dl.dropboxusercontent.com/u/20875109/flappybirdsounds/sfx_point.ogg"
)

camera = gamebox.Camera(800, 600)

pipes = []
counter = 0
score = []

# sheet1 = [gamebox.from_image(200, 200, "bluebird-downflap.png"). gamebox.from_image(200, 200, "bluebird-midflap.png"),
#           gamebox.from_image(200, 200, "bluebird-upflap.png")]
# sheet2 = [gamebox.from_image(200, 200, "redbird-downflap.png"). gamebox.from_image(200, 200, "redbird-midflap.png"),
#           gamebox.from_image(200, 200, "redbird-upflap.png")]

frame = 0
direction = 0
counter1 = 0
Ejemplo n.º 18
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()
Ejemplo n.º 19
0
def tick(keys):
    global game_on, background, count, time, score
    if pygame.K_RETURN in keys:
        game_on = True
    if game_on:

        character.yspeed += 10

        if pygame.K_SPACE in keys:
            character.yspeed -= 310

        character.y = character.y + character.yspeed
        if character.y < 0:
            character.y = 0
        keys.clear()

        if character.touches(ground):
            character.move_to_stop_overlapping(ground)
            camera.draw(ground)
        camera.draw(background)

        time += 1
        seconds = str(int((time / ticks_per_second))).zfill(1)
        timer = gamebox.from_text(120, 40, "Time: " + seconds + "s", "Snap ITC", 24, "white")
        camera.draw(timer)

        fence.x -= 20
        if fence.right < camera.left:
            fence.x = 1200
        character.yspeed = 0

        if character.right_touches(fence):
            character.move_to_stop_overlapping(fence)
            character.yspeed -= 290
            count += 1
            music1 = gamebox.load_sound('baa.wav')
            music1.play()
        if character.bottom_touches(fence):
            character.move_to_stop_overlapping(fence)
            character.yspeed -= 160
            count += 1
            music1 = gamebox.load_sound('baa.wav')
            music1.play()
        for clove in clovers:
            clove.x -= 20
            if character.touches(clove):
                clovers.remove(clove)
                if count != 0:
                    count -= 1
            camera.draw(clove)
        if time % 300 == 0 and time != 0:
            new_clover = gamebox.from_image(900, 580, "clover.png")
            clovers.append(new_clover)
        camera.draw(fence)
        camera.draw(character)
        camera.draw(lives)

        for healths in health:
            if count == 0:
                camera.draw(healths)
            if count == 1:
                camera.draw(health[1])
                camera.draw(health[2])
            if count == 2:
                camera.draw(health[2])
            if count == 3:
                gamebox.pause()
                score = seconds
                game_over = gamebox.from_text(camera.x, 300, "GAME OVER!", "Snap ITC", 80, 'white')
                scorer = gamebox.from_text(camera.x, 375, "Score: " + str(score), "Snap ITC", 90, "white")
                camera.draw(game_over)
                camera.draw(scorer)

    camera.display()
Ejemplo n.º 20
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()
def shoot_bullet(bullet):
    bullet.x = player.x
    bullet.y = 520
    bullet.speedy = 20

# score
score = 0

# game over screen
game_over_background = gamebox.from_color(400, 300, "black", 800, 600)

#sprite_counter for animations
sprite_counter = 0

# sound
death_sound = gamebox.load_sound("explosion.wav")
game_music = gamebox.load_sound("music1.wav")
music_player = game_music.play(-1)
bullet_sound = gamebox.load_sound("laser1.wav")
enemy_explosion_sound = gamebox.load_sound("finalenemyexplosion.wav")
lose_life_sound = gamebox.load_sound("loselifesound.wav")

# lives
life1 = gamebox.from_image(20, 20, "lifeimage.png")
life2 = gamebox.from_image(50, 20, "lifeimage.png")
life3 = gamebox.from_image(80, 20, "lifeimage.png")
lives = [True, True, True]

def lose_health():
    for i in range(len(lives)):
        if lives[i] == True:
Ejemplo n.º 22
0
Archivo: game.py Proyecto: mjq4my/Games
    600, 350,
    "http://primalsurvivor.com/wp-content/uploads/2014/10/apocalypsesurvivor1.png"
)
win_pic.size = 1200, 700
game_over = gamebox.from_text(camera.x, 100, "The zombies ate you, sorry.",
                              "Impact", 70, "red")
game_winner = gamebox.from_text(camera.x, 500,
                                "You won! You slayed all the zombies!",
                                "Impact", 70, "white")
backgr.size = 1200, 700
shooter.size = 100, 150
first_zombies = []
second_zombies = []
last_zombies = []
bullets = []
gunshot = gamebox.load_sound("gun_fire.wav")
reload = gamebox.load_sound("gun_cocking.wav")
zombiedie = gamebox.load_sound("zombie_die.wav")
ammo = 100
zombie_speed = 4
shooter_speed = 10
frame = 0
frames = str(frame)
game_on = False
lose_game = False

for z in range(15):
    x = random.randrange(1250, 1850)
    y = random.randrange(50, 650)
    first_zombies.append(gamebox.from_image(x, y, "zombie.png"))
for z in range(20):
Ejemplo n.º 23
0
leftGunFire = gamebox.from_image(0,0,'LgunFire.png')
tankFire = gamebox.from_image(0,0,'tankFire.png')
leftTankFire = gamebox.from_image(0,0,'LtankFire.png')

character = gamebox.from_image(0,200,walkSheet[0])

#background
backGround = gamebox.from_image(0,460,'background.png')






#Sound Effects
loadSound = gamebox.load_sound('gunUp.wav')
shotSound = gamebox.load_sound('Shot.wav')
tankFireSound = gamebox.load_sound('tankFire.wav')
tankSound = gamebox.load_sound('tankRide.wav')
explosionSound = gamebox.load_sound('explosion.wav')
flySound = gamebox.load_sound('flySound.wav')


wahoowa = gamebox.from_image(0,0,'wahoowa.png')
wahoowa.temp = 0

Rounds = 0

#initialSetup ------ Run Once
def initialSetup():
    character.facing = None
Ejemplo n.º 24
0
# Background Stuff
top_border = gamebox.from_color(camera.x, 58, 'white', 800, 2)
bark = gamebox.from_image(
    camera.x, camera.y,
    'https://i.pinimg.com/originals/fd/47/66/fd47660f666b3860bf9b3aee2ef0a32b.jpg'
)
bark.rotate(90)
splash_background = gamebox.from_image(
    camera.x, camera.y,
    "https://previews.123rf.com/images/aopsan/aopsan1205/aopsan120500032/13644442-Green-grass-background-Stock-Photo.jpg"
)
show_splash = True

# Sounds
caw = gamebox.load_sound(
    'http://static1.grsites.com/archive/sounds/animals/animals010.wav')
apple_bite = gamebox.load_sound(
    'http://pages.cs.wisc.edu/~bahls/all/Bellipax/VehicleDie2.WAV')

# Worm
worm = [gamebox.from_color(camera.x, camera.y, 'lightgreen', 20, 20)]
worm_lives = 3

# Apple & Bird Coordinates
apple_x = random.randint(60, 780)
apple_y = random.randint(80, 580)
bird_x = random.randint(60, 780)
bird_y = random.randint(80, 580)

# Apple & Bird Icons
apple = gamebox.from_image(
Ejemplo n.º 25
0
powerup_bomb = []
points = 0
wall_left = gamebox.from_color(0, 400, 'cyan', 15, 800)
wall_right = gamebox.from_color(600, 400, 'cyan', 15, 800)
colors = [
    'green', 'cyan', 'yellow', 'magenta', 'orange', 'blue1', 'chartreuse1',
    'deeppink1'
]
sheet = gamebox.load_sprite_sheet(
    'http://www.williammalone.com/articles/create-html5-canvas-javascript-sprite-animation/images/coin-sprite-animation-sprite-sheet.png',
    1, 10)
#sheet = gamebox.load_sprite_sheet('ball_sprite.png',8,12)
frame = 0
ball = gamebox.from_color(300, 100, 'red', 21, 21)
highscore = 0
game_sound = gamebox.load_sound("arcade_music.wav")
coin_sound = gamebox.load_sound('coin_sound.wav')
bomb_sound = gamebox.load_sound('bomb_sound.wav')
splat_sound = gamebox.load_sound('splat_sound.wav')
speed_sound = gamebox.load_sound('speed_sound.wav')
wrap_sound = gamebox.load_sound('paddle.wav')
end_game_timer = 0


def tick(keys):
    global state
    global counter
    global timer
    global timer2
    global walls
    global powerup_speed
Ejemplo n.º 26
0
camera = gamebox.Camera(800, 600)
character = gamebox.from_color(100, 100, "blue", 10, 10)
character2 = gamebox.from_color(100, 100, "cyan", 10, 10)
lives = 3
lives2 = 3
lives2_left = gamebox.from_text(680, 50, "p2 Lives: " + str(lives2), "Arial",
                                20, "Black")
lives_left = gamebox.from_text(680, 30, "p1 Lives: " + str(lives), "Arial", 20,
                               "Black")
goal_size = gamebox.from_text(700, 70, "Goal Size: = 100", "Arial", 20,
                              "Black")
respawn_zone = gamebox.from_color(20, 20, "grey", 40, 40)
game_over = False
game_on = False

orb_sound = gamebox.load_sound("wall.wav")
game_music = gamebox.load_sound("Pim Poy.wav")
game_music.play(-1)

orbs = []
for number in range(0, 30):
    size = random.randint(15, 50)
    small_size = random.randint(5, 10)
    colors = ["green", "red", "orange", "purple"]
    orbs.append(
        gamebox.from_color(random.randint(150, 700), random.randint(150, 500),
                           colors[random.randint(0, 3)], size, size))
    orbs.append(
        gamebox.from_color(random.randint(150, 700), random.randint(150, 500),
                           colors[random.randint(0,
                                                 3)], small_size, small_size))
Ejemplo n.º 27
0
# Connor Bottcher (cb4wa) Luke Masters (lsm5fm)

import pygame
import gamebox
import global_stage
import level_one
import level_two

music1 = gamebox.load_sound('Spongebob_Uke.wav')
music2 = gamebox.load_sound('Spongebob Pizza song.wav')

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"
Ejemplo n.º 28
0
extra_hit2 = gamebox.from_image(0, 0, p2_charsheet[7])
p1_showtime = 0
p1_hitshowtime = 0
p2_showtime = 0
p2_hitshowtime = 0
p1_hittime = 0
p2_hittime = 0
p2_charrunning = gamebox.load_sprite_sheet("Char2_running.png", 2, 15)
p1_charrunning = gamebox.load_sprite_sheet("Char1_running.png", 2, 11)
r2 = 0
r1 = 0

p1_points = 0
p2_points = 0

hitsound = gamebox.load_sound("Explosion.wav")
clicksound = gamebox.load_sound("Click Sound.wav")
jumpsound = gamebox.load_sound("Jump.wav")


def tick(keys):
    global count, temp, p1_direction, p2_direction, menu, p2_on, p1_stat, p2_stat, p1_death, p2_death, p1_xhitspeed, \
        p1_yhitspeed, p2_xhitspeed, p2_yhitspeed, p1_punches, p2_punches, mode, submode, winner, p1_points, p2_points, \
        p1_char, p1_showtime, p2_showtime, p1_airjump, p2_airjump, p1_hitshowtime, p2_hitshowtime, p1_hittime, \
        p2_hittime, r2, r1

    if menu == -1:
        camera.clear("white")

        # Words
        camera.draw(
Ejemplo n.º 29
0
import pygame
import gamebox

camera = gamebox.Camera(800, 600)

p_width = 10
p_height = 80
ball_velocity = 15
player_speed = 14
p1_score = 0
p2_score = 0
game_on = False

ticker = 0

paddle_sound = gamebox.load_sound("paddle.wav")
wall_sound = gamebox.load_sound("wall.wav")

walls = [
    gamebox.from_color(400, 600, "green", 1000, 20),
    gamebox.from_color(400, 0, "green", 1000, 20),
]

p1 = gamebox.from_color(20, 400, "red", 15, 100)
p2 = gamebox.from_color(780, 400, "yellow", 15, 100)
ball = gamebox.from_color(400, 300, "green", 20, 20)

ball.xspeed = ball_velocity
ball.yspeed = ball_velocity

Ejemplo n.º 30
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
Ejemplo n.º 31
0
platforms = [
    gamebox.from_color(camera.x, camera.bottom, 'dark green',
                       camera.right + 10, 40)
]

rain = [
    gamebox.from_color(camera.left + 100, camera.top, 'red', 10, 10),
    gamebox.from_color(camera.left + 200, camera.top, 'red', 10, 10),
    gamebox.from_color(camera.left + 300, camera.top, 'red', 10, 10)
]

healthplus = [
    gamebox.from_image(camera.right + 1000, camera.top + 300, 'plus.png')
]
healthplus[0].size = 15, 15
music = gamebox.load_sound("savantsplinter.wav")

box = gamebox.from_text(40, 200, "HE", "Arial", 35, "red")

lava = gamebox.from_color(camera.x, camera.bottom, 'red', randsize, 40)
coins = [
    gamebox.from_image(
        random.randrange(camera.right + 100, camera.right + 300),
        random.randrange(220, 300), "coin.png"),
    gamebox.from_image(
        random.randrange(camera.right + 100, camera.right + 300),
        random.randrange(220, 300), "coin.png"),
    gamebox.from_image(
        random.randrange(camera.right + 100, camera.right + 300),
        random.randrange(220, 300), "coin.png")
]
Ejemplo n.º 32
0
import pygame
import gamebox

camera = gamebox.Camera(1142, 636)
background = gamebox.from_image(camera.x, camera.y, "night_time.png")
creators = gamebox.from_text(280, 20, "Creators: Christine Li (cjl4ev), Ruolin Chen (rlc8my)", "Snap ITC", 18, "white")
game_name = gamebox.from_text(camera.x, 280, "Counting Sheep", "Snap ITC", 60, "white")
description = gamebox.from_text(camera.x, 340, "How long can you jump fences for?", "Snap ITC", 24, "white")
rules1 = gamebox.from_text(camera.x, 370, "Jump fences without touching them or you lose a life!", "Snap ITC", 24,
                           "white")
rules2 = gamebox.from_text(camera.x, 400, "You get three lives, collect clovers to recover lives.", "Snap ITC", 24,
                           "white")
p1_instructions = gamebox.from_text(camera.x, 440, "Press SPACE to Jump", "Snap ITC", 24, "white")
to_start = gamebox.from_text(camera.x, 480, "Press ENTER to Start", "Snap ITC", 32, "white")
music = gamebox.load_sound('crickets_compressed.wav')
music_player = music.play(-1)

ground = gamebox.from_color(600, 634, "black", 1200, 50)

fence = gamebox.from_image(1000, 550, "fence.png")
fence.scale_by(.50)

character = gamebox.from_image(350, 545, "sheep.png")
character.scale_by(.20)

lives = gamebox.from_text(950, 40, "Lives left:", "Snap ITC", 24, "white")

health3 = gamebox.from_image(1075, 100, "sheep.png")
health3.scale_by(.1)
health2 = gamebox.from_image(990, 100, "sheep.png")
Ejemplo n.º 33
0
flip sprites
resize player

grid-based motion
end game on objective
options menu
play again
computer vs human
'''

import pygame
import gamebox
camera = gamebox.Camera(800, 600)
logo = gamebox.from_image(0, 0, "spritesheet.png")

music = gamebox.load_sound("http://www.gnu.org/fun/jokes/eternal-flame.ogg")

music.play()


# make a method that will be called every frame. Must have parameter “keys”
def tick(keys):
    camera.clear('white')
    if pygame.K_UP in keys:
        # you can check which keys are being pressed
        print("the up arrow key is currently being pressed")
    if camera.mouseclick:
        # true if some mouse button is being pressed
        logo.center = camera.mouse
    # the current mouse position
    camera.draw(logo)
Ejemplo n.º 34
0
import level_one

x = 1300
y = 600

level = global_stage.level
camera = global_stage.camera

if global_stage.level == 2:
    musicplayer2 = music2.play(-1)
origin_x = 120
origin_y = 465
background = []
check = 0
stage = 1
not_lame = gamebox.load_sound('notlame.wav')
hit_check = 0
hit_moment = 0
hit_interval = 0
circle_stage = 1
face_check = 0
time = 0
jump_check = 0
seconds = 0
minutes = 0
jf_stage = 1
spat_stage = 1
secretformula_check = 0
spat_check = 0
stick_check = 0
pizza_health = 8
Ejemplo n.º 35
0
    bullet.x = player.x
    bullet.y = 520
    bullet.speedy = 20


# score
score = 0

# game over screen
game_over_background = gamebox.from_color(400, 300, "black", 800, 600)

#sprite_counter for animations
sprite_counter = 0

# sound
death_sound = gamebox.load_sound("explosion.wav")
game_music = gamebox.load_sound("music1.wav")
music_player = game_music.play(-1)
bullet_sound = gamebox.load_sound("laser1.wav")
enemy_explosion_sound = gamebox.load_sound("finalenemyexplosion.wav")
lose_life_sound = gamebox.load_sound("loselifesound.wav")

# lives
life1 = gamebox.from_image(20, 20, "lifeimage.png")
life2 = gamebox.from_image(50, 20, "lifeimage.png")
life3 = gamebox.from_image(80, 20, "lifeimage.png")
lives = [True, True, True]


def lose_health():
    for i in range(len(lives)):
Ejemplo n.º 36
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