Update Game_V2.py
parent
7b0dae6f96
commit
a43c590d7b
13
Game_V2.py
13
Game_V2.py
|
@ -7,11 +7,12 @@ SCREEN_Y = 720
|
|||
|
||||
# pygame setup
|
||||
pygame.init()
|
||||
pygame.display.set_caption("Vampire survivors")
|
||||
pygame.display.set_caption("Rouglite")
|
||||
screen = pygame.display.set_mode((SCREEN_X, SCREEN_Y))
|
||||
clock = pygame.time.Clock()
|
||||
running = True
|
||||
|
||||
|
||||
class Player(pygame.sprite.Sprite):
|
||||
def __init__(self, pos, group):
|
||||
super().__init__(group)
|
||||
|
@ -19,6 +20,7 @@ class Player(pygame.sprite.Sprite):
|
|||
self.rect = self.image.get_rect(center = pos)
|
||||
self.direction = pygame.math.Vector2()
|
||||
self.speed = 2.25
|
||||
self.time = 0
|
||||
|
||||
#health
|
||||
self.current_health = 1000 #health
|
||||
|
@ -227,12 +229,14 @@ class Enemy(pygame.sprite.Sprite):
|
|||
self.kill()
|
||||
|
||||
|
||||
|
||||
def update(self):
|
||||
self.direction = pygame.math.Vector2(player.rect.center) - self.rect.center
|
||||
if(pygame.math.Vector2.length(self.direction)<20):
|
||||
player.get_damage(200)
|
||||
self.kill()
|
||||
enemies.remove(self)
|
||||
player.time = 0
|
||||
self.pos += self.direction.normalize() * self.speed
|
||||
self.rect.center = (round(self.pos.x), round(self.pos.y))
|
||||
|
||||
|
@ -302,6 +306,11 @@ while running:
|
|||
if e.key == pygame.K_DOWN:
|
||||
player.get_damage(200)
|
||||
|
||||
if player.time > 3:
|
||||
if player.current_health < 999:
|
||||
player.get_health(200)
|
||||
player.time -= 1.5
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -315,6 +324,8 @@ while running:
|
|||
pygame.display.flip()
|
||||
|
||||
clock.tick(60)
|
||||
player.time += 0.016
|
||||
print(player.time)
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue