Added revisionshash for debbugging
This commit is contained in:
@@ -42,6 +42,7 @@ class Player(GameObject):
|
||||
self.screen = screen
|
||||
self.points = 0
|
||||
self.lifes = 2
|
||||
self.kills = 0
|
||||
|
||||
def handle_input(self, event:pygame.event.EventType):
|
||||
if(event.type == pygame.KEYDOWN and event.key == pygame.K_LEFT):
|
||||
@@ -173,3 +174,11 @@ class Projectile(GameObject):
|
||||
class Item(GameObject):
|
||||
def __init__(self, name, pos_x, pos_y, width, height, image=None) -> None:
|
||||
super().__init__(name, pos_x, pos_y, width, height, image)
|
||||
|
||||
class item_extra_life(Item):
|
||||
def __init__(self, name, pos_x, pos_y, width, height, image=None) -> None:
|
||||
super().__init__(name, pos_x, pos_y, width, height, image)
|
||||
|
||||
class Weapons(GameObject):
|
||||
def __init__(self, name, pos_x, pos_y, width, height, image=None) -> None:
|
||||
super().__init__(name, pos_x, pos_y, width, height, image)
|
||||
35
test.py
35
test.py
@@ -1,7 +1,9 @@
|
||||
import pygame
|
||||
import GameObject
|
||||
import Utils
|
||||
import time
|
||||
import random
|
||||
import subprocess
|
||||
|
||||
pygame.init()
|
||||
|
||||
@@ -13,10 +15,19 @@ screen = pygame.display.set_mode((1024,768)) #TODO Add fullscreen mode
|
||||
|
||||
clock = pygame.time.Clock()
|
||||
|
||||
WEISS = (255,255,255)
|
||||
SCHWARZ = (0,0,0)
|
||||
GRUEN = (0,255,0)
|
||||
ROT = (255,0,0)
|
||||
|
||||
image_enemy = Utils.load_image("Rastergrafik.png")
|
||||
testimage = Utils.load_image("Rastergrafik.png")
|
||||
|
||||
font1 = pygame.font.Font("/usr/share/fonts/TTF/Inconsolata-UltraExpandedExtraBold.ttf", 30)
|
||||
font2 = pygame.font.Font("/usr/share/fonts/TTF/Inconsolata-UltraExpandedExtraBold.ttf", 12)
|
||||
|
||||
short_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('ascii').strip()
|
||||
hash_label = font2.render(F"git-hash: {short_hash}", 1, ROT)
|
||||
|
||||
#testimage.set_colorkey((255,0,255), pygame.RLEACCELOK)
|
||||
|
||||
@@ -39,9 +50,13 @@ for enemys in range(80):
|
||||
i += 1
|
||||
|
||||
gamestate = True
|
||||
frametime =0
|
||||
milliseconds = pygame.time.get_ticks()
|
||||
|
||||
seconds = milliseconds/1000
|
||||
|
||||
while(gamestate):
|
||||
|
||||
frametime = clock.get_time()
|
||||
screen.fill((8,31,61))
|
||||
|
||||
for event in pygame.event.get():
|
||||
@@ -88,6 +103,8 @@ while(gamestate):
|
||||
print("Spieler1 Lifes: ", player1.lifes)
|
||||
print("Spieler2 Lifes: ", player2.lifes)
|
||||
|
||||
#TODO If Playerposition are on the same x-axis then gamble hit by 50% chance
|
||||
|
||||
for projectiles in GameObject.Projectile.shots:
|
||||
projectiles:dict
|
||||
for key, projectile in projectiles.items():
|
||||
@@ -107,6 +124,11 @@ while(gamestate):
|
||||
del GameObject.Projectile.shots[index]
|
||||
print(F"Player-Points: {player1.points}")
|
||||
print(F"Player-Points: {player2.points}")
|
||||
if(projectile.name == "Player"):
|
||||
player1.kills += 1
|
||||
|
||||
if(projectile.name == "Player2"):
|
||||
player2.kills += 1
|
||||
|
||||
#TODO Buggy pygame colliderect is true until projectile passed the hole playrect
|
||||
# Life decrease only once!
|
||||
@@ -129,8 +151,16 @@ while(gamestate):
|
||||
index = GameObject.Projectile.shots.index(projectiles)
|
||||
del GameObject.Projectile.shots[index]
|
||||
|
||||
milliseconds = pygame.time.get_ticks()
|
||||
seconds = milliseconds / 1000
|
||||
now = time.time_ns()
|
||||
|
||||
print("Playerkills 1:", player1.kills)
|
||||
print("Playerkills 2:", player2.kills)
|
||||
|
||||
player1.render(screen)
|
||||
player2.render(screen)
|
||||
print(int(seconds))
|
||||
|
||||
rand = random.randint(0, 100)
|
||||
for enemy in spawned_enemys:
|
||||
@@ -148,9 +178,10 @@ while(gamestate):
|
||||
|
||||
label1 = font1.render(F"Score: {player1.points}", True, (255,0,0))
|
||||
screen.blit(label1, ((screen.get_size()[0]/2)-(label1.get_size()[0]/2), screen.get_size()[1]-50))
|
||||
screen.blit(hash_label, (25, screen.get_size()[1] -25))
|
||||
|
||||
#if(mouse_pos <= (image.topleft+image.size) and mouse_pos >= image.topleft):
|
||||
# print("HIIIIITTT!!!!")
|
||||
|
||||
frametime = 0
|
||||
clock.tick(60)
|
||||
pygame.display.flip()
|
||||
Reference in New Issue
Block a user