Esempio n. 1
0
    shark = Shark("square", "dimgray", random.randint(350, 600),
                  random.choice(y_cors))
    sharks.append(shark)
    powerup = Powerup("square", "gold", random.randint(350, 600),
                      random.choice(y_cors))
    powerups.append(powerup)
    seaweed = Seaweed("square", "seagreen", random.randint(350, 600),
                      random.choice(y_cors))
    seaweeds.append(seaweed)

wave = Wave("square", "white", random.randint(-600, -350),
            random.choice(y_cors))

# Create Labels
distance_label = spgl.Label(
    "Distance From Shore: {} // Fireballs: {}".format(player.distance,
                                                      player.powerup), "white",
    -380, 280)
distance_label.set_font_size(15)

# Set Keyboard Bindings
game.set_keyboard_binding(spgl.KEY_UP, player.move_up)
game.set_keyboard_binding(spgl.KEY_DOWN, player.move_down)
game.set_keyboard_binding(spgl.KEY_SPACE, player.shoot_fireball)

# Set background image
game.set_background("bg.gif")

play_again_title = ""

game.play_sound("bensound-jazzyfrenchy.mp3", 105)
Esempio n. 2
0
balloons = []
for count in range(13):
    balloons.append(
        Balloon("circle", "green", random.randint(-250, 250),
                random.randint(-250, 250)))

birds = []
for count in range(5):
    birds.append(
        Bird("square", "pink", random.randint(-250, 250),
             random.randint(-250, 250)))

# Create Labels
# Keep List of Labels

score_label = spgl.Label("Score: 0", "white", -300, 300)
score_label.set_font_size(24)

# Create Buttons

# Set Keyboard Bindings
game.set_keyboard_binding(spgl.KEY_UP, russell.moveup)
game.set_keyboard_binding(spgl.KEY_DOWN, russell.movedown)
game.set_keyboard_binding(spgl.KEY_LEFT, russell.moveleft)
game.set_keyboard_binding(spgl.KEY_RIGHT, russell.moveright)

game.set_background("blue.gif")
while True:
    # Call the game tick method
    game.tick()
Esempio n. 3
0
points = []

for count in range(9):
    points.append(Point("Webp.net-resizeimage copy 3.gif", "yellow", 42, 48))

enemies = []
for count in range(4):
    enemies.append(Enemy("Webp.net-resizeimage-2.gif", "red", 54, 54))

enemies2 = []
for count in range(4):
    enemies2.append(Enemy2("Webp.net-resizeimage copy 4.gif", "red", 49, 44))

# Create Labels
score_label = spgl.Label("Score: 0 ", "white", 300, 250, "Times New Roman", 20)

# Set Keyboard Bindings
game.set_keyboard_binding(spgl.KEY_UP, player.move_up)
game.set_keyboard_binding(spgl.KEY_DOWN, player.move_down)
game.set_keyboard_binding(spgl.KEY_LEFT, player.move_left)
game.set_keyboard_binding(spgl.KEY_RIGHT, player.move_right)
game.set_keyboard_binding(spgl.KEY_ESCAPE, game.exit)

while True:
    game.tick()

    # Check player enemy collision
    for enemy in enemies:
        if game.is_collision(player, enemy):
            player.score -= 10
Esempio n. 4
0
# Create Functions

def end_game():
	game.exit()
	
#Draw border


# Initial Game setup
game = spgl.Game(800, 600, "black", "TRON",0)

# Create Sprites
player = Player ("square", "blue", 100, 0)
player2 = Player ("square", "red", -100, 0)
# Create Labels
lbl_player_score = spgl.Label("Player 1: 0", "white", 320, 280)
lbl_player2_score = spgl.Label("Player 2: 0", "white", -380, 280)

# Create Buttons

# Set Keyboard Bindings
game.set_keyboard_binding(spgl.KEY_LEFT, player.turn_left)
game.set_keyboard_binding(spgl.KEY_RIGHT, player.turn_right)
game.set_keyboard_binding(spgl.KEY_UP, player.turn_up)
game.set_keyboard_binding(spgl.KEY_DOWN, player.turn_down)

game.set_keyboard_binding("a", player2.turn_left)
game.set_keyboard_binding("d", player2.turn_right)
game.set_keyboard_binding("w", player2.turn_up)
game.set_keyboard_binding("s", player2.turn_down)
game.set_keyboard_binding("q", end_game)
Esempio n. 5
0
for player_missile in player_missiles_storage:
    player_missiles.append(player_missile)

for i in range(30):
    enemy_missiles_storage.append(
        EnemyMissile("circle", "red", random.randint(-450, 450),
                     random.randint(400, 800)))

