Untitled
unknown
plain_text
a year ago
1.6 kB
18
Indexable
import pygame
pygame.init()
SCREEN_WIDTH = 500
SCREEN_HEIGHT = 500
clock = pygame.time.Clock()
#colors
CYAN = (0, 255, 255)
#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 fill(self,frame_color, thicknes):
pygame.draw.rect(main_window, self.fill_color, self.rect)
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 )
start_x = 5
start_y = 5
monsters = []
count = 9
for j in range (3):
x = start_x + (55/2 * j) #координата у кожному слід стовпці
y = start_y + (55 * j)
for i in range (count):
monster = Picture("enemy.png",x, y, 50, 50, None)
monsters.append(monster)
x = x + 55
count -= 1
while True:
window.fill(CYAN)
for m in monsters:
m.draw()
ball.draw()
platform.draw()
pygame.display.update()
clock.tick(60)
Editor is loading...
Leave a Comment