import pygame
pygame.init()
WIDTH = 800
HEIGHT = 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Моя первая программа")
WHITE = (255, 255, 255)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
PURPLE = (183, 98, 228)
BLACK = (0, 0, 0, 0)
FPS = 60
clock = pygame.time.Clock()
class Puli:
def __init__(self, x, y, speed):
self.x, self.y = x, y
self.speed = speed
Pulis.append(self)
def update(self):
self.x -= self.speed
if self.y < 0:
Pulis.remove(self)
def draw(self):
pygame.draw.circle(screen, GREEN, (self.x, self.y), 2)
playerx, playery = WIDTH // 2, HEIGHT - 30
Pulis = []
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
mouseX, mouseY = pygame.mouse.get_pos()
b1, b2, b3 = pygame.mouse.get_pressed()
playerx += (mouseX - playerx) * 0.1
if b1:
b = Puli(playerx, playery, 5)
for Puli in Pulis:
Puli.update()
screen.fill(BLACK)
pygame.draw.circle(screen, RED, (playerx, playery), 10)
pygame.draw.line(screen, RED, (playerx, playery), (playerx, playery - 20), 5)
for Puli in Pulis:
Puli.draw()
pygame.display.update()
clock.tick(FPS)
pygame.QUIT()
<b>вот ошибка</b>
Traceback (most recent call last):
File "C:\Users\user\PycharmProjects\telegram\game.py", line 51, in <module>
b = Puli(playerx, playery, 5)
TypeError: 'Puli' object is not callable