28 lines
802 B
Python
28 lines
802 B
Python
import pygame
|
|
|
|
class GameObject():
|
|
def __init__(self, name, posx:int, posy:int, sizex, sizey, spritepath:str, surface:pygame.Surface) -> None:
|
|
self._posx = posx
|
|
self._posy = posy
|
|
self._size = [sizex, sizey]
|
|
self._name = name
|
|
self._surface = surface
|
|
self._spritepath:str = ""
|
|
self._sprite:pygame.Surface
|
|
self._rect:pygame.rect
|
|
if(len(spritepath) > 0):
|
|
self._sprite = pygame.image.load(spritepath)
|
|
self._rect = self._sprite.get_rect()
|
|
|
|
|
|
def move(self, x,y):
|
|
self._posx += x
|
|
self._posy += y
|
|
|
|
|
|
def draw(self):
|
|
self._rect = pygame.Surface.blit(self._surface, self._sprite, (self._posx, self._posy))
|
|
|
|
|
|
def get_position(self):
|
|
return(self._posx, self._posy) |