Skip to content

Commit

Permalink
Remove unused comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepbot-zapp committed Nov 23, 2024
1 parent a866bda commit 73350ef
Show file tree
Hide file tree
Showing 14 changed files with 125 additions and 125 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# BrickMania


**BrickMania** is a modern take on the classic **BrickBreaker** game.

Expand All @@ -9,39 +9,39 @@ A special thanks to [@khsaad](https://github.com/khsaad04), [@aarthex](https://g

---

## How to Play

### Keyboard Controls



- Move the block using the **WASD** or **Arrow** keys.
- Pause or resume the game by pressing the **Spacebar**.
- To quit the game while it’s not running, press the **Q** key.
- To go back to main menu press **Left Shift** key.

### Options


On the start menu, you can select certain options that modify gameplay. Currently, these settings do not persist across restarts, but this feature is planned for future updates.

You can navigate the options using the arrow keys.

- **Mute Music** / **Unmute Music**: Mutes / Unmutes the game’s music and sounds.

### Special Moves


Special moves are powerful abilities with cooldowns. There are currently **2** special moves available:

- Every 20 seconds, you’ll gain a **SPECIAL Ball**, which is red in color. You can activate it by pressing either the **W** key or the **Down Arrow** key.

- Every 60 seconds, you’ll unlock the **Brick Destruction** powerup, which instantly destroys all remaining bricks on the board.

### Powerups


Powerups are items that drop randomly as you play, either after destroying bricks or at specific intervals.

- After breaking a brick, there’s a chance an **Extra Ball** powerup will begin to fall. Catch it, and you’ll gain an additional ball that can help you clear more bricks! However, be cautious—each extra ball makes the game significantly faster!


### Game Mechanics


- If you stay stationary for too long (5 seconds), the paddle will move on its own.

Expand Down
4 changes: 2 additions & 2 deletions helpers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
__all__ = [
# Classes

"Settings",
# Constants

"SCALE",
"WIDTH",
"HEIGHT",
Expand Down
8 changes: 4 additions & 4 deletions helpers/loading_combinations.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
)


# Trigonometric and Hyperbolic Functions

def sec(x):
"""Secant of x."""
return 1 / cos(x)
Expand All @@ -31,7 +31,7 @@ def cot(x):
return 1 / tan(x)


# Inverse Hyperbolic Functions

def inv_sinh(x):
"""Inverse hyperbolic sine of x."""
return 1 / sinh(x)
Expand All @@ -47,7 +47,7 @@ def inv_tanh(x):
return 1 / tanh(x)


# Inverse Trigonometric Functions

def inv_asin(x):
"""Inverse sine of x."""
return 1 / asin(x)
Expand All @@ -63,7 +63,7 @@ def inv_atan(x):
return 1 / atan(x)


# Combinations of functions

combs = (
(sin, cos),
(sin, tan),
Expand Down
32 changes: 16 additions & 16 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ def __init__(
scale=SCALE,
) -> None:
pygame.init()
# window

self.height = height
self.width = width
self.scale = scale
self.screen = pygame.display.set_mode((self.width, self.height))
# colors

self.colors = Color()
# game variables

self.clock = pygame.time.Clock()
self._music_files = track_path, track1, track2, track3
self.music_is_playing = False
self.is_main_menu = True
self.volume = 0.0
# entity variables

self.trails = {}
# pages

self.main_menu = MainMenu(self.screen, self.height, self.width, self.scale, self)
self.settings_page = Settings(
self.screen,
Expand Down Expand Up @@ -69,8 +69,8 @@ def run_loading_screen(self):
"""Call the dynamic loading screen function."""
result = (
loading_screen(self.colors)
) # The loading screen runs until user presses Enter or Shift
return result # Return value determines the next action (e.g., continue or go back)
)
return result

def gameloop(self):
while True:
Expand All @@ -82,7 +82,7 @@ def gameloop(self):

self.screen.fill(self.colors.BLACK)

# Handle main menu and get selected option

if self.is_main_menu:
selected_option = self.main_menu.generate(
self.colors, brick_width, brick_height, self.clock
Expand All @@ -93,26 +93,26 @@ def gameloop(self):
pygame.quit()
sys.exit()

# Process selected option
if selected_option == 0: # Start the game

if selected_option == 0:
self.is_main_menu = False
back_to_main_menu = (
self.run_loading_screen()
) # Show the animated loading screen
if not back_to_main_menu: # User pressed Enter to continue
)
if not back_to_main_menu:
self.is_main_menu = self.game_page.runner(
self.colors,
brick_height,
brick_width,
self.trails,
self.clock,
)
else: # User pressed Shift to return to the main menu
else:
self.is_main_menu = True
elif selected_option == 1: # Settings
elif selected_option == 1:
self.is_main_menu = False
self.is_main_menu = self.settings_page.display()#self.colors)
elif selected_option == 2: # Info
self.is_main_menu = self.settings_page.display()
elif selected_option == 2:
self.is_main_menu = False
self.is_main_menu = self.info_page.scroll(self.colors)

Expand Down
6 changes: 3 additions & 3 deletions models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
__all__ = [
# Classes

"Ball",
"Brick",
"Color",
"FallingTile",
"Player",
"PowerUp",
"SpecialBall",
# Functions

"create_new_bricks",
"draw_bricks",
"drop_powerup",
# Types

"ColorType",
]

Expand Down
20 changes: 10 additions & 10 deletions models/ball.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(
ball_speed_x=ball_speed_x,
ball_speed_y=ball_speed_y,
) -> None:
# Initialization of ball properties

self.screen = screen
self.height = height - 150
self.width = width
Expand All @@ -36,15 +36,15 @@ def draw_ball(self, screen, color, ball_id, x, y, ball_trails):
"""Draw the ball and its trail."""
max_alpha = 50

# Initialize trail for this ball

trail = ball_trails.setdefault(ball_id, [])
trail.append((x, y))

# Limit the trail length

if len(trail) > trail_length:
trail.pop(0)

# Draw the trail

for i, (tx, ty) in enumerate(trail):
alpha = max_alpha - int(max_alpha * (i / trail_length))
trail_surface = pygame.Surface(
Expand All @@ -58,7 +58,7 @@ def draw_ball(self, screen, color, ball_id, x, y, ball_trails):
)
screen.blit(trail_surface, (tx - self.ball_radius, ty - self.ball_radius))

# Draw the ball's core with a shaded effect

for depth in range(self.ball_radius, 0, -1):
shade_factor = depth / self.ball_radius
shaded_color = (
Expand All @@ -68,7 +68,7 @@ def draw_ball(self, screen, color, ball_id, x, y, ball_trails):
)
pygame.draw.circle(screen, shaded_color, (int(x), int(y)), depth)

# Draw the highlight on the ball

highlight_color = (
min(color[0] + 80, 255),
min(color[1] + 80, 255),
Expand All @@ -86,7 +86,7 @@ def move_ball(self, dt, player: Player):
self.x += self.dx * dt
self.y += self.dy * dt

# Check collisions with walls

if self.x <= self.ball_radius or self.x >= self.width - self.ball_radius:
self.dx = -self.dx
self.x = max(self.ball_radius, min(self.x, self.width - self.ball_radius))
Expand All @@ -95,11 +95,11 @@ def move_ball(self, dt, player: Player):
self.dy = abs(self.dy)
self.y = self.ball_radius

# Check if ball crosses the bottom boundary

if self.y >= self.height - self.ball_radius - 60 and not self.ball_crossed_line:
self.ball_crossed_line = True

# Handle paddle collision

self._handle_paddle_collision(player)

return self.x, self.y, self.dx, self.dy
Expand All @@ -114,7 +114,7 @@ def _handle_paddle_collision(self, player: Player):
< self.y + self.ball_radius
< player.y_start + player.player_height
):
# Adjust ball direction based on paddle hit location

paddle_center = player.x_start + player.player_width / 2
self.dx = self.ball_speed_x * (
(self.x - paddle_center) / (player.player_width / 2)
Expand Down
16 changes: 8 additions & 8 deletions models/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ def __init__(
self.player_width = player_width
self.player_speed = player_speed

# Calculate player position at start

self.x_start = (self.width * self.scale - self.player_width) // 2
self.y_start = self.height * scale - self.player_height - 70
self.x_end = self.x_start + self.player_width # Unused currently
self.y_end = self.y_start - self.player_height # Unused currently
self.x_end = self.x_start + self.player_width
self.y_end = self.y_start - self.player_height


def draw_player(self, color):
"""Draw the player character as a rectangle with a 3D-like gradient effect."""
gradient_steps = 10 # Number of gradient steps to create depth effect
gradient_steps = 10
base_color = color.BLUE
for i in range(gradient_steps):
# Calculate color variations for the gradient effect
# As `i` increases, the rectangle becomes darker to simulate depth


shade_factor = i / gradient_steps
r = int(base_color[0] * (1 - shade_factor))
g = int(base_color[1] * (1 - shade_factor))
b = int(base_color[2] * (1 - shade_factor))

# Adjust the rectangle's position slightly to create a layered effect

pygame.draw.rect(
self.screen,
(r, g, b),
Expand All @@ -64,4 +64,4 @@ def move_player(self, dt, keys, min_limit, max_limit):
) and self.x_start < WIDTH - self.player_width - max_limit:
self.x_start += self.player_speed * dt

return time.time() # Time used for tracking, though this is unused
return time.time()
12 changes: 6 additions & 6 deletions models/special_ball.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ def move(self, ball_radius, width, dt):

def draw(self, screen, ball_radius, color):
"""Draw the ball on the screen with a 3D-like gradient effect."""
gradient_steps = 10 # Number of gradient steps to create the depth effect
gradient_steps = 10
base_color = color.RED

# Create the gradient effect by drawing multiple circles

for i in range(gradient_steps):
# Calculate the shading for each circle, giving the effect of light direction

shade_factor = i / gradient_steps
r = int(base_color[0] * (1 - shade_factor))
g = int(base_color[1] * (1 - shade_factor))
b = int(base_color[2] * (1 - shade_factor))

# Draw each circle slightly smaller and with darker color for the 3D effect

circle(
screen,
(r, g, b), # Adjusted color for each layer
(r, g, b),
(self.x, self.y),
ball_radius - i # Each layer gets progressively smaller
ball_radius - i
)
4 changes: 2 additions & 2 deletions pages/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
__all__ = [
# Classes

"Info",
"MainGame",
"MainMenu",
"Page",
"Settings",
# Functions

"loading_screen",
]

Expand Down
8 changes: 4 additions & 4 deletions pages/info_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ class Info(Page):
def __init__(self, screen, height, width, scale, game):
super().__init__(screen, height, width, scale, game)
self.fonts = (
pygame.font.Font(None, 20), # Font
pygame.font.Font(None, 30), # Bold
pygame.font.Font(None, 24), # Subtitle
pygame.font.Font(None, 26), # Bottom
pygame.font.Font(None, 20),
pygame.font.Font(None, 30),
pygame.font.Font(None, 24),
pygame.font.Font(None, 26),
)
self.sprite_width = self.sprite_height = 50
self.top_margin = 50
Expand Down
Loading

0 comments on commit 73350ef

Please sign in to comment.