ed-game-legacy 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 qq-name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,29 @@
1
+ Metadata-Version: 2.2
2
+ Name: ed-game-legacy
3
+ Version: 1.0.0
4
+ Summary: Earth Defense Game - Legacy version for legacy Python.
5
+ Author-email: qq-name <52765856@qq.com>
6
+ License: MIT
7
+ Requires-Python: <3.11,>=3.9
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: pygame-ce==2.5.6
11
+
12
+ # ed-game-legacy
13
+
14
+ **WARNING: This is a FROZEN legacy version for legacy Python. It will not receive any new features or bug fixes.**
15
+
16
+ If you are using Python 3.11 or higher, please install the main package instead:
17
+
18
+ ```bash
19
+ pip install ed-game
20
+ ```
21
+ Installation (For Python 3.9 and 3.10 only)
22
+ ```bash
23
+ pip install ed-game-legacy
24
+ ```
25
+ Usage
26
+ ```python
27
+ import ed_game_legacy
28
+ ed_game_legacy.run()
29
+ ```
@@ -0,0 +1,18 @@
1
+ # ed-game-legacy
2
+
3
+ **WARNING: This is a FROZEN legacy version for legacy Python. It will not receive any new features or bug fixes.**
4
+
5
+ If you are using Python 3.11 or higher, please install the main package instead:
6
+
7
+ ```bash
8
+ pip install ed-game
9
+ ```
10
+ Installation (For Python 3.9 and 3.10 only)
11
+ ```bash
12
+ pip install ed-game-legacy
13
+ ```
14
+ Usage
15
+ ```python
16
+ import ed_game_legacy
17
+ ed_game_legacy.run()
18
+ ```
@@ -0,0 +1,19 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0.0,<76.0.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "ed-game-legacy"
7
+ version = "1.0.0"
8
+ description = "Earth Defense Game - Legacy version for legacy Python. "
9
+ readme = "README.md"
10
+ requires-python = ">=3.9, <3.11"
11
+ dependencies = ["pygame-ce==2.5.6"]
12
+ authors = [{name = "qq-name", email = "52765856@qq.com"}]
13
+ license = {text = "MIT"}
14
+
15
+ [tool.setuptools.packages.find]
16
+ where = ["src"]
17
+
18
+ [tool.setuptools.package-data]
19
+ ed_game_legacy = ["*.ttf"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,11 @@
1
+ """ed-game-legacy package"""
2
+
3
+ from .game import StarGuardian
4
+
5
+ def run(speed_multiplier=1.0):
6
+ """Start the game"""
7
+ game = StarGuardian(speed_multiplier=speed_multiplier)
8
+ game.run()
9
+
10
+ __version__ = "1.0.0"
11
+ __all__ = ["run"]
@@ -0,0 +1,571 @@
1
+ import pygame
2
+ import random
3
+ import math
4
+ import sys
5
+
6
+ # ============================================================
7
+ # Configuration
8
+ # ============================================================
9
+ WIDTH = 1800
10
+ HEIGHT = 1050
11
+ FPS = 60
12
+
13
+ COLORS = {
14
+ 'bg': (2, 6, 23),
15
+ 'enemy': (255, 58, 111),
16
+ 'enemy_elite': (255, 136, 68),
17
+ 'enemy_boss': (180, 50, 255),
18
+ 'bullet': (255, 255, 128),
19
+ 'bullet_core': (255, 204, 68),
20
+ 'player_main': (62, 255, 250),
21
+ 'player_core': (0, 204, 255),
22
+ 'player_fire': (255, 102, 0),
23
+ 'score': (0, 255, 255),
24
+ 'lives': (255, 51, 102),
25
+ 'status': (255, 215, 0),
26
+ 'gameover': (255, 68, 102),
27
+ 'white': (255, 255, 255),
28
+ 'gold': (255, 215, 0),
29
+ 'heart': (255, 80, 120),
30
+ }
31
+
32
+ # Speed parameters
33
+ BASE_ENEMY_SPEED = 0.31
34
+ MAX_ENEMY_SPEED = 0.65
35
+ ELITE_SPEED_FACTOR = 0.84
36
+ BOSS_SPEED_FACTOR = 0.2
37
+ BULLET_SPEED = -7.2
38
+ PLAYER_SPEED = 6.2
39
+ PLAYER_RADIUS = 15
40
+ INVINCIBLE_DURATION = 55
41
+ SHOOT_COOLDOWN_FRAMES = 9
42
+ BASE_SPAWN_DELAY = 48
43
+ STAR_COUNT = 220
44
+ BOSS_SIZE_MULTIPLIER = 4
45
+ BOSS_SPAWN_INTERVAL = 20 * 1000
46
+
47
+
48
+ # ============================================================
49
+ # Game Class - Pure Python Version (Cross-platform)
50
+ # ============================================================
51
+ class StarGuardian:
52
+ def __init__(self, speed_multiplier=1.0):
53
+ pygame.init()
54
+ self.speed_multiplier = max(0.1, min(5.0, speed_multiplier))
55
+ self.screen = pygame.display.set_mode((WIDTH, HEIGHT))
56
+ pygame.display.set_caption("Star Guardian · Ultra Slow Drift")
57
+ self.clock = pygame.time.Clock()
58
+
59
+ # Load fonts
60
+ self._load_fonts()
61
+
62
+ # Game state
63
+ self.reset_game()
64
+
65
+ # Star background
66
+ self.stars = self._init_stars()
67
+
68
+ def _load_fonts(self):
69
+ try:
70
+ self.font_large = pygame.font.Font("C:/Windows/Fonts/simhei.ttf", 48)
71
+ self.font_medium = pygame.font.Font("C:/Windows/Fonts/simhei.ttf", 28)
72
+ self.font_small = pygame.font.Font("C:/Windows/Fonts/simhei.ttf", 20)
73
+ self.font_tiny = pygame.font.Font("C:/Windows/Fonts/simhei.ttf", 14)
74
+ except:
75
+ self.font_large = pygame.font.SysFont("simhei", 48)
76
+ self.font_medium = pygame.font.SysFont("simhei", 28)
77
+ self.font_small = pygame.font.SysFont("simhei", 20)
78
+ self.font_tiny = pygame.font.SysFont("simhei", 14)
79
+
80
+ def _init_stars(self):
81
+ stars = []
82
+ for _ in range(STAR_COUNT):
83
+ stars.append({
84
+ 'x': random.randint(0, WIDTH),
85
+ 'y': random.randint(0, HEIGHT),
86
+ 'radius': random.uniform(1, 3.2),
87
+ 'speed': random.uniform(0.2, 0.6),
88
+ 'color': (255, 240, 200),
89
+ })
90
+ return stars
91
+
92
+ def reset_game(self):
93
+ self.game_active = True
94
+ self.score = 0
95
+ self.lives = 3
96
+ self.invincible = 0
97
+ self.wave_level = 1
98
+ self.enemy_speed_current = BASE_ENEMY_SPEED * self.speed_multiplier
99
+ self.spawn_delay_current = BASE_SPAWN_DELAY
100
+
101
+ self.player_x = WIDTH // 2
102
+ self.player_y = HEIGHT - 60
103
+ self.left_pressed = False
104
+ self.right_pressed = False
105
+ self.shoot_pressed = False
106
+ self.shoot_cooldown = 0
107
+
108
+ self.bullets = []
109
+ self.enemies = []
110
+ self.powerups = []
111
+ self.explosions = []
112
+ self.particles = []
113
+
114
+ self.status_message = "Slow Mode | Enemies move ~5 mm/sec"
115
+ self.status_msg_timer = 0
116
+ self.enemy_spawn_timer = 20
117
+ self.last_boss_spawn_time = pygame.time.get_ticks()
118
+ self.boss_spawn_timer = 0
119
+
120
+ for _ in range(3):
121
+ self.spawn_enemy()
122
+
123
+ # ===== Drawing Utilities =====
124
+ def draw_text(self, text, x, y, color, center=False, font=None):
125
+ if font is None:
126
+ font = self.font_medium
127
+ surface = font.render(text, True, color)
128
+ rect = surface.get_rect()
129
+ if center:
130
+ rect.center = (x, y)
131
+ else:
132
+ rect.topleft = (x, y)
133
+ self.screen.blit(surface, rect)
134
+
135
+ def draw_circle(self, x, y, radius, color, width=0):
136
+ pygame.draw.circle(self.screen, color, (int(x), int(y)), int(radius), width)
137
+
138
+ def draw_star(self, cx, cy, size):
139
+ points = []
140
+ outer_r = size
141
+ inner_r = size * 0.4
142
+ for i in range(5):
143
+ angle = math.radians(90 - i * 72)
144
+ points.append((cx + outer_r * math.cos(angle), cy - outer_r * math.sin(angle)))
145
+ angle = math.radians(90 - (i + 0.5) * 72)
146
+ points.append((cx + inner_r * math.cos(angle), cy - inner_r * math.sin(angle)))
147
+ pygame.draw.polygon(self.screen, COLORS['gold'], points)
148
+
149
+ def draw_heart(self, cx, cy, size):
150
+ points = []
151
+ scale = size / 15
152
+ for t in range(0, 360, 10):
153
+ rad = math.radians(t)
154
+ x = 16 * math.sin(rad) ** 3
155
+ y = 13 * math.cos(rad) - 5 * math.cos(2*rad) - 2 * math.cos(3*rad) - math.cos(4*rad)
156
+ points.append((cx + x * scale, cy - y * scale))
157
+ if len(points) > 2:
158
+ pygame.draw.polygon(self.screen, COLORS['heart'], points)
159
+
160
+ def draw_crown(self, cx, cy, size):
161
+ points = [
162
+ (cx - size, cy + size),
163
+ (cx - size*0.5, cy - size),
164
+ (cx, cy - size*0.5),
165
+ (cx + size*0.5, cy - size),
166
+ (cx + size, cy + size),
167
+ (cx + size*0.6, cy + size*0.3),
168
+ (cx, cy),
169
+ (cx - size*0.6, cy + size*0.3),
170
+ ]
171
+ pygame.draw.polygon(self.screen, COLORS['gold'], points)
172
+
173
+ # ===== Spawning Logic =====
174
+ def spawn_enemy(self, is_boss=False):
175
+ if is_boss:
176
+ radius = 12 * BOSS_SIZE_MULTIPLIER
177
+ x = random.randint(radius, WIDTH - radius)
178
+ speed = self.enemy_speed_current * BOSS_SPEED_FACTOR
179
+ hp = 50
180
+ score_val = 200
181
+ color = COLORS['enemy_boss']
182
+
183
+ self.enemies.append({
184
+ 'x': x, 'y': -radius,
185
+ 'radius': radius,
186
+ 'speed_y': speed,
187
+ 'color': color,
188
+ 'hp': hp,
189
+ 'max_hp': hp,
190
+ 'score_value': score_val,
191
+ 'elite': False,
192
+ 'is_boss': True
193
+ })
194
+ self.status_message = "⚠️ Giant Overlord Descends! ⚠️"
195
+ self.status_msg_timer = 90
196
+ else:
197
+ radius = 12
198
+ x = random.randint(radius, WIDTH - radius)
199
+ speed = self.enemy_speed_current
200
+ hp = 1
201
+ score_val = 10
202
+ is_elite = (self.wave_level >= 2 and random.random() < 0.12)
203
+ color = COLORS['enemy_elite'] if is_elite else COLORS['enemy']
204
+
205
+ if is_elite:
206
+ radius = 16
207
+ hp = 2
208
+ score_val = 30
209
+ speed *= ELITE_SPEED_FACTOR
210
+ if speed < 0.22:
211
+ speed = 0.22
212
+
213
+ self.enemies.append({
214
+ 'x': x, 'y': -radius,
215
+ 'radius': radius,
216
+ 'speed_y': speed,
217
+ 'color': color,
218
+ 'hp': hp,
219
+ 'max_hp': hp,
220
+ 'score_value': score_val,
221
+ 'elite': is_elite,
222
+ 'is_boss': False
223
+ })
224
+
225
+ def spawn_powerup(self, x, y, is_boss=False):
226
+ if is_boss:
227
+ for _ in range(3):
228
+ if random.random() < 0.8:
229
+ self.powerups.append({
230
+ 'x': x + random.randint(-20, 20),
231
+ 'y': y,
232
+ 'radius': 9,
233
+ 'type': 'heart',
234
+ 'speed_y': 1.2
235
+ })
236
+ else:
237
+ if random.random() < 0.12:
238
+ self.powerups.append({
239
+ 'x': x, 'y': y,
240
+ 'radius': 9,
241
+ 'type': 'heart',
242
+ 'speed_y': 1.2
243
+ })
244
+
245
+ def add_explosion(self, px, py, is_boss=False):
246
+ self.explosions.append({
247
+ 'x': px, 'y': py,
248
+ 'life': 6 if not is_boss else 20,
249
+ 'max_life': 6 if not is_boss else 20,
250
+ 'radius': 12 if not is_boss else 30
251
+ })
252
+ count = 8 if not is_boss else 30
253
+ for _ in range(count):
254
+ self.particles.append({
255
+ 'x': px, 'y': py,
256
+ 'vx': (random.random() - 0.5) * 3.5,
257
+ 'vy': (random.random() - 0.5) * 3 - 1,
258
+ 'life': 6 if not is_boss else 20,
259
+ 'size': random.random() * 3 + 1.5,
260
+ 'color': (random.randint(200, 255), random.randint(100, 180), random.randint(50, 150))
261
+ })
262
+
263
+ # ===== Update Logic =====
264
+ def update_difficulty(self):
265
+ raw_wave = 1 + self.score // 550
266
+ raw_wave = min(raw_wave, 9)
267
+ if raw_wave > self.wave_level:
268
+ self.wave_level = raw_wave
269
+ new_speed = (BASE_ENEMY_SPEED + (self.wave_level - 1) * 0.035) * self.speed_multiplier
270
+ if new_speed > MAX_ENEMY_SPEED * self.speed_multiplier:
271
+ new_speed = MAX_ENEMY_SPEED * self.speed_multiplier
272
+ self.enemy_speed_current = new_speed
273
+ self.spawn_delay_current = max(32, 52 - int(self.wave_level * 1.5))
274
+ speed_mm = self.enemy_speed_current * 60 * 0.2646 / self.speed_multiplier
275
+ self.status_message = f"Intensity Lv.{self.wave_level} | Speed ≈ {speed_mm:.1f} mm/sec"
276
+ self.status_msg_timer = 120
277
+
278
+ def shoot_bullet(self):
279
+ if not self.game_active:
280
+ return
281
+ self.bullets.append({
282
+ 'x': self.player_x, 'y': self.player_y - 12,
283
+ 'radius': 5,
284
+ 'speed_y': BULLET_SPEED,
285
+ 'damage': 1
286
+ })
287
+ if self.score >= 600 and random.random() < 0.45:
288
+ self.bullets.append({
289
+ 'x': self.player_x - 7, 'y': self.player_y - 8,
290
+ 'radius': 4.2, 'speed_y': BULLET_SPEED, 'damage': 1
291
+ })
292
+ self.bullets.append({
293
+ 'x': self.player_x + 7, 'y': self.player_y - 8,
294
+ 'radius': 4.2, 'speed_y': BULLET_SPEED, 'damage': 1
295
+ })
296
+ self.shoot_cooldown = SHOOT_COOLDOWN_FRAMES
297
+
298
+ def update(self):
299
+ if not self.game_active:
300
+ return
301
+
302
+ if self.invincible > 0:
303
+ self.invincible -= 1
304
+ if self.shoot_cooldown > 0:
305
+ self.shoot_cooldown -= 1
306
+
307
+ # Player movement
308
+ if self.left_pressed:
309
+ self.player_x -= PLAYER_SPEED
310
+ if self.right_pressed:
311
+ self.player_x += PLAYER_SPEED
312
+ self.player_x = max(PLAYER_RADIUS + 5, min(WIDTH - PLAYER_RADIUS - 5, self.player_x))
313
+
314
+ if self.shoot_pressed and self.shoot_cooldown == 0:
315
+ self.shoot_bullet()
316
+
317
+ # Boss spawn timer
318
+ current_time = pygame.time.get_ticks()
319
+ if self.game_active and current_time - self.last_boss_spawn_time >= BOSS_SPAWN_INTERVAL:
320
+ self.spawn_enemy(is_boss=True)
321
+ self.last_boss_spawn_time = current_time
322
+ self.status_message = "👑 Giant Overlord Arrives! 100x HP, Ultra Slow! 👑"
323
+ self.status_msg_timer = 120
324
+
325
+ # Bullets update
326
+ for b in self.bullets[:]:
327
+ b['y'] += b['speed_y']
328
+ if b['y'] + b['radius'] < 0 or b['y'] - b['radius'] > HEIGHT:
329
+ self.bullets.remove(b)
330
+
331
+ # Enemies update (✅ 只删除,不扣血)
332
+ for e in self.enemies[:]:
333
+ e['y'] += e['speed_y']
334
+ if e['y'] + e['radius'] > HEIGHT + 40:
335
+ self.enemies.remove(e)
336
+
337
+ # Bullet-Enemy collisions
338
+ for b in self.bullets[:]:
339
+ hit = None
340
+ for e in self.enemies:
341
+ if math.hypot(b['x'] - e['x'], b['y'] - e['y']) < b['radius'] + e['radius']:
342
+ hit = e
343
+ break
344
+ if hit:
345
+ self.bullets.remove(b)
346
+ hit['hp'] -= b['damage']
347
+ if hit['hp'] <= 0:
348
+ self.score += hit['score_value']
349
+ self.update_difficulty()
350
+ self.add_explosion(hit['x'], hit['y'], is_boss=hit['is_boss'])
351
+ self.spawn_powerup(hit['x'], hit['y'], is_boss=hit['is_boss'])
352
+ self.enemies.remove(hit)
353
+ else:
354
+ count = 4 if not hit['is_boss'] else 12
355
+ for _ in range(count):
356
+ self.particles.append({
357
+ 'x': hit['x'], 'y': hit['y'],
358
+ 'vx': (random.random() - 0.5) * 2.5,
359
+ 'vy': (random.random() - 0.5) * 2.5,
360
+ 'life': 8,
361
+ 'size': 2 if not hit['is_boss'] else 4,
362
+ 'color': (255, 170, 51)
363
+ })
364
+
365
+ # Player-Enemy collisions
366
+ for e in self.enemies[:]:
367
+ if math.hypot(self.player_x - e['x'], self.player_y - e['y']) < PLAYER_RADIUS + e['radius']:
368
+ if self.invincible <= 0 and self.game_active:
369
+ self.lives -= 1
370
+ if self.lives <= 0:
371
+ self.lives = 0
372
+ self.game_active = False
373
+ self.status_message = "Slow Defeat | Press R to Restart"
374
+ self.add_explosion(self.player_x, self.player_y)
375
+ return
376
+ else:
377
+ self.invincible = INVINCIBLE_DURATION
378
+ self.add_explosion(self.player_x, self.player_y - 6)
379
+ self.status_message = "Collision Damage! Brief Invincibility"
380
+ self.status_msg_timer = 60
381
+ self.add_explosion(e['x'], e['y'])
382
+ self.enemies.remove(e)
383
+
384
+ # Powerups
385
+ for p in self.powerups[:]:
386
+ p['y'] += p['speed_y']
387
+
388
+ # Auto-collect at bottom
389
+ if p['y'] + p['radius'] > HEIGHT + 30:
390
+ if p['type'] == 'heart':
391
+ if self.lives < 5:
392
+ self.lives += 1
393
+ self.status_message = "Auto Collect +1 Life"
394
+ else:
395
+ self.score += 25
396
+ self.status_message = "Auto Collect +25 Points"
397
+ self.status_msg_timer = 60
398
+ self.add_explosion(p['x'], p['y'])
399
+ self.powerups.remove(p)
400
+ continue
401
+
402
+ # Player pickup
403
+ if math.hypot(self.player_x - p['x'], self.player_y - p['y']) < PLAYER_RADIUS + p['radius']:
404
+ if p['type'] == 'heart':
405
+ if self.lives < 5:
406
+ self.lives += 1
407
+ self.status_message = "Repair Core +1 Life"
408
+ else:
409
+ self.score += 25
410
+ self.status_message = "Energy Full +25 Points"
411
+ self.status_msg_timer = 60
412
+ self.add_explosion(p['x'], p['y'])
413
+ self.powerups.remove(p)
414
+
415
+ # Enemy spawning
416
+ if self.enemy_spawn_timer <= 0:
417
+ count = 2 if (self.wave_level >= 4 and random.random() < 0.3) else 1
418
+ for _ in range(count):
419
+ self.spawn_enemy()
420
+ self.enemy_spawn_timer = max(34, self.spawn_delay_current - int(self.wave_level * 1.2))
421
+ else:
422
+ self.enemy_spawn_timer -= 1
423
+
424
+ if self.wave_level >= 2 and random.random() < 0.008 and len(self.enemies) < 20:
425
+ self.spawn_enemy()
426
+
427
+ # Particles / Explosions
428
+ for p in self.particles[:]:
429
+ p['x'] += p['vx']
430
+ p['y'] += p['vy']
431
+ p['life'] -= 1
432
+ if p['life'] <= 0:
433
+ self.particles.remove(p)
434
+
435
+ for ex in self.explosions[:]:
436
+ ex['life'] -= 1
437
+ if ex['life'] <= 0:
438
+ self.explosions.remove(ex)
439
+
440
+ if self.status_msg_timer > 0:
441
+ self.status_msg_timer -= 1
442
+ if self.status_msg_timer == 0 and self.game_active:
443
+ self.status_message = "Slow Galaxy · Casual Shooting"
444
+
445
+ if self.lives <= 0:
446
+ self.game_active = False
447
+ self.status_message = "Slow World Ends | Press R to Continue"
448
+
449
+ # ===== Draw Logic =====
450
+ def draw(self):
451
+ self.screen.fill(COLORS['bg'])
452
+
453
+ # Stars
454
+ for s in self.stars:
455
+ s['y'] += s['speed'] * 0.3
456
+ if s['y'] > HEIGHT:
457
+ s['y'] = 0
458
+ self.draw_circle(s['x'], s['y'], s['radius'], s['color'])
459
+
460
+ # Enemies
461
+ for e in self.enemies:
462
+ self.draw_circle(e['x'], e['y'], e['radius'] - 1, e['color'])
463
+ self.draw_circle(e['x'], e['y'], e['radius'] - 4, (170, 34, 34))
464
+
465
+ if e['is_boss']:
466
+ self.draw_crown(e['x'], e['y'] - e['radius'] // 2, 12)
467
+ bar_width = 80 * (e['hp'] / e['max_hp'])
468
+ pygame.draw.rect(self.screen, (255, 50, 50), (e['x'] - 40, e['y'] - e['radius'] - 8, 80, 6))
469
+ pygame.draw.rect(self.screen, (0, 255, 0), (e['x'] - 40, e['y'] - e['radius'] - 8, int(bar_width), 6))
470
+ elif e['elite']:
471
+ self.draw_star(e['x'], e['y'] - 8, 8)
472
+ if e['hp'] > 1:
473
+ bar_width = 20 * (e['hp'] / 2)
474
+ pygame.draw.rect(self.screen, (255, 170, 85), (e['x'] - 10, e['y'] - e['radius'] - 4, int(bar_width), 4))
475
+
476
+ # Powerups
477
+ for p in self.powerups:
478
+ self.draw_circle(p['x'], p['y'], p['radius'] - 2, (255, 94, 126))
479
+ self.draw_heart(p['x'], p['y'] + 2, 10)
480
+
481
+ # Bullets
482
+ for b in self.bullets:
483
+ self.draw_circle(b['x'], b['y'], b['radius'] - 1, COLORS['bullet'])
484
+ self.draw_circle(b['x'], b['y'], b['radius'] - 2, COLORS['bullet_core'])
485
+
486
+ # Player (✅ 删除了闪烁逻辑,常驻显示)
487
+ self.draw_circle(self.player_x, self.player_y, 16, COLORS['player_main'])
488
+ self.draw_circle(self.player_x, self.player_y - 4, 6, COLORS['player_core'])
489
+ self.draw_circle(self.player_x - 3, self.player_y - 6, 2, COLORS['white'])
490
+ self.draw_circle(self.player_x + 3, self.player_y - 6, 2, COLORS['white'])
491
+ self.draw_circle(self.player_x, self.player_y + 18, 6, COLORS['player_fire'])
492
+ self.draw_circle(self.player_x - 3, self.player_y + 16, 4, COLORS['player_fire'])
493
+ self.draw_circle(self.player_x + 3, self.player_y + 16, 4, COLORS['player_fire'])
494
+ self.draw_circle(self.player_x, self.player_y, 19, (0, 255, 255, 100), width=1)
495
+
496
+ # Explosions
497
+ for ex in self.explosions:
498
+ ratio = ex['life'] / ex['max_life']
499
+ r = ex['radius'] * (0.5 + ratio * 0.5)
500
+ self.draw_circle(ex['x'], ex['y'], r, (255, 100, 30))
501
+ self.draw_circle(ex['x'], ex['y'], r * 0.6, (255, 200, 50))
502
+
503
+ for p in self.particles:
504
+ self.draw_circle(p['x'], p['y'], p['size'], p['color'])
505
+
506
+ # UI
507
+ self.draw_text(f"Score: {self.score}", 30, 20, COLORS['score'], font=self.font_medium)
508
+ self.draw_text(f"Lives: {self.lives}", WIDTH - 220, 20, COLORS['lives'], font=self.font_medium)
509
+ self.draw_text(f"Intensity: {min(10, self.wave_level)}", WIDTH // 2 - 50, 20, COLORS['score'], font=self.font_medium)
510
+ self.draw_text(self.status_message, WIDTH // 2, HEIGHT - 30, COLORS['status'], center=True, font=self.font_small)
511
+
512
+ # Boss timer
513
+ current_time = pygame.time.get_ticks()
514
+ time_since_boss = current_time - self.last_boss_spawn_time
515
+ time_to_next_boss = max(0, BOSS_SPAWN_INTERVAL - time_since_boss) // 1000
516
+ self.draw_text(f"Next Giant Boss: {time_to_next_boss}s", WIDTH // 2, HEIGHT - 55, (200, 200, 100), center=True, font=self.font_tiny)
517
+
518
+ self.draw_text("A/D ←→ | Shoot Space/K/↑ | R Restart", WIDTH // 2, HEIGHT - 10, (127, 140, 141), center=True, font=self.font_tiny)
519
+
520
+ if not self.game_active:
521
+ self.draw_text("GAME OVER", WIDTH // 2, HEIGHT // 2 - 30, COLORS['gameover'], center=True, font=self.font_large)
522
+ self.draw_text("Press [ R ] to Restart", WIDTH // 2, HEIGHT // 2 + 20, (187, 221, 255), center=True, font=self.font_small)
523
+
524
+ pygame.display.flip()
525
+
526
+ # ===== Event Handling =====
527
+ def handle_events(self):
528
+ for event in pygame.event.get():
529
+ if event.type == pygame.QUIT:
530
+ return False
531
+
532
+ elif event.type == pygame.KEYDOWN:
533
+ if event.key == pygame.K_LEFT or event.key == pygame.K_a:
534
+ self.left_pressed = True
535
+ elif event.key == pygame.K_RIGHT or event.key == pygame.K_d:
536
+ self.right_pressed = True
537
+ elif event.key == pygame.K_SPACE or event.key == pygame.K_UP or event.key == pygame.K_k:
538
+ self.shoot_pressed = True
539
+ elif event.key == pygame.K_r:
540
+ self.reset_game()
541
+ elif event.key == pygame.K_ESCAPE:
542
+ return False
543
+
544
+ elif event.type == pygame.KEYUP:
545
+ if event.key == pygame.K_LEFT or event.key == pygame.K_a:
546
+ self.left_pressed = False
547
+ elif event.key == pygame.K_RIGHT or event.key == pygame.K_d:
548
+ self.right_pressed = False
549
+ elif event.key == pygame.K_SPACE or event.key == pygame.K_UP or event.key == pygame.K_k:
550
+ self.shoot_pressed = False
551
+
552
+ return True
553
+
554
+ # ===== Main Loop =====
555
+ def run(self):
556
+ running = True
557
+ while running:
558
+ running = self.handle_events()
559
+ self.update()
560
+ self.draw()
561
+ self.clock.tick(FPS)
562
+ pygame.quit()
563
+ sys.exit()
564
+
565
+
566
+ # ============================================================
567
+ # Entry Point
568
+ # ============================================================
569
+ if __name__ == "__main__":
570
+ game = StarGuardian()
571
+ game.run()
@@ -0,0 +1,29 @@
1
+ Metadata-Version: 2.2
2
+ Name: ed-game-legacy
3
+ Version: 1.0.0
4
+ Summary: Earth Defense Game - Legacy version for legacy Python.
5
+ Author-email: qq-name <52765856@qq.com>
6
+ License: MIT
7
+ Requires-Python: <3.11,>=3.9
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: pygame-ce==2.5.6
11
+
12
+ # ed-game-legacy
13
+
14
+ **WARNING: This is a FROZEN legacy version for legacy Python. It will not receive any new features or bug fixes.**
15
+
16
+ If you are using Python 3.11 or higher, please install the main package instead:
17
+
18
+ ```bash
19
+ pip install ed-game
20
+ ```
21
+ Installation (For Python 3.9 and 3.10 only)
22
+ ```bash
23
+ pip install ed-game-legacy
24
+ ```
25
+ Usage
26
+ ```python
27
+ import ed_game_legacy
28
+ ed_game_legacy.run()
29
+ ```
@@ -0,0 +1,11 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/ed_game_legacy/__init__.py
5
+ src/ed_game_legacy/game.py
6
+ src/ed_game_legacy/simhei.ttf
7
+ src/ed_game_legacy.egg-info/PKG-INFO
8
+ src/ed_game_legacy.egg-info/SOURCES.txt
9
+ src/ed_game_legacy.egg-info/dependency_links.txt
10
+ src/ed_game_legacy.egg-info/requires.txt
11
+ src/ed_game_legacy.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ pygame-ce==2.5.6
@@ -0,0 +1 @@
1
+ ed_game_legacy