forked from erhs-53-hackers/Asteroid-Colliders
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameObject.py
35 lines (26 loc) · 865 Bytes
/
GameObject.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
'''
Created on Nov 1, 2011
@author: Michael
'''
from Sprite import Sprite
from pygame import Rect
import pygame
class GameObject:
def __init__(self, x, y, width, height, images, fps, looping):
self.x = x
self.y = y
self.width = width
self.height = height
self.sprite = Sprite(images, fps, looping)
def update(self, gameTime):
self.sprite.update(gameTime)
def draw(self, surface):
surface.blit(self.getImage(), self.getRect())
def getRect(self):
return Rect(self.x, self.y, self.width, self.height)
def getImage(self):
return self.sprite.getImage()
def setSprite(self, sprite):
self.sprite = sprite
def getHitMask(self):
return pygame.surfarray.array_alpha(self.sprite.getImage())