34 lines
1002 B
Python
34 lines
1002 B
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 |