-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathweapon.py
23 lines (18 loc) · 844 Bytes
/
weapon.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import pygame
class Weapon(pygame.sprite.Sprite):
def __init__(self,player,groups):
super().__init__(groups)
self.sprite_type = 'weapon'
direction = player.status.split('_')[0]
# graphic
self.image = pygame.Surface((50, 50)) # Create an empty surface
self.image.set_alpha(0) # Make it fully transparent
# placement
if direction == 'right':
self.rect = self.image.get_rect(midleft = player.rect.midright )
elif direction == 'left':
self.rect = self.image.get_rect(midright = player.rect.midleft )
elif direction == 'down':
self.rect = self.image.get_rect(midtop = player.rect.midbottom )
else:
self.rect = self.image.get_rect(midbottom = player.rect.midtop )