-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomet_event.py
More file actions
55 lines (44 loc) · 1.6 KB
/
Copy pathcomet_event.py
File metadata and controls
55 lines (44 loc) · 1.6 KB
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
import pygame
from comet import Comet
class CometFallEvent:
#lors du chargelent -> créer un compteur
def __init__(self, game):
self.percent = 0
self.percent_speed = 10
self.game = game
self.fall_mode = False
#definir un groupe de sprite pour stocker nos cometes
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):
#boucler entre 1 et 10
for i in range(1, 10) :
#apparaitre 1 premiere boule de feu
self.all_comets.add(Comet(self))
def attempt_fall(self):
if self.is_full_loaded() and len(self.game.all_monsters) == 0:
print("Pluie de cometes !!")
self.meteor_fall()
self.fall_mode = True #activier l'evenement
def update_bar(self, surface):
#ajouter des pourcent à la bar
self.add_percent()
#barre noir (en arriere plan)
pygame.draw.rect(surface, (0, 0, 0), [
0, #axe des x
surface.get_height() - 20, #axe des y
surface.get_width(), #longueur de la fenetre
10 #epaisseur de la barre
])
#bar rouge (jauge d'event)
pygame.draw.rect(surface, (187, 11, 11), [
0, # axe des x
surface.get_height() -20, # axe des y
(surface.get_width() / 100) * self.percent, # longueur de la fenetre
10 # epaisseur de la barre
])