-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitem.py
93 lines (80 loc) · 2.89 KB
/
item.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
import random
from animation import Animation
from engine import StraightTrajectoryProvider, TrajectorySprite
from surface_factory import SurfaceFactory, crop, trim
class Item(TrajectorySprite):
def __init__(
self, animation: Animation, angle_offset: float, trajectory_provider, *groups
):
super().__init__(animation, angle_offset, trajectory_provider, *groups)
class PowerCapsule(Item):
def __init__(
self,
factory: SurfaceFactory,
initial_pos: tuple[int, int],
angle: float,
*groups,
):
animation = Animation.static(trim(factory.surfaces["items"][0]))
rotation_speed = random.choice([360, -360])
trajectory_provider = StraightTrajectoryProvider(
initial_pos, None, angle, 40.0, rotation_speed
)
super().__init__(animation, 0.0, trajectory_provider, *groups)
self.power = 50.0
class IceCream(Item):
def __init__(
self,
factory: SurfaceFactory,
initial_pos: tuple[int, int],
angle: float,
*groups,
):
animation = Animation.static(crop(factory.surfaces["items"][1], 2, 2, 12, 14))
rotation_speed = random.choice([360, -360])
trajectory_provider = StraightTrajectoryProvider(
initial_pos, None, angle, 40.0, rotation_speed
)
super().__init__(animation, 0.0, trajectory_provider, *groups)
class FlakCannon(Item):
def __init__(
self,
factory: SurfaceFactory,
initial_pos: tuple[int, int],
angle: float,
*groups,
):
animation = Animation.static(factory.surfaces["guns"][0])
rotation_speed = random.choice([360, -360])
trajectory_provider = StraightTrajectoryProvider(
initial_pos, None, angle, speed=40.0, angular_speed=rotation_speed
)
super().__init__(animation, 0.0, trajectory_provider, *groups)
class Minigun(Item):
def __init__(
self,
factory: SurfaceFactory,
initial_pos: tuple[int, int],
angle: float,
*groups,
):
animation = Animation.static(factory.surfaces["guns"][1])
rotation_speed = random.choice([360, -360])
trajectory_provider = StraightTrajectoryProvider(
initial_pos, None, angle, speed=40.0, angular_speed=rotation_speed
)
super().__init__(animation, 0.0, trajectory_provider, *groups)
class TurboLaser(Item):
def __init__(
self,
factory: SurfaceFactory,
initial_pos: tuple[int, int],
angle: float,
*groups,
):
animation = Animation.static(factory.surfaces["guns"][2])
rotation_speed = random.choice([360, -360])
trajectory_provider = StraightTrajectoryProvider(
initial_pos, None, angle, speed=40.0, angular_speed=rotation_speed
)
super().__init__(animation, 0.0, trajectory_provider, *groups)