|
42 | 42 | # Game loop
|
43 | 43 | running = True
|
44 | 44 | clock = pygame.time.Clock()
|
45 |
| -pygame.mixer.music.play(-1) |
| 45 | +pygame.mixer.music.play(-1) |
46 | 46 |
|
47 | 47 | while running:
|
48 | 48 | for event in pygame.event.get():
|
|
82 | 82 | obstacles[i] = (obstacle_x, obstacle_y + obstacle_speed)
|
83 | 83 | elif obstacle_type == "tri":
|
84 | 84 | # Triangular obstacle: move diagonally
|
85 |
| - obstacles[i] = (obstacle_x + obstacle_speed, obstacle_y + obstacle_speed) |
| 85 | + obstacles[i] = (obstacle_x + obstacle_speed, |
| 86 | + obstacle_y + obstacle_speed) |
86 | 87 | elif obstacle_type == "circle":
|
87 | 88 | # Rotating circular obstacle: update the angle
|
88 | 89 | angle = 0.1 # Adjust the rotation speed
|
89 | 90 | rotated_obstacle_x = obstacle_x + (obstacle_width // 2)
|
90 | 91 | rotated_obstacle_y = obstacle_y + (obstacle_height // 2)
|
91 | 92 | obstacles[i] = (rotated_obstacle_x - obstacle_width // 2 * math.cos(angle),
|
92 |
| - rotated_obstacle_y - obstacle_height // 2 * math.sin(angle), |
| 93 | + rotated_obstacle_y - |
| 94 | + obstacle_height // 2 * math.sin(angle), |
93 | 95 | "circle")
|
94 | 96 |
|
95 | 97 | # Remove obstacles that are off the screen
|
|
114 | 116 | screen.fill(WHITE)
|
115 | 117 |
|
116 | 118 | # Draw the player
|
117 |
| - pygame.draw.rect(screen, (0, 0, 255), (player_x, player_y, player_width, player_height)) |
| 119 | + pygame.draw.rect(screen, (0, 0, 255), (player_x, |
| 120 | + player_y, player_width, player_height)) |
118 | 121 |
|
119 | 122 | # Draw the obstacles
|
120 | 123 | for obstacle_x, obstacle_y, obstacle_type in obstacles:
|
121 | 124 | if obstacle_type == "rect":
|
122 |
| - pygame.draw.rect(screen, (255, 0, 0), (obstacle_x, obstacle_y, obstacle_width, obstacle_height)) |
| 125 | + pygame.draw.rect(screen, (255, 0, 0), (obstacle_x, |
| 126 | + obstacle_y, obstacle_width, obstacle_height)) |
123 | 127 | elif obstacle_type == "tri":
|
124 | 128 | pygame.draw.polygon(screen, (0, 255, 0), [(obstacle_x, obstacle_y), (obstacle_x + obstacle_width, obstacle_y),
|
125 | 129 | (obstacle_x + obstacle_width // 2, obstacle_y + obstacle_height)])
|
|
0 commit comments