Untitled

 avatar
unknown
plain_text
10 months ago
1.3 kB
14
Indexable
import pygame

pygame.init()

SCREEN_WIDTH = 500
SCREEN_HEIGHT = 500

clock = pygame.time.Clock()

#colors
CYAN = (0, 200, 50)


#window
window = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))




class Area():
    def __init__(self, x, y, width, height, color):
        self.rect = pygame.Rect(x, y , width, height)
        self.fill_color = color

    def change_color(self, new_color):
        self.fill_color = new_color

    def outline(self, frame_color, thicknes):
        pygame.draw.rect(main_window, frame_color, self.rect, thicknes)
    
    def fill(self,frame_color, thicknes):
        pygame.draw.rect(main_window, self.fill_color, self.rect)
        #self.outline(frame_color, thicknes)

    def collidepoint(self, x, y):
        return self.rect.collidepoint(x, y)

class Picture(Area):
    def __init__(self, filename, x, y, width, height, color ):
        super().__init__(x, y, width, height, color)
        self.image = pygame.image.load(filename)
    def draw(self):
        window.blit(self.image, (self.rect.x, self.rect.y))

ball = Picture( "ball.png", 250, 300, 50, 50, None)
platform = Picture("platform.png", 250, 350, 100, 50, None  )


while True:
    window.fill(CYAN)

    ball.draw()
    platform.draw()

    pygame.display.update()
    clock.tick(60)
Editor is loading...
Leave a Comment