-
Notifications
You must be signed in to change notification settings - Fork 0
/
customSprite.py
31 lines (25 loc) · 983 Bytes
/
customSprite.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
import pygame
import random
class Player(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.Surface((50, 50))
self.image = pygame.image.load('ball.png')
self.rect = self.image.get_rect()
self.rect.center = (450,450)
def update(self,box_mov,right_mov,direction,movement = None):
self.rect.centery+=box_mov
self.rect.centerx +=right_mov
if movement == 'space':
self.rect.centery-=5
class obs(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
i = random.randint(1,7)
self.image = pygame.Surface((7,7))
self.image.fill((255,255,255))
self.rect = self.image.get_rect()
self. image = pygame.transform.rotate(self.image,random.randint(-180,180))
self.rect.center = (random.randint(310,590),-5)
def update(self,grav):
self.rect.centery +=grav