-
Notifications
You must be signed in to change notification settings - Fork 0
/
cactus.py
112 lines (100 loc) · 3.7 KB
/
cactus.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import pygame
import random
pygame.init()
class Cactus(pygame.sprite.Sprite):
def __init__(self, jeu):
super().__init__()
self.jeu = jeu
self.image = pygame.image.load('assets/cactus.png')
self.image = pygame.transform.scale(self.image, (128, 128))
self.rect = self.image.get_rect()
self.rect.x = 2000
self.rect.y = 500
self.vitesse = 9
def mouvement(self):
if self.jeu.collisions(self, self.jeu.genererJoueur):
self.jeu.gameOver()
self.rect.x -= self.vitesse
if self.rect.x <= -200:
self.jeu.nbreCactus = random.randint(1, 3)
self.rect.x = 760
if self.jeu.score == 5000:
self.vitesse += 0.15
if self.jeu.score == 10000:
self.vitesse += 0.15
if self.jeu.score == 20000:
self.vitesse += 0.15
if self.jeu.score == 40000:
self.vitesse += 0.15
if self.jeu.score == 60000:
self.vitesse += 0.15
if self.jeu.score == 100000:
self.vitesse += 0.15
class Cactus2(pygame.sprite.Sprite):
def __init__(self, jeu):
super().__init__()
self.jeu = jeu
self.image = pygame.image.load('assets/cactus.png')
self.image = pygame.transform.scale(self.image, (128, 128))
self.rect = self.image.get_rect()
self.rect.x = 2100
self.rect.y = 500
self.vitesse = 9
def mouvement(self):
if self.jeu.collisions(self, self.jeu.genererJoueur):
self.jeu.gameOver()
self.rect.x -= self.vitesse
if self.rect.x <= -200:
self.rect.x = 760
if self.jeu.nbreCactus == 1:
self.image = pygame.image.load('assets/Cache.png')
self.image = pygame.transform.scale(self.image, (128, 128))
else:
self.image = pygame.image.load('assets/cactus.png')
self.image = pygame.transform.scale(self.image, (128, 128))
if self.jeu.score == 5000:
self.vitesse += 0.15
if self.jeu.score == 10000:
self.vitesse += 0.15
if self.jeu.score == 20000:
self.vitesse += 0.15
if self.jeu.score == 40000:
self.vitesse += 0.15
if self.jeu.score == 60000:
self.vitesse += 0.15
if self.jeu.score == 100000:
self.vitesse += 0.15
class Cactus3(pygame.sprite.Sprite):
def __init__(self, jeu):
super().__init__()
self.jeu = jeu
self.image = pygame.image.load('assets/cactus.png')
self.image = pygame.transform.scale(self.image, (128, 128))
self.rect = self.image.get_rect()
self.rect.x = 2200
self.rect.y = 500
self.vitesse = 9
def mouvement(self):
if self.jeu.collisions(self, self.jeu.genererJoueur):
self.jeu.gameOver()
self.rect.x -= self.vitesse
if self.rect.x <= -200:
self.rect.x = 760
if self.jeu.nbreCactus < 3:
self.image = pygame.image.load('assets/Cache.png')
self.image = pygame.transform.scale(self.image, (128, 128))
else:
self.image = pygame.image.load('assets/cactus.png')
self.image = pygame.transform.scale(self.image, (128, 128))
if self.jeu.score == 5000:
self.vitesse += 0.15
if self.jeu.score == 10000:
self.vitesse += 0.15
if self.jeu.score == 20000:
self.vitesse += 0.15
if self.jeu.score == 40000:
self.vitesse += 0.15
if self.jeu.score == 60000:
self.vitesse += 0.15
if self.jeu.score == 100000:
self.vitesse += 0.15