Renamed Gameobjects class

Changed movement to classmethod
This commit is contained in:
2024-07-21 19:09:45 +02:00
parent 5d45bd9b05
commit f3d43d55a2
2 changed files with 35 additions and 33 deletions

View File

@@ -1,23 +1,28 @@
import pygame
class GameObjects():
def __init__(self, name, posx:int, posy:int, sprite:str) -> None:
self.posx = posx
self.posy = posy
self.name = name
self.sprite:str = ""
self.rect:pygame.rect
if(sprite != ""):
pygame.image.load(sprite)
pass
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
pass
self._posx += x
self._posy += y
def draw(self):
pygame.Surface.blit()
pass
self._rect = pygame.Surface.blit(self._surface, self._sprite, (self._posx, self._posy))
def get_position(self):
return(self._posx, self._posy)