-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.py
More file actions
156 lines (121 loc) · 3.58 KB
/
config.py
File metadata and controls
156 lines (121 loc) · 3.58 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
from dataclasses import dataclass
import numpy as np
@dataclass(frozen=True)
class WindowConfig:
width: int = 1200
height: int = 700
@dataclass(frozen=True)
class GameConfig:
fps: int = 60
@dataclass(frozen=True)
class Color:
black: tuple[int, int, int] = (0, 0, 0)
red: tuple[int, int, int] = (255, 0, 0)
green: tuple[int, int, int] = (0, 255, 0)
blue: tuple[int, int, int] = (0, 0, 255)
orange: tuple[int, int, int] = (255, 127, 0)
yellow: tuple[int, int, int] = (255, 255, 0)
light_blue: tuple[int, int, int] = (30, 144, 255)
white: tuple[int, int, int] = (255, 255, 255)
light_gray: tuple[int, int, int] = (150, 150, 150)
@dataclass(frozen=True)
class MapConfig:
bg_color: tuple[int, int, int] = Color().black
width = 1600
height = 900
@dataclass(frozen=True)
class DefaultEntityConfig:
color: tuple[int, int, int] = Color().light_gray
width: int = 20
height: int = 20
start_x: int = 20
start_y: int = 20
health: int = 100
@dataclass(frozen=True)
class PlayerConfig:
color: tuple[int, int, int] = Color().blue
width: int = 40
height: int = 40
speed: int = 5
initial_jump_velocity: int = -20
health: int = 100
@property
def radius(self) -> float:
return np.sqrt(self.width**2 + self.height**2) / 2
@property
def start_x(self) -> float:
return (WindowConfig().width - self.width) / 2
@property
def start_y(self) -> float:
return (WindowConfig().height - self.height) / 2
@dataclass(frozen=True)
class BotConfig:
color: tuple[int, int, int] = Color().red
width: int = 10
height: int = 10
speed: float = PlayerConfig().speed * 0.6
health: int = 100
spawn_range: int = 200 # R - r for ring
@property
def radius(self) -> float:
return np.sqrt(self.width**2 + self.height**2) / 2
@property
def min_spawn_radius(self) -> float: # r for ring
return PlayerConfig().radius + self.radius + self.radius
@property
def max_spawn_radius(self) -> float: # R for ring
return self.min_spawn_radius + self.spawn_range
@dataclass(frozen=True)
class SprinterBotConfig(BotConfig):
color: tuple[int, int, int] = Color().orange
width: int = 5
height: int = 5
speed: float = 0.95 * PlayerConfig().speed
time_to_max_speed: int = 3
@dataclass(frozen=True)
class BulletConfig:
color: tuple[int, int, int] = Color().yellow
radius: int = 5
width: int = 10
height: int = 10
speed: int = 15
damage: int = 10
@dataclass(frozen=True)
class PhysicsConfig:
gravity: float = 1
@dataclass(frozen=True)
class HealthBarConfig:
height: int = 5
width: int = 80
y_offset: int = 20
font = None
font_size: int = 20
@dataclass(frozen=True)
class ObstacleConfig:
color: tuple[int, int, int] = Color().green
@dataclass(frozen=True)
class WeaponConfig:
@dataclass(frozen=True)
class Gun:
bullets_per_shot: int = 1
reload_time: int = 30
magazine_capacity: int = 10
spread_angle: float = 0
offset: int = 0
time_between_shots: int = 20
@dataclass(frozen=True)
class Shotgun:
bullets_per_shot: int = 5
reload_time: int = 120
magazine_capacity: int = 10
spread_angle: float = 0.3
offset: int = 5
time_between_shots: int = 20
@dataclass(frozen=True)
class Auto:
bullets_per_shot: int = 1
reload_time: int = 60
magazine_capacity: int = 25
spread_angle: float = 0.1
offset: int = 0
time_between_shots: int = 5