for now removed card class from hirarchy and added possibillity to render sprites on screen

This commit is contained in:
2023-12-07 22:39:34 +01:00
parent 0d89b1ce84
commit 8d7a67a454
20 changed files with 95 additions and 56 deletions

View File

@@ -1,6 +1,7 @@
import pygame
from pygame.locals import *
from Classes.Objects.Cards.MonsterCard import MonsterCard
from Classes.System.Window import Window
from Classes.System.InputHandler import InputHandler
@@ -9,35 +10,41 @@ class App:
__window:Window
__running:bool = True
__player = pygame.Rect((300,250, 50,50))
# __player = pygame.Rect((300,250, 50,50))
__FPS = 60
__speed = 5
__clock = pygame.time.Clock()
def __init__(self, width:int=800, height:int=600, title:str="default title"):
def __init__(self, width:int=1280, height:int=720, title:str="default title"):
self.__window = Window(width=width, height=height, title=title)
self.startGameLoop()
self.onCleanup()
def startGameLoop(self):
# create sprite groups
cards = pygame.sprite.Group()
testMonsterCard = MonsterCard((500,500), "Assets/Cards/MonsterCards/testmonstercard/")
cards.add(testMonsterCard)
while self.__running:
self.__clock.tick(self.__FPS)
#temporary refresh
self.__window.getScreen().fill((0,0,0))
pygame.draw.rect(self.__window.getScreen(), (255,0,0), self.__player)
self.__player.move_ip((InputHandler.getInputAxis()[0]*self.__speed),(InputHandler.getInputAxis()[1]*self.__speed))
# update sprite groups
cards.update()
# draw groups
self.__window.drawSpriteGroup(cards)
# event handler
self.handleEvent(pygame.event.get())
# emits update to the game
pygame.display.update()
# handles incoming eventqueue
# handles incoming event queue
def handleEvent(self, events):
for event in events:
if event.type == pygame.QUIT: