Skip to main content

New Page

Follow-Up Assignment Series: Python Game Development


Assignment

11 - Score Multiplier and Bonus Points

Introduction

Introduction:

In this assignment, we'll introduce a score multiplier feature. If a player hits the ball multiple times without missing, their score will increase faster. This concept is similar to a combo multiplier in many games, encouraging players to keep the ball in play to maximize their score.

Task:

Task

  1. Multiplier Logic:

    • Create a multiplier variable starting at 1.
    • Every time the ball hits the paddle without the player missing, increase the multiplier by 0.5 (up to a maximum of 3x).
    • When the player misses, reset the multiplier to 1.
  2. Update Score Function:

    • Modify the update_score() function to display the current multiplier alongside the score.
Example Code Snippet:
# Initialize the multiplier
multiplier = 1.0

# Update the score function to include the multiplier
def update_score():
    pen.clear()
    pen.write(f"Score: {score} Levens: {lives} Multiplier: {multiplier}x", align="center", font=("Courier", 24, "normal"))

# Update multiplier in the game loop
if hit_paddle:
    multiplier = min(multiplier + 0.5, 3)
    score += int(1 * multiplier)
else:
    multiplier = 1