Skip to content

Commit

Permalink
finish of christmas update but mabye music?
Browse files Browse the repository at this point in the history
  • Loading branch information
bertie-wooster committed Dec 12, 2019
1 parent f9039eb commit 6122dc8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
Binary file added images/snow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/snow2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sounds/snow_boom.wav
Binary file not shown.
31 changes: 28 additions & 3 deletions stackytower.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,18 @@ class Player:

# In this game there are two players who race to build a tower of blocks.
# Each tower will be represented by a list created here. We can put blocks
# in the lists.
# in the list
player1.tower = []
player2.tower = []

snows = []
def snowfall():
snowflake = Actor(random.choice(['snow', 'snow2']), pos = (random.randint(0, WIDTH), 0))
animate(snowflake, duration = random.uniform(8, 12), y = HEIGHT, on_finished=kill_snow)
snows.append(snowflake)
def kill_snow():
for snowflake in list(snows):
if snowflake.y == HEIGHT:
snows.remove(snowflake)
def flip_actor_image(actor):
"""This is a hack to flip actor images.
Expand Down Expand Up @@ -152,6 +160,8 @@ def draw():
screen.blit('background_winter', (0, 0))
active_player_marker.draw()
draw_later = []
for snow in snows:
snow.draw()
for block in player1.tower:
if block.image != 'small_shield':
block.draw()
Expand Down Expand Up @@ -358,6 +368,7 @@ def fire_cannon(player, cannon_block):
animate(cannon_ball, x=end_shot_x)
def fire_snowball_cannon(player, snowball_cannon_block):
snowball = Actor('snowball', pos=snowball_cannon_block.pos)
sounds.snow_boom.play()
target, end_shot_x = get_target_player_and_x(player, snowball_cannon_block)
shots_fired.append(snowball)
snowball.target_player = target
Expand Down Expand Up @@ -421,6 +432,7 @@ def get_tower_top_y(player):
def update():
global small_shield, small_shield_healths, small_shield_health
# check missed shots to see if they go off screen
snowfall()
for shot in list(shots_missed):
if shot.x >= WIDTH or shot.x <= 0:
shots_missed.remove(shot)
Expand Down Expand Up @@ -605,15 +617,28 @@ def draw_menu():
centerx=WIDTH // 2,
centery=title_top + 20,
fontname="1980xx",
color=(200, 255, 0),
fontsize=32)
if show_instructions:
draw_instructions(title_top + 40, box_left + 10)
return
screen.draw.text("CHRISTMAS UPDATE",
centerx=WIDTH // 2,
centery=HEIGHT // 2 + 130,
fontname="1980xx",
color=(255, 0, 0),
fontsize=30)
screen.draw.text("2 NEW CHRISTMAS BLOCKS!",
centerx=WIDTH // 2,
centery=HEIGHT // 2 + 160,
fontname="1980xx",
color=(0, 255, 0),
fontsize=25)
for i, text in enumerate(menu_options):
if i == selected_option:
color = (255, 0, 0)
else:
color = (255, 255, 255)
color = (0, 255, 0)
screen.draw.text(text,
centerx=WIDTH // 2,
centery=title_top + i * 30 + 80,
Expand Down

0 comments on commit 6122dc8

Please sign in to comment.