-
Notifications
You must be signed in to change notification settings - Fork 0
/
player_attacks.py
46 lines (40 loc) · 1.41 KB
/
player_attacks.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
import pygame
from pygame.locals import *
import sprite
############################
# This is currently broken #
# ------------------------ #
# Also, I've decided that #
# making a pacifist Touhou #
# game is more interesting #
# to me in the first place #
############################
def BeamAttack(x, y, p_attacks, sprites):
new_beam = PlayerBeam(x, y)
sprites.add(new_beam)
p_attacks.add(new_beam)
return new_beam
class PlayerBeam(sprite.Sprite):
def __init__(self, spawn_x, spawn_y):
super().__init__("res/img/beam1.png", spawn_x, spawn_y)
self.mask = pygame.mask.from_surface(pygame.image.load("res/img/beam3.png"))
self.rect = self.image.get_rect()
self.doing_damage = False
self.cancel = False
self.frame_timer = 0
self.anim = 0
def update(self):
self.frame_timer += 1
if self.frame_timer % 10 == 0 and self.anim < 3:
self.anim += 1
self.image = pygame.image.load(f"res/img/beam{self.anim}.png")
if self.anim == 3:
self.doing_damage = True
else:
self.doing_damage = False
if self.cancel:
if self.frame_timer % 10 == 0 and self.anim > 0:
self.anim -= 1
self.image = pygame.image.load(f"res/img/beam{self.anim}.png")
if self.anim == 0:
self.kill()