-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpop.py
34 lines (22 loc) · 953 Bytes
/
pop.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
import pygame
from player import POSITION
from random import randint
class POP(pygame.sprite.Sprite):
def __init__(self, screen, velocity):
super().__init__()
pygame.init()
self.screen = screen
self.image = pygame.image.load(f'./assets/img/pop{str(randint(1,3))}.png')
self.image = pygame.transform.scale(self.image, (50, 50))
self.start_pos = randint(POSITION['total_left'], POSITION['total_right'])
self.rect = self.image.get_rect(center=(self.start_pos, 0))
self.x = self.rect.x
self.x = self.start_pos
self.y = self.rect.y
self.y = 0
self.velocity = velocity
def fall(self): self.y += self.velocity
def update(self):
self.screen.blit(self.image, (self.x, self.y))
self.rect = self.image.get_rect(center=(self.x, self.y))
self.fall()