Some cleanup
This commit is contained in:
@@ -151,11 +151,8 @@ class Enemy(GameObject):
|
||||
self.weapon:Weapons = None
|
||||
|
||||
def fire(self, screen):
|
||||
#print("Schieße!!!!")
|
||||
#shot = Projectile("Enemy", self.pos_x+(self.width/2),self.pos_y+self.height,5,10, screen, 2)
|
||||
self.weapon.fire()
|
||||
|
||||
|
||||
def firecontrol(self, screen):
|
||||
if(len(Projectile.shots) > 0):
|
||||
for objects in Projectile.shots:
|
||||
@@ -220,9 +217,9 @@ class Weapons(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)
|
||||
self.speed = 5
|
||||
self.speed = 2
|
||||
|
||||
def move(self, x, y):
|
||||
def move(self, x:int, y:int):
|
||||
self.pos_x += x
|
||||
self.pos_y += y
|
||||
|
||||
|
||||
19
game.py
19
game.py
@@ -18,6 +18,7 @@ items = [
|
||||
GameObject.item_extra_life("Extra-Life", 0, 0, 30, 30, None)
|
||||
]
|
||||
|
||||
enemys_spawned = list()
|
||||
items_spawned = list()
|
||||
|
||||
#Override
|
||||
@@ -30,7 +31,7 @@ def loadlevels():
|
||||
|
||||
def item_handler(screen:pygame.Surface):
|
||||
|
||||
spawn_chance = random.randint(0, 10)
|
||||
spawn_chance = random.randint(0, 1000)
|
||||
print(spawn_chance)
|
||||
if(spawn_chance == 0):
|
||||
#print("Spawne item")
|
||||
@@ -39,13 +40,25 @@ def item_handler(screen:pygame.Surface):
|
||||
for item in items_spawned:
|
||||
item:GameObject.Item
|
||||
print(item)
|
||||
|
||||
if(item.pos_y >= screen.get_size()[1]):
|
||||
items_spawned.remove(item)
|
||||
item.move(0, item.speed)
|
||||
item.render(screen)
|
||||
|
||||
pass
|
||||
|
||||
def spawn_item_random(screen:pygame.Surface):
|
||||
|
||||
items_spawned.append(copy.deepcopy(items[0]))
|
||||
print("Spawn")
|
||||
pass
|
||||
|
||||
def spawn_enemys(type:object, count:int):
|
||||
for i in range(count):
|
||||
pass
|
||||
pass
|
||||
|
||||
def run(screen:pygame.Surface):
|
||||
screen = screen
|
||||
item_handler(screen)
|
||||
|
||||
pass
|
||||
54
test.py
54
test.py
@@ -113,32 +113,13 @@ while(gamestate):
|
||||
player2.move("right")
|
||||
#print("rechts")
|
||||
|
||||
#image = screen.blit(testimage, (pos_x, pos_y))
|
||||
|
||||
mouse_pos = pygame.mouse.get_pos()
|
||||
#print(int(pygame.time.get_ticks()/1000))
|
||||
|
||||
#print(mouse_pos)
|
||||
#print(image.topleft) #Gibt die Position einen Surfaces "obenlinks" aus
|
||||
#print(image.size) #Gibt die Größe eines Surfaces aus
|
||||
|
||||
#max = tuple(map(lambda i, j : i+j, image.topleft, image.size))
|
||||
#Wenn Mausposition X-Achse innerhalb Anfangsposition+Breite
|
||||
#if(mouse_pos[0] <= max[0] and mouse_pos[0] >= image.topleft[0]):
|
||||
#Wenn Mausposition Y-Achse innerhalb Anfangsposition+Höhe
|
||||
#if(mouse_pos[1] <= max[1] and mouse_pos[1] >= image.topleft[1]):
|
||||
#print("Treffer")
|
||||
#pos_x = mouse_pos[0]
|
||||
#pos_y = mouse_pos[1]
|
||||
game.run(screen)
|
||||
healthbar1.update(player1.get_health())
|
||||
healthbar1.render(screen)
|
||||
player1.firecontrol(screen)
|
||||
player2.firecontrol(screen)
|
||||
game.item_handler(screen)
|
||||
|
||||
#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:
|
||||
@@ -201,14 +182,8 @@ while(gamestate):
|
||||
seconds = milliseconds / 1000
|
||||
now = time.time_ns()
|
||||
|
||||
#print("Playerkills 1:", player1.kills)
|
||||
#print("Playerkills 2:", player2.kills)
|
||||
|
||||
#print(F"Player 1 Health: {player1.get_health()}")
|
||||
#print(F"Player 2 Health: {player2.get_health()}")
|
||||
player1.render(screen)
|
||||
player2.render(screen)
|
||||
#print(int(seconds), "\r")
|
||||
|
||||
rand = random.randint(0, 100)
|
||||
for enemy in spawned_enemys:
|
||||
@@ -241,4 +216,27 @@ while(gamestate):
|
||||
#if(mouse_pos <= (image.topleft+image.size) and mouse_pos >= image.topleft):
|
||||
# print("HIIIIITTT!!!!")
|
||||
clock.tick(60)
|
||||
pygame.display.flip()
|
||||
pygame.display.flip()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#image = screen.blit(testimage, (pos_x, pos_y))
|
||||
|
||||
#mouse_pos = pygame.mouse.get_pos()
|
||||
#print(int(pygame.time.get_ticks()/1000))
|
||||
|
||||
#print(mouse_pos)
|
||||
#print(image.topleft) #Gibt die Position einen Surfaces "obenlinks" aus
|
||||
#print(image.size) #Gibt die Größe eines Surfaces aus
|
||||
|
||||
#max = tuple(map(lambda i, j : i+j, image.topleft, image.size))
|
||||
#Wenn Mausposition X-Achse innerhalb Anfangsposition+Breite
|
||||
#if(mouse_pos[0] <= max[0] and mouse_pos[0] >= image.topleft[0]):
|
||||
#Wenn Mausposition Y-Achse innerhalb Anfangsposition+Höhe
|
||||
#if(mouse_pos[1] <= max[1] and mouse_pos[1] >= image.topleft[1]):
|
||||
#print("Treffer")
|
||||
#pos_x = mouse_pos[0]
|
||||
#pos_y = mouse_pos[1]
|
||||
Reference in New Issue
Block a user