-
Notifications
You must be signed in to change notification settings - Fork 0
/
person.py
31 lines (25 loc) · 991 Bytes
/
person.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
__author__ = 'raghuram'
import pygame
class PersonSprite(pygame.sprite.Sprite):
def __init__(self, image_left, image_right, position, width, height, state):
pygame.sprite.Sprite.__init__(self)
self.left = pygame.image.load(image_left)
self.right = pygame.image.load(image_right)
self.position = position
self.state = state
if state == 0:
self.image = self.left
else:
self.image = self.right
self.left = pygame.transform.scale(self.left, (width, height))
self.right = pygame.transform.scale(self.right, (width, height))
self.image = self.left
self.rect = pygame.Rect(self.image.get_rect())
self.rect.topleft = position
def personhit(self):
self.image = self.hit
def setPosition(self, position):
self.position = position
pygame.Rect(self.image.get_rect()).topleft = position
def getPosition(self):
return self.position