for enemy_missile in enemy_missiles_storage:
    if len(enemy_missiles) < game.level:
        enemy_missile.set_target(random.choice(cities + silos))
        enemy_missiles.append(enemy_missile)

# Create Labels
status_label = spgl.Label(
    "Missile Command  \nLevel: {}  \nScore: {}  \nCities: {}  \nSilos: {}  \nPlayer Missiles: {}  \nEnemy Missiles: {}",
    "white", -390, 160)

# Create Buttons

# Set Keyboard Bindings

while True:
    # Call the game tick method
    game.tick()

    # Check to see if the player missile collides with the enemy missiles
    for player_missile in player_missiles:
        for enemy_missile in enemy_missiles:
            # Check if the player missile is exploding
            if player_missile.state == "explode":
Esempio n. 6
0
obstacle_1 = Obstacle("square", "red", 0, 100)
obstacle_2 = Obstacle("square", "red", 500, 300)
obstacle_3 = Obstacle("square", "red", 250, -200)

# sprite_name.set_image("image_name.gif", width, height)
obstacle_1.set_image("brick.gif", 70, 100)
obstacle_2.set_image("brick.gif", 70, 100)
obstacle_3.set_image("brick.gif", 70, 100)
player.set_image("MainGuySpriteSheet.gif", 65, 65)

# player.set_image("

obstacles = [obstacle_1, obstacle_2, obstacle_3]

# Create Labels
label_score = spgl.Label("Score: 0", "white", -525, 270)
#label_score.size_font_size(20)

label_lives = spgl.Label("Lives left: 5", "white", -525, 250)

# Create Buttons

# Set Keyboard Bindings

game.set_keyboard_binding(ball.shoot, "Right")
game.set_keyboard_binding(player.rotate_up, "Up")
game.set_keyboard_binding(player.rotate_down, "Down")
game.set_keyboard_binding(ball.rotate_up, "Up")
game.set_keyboard_binding(ball.rotate_down, "Down")
while True:
    # Call the game tick method
balloons = []
for count in range(8):
    balloons.append(
        Balloon("circle", "green", random.randint(-250, 250),
                random.randint(-250, 250)))

birds = []
for count in range(5):
    birds.append(
        Bird("square", "pink", random.randint(-250, 250),
             random.randint(-250, 250)))

# Create Labels
# Keep List of Labels

score_label = spgl.Label("Score: 0", "white", -300, 300)
score_label.set_font_size(24)
time_label = spgl.Label("Time: 30", "white", 300, -300)
time_label.set_font_size(24)

# Create Buttons

# Set Keyboard Bindings
game.set_keyboard_binding(spgl.KEY_UP, russell.moveup)
game.set_keyboard_binding(spgl.KEY_DOWN, russell.movedown)
game.set_keyboard_binding(spgl.KEY_LEFT, russell.moveleft)
game.set_keyboard_binding(spgl.KEY_RIGHT, russell.moveright)

while True:
    # Call the game tick method
    game.tick()
Esempio n. 8
0
		black = random.choice(blacks)
		black.place_random()
	else:
		if len(remaining_colors) > 0:
			next_color = random.choice(remaining_colors)
			remaining_colors.remove(next_color)
			next_color.place_random()		

def place_color():
	next_color = random.choice(remaining_colors1)
	remaining_colors1.remove(next_color)
	next_color.place_random()
	

# Create Labels
lbl_lives = spgl.Label("Lives left: 3", "red", -350, 360)

lbl_lives.set_font_name("Georgia") 
lbl_lives.set_font_size(20) 

lbl_time = spgl.Label("Time Left", "Blue", 170, 360)
lbl_time.update("Time Left: {} seconds".format(game.timer))

lbl_time.set_font_name("Georgia") 
lbl_time.set_font_size(20) 

# Create Buttons

# Set Keyboard Bindings
turtle.listen()
turtle.onkey(player.turn_left, "Left")
keyboard_P = Keyboard_Image("keyboard_P.gif", "white", 345.0, -147.0)
keyboard_Q = Keyboard_Image("keyboard_Q.gif", "white", -375.0, -147.0)
keyboard_R = Keyboard_Image("keyboard_R.gif", "white", -135.0, -147.0)
keyboard_S = Keyboard_Image("keyboard_S.gif", "white", -255.0, -207.0)
keyboard_T = Keyboard_Image("keyboard_T.gif", "white", -55.0, -147.0)
keyboard_U = Keyboard_Image("keyboard_U.gif", "white", 105.0, -147.0)
keyboard_V = Keyboard_Image("keyboard_V.gif", "white", -55.0, -280.0)
keyboard_W = Keyboard_Image("keyboard_W.gif", "white", -295.0, -147.0)
keyboard_X = Keyboard_Image("keyboard_X.gif", "white", -215.0, -280.0)
keyboard_Y = Keyboard_Image("keyboard_Y.gif", "white", 25.0, -147.0)
keyboard_Z = Keyboard_Image("keyboard_Z.gif", "white", -295, -280.0)

