Changed some classes

This commit is contained in:
Christian
2024-08-08 15:10:10 +02:00
parent 5d42915e56
commit 2171f51145
3 changed files with 36 additions and 18 deletions

View File

@@ -1,22 +1,34 @@
import pygame
class GameObject(object):
def __init__(self, name, pos_x, pos_y, image=None,) -> None:
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))
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