-
Notifications
You must be signed in to change notification settings - Fork 0
/
projectil.py
38 lines (30 loc) · 1.14 KB
/
projectil.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
import pygame
class Projectile(pygame.sprite.Sprite):
def __init__(self, player):
super().__init__()
self.velocity = 5
self.player = player
self.image = pygame.image.load('assets/projectile.png')
self.image = pygame.transform.scale(self.image, (50, 50))
self.rect = self.image.get_rect()
self.rect.x = player.rect.x + 120
self.rect.y = player.rect.y + 80
self.orgin_image = self.image
self.angle = 0
def rotate(self):
self.angle += 5
self.image = pygame.transform.rotozoom(self.orgin_image, self.angle, 1)
self.rect = self.image.get_rect(center = self.rect.center)
def remove(self):
self.player.all_projectiles.remove(self)
def move(self):
self.rect.x += self.velocity
self.rotate()
if self.player.game.check_collision(self, self.player.game.all_monsters):
# supprimer le projectile
self.remove()
if self.rect.x > 1080:
pass
# supprimer le projectile
self.remove()
print("projectil remove")