diff --git a/data/models/player_test.png b/data/models/player_test.png new file mode 100644 index 0000000..3273866 Binary files /dev/null and b/data/models/player_test.png differ diff --git a/modules/GameObject.py b/modules/GameObject.py index b4b6d01..d0263a5 100644 --- a/modules/GameObject.py +++ b/modules/GameObject.py @@ -2,6 +2,8 @@ import pygame import random as rand class GameObject(): + """TODO Install a body array with positions of mainbody and adders""" + _size_rect_x:int _size_rect_y:int __movespeed = int() diff --git a/pygame-test.py b/pygame-test.py index d07cb2f..dd68845 100644 --- a/pygame-test.py +++ b/pygame-test.py @@ -9,6 +9,7 @@ pygame.init() MAINSCREEN_SIZE = (1024,768) MAINSCREEN = pygame.display.set_mode(MAINSCREEN_SIZE) pygame.display.set_caption("Testgame") +my_font = pygame.font.SysFont('times new roman', 26) WEISS = ( 255, 255, 255) SCHWARZ = (0,0,0) @@ -21,6 +22,9 @@ clock = pygame.time.Clock() #TODO: Make Grid for running Rect """TODO: Add new controlstructure for User-class on first login Actually buggy if player logsin the first time, because there is no playerselected before there was an insterquery!!! + + Make a live scoreboard + """ #Behandelt später die Hauptschleife und Klassenobjekte @@ -28,6 +32,8 @@ class Game(): __state = {"win":False, "lose":False, "paused":False} def __init__(self) -> None: pass + def scoreboard(self): + pass #Handles all collided objects an adds it as playerfollower def start_game(): @@ -65,23 +71,21 @@ menu.add.button('Play', start_game) menu.add.button('Quit', pygame_menu.events.EXIT) menu.mainloop(MAINSCREEN) +player = Player("Player", MAINSCREEN, MAINSCREEN_SIZE, 10, 10, 10, is_player=False, is_rect=True, color=(0,255,0) ,rect_size=(80,80)) + def spawn_entities(x:int, list_of_objects:list): count = 0 for y in range(x): rect_size = 80 Entity = Block("Entitiy-"+str(count), MAINSCREEN, MAINSCREEN_SIZE, rand.randint(1,MAINSCREEN_SIZE[0]), rand.randint(1,MAINSCREEN_SIZE[1]), rand.randint(1,15), is_rect=True, rect_size=(rect_size,rect_size)) Entity.get_name(True) - list_of_objects.append(Entity) + if(Entity.get_position() > player.get_position() + player.get_rect_size() or Entity.get_position() < player.get_position() + player.get_rect_size()): + list_of_objects.append(Entity) + else: + print("Object zu nach an Spieler") count += 1 -player = Player("Player", MAINSCREEN, MAINSCREEN_SIZE, 10, 10, 10, is_player=False, is_rect=True, color=(0,255,0) ,rect_size=(80,80)) -goo = GOIMAGE("TESTOBJEKT", MAINSCREEN, MAINSCREEN_SIZE, 0,0,0,image="data/models/testmodel.bmp") - -testlist = list() -for y in range(10): - Entity = GOIMAGE("Testobject", MAINSCREEN, MAINSCREEN_SIZE, posx_init=rand.randint(10, 600), posy_init=rand.randint(10, 600), image="data/models/testmodel.bmp") - testlist.append(Entity) background = pygame.surface.Surface((640,480)) @@ -89,7 +93,7 @@ x = 3600 invert = False colided_objects = list() spawned_entities = list() -spawn_entities(150, spawned_entities) +spawn_entities(20, spawned_entities) count_hidden_entities = 0 count_spawend_enities = len(spawned_entities) print("Es wurden " + str(count_spawend_enities)+ " Objekte gespawnt") @@ -119,7 +123,8 @@ while active == True: #print("Keydown") player.change_direction("left") - goo.draw() + text_surface = my_font.render('Score: '+str(player.get_player_score()), False, (0, 0, 0)) + MAINSCREEN.blit(text_surface, (0,0)) player.draw() player.update_pos_lastframe(player.get_position()[0], player.get_position()[1], False) @@ -144,10 +149,6 @@ while active == True: append_follwer(xy[0], xy[1]) count_follower += 1 - for t in testlist: - t:GOIMAGE - t.draw() - #Zeichnet alle Verfolgerobjekte, sofern sie vorliegend sind #TODO: Follower sollen ab dem zweiten Objekt dem vorangegangenen Objekt folgen und nicht dem player @@ -155,23 +156,6 @@ while active == True: # colided_objects[0].set_position_player(player.get_position(), player.get_playermovedirection(), True) i=0 - if(colided_objects): - pass - """ - #TODO:Berechne Position follower Objekte anhand Position aus letztem Frame - for follower in colided_objects: - follower:Block - if(i >= 0): - colided_objects[0].set_position_player(player.get_position(), player.get_playermovedirection(), True) - pass - if(i > 0 and i <= len(colided_objects)): - #colided_objects[i].set_position_player(follower.set_position(colided_objects[i-1].get_position()), player.get_playermovedirection(), True) - pass - follower.draw() - i += 1""" - - - if(count_hidden_entities == count_spawend_enities): print("WIN!!!") if(player.get_player_score() > User.gethighscore()): @@ -184,8 +168,8 @@ while active == True: if(x == 0): for y in spawned_entities: - y.hide() - pass + #y.hide() + pass x -= 1 #print("Objekt-Koordinaten= X: "+str(rect1.x)+" Y: "+str(rect1.y)+"", end="\r")