-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomet_event.py
57 lines (44 loc) · 1.57 KB
/
comet_event.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import pygame
from comet import Comet
class CometFallEvent:
def __init__(self,game) -> None:
self.game = game
self.percent = 0
self.percent_speed = 30
self.fall_mode = False
self.all_comets = pygame.sprite.Group()
def add_percent(self):
self.percent += self.percent_speed/100
def is_full_loaded(self):
return self.percent >= 100
def reset_percent(self):
self.percent = 0
def meteor_fall(self):
# Apparaitre une premiere boule de feu
self.all_comets.add(Comet(self))
self.all_comets.add(Comet(self))
self.all_comets.add(Comet(self))
def attempt_fall(self):
if self.is_full_loaded() and len(self.game.all_monsters) == 0:
print("Pluit de Cometes")
self.meteor_fall()
#self.reset_percent()
self.fall_mode = True
def update_bar(self, surface):
self.add_percent()
# Essayer de declencher la pluie
# self.attempt_fall()
# barre noir (en arriere plan)
pygame.draw.rect(surface, (0, 0, 0), [
0,# l'axe des x
surface.get_height()-10, # l'axe des y
surface.get_width(),# Longueur de la fenetre
10 #epaisseur de la barre
])
# barre rouge (en jauge d'event)
pygame.draw.rect(surface, (187, 11, 11), [
0,# l'axe des x
surface.get_height()-10, # l'axe des y
(surface.get_width() / 100) * self.percent,# Longueur de la fenetre
10 #epaisseur de la barre
])