Files
test/GameObject.py
2024-08-08 21:52:00 +02:00

40 lines
1.2 KiB
Python

import pygame
class GameObject(object):
objects = list()
def __init__(self, name, pos_x, pos_y, width, height, image=None) -> None:
self.name = name
self.pos_x = pos_x
self.pos_y = pos_y
self.width = width
self.height = height
self.image = image
self.objects.append(self)
pass
def get_objectinfo(self):
print(F"Gameobject-Info: \n",
F"Name: {self.name}\n",
F"Position x: {self.pos_x} y: {self.pos_y}\n",
F"Size = width: {self.width} height: {self.height}"
)
def render(self, screen:pygame.Surface):
if(self.image is not None):
screen.blit(self.image, (self.pos_x, self.pos_y, ))
else:
print("Kein Image hinterlegt!")
def setpos(self, pos_x, pos_y):
self.pos_x = pos_x
self.pos_y = pos_y
def setsize(self, width, height):
self.width = width
self.height = height
class Player(GameObject):
def __init__(self, name, pos_x, pos_y, width, height, image=None) -> None:
super().__init__(name, pos_x, pos_y, width, height, image)