'How can i draw rectangles in multiple rows and columns in pygame?
I'm trying to make the Brick Breakout game. However, I'm having a problem drawing the bricks. I actually can draw them all, but I'm looking for a professional way to do it in order to use less code lines. Here is some of my code, but it's useless:
pygame.draw.rect(screen1, brick_colors[b], (x1, y1, 60, 12))
pygame.draw.rect(screen1, brick_colors[b], (x2, y1, 60, 12))
pygame.draw.rect(screen1, brick_colors[b], (x3, y1, 60, 12))
pygame.draw.rect(screen1, brick_colors[b], (x4, y1, 60, 12))
pygame.draw.rect(screen1, brick_colors[b], (x5, y1, 60, 12))
pygame.draw.rect(screen1, brick_colors[b], (x6, y1, 60, 12))
pygame.draw.rect(screen1, brick_colors[b], (x7, y1, 60, 12))
pygame.draw.rect(screen1, brick_colors[b], (x8, y1, 60, 12))
So, is there a method using the for loop for example to do the work? Note: the bricks should be 8 lines and 8 per line.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
