Added revisionshash for debbugging
This commit is contained in:
@@ -42,6 +42,7 @@ class Player(GameObject):
|
|||||||
self.screen = screen
|
self.screen = screen
|
||||||
self.points = 0
|
self.points = 0
|
||||||
self.lifes = 2
|
self.lifes = 2
|
||||||
|
self.kills = 0
|
||||||
|
|
||||||
def handle_input(self, event:pygame.event.EventType):
|
def handle_input(self, event:pygame.event.EventType):
|
||||||
if(event.type == pygame.KEYDOWN and event.key == pygame.K_LEFT):
|
if(event.type == pygame.KEYDOWN and event.key == pygame.K_LEFT):
|
||||||
@@ -171,5 +172,13 @@ class Projectile(GameObject):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
class Item(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:
|
def __init__(self, name, pos_x, pos_y, width, height, image=None) -> None:
|
||||||
super().__init__(name, pos_x, pos_y, width, height, image)
|
super().__init__(name, pos_x, pos_y, width, height, image)
|
||||||
35
test.py
35
test.py
@@ -1,7 +1,9 @@
|
|||||||
import pygame
|
import pygame
|
||||||
import GameObject
|
import GameObject
|
||||||
import Utils
|
import Utils
|
||||||
|
import time
|
||||||
import random
|
import random
|
||||||
|
import subprocess
|
||||||
|
|
||||||
pygame.init()
|
pygame.init()
|
||||||
|
|
||||||
@@ -13,10 +15,19 @@ screen = pygame.display.set_mode((1024,768)) #TODO Add fullscreen mode
|
|||||||
|
|
||||||
clock = pygame.time.Clock()
|
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")
|
image_enemy = Utils.load_image("Rastergrafik.png")
|
||||||
testimage = Utils.load_image("Rastergrafik.png")
|
testimage = Utils.load_image("Rastergrafik.png")
|
||||||
|
|
||||||
font1 = pygame.font.Font("/usr/share/fonts/TTF/Inconsolata-UltraExpandedExtraBold.ttf", 30)
|
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)
|
#testimage.set_colorkey((255,0,255), pygame.RLEACCELOK)
|
||||||
|
|
||||||
@@ -39,9 +50,13 @@ for enemys in range(80):
|
|||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
gamestate = True
|
gamestate = True
|
||||||
|
frametime =0
|
||||||
|
milliseconds = pygame.time.get_ticks()
|
||||||
|
|
||||||
|
seconds = milliseconds/1000
|
||||||
|
|
||||||
while(gamestate):
|
while(gamestate):
|
||||||
|
frametime = clock.get_time()
|
||||||
screen.fill((8,31,61))
|
screen.fill((8,31,61))
|
||||||
|
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
@@ -88,6 +103,8 @@ while(gamestate):
|
|||||||
print("Spieler1 Lifes: ", player1.lifes)
|
print("Spieler1 Lifes: ", player1.lifes)
|
||||||
print("Spieler2 Lifes: ", player2.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:
|
for projectiles in GameObject.Projectile.shots:
|
||||||
projectiles:dict
|
projectiles:dict
|
||||||
for key, projectile in projectiles.items():
|
for key, projectile in projectiles.items():
|
||||||
@@ -107,6 +124,11 @@ while(gamestate):
|
|||||||
del GameObject.Projectile.shots[index]
|
del GameObject.Projectile.shots[index]
|
||||||
print(F"Player-Points: {player1.points}")
|
print(F"Player-Points: {player1.points}")
|
||||||
print(F"Player-Points: {player2.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
|
#TODO Buggy pygame colliderect is true until projectile passed the hole playrect
|
||||||
# Life decrease only once!
|
# Life decrease only once!
|
||||||
@@ -129,8 +151,16 @@ while(gamestate):
|
|||||||
index = GameObject.Projectile.shots.index(projectiles)
|
index = GameObject.Projectile.shots.index(projectiles)
|
||||||
del GameObject.Projectile.shots[index]
|
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)
|
player1.render(screen)
|
||||||
player2.render(screen)
|
player2.render(screen)
|
||||||
|
print(int(seconds))
|
||||||
|
|
||||||
rand = random.randint(0, 100)
|
rand = random.randint(0, 100)
|
||||||
for enemy in spawned_enemys:
|
for enemy in spawned_enemys:
|
||||||
@@ -148,9 +178,10 @@ while(gamestate):
|
|||||||
|
|
||||||
label1 = font1.render(F"Score: {player1.points}", True, (255,0,0))
|
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(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):
|
#if(mouse_pos <= (image.topleft+image.size) and mouse_pos >= image.topleft):
|
||||||
# print("HIIIIITTT!!!!")
|
# print("HIIIIITTT!!!!")
|
||||||
|
frametime = 0
|
||||||
clock.tick(60)
|
clock.tick(60)
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
Reference in New Issue
Block a user