-
Notifications
You must be signed in to change notification settings - Fork 0
/
weapons.py
56 lines (41 loc) · 2.21 KB
/
weapons.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
from settings import *
class Weapon(pygame.sprite.Sprite):
def __init__(self, player, index) -> None:
super().__init__()
# images depending on player posititon
# axe images
self.axe_image_up = pygame.image.load('graphics/weapons/axe/up.png').convert_alpha()
self.axe_image_down = pygame.image.load('graphics/weapons/axe/down.png').convert_alpha()
self.axe_image_left = pygame.image.load('graphics/weapons/axe/left.png').convert_alpha()
self.axe_image_right = pygame.image.load('graphics/weapons/axe/right.png').convert_alpha()
# sword images
self.sword_image_up = pygame.image.load('graphics/weapons/sword/up.png').convert_alpha()
self.sword_image_down = pygame.image.load('graphics/weapons/sword/down.png').convert_alpha()
self.sword_image_left = pygame.image.load('graphics/weapons/sword/left.png').convert_alpha()
self.sword_image_right = pygame.image.load('graphics/weapons/sword/right.png').convert_alpha()
if player.up:
if index == 1:
self.image = self.axe_image_up
if index == 2:
self.image = self.sword_image_up
self.rect = self.image.get_rect(midbottom=(player.rect.centerx-10, player.rect.top))
if player.down:
if index == 1:
self.image = self.axe_image_down
if index == 2:
self.image = self.sword_image_down
self.rect = self.image.get_rect(midtop=(player.rect.centerx-10, player.rect.bottom))
if player.left:
if index == 1:
self.image = self.axe_image_left
if index == 2:
self.image = self.sword_image_left
self.rect = self.image.get_rect(midright=(player.rect.left, player.rect.centery+15))
if player.right:
if index == 1:
self.image = self.axe_image_right
if index == 2:
self.image = self.sword_image_right
self.rect = self.image.get_rect(midleft=(player.rect.right, player.rect.centery+15))
# weapon damage
self.weapon_damage = 20