Added some testsprites
Added 2 Player gamemode Some changes to get second player handled
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import pygame
|
||||
|
||||
import interface
|
||||
#Statics
|
||||
spawned_enemys = list()
|
||||
|
||||
@@ -25,7 +25,7 @@ class GameObject(object):
|
||||
|
||||
def render(self, screen:pygame.Surface):
|
||||
if(self.image is not None):
|
||||
self.rect = screen.blit(self.image, (self.pos_x, self.pos_y))
|
||||
self.rect = screen.blit(self.image, (self.pos_x, self.pos_y, self.width, self.height))
|
||||
else:
|
||||
self.rect = pygame.draw.rect(screen, (255,0,0), (self.pos_x, self.pos_y, self.width, self.height))
|
||||
return
|
||||
@@ -47,7 +47,8 @@ class Player(GameObject):
|
||||
self._health = 100
|
||||
self.lifes = 2
|
||||
self.kills = 0
|
||||
self._healthbar = pygame.rect.Rect((15, self.screen.get_size()[1]-50, 100, 20))
|
||||
#self._healthbar = pygame.rect.Rect((15, self.screen.get_size()[1]-50, 100, 20))
|
||||
self.healthbar = interface.Healthbar(screen, "Player1", 25, screen.get_size()[1]-80, 300, 10, self.get_health())
|
||||
|
||||
def handle_input(self, event:pygame.event.EventType):
|
||||
if(event.type == pygame.KEYDOWN and event.key == pygame.K_LEFT):
|
||||
@@ -90,6 +91,10 @@ class Player(GameObject):
|
||||
if(direction == "right"):
|
||||
self.pos_x += self._speed
|
||||
|
||||
def update_interface(self):
|
||||
self.healthbar.update(self._health)
|
||||
self.healthbar.render(self.screen)
|
||||
|
||||
def fire(self, screen):
|
||||
projectile_width = 6
|
||||
projectile_height = 10
|
||||
@@ -110,6 +115,7 @@ class Player(GameObject):
|
||||
|
||||
def get_health(self):
|
||||
return self._health
|
||||
|
||||
|
||||
class Player2(Player):
|
||||
def __init__(self, name, screen, pos_x, pos_y, width, height, image=None) -> None:
|
||||
@@ -210,6 +216,7 @@ class Weapons(GameObject):
|
||||
self.duration = duration
|
||||
self.sprite = ""
|
||||
self.mountingpos = list()
|
||||
self.soundfile = ""
|
||||
|
||||
def fire(self):
|
||||
print(F"Feuere: {self.name}")
|
||||
|
||||
Reference in New Issue
Block a user