hangman = Hangman()

# Create Labels
dash_label = spgl.Label("_", "white", 0, 0)

dash_label.set_font_name("Krungthep")
dash_label.set_font_size(100)

dash_label.set_font_name("Krungthep")
dash_label.set_font_type("bold")
dash_label.set_font_size(60)

score_label = spgl.Label("SCORE: 0", "white", -459.0, -77.0)
score_label.set_font_name("Krungthep")
score_label.set_font_size(20)

chances_label = spgl.Label("CHANCES: 5", "white", -459.0, -100.0)
chances_label.set_font_name("Krungthep")
chances_label.set_font_size(20)
Esempio n. 10
0
# Create Player
player = Player("triangle", "white", -400, 0)

# Create Orbs
for i in range(100):
    color = random.choice(["red", "yellow", "green"])
    shape = random.choice(["circle", "square", "triangle", "arrow"])
    orb = Orb(shape, color, 0, 0)
    speed = random.randint(1, 5)
    orb.speed = speed

# Create Explosion
explosion = Explosion()

# Create Labels
score_label = spgl.Label("Score: 0 Highscore: {}".format(game.highscore),
                         "white", -380, 280)

# Create Buttons

# Set Keyboard Bindings
game.set_keyboard_binding(spgl.KEY_UP, player.accelerate)
game.set_keyboard_binding(spgl.KEY_DOWN, player.decelerate)
game.set_keyboard_binding(spgl.KEY_LEFT, player.rotate_left)
game.set_keyboard_binding(spgl.KEY_RIGHT, player.rotate_right)
game.set_keyboard_binding(spgl.KEY_ESCAPE, game.exit)

while True:
    # Call the game tick method
    game.tick()

    # Put your game logic here
Esempio n. 11
0
depth = Player.depth
enemy_heading = Enemy.heading
rudder = Player.rudder
desired = Player.desired_speed

# Create Sprites
# Create Enemy
enemy = Enemy("square", "brown", 0, 0)
# Create Player
player = Player("triangle", "white", 0, 0)
#player = Player("triangle", "white", -game.SCREEN_WIDTH / 2 , game.SCREEN_HEIGHT / 2 -1000)

# Create Labels

navigation_label = spgl.Label(
    "Current: \nHeading: Heading: {}".format(Player.heading), "Green",
    -game.SCREEN_WIDTH / 2 + 10, game.SCREEN_HEIGHT / 2 - 100)

tracking_label = spgl.Label(
    "Contact Data: \nHeading: Heading  {}".format(Enemy.heading), "Red",
    -game.SCREEN_WIDTH / 2 + 10, game.SCREEN_HEIGHT / 2 - 300)
# Create Buttons

# Set Keyboard Bindings
game.set_keyboard_binding(spgl.KEY_UP, player.accelerate)
game.set_keyboard_binding(spgl.KEY_DOWN, player.decelerate)

game.set_keyboard_binding(spgl.KEY_LEFT, player.rotate_left)
game.set_keyboard_binding(spgl.KEY_RIGHT, player.rotate_right)
#game.set_keyboard_binding(spgl.KEY_C, player.change_course)
game.set_keyboard_binding(spgl.KEY_R, player.set_rudder)
Esempio n. 12
0
for player_missile in player_missiles_storage:
    player_missiles.append(player_missile)

for i in range(30):
    enemy_missiles_storage.append(
        EnemyMissile("circle", "red", random.randint(-450, 450),
                     random.randint(400, 800)))

for enemy_missile in enemy_missiles_storage:
    if len(enemy_missiles) < game.level:
        enemy_missile.set_target(random.choice(cities))
        enemy_missiles.append(enemy_missile)

# scoring
game_status = spgl.Label(
    "Level: {} \nScore: {} \nCities: {}  \nSilos: {} \nPlayer Missiles: {} \nEnemy Missiles: {}",
    "white", -390, 210)

while True:
    game.tick()

    # check if player missile collides with enemy missile
    for player_missile in player_missiles:
        for enemy_missile in enemy_missiles:
            check_collision(player_missile, enemy_missile)

    # check if enemy missile collides with city or silos
    for enemy_missile in enemy_missiles:
        for city in cities:
            check_collision(enemy_missile, city)
Esempio n. 13
0
player = Player("Layer 12.gif", "white", -300, -100)
player.questions_answered = 0
dog = Dog("Dog.gif", "darkgoldenrod", -390, -120)
question1 = Question("question_small.gif", "yellow", -200, -70)
question2 = Question("question_small.gif", "yellow", -120, -10)
question3 = Question("question_small.gif", "yellow", 0, 10)
question4 = Question("question_small.gif", "yellow", 80, -50)
question5 = Question("question_small.gif", "yellow", 150, 0)
question6 = Question("question_small.gif", "yellow", 220, 20)
gate = Gate("Gate.gif", "dimgray", 275, -115)
gate.set_image("Gate.gif", 93, 82)
house = House("house.gif", "slategrey", 350, -100)
house.set_image("house.gif", 157, 100)

# Create Labels
score_label = spgl.Label("Score: 0", "black", -390, 200)

# Create Buttons


# Set Keyboard Bindings
def set_keyboard_bindings():
    wn = spgl.turtle.Screen()
    game.set_keyboard_binding(spgl.KEY_SPACE, player.jump)
    game.set_keyboard_binding(spgl.KEY_LEFT, player.move_left)
    game.set_keyboard_binding(spgl.KEY_RIGHT, player.move_right)
    game.set_keyboard_binding(spgl.KEY_ESCAPE, game.exit)


set_keyboard_bindings()
Esempio n. 14
0
banana = Banana("banana.gif", "black", random.randint(450, 1000), -130)
banana.set_image("banana.gif", 54, 57)

brick = Brick("brick.gif", "white", random.randint(800, 1000), 5)
brick.set_image("brick.gif", 60, 10)

mushroom = Mushroom("mushroom.gif", "white", random.randint(800, 1000), 5)
mushroom.set_image("mushroom.gif", 60, 10)

goomba = Goomba("goomba.gif", "black", random.randint(600, 1000), -120)
goomba.set_image("goomba.gif", 54, 57)

objects = [shell, plant, coin, banana, brick]

score_label = spgl.Label("Score: 0", "white", -380, 260)
score_label.set_font_size(20)
lives_label = spgl.Label("Lives: 6", "white", -270, 260)
lives_label.set_font_size(20)

# Set Keyboard Bindings
game.set_keyboard_binding(spgl.KEY_UP, player.up)
game.set_keyboard_binding(spgl.KEY_DOWN, player.down)

if player.score > 500:
    banana = Banana("banana.gif", "black", random.randint(100, 1000), -130)

if player.score > 1000:
    goomba = Goomba("goomba.gif", "black", random.randint(100, 1000), -130)

if game.is_collision(player, brick):
Esempio n. 15
0
amulet = Scenery("square", "black", 950, 950)

#Create moving objects
player = Player("circle", "red", -475, -92)

master_guard = Enemy("square", "red", False, -315, 90)

guard_1 = Enemy("square", "red", True, -240, -55)
guard_2 = Enemy("square", "red", True, -100, -10)
guard_3 = Enemy("square", "red", True, 115, -15)

enemies = [master_guard, guard_1, guard_2, guard_3]

# Create Labels
#inventory_lbl = spgl.Label("Inventory", "white", -495, -150, font_size=30)
moves_lbl = spgl.Label("Athena", "white", 20, -150, font_size=30)
player_HP_lbl = spgl.Label("Health: {}".format(player.HP),
                           "white",
                           20,
                           -170,
                           font_size=20)

enemy_name_lbl = spgl.Label("", "white", 350, -155, font_size=30)

game_over_lbl = spgl.Label("", "red", -160, -50, font_size=70)

player_damage_lbl = spgl.Label("", "red", 195, -230, font_size=20)
enemy_damage_lbl = spgl.Label("", "red", 330, -230, font_size=20)
locked_lbl = spgl.Label("", "white", -200, -150, font_size=20)

# Create Buttons
Esempio n. 16
0
#COINS
coins = []
coins.append(Coin("coins.gif", "blue", -150, 250))
coins.append(Coin("coins.gif", "blue", 200, 95))
coins.append(Coin("coins.gif", "blue", -240, 75))
coins.append(Coin("coins.gif", "blue", -180, 250))
coins.append(Coin("coins.gif", "blue", 40, 45))

for coin in coins:
    coin.set_bounding_box(30, 20)

# Create Labels
score_label = spgl.Label("SCORE : {}".format(game.coins),
                         "white",
                         -360,
                         260,
                         font_size=20)
game.set_background("background.gif")

# Set Keyboard Bindings
game.set_keyboard_binding(spgl.KEY_SPACE, player.jump)
game.set_keyboard_binding(spgl.KEY_LEFT, player.turn_left)
game.set_keyboard_binding(spgl.KEY_RIGHT, player.turn_right)
game.set_keyboard_binding(game.exit, "q")

while True:
    os.system("clear")

    # Call the game tick method
    game.tick()