-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcollide_object.py
35 lines (28 loc) · 990 Bytes
/
collide_object.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
import pygame
import config
import assets
import random
class CollideObject(pygame.sprite.Sprite):
def __init__(self, cords=None):
pygame.sprite.Sprite.__init__(self)
self.collided = False
if cords is not None:
self.x_pos = cords[0]
self.y_pos = cords[1]
self.image = assets.object_sprites[
random.randint(
0, len(assets.object_sprites) - 1
)
].convert_alpha()
self.mask = pygame.mask.from_surface(self.image)
self.rect = self.image.get_rect(center=(self.x_pos, self.y_pos))
def update(self):
self.rect.left -= config.OBJECT_PACE
if self.rect.right <= 0:
self.rect.left = config.WIDTH + random.randint(80, 500)
self.image = assets.object_sprites[
random.randint(
0, len(assets.object_sprites) - 1
)
].convert_alpha()
self.collided = False