'Pygame shape border not appearing
I've just started learning python, and I was messing around with classes to understand them better when I notice something.
When I run the code below I expected both shapes to just be borders, but the blue one is filled.
I googled for answers, but the results were all to do with shapes not appearing at all.
I also tried adding more numbers to the rectangle
e.g:
rectangle = pygame.draw.rect(self.screen, self.color, (self.height, self.width, self.location_x, self.location_y), self.border, 10, 20, 20, 20, 20)
But, that rounded the corners.
I would like to know why the blue rectangle isn't a boarder and how to make it one. Thank you.
import pygame
screen = pygame.display.set_mode ((500, 500))
red = (255, 0, 0)
green = (0, 255, 0)
blue = (0, 0, 255)
class shape():
def __init__(self, screen, color, location_x, location_y, border):
self.screen = screen
self.color = color
self.location_x = location_x
self.location_y = location_y
self.border = border
class rectangle(shape):
def __init__(self, screen, color, location_x, location_y, border, height, width):
shape.__init__(self, screen, color, location_x, location_y, border)
self.height = height
self.width = width
def draw(self):
rectangle = pygame.draw.rect(self.screen, self.color, (self.height, self.width, self.location_x, self.location_y), self.border)
Rectangle = rectangle(screen, blue, 50, 50, 100, 100, 5)
Rectangle.draw()
pygame.draw.rect(screen, red, (400, 400, 50, 50), 3)
pygame.display.flip()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
