forked from virtualeiro/pygame-imfvj2-2023-24
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAula6_projectile1.py
49 lines (37 loc) · 1.08 KB
/
Aula6_projectile1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import pygame
import sys
class Projectile:
def __init__(self, x, y, radius, color):
self.x = x
self.y = y
self.radius = radius
self.color = color
def draw(self, screen):
pygame.draw.circle(screen, self.color, (self.x, self.y), self.radius)
def main():
# Initialize Pygame
pygame.init()
# Set up the display window
width = 800
height = 600
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption("Particle Class Example")
# Define colors (RGB format)
BLACK = (0, 0, 0)
# Create a Particle object
particle = Projectile(20, height // 2, 5, BLACK)
# Main loop
while True:
# Handle events
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
# Fill the background with white
screen.fill((255, 255, 255))
# Draw the particle
particle.draw(screen)
# Update the display
pygame.display.flip()
if __name__ == "__main__":
main()