Python version: 3.13.0
SDL (don't know what this is) version: 2.28.4
Pygame version: 2.6.1
First of all, here's the code (of interest because the entire code is too big):
Paddle class:
class paddle():
def __init__(self):
self.height = 10
self.width = int(screen_width / cols)
self.x = int((screen_width / 2) - (self.width / 2))
self.y = screen_height * (self.height * 2)
self.speed = 10
self.rect = pygame.Rect(self.x, self.y, self.width, self.height)
self.direction = 0
def move(self):
self.direction = 0
key = pygame.key.get_pressed()
if key[pygame.K_a] and self.rect.left > 0:
self.rect.x -= self.speed
self.direction = -1
if key[pygame.K_d] and self.rect.right < screen_width:
self.rect.x += self.speed
self.direction = 1
def draw(self):
pygame.draw.rect(screen, paddle_color, self.rect)
pygame.draw.rect(screen, paddle_outline, self.rect, 3)
Paddle instance:
player_paddle = paddle()
Game loop:
run = True
while run:
screen.fill(bg_color)
wall.draw_wall()
player_paddle.draw()
player_paddle.move()
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
pygame.display.update()
pygame.quit()
This game is supposed to be very similar to Breakout, but the paddle doesn't show up on the screen. I tried removing the code that prevents it from moving if it's outside of the screen and changing the x and y positions and none of that worked, the result is always the same. For the record, the color of the paddle and the background are different.