ed-game 3.1.0__tar.gz → 4.0.0.dev1__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.
- ed_game-4.0.0.dev1/PKG-INFO +68 -0
- ed_game-4.0.0.dev1/README.md +45 -0
- {ed_game-3.1.0 → ed_game-4.0.0.dev1}/edgame_core.cpp +29 -11
- {ed_game-3.1.0 → ed_game-4.0.0.dev1}/pyproject.toml +5 -2
- {ed_game-3.1.0 → ed_game-4.0.0.dev1}/src/ed_game/__init__.py +1 -1
- {ed_game-3.1.0 → ed_game-4.0.0.dev1}/src/ed_game/game_1.py +6 -2
- {ed_game-3.1.0 → ed_game-4.0.0.dev1}/src/ed_game/game_2.py +32 -0
- ed_game-4.0.0.dev1/src/ed_game.egg-info/PKG-INFO +68 -0
- {ed_game-3.1.0 → ed_game-4.0.0.dev1}/src/ed_game.egg-info/SOURCES.txt +3 -2
- {ed_game-3.1.0 → ed_game-4.0.0.dev1}/src/ed_game.egg-info/requires.txt +1 -0
- {ed_game-3.1.0 → ed_game-4.0.0.dev1}/src/ed_game.egg-info/top_level.txt +1 -0
- ed_game-4.0.0.dev1/src/new/__init__.py +1 -0
- ed_game-4.0.0.dev1/src/new/game.py +158 -0
- ed_game-3.1.0/PKG-INFO +0 -51
- ed_game-3.1.0/README.md +0 -29
- ed_game-3.1.0/src/ed_game/edgame_core.dll +0 -0
- ed_game-3.1.0/src/ed_game.egg-info/PKG-INFO +0 -51
- {ed_game-3.1.0 → ed_game-4.0.0.dev1}/LICENSE +0 -0
- {ed_game-3.1.0 → ed_game-4.0.0.dev1}/MANIFEST.in +0 -0
- {ed_game-3.1.0 → ed_game-4.0.0.dev1}/setup.cfg +0 -0
- {ed_game-3.1.0 → ed_game-4.0.0.dev1}/src/ed_game.egg-info/dependency_links.txt +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ed-game
|
|
3
|
+
Version: 4.0.0.dev1
|
|
4
|
+
Summary: Earth Defense Game
|
|
5
|
+
Author-email: qq-name <your@email.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://pypi.org/project/ed-game/
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.16
|
|
13
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
14
|
+
Classifier: Operating System :: MacOS
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Topic :: Games/Entertainment
|
|
17
|
+
Requires-Python: >=3.13
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: pygame-ce>=2.5.3
|
|
21
|
+
Requires-Dist: pyglet>=2.0
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
Installing:
|
|
25
|
+
```bash
|
|
26
|
+
pip install ed-game
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
or:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip3 install ed-game
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Usage:
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
import ed_game
|
|
39
|
+
ed_game.run()
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
ed-game dependencies:
|
|
43
|
+
|
|
44
|
+
setuptools>=77.3.4 (is build)
|
|
45
|
+
|
|
46
|
+
pygame-ce >= 2.5.3 (core of 2.x / 3.x /4.x)
|
|
47
|
+
|
|
48
|
+
pyglet >= 2.0 (core of 4.x New Game)
|
|
49
|
+
|
|
50
|
+
CPython >= 3.13
|
|
51
|
+
|
|
52
|
+
Earth Defense Game - A cross-platform shooter.
|
|
53
|
+
|
|
54
|
+
Windows / 2.x & 3.x: Uses a high-performance C++ extension for precise, ultra-slow enemy movement and fast collision detection.
|
|
55
|
+
|
|
56
|
+
Other platforms / 2.x & 3.x: Runs a 100% Pure Python fallback.
|
|
57
|
+
|
|
58
|
+
4.x New Game: A brand new implementation using the Pyglet library.
|
|
59
|
+
|
|
60
|
+
🆕 What's New in 4.0.0dev1
|
|
61
|
+
New Ed-Game Engine: Added a completely new implementation (ed_game.new) built with the Pyglet library, moving away from Pygame.
|
|
62
|
+
|
|
63
|
+
Early Access: Please note that this is an early dev release. There may be bugs and performance issues before 4.0.0rc1.
|
|
64
|
+
|
|
65
|
+
⚠️ Known Issues
|
|
66
|
+
We have identified runtime visual bugs in ed_game 4.0.0dev1 and ed_game 3.2.0.
|
|
67
|
+
|
|
68
|
+
These issues will be fixed in the upcoming ed_game 4.0.0dev2 and ed_game 3.2.1 (or 3.3.0).
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
Installing:
|
|
2
|
+
```bash
|
|
3
|
+
pip install ed-game
|
|
4
|
+
```
|
|
5
|
+
|
|
6
|
+
or:
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
pip3 install ed-game
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Usage:
|
|
13
|
+
|
|
14
|
+
```python
|
|
15
|
+
import ed_game
|
|
16
|
+
ed_game.run()
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
ed-game dependencies:
|
|
20
|
+
|
|
21
|
+
setuptools>=77.3.4 (is build)
|
|
22
|
+
|
|
23
|
+
pygame-ce >= 2.5.3 (core of 2.x / 3.x /4.x)
|
|
24
|
+
|
|
25
|
+
pyglet >= 2.0 (core of 4.x New Game)
|
|
26
|
+
|
|
27
|
+
CPython >= 3.13
|
|
28
|
+
|
|
29
|
+
Earth Defense Game - A cross-platform shooter.
|
|
30
|
+
|
|
31
|
+
Windows / 2.x & 3.x: Uses a high-performance C++ extension for precise, ultra-slow enemy movement and fast collision detection.
|
|
32
|
+
|
|
33
|
+
Other platforms / 2.x & 3.x: Runs a 100% Pure Python fallback.
|
|
34
|
+
|
|
35
|
+
4.x New Game: A brand new implementation using the Pyglet library.
|
|
36
|
+
|
|
37
|
+
🆕 What's New in 4.0.0dev1
|
|
38
|
+
New Ed-Game Engine: Added a completely new implementation (ed_game.new) built with the Pyglet library, moving away from Pygame.
|
|
39
|
+
|
|
40
|
+
Early Access: Please note that this is an early dev release. There may be bugs and performance issues before 4.0.0rc1.
|
|
41
|
+
|
|
42
|
+
⚠️ Known Issues
|
|
43
|
+
We have identified runtime visual bugs in ed_game 4.0.0dev1 and ed_game 3.2.0.
|
|
44
|
+
|
|
45
|
+
These issues will be fixed in the upcoming ed_game 4.0.0dev2 and ed_game 3.2.1 (or 3.3.0).
|
|
@@ -29,13 +29,6 @@ struct Enemy {
|
|
|
29
29
|
int32_t is_boss;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
struct Powerup {
|
|
33
|
-
float x, y;
|
|
34
|
-
float speed_y;
|
|
35
|
-
int32_t radius;
|
|
36
|
-
int32_t type;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
32
|
struct KillInfo {
|
|
40
33
|
float x, y;
|
|
41
34
|
int32_t score;
|
|
@@ -45,7 +38,9 @@ struct KillInfo {
|
|
|
45
38
|
|
|
46
39
|
static std::vector<Bullet> g_bullets;
|
|
47
40
|
static std::vector<Enemy> g_enemies;
|
|
48
|
-
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
static int32_t g_boss_fire_cooldown = 0;
|
|
49
44
|
|
|
50
45
|
static inline void remove_bullet_internal(int32_t index) {
|
|
51
46
|
if (index >= 0 && index < static_cast<int32_t>(g_bullets.size())) {
|
|
@@ -64,7 +59,18 @@ static inline void remove_enemy_internal(int32_t index) {
|
|
|
64
59
|
EXPORT void update_all() {
|
|
65
60
|
for (auto& b : g_bullets) { b.x += b.speed_x; b.y += b.speed_y; }
|
|
66
61
|
for (auto& e : g_enemies) e.y += e.speed_y;
|
|
67
|
-
|
|
62
|
+
|
|
63
|
+
if (g_boss_fire_cooldown > 0) {
|
|
64
|
+
g_boss_fire_cooldown--;
|
|
65
|
+
} else {
|
|
66
|
+
for (auto& e : g_enemies) {
|
|
67
|
+
if (e.is_boss) {
|
|
68
|
+
g_bullets.push_back({e.x, e.y + e.radius, 0.0f, 5.0f, 8, 1});
|
|
69
|
+
g_boss_fire_cooldown = 60;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
68
74
|
}
|
|
69
75
|
|
|
70
76
|
EXPORT int32_t add_bullet(float x, float y, float speed_x, float speed_y, int32_t radius, int32_t damage) {
|
|
@@ -80,7 +86,7 @@ EXPORT int32_t add_enemy(float x, float y, float speed_y, int32_t radius, int32_
|
|
|
80
86
|
EXPORT void clear_all() {
|
|
81
87
|
g_bullets.clear();
|
|
82
88
|
g_enemies.clear();
|
|
83
|
-
|
|
89
|
+
g_boss_fire_cooldown = 0;
|
|
84
90
|
}
|
|
85
91
|
|
|
86
92
|
EXPORT int32_t get_bullet_count() { return static_cast<int32_t>(g_bullets.size()); }
|
|
@@ -135,13 +141,16 @@ EXPORT int32_t process_bullet_enemy_collision(KillInfo* kills, int32_t max_kills
|
|
|
135
141
|
|
|
136
142
|
for (int32_t i = 0; i < static_cast<int32_t>(g_bullets.size()); ++i) {
|
|
137
143
|
if (bullet_dead[i]) continue;
|
|
144
|
+
|
|
145
|
+
if (g_bullets[i].speed_y > 0) continue;
|
|
146
|
+
|
|
138
147
|
for (int32_t j = 0; j < static_cast<int32_t>(g_enemies.size()); ++j) {
|
|
139
148
|
if (enemy_dead[j]) continue;
|
|
140
149
|
|
|
141
|
-
// Broad-phase filtering
|
|
142
150
|
float dx = g_bullets[i].x - g_enemies[j].x;
|
|
143
151
|
float dy = g_bullets[i].y - g_enemies[j].y;
|
|
144
152
|
float rsum = (float)(g_bullets[i].radius + g_enemies[j].radius);
|
|
153
|
+
|
|
145
154
|
if (dx > rsum || dx < -rsum) continue;
|
|
146
155
|
if (dy > rsum || dy < -rsum) continue;
|
|
147
156
|
|
|
@@ -179,5 +188,14 @@ EXPORT int32_t process_player_enemy_collision(float px, float py, float pr, floa
|
|
|
179
188
|
return 1;
|
|
180
189
|
}
|
|
181
190
|
}
|
|
191
|
+
|
|
192
|
+
for (int32_t i = 0; i < static_cast<int32_t>(g_bullets.size()); ++i) {
|
|
193
|
+
if (g_bullets[i].speed_y > 0 && collide(px, py, pr, g_bullets[i].x, g_bullets[i].y, (float)g_bullets[i].radius)) {
|
|
194
|
+
*out_x = g_bullets[i].x;
|
|
195
|
+
*out_y = g_bullets[i].y;
|
|
196
|
+
remove_bullet_internal(i);
|
|
197
|
+
return 1;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
182
200
|
return 0;
|
|
183
201
|
}
|
|
@@ -4,13 +4,16 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "ed-game"
|
|
7
|
-
version = "
|
|
7
|
+
version = "4.0.0dev1"
|
|
8
8
|
description = "Earth Defense Game"
|
|
9
9
|
authors = [{name = "qq-name", email = "your@email.com"}]
|
|
10
10
|
readme = "README.md"
|
|
11
11
|
requires-python = ">=3.13"
|
|
12
12
|
license = "MIT"
|
|
13
|
-
dependencies = [
|
|
13
|
+
dependencies = [
|
|
14
|
+
"pygame-ce>=2.5.3",
|
|
15
|
+
"pyglet>=2.0"
|
|
16
|
+
]
|
|
14
17
|
|
|
15
18
|
classifiers = [
|
|
16
19
|
"Programming Language :: Python :: 3",
|
|
@@ -327,8 +327,12 @@ class StarGuardian:
|
|
|
327
327
|
arr_b = (CBullet * n_b)()
|
|
328
328
|
lib.get_bullets(arr_b)
|
|
329
329
|
for b in arr_b:
|
|
330
|
-
|
|
331
|
-
|
|
330
|
+
# If speed_y > 0, it's a Boss bullet, draw it red
|
|
331
|
+
if b.speed_y > 0:
|
|
332
|
+
pygame.draw.circle(self.screen, (255, 0, 0), (int(b.x) + shake_x, int(b.y) + shake_y), b.radius)
|
|
333
|
+
pygame.draw.circle(self.screen, (255, 255, 255), (int(b.x) + shake_x, int(b.y) + shake_y), b.radius // 2)
|
|
334
|
+
else:
|
|
335
|
+
self.screen.blit(self.bullet_surface, (int(b.x) - 6 + shake_x, int(b.y) - 6 + shake_y))
|
|
332
336
|
for i, (tx, ty) in enumerate(self.player_trail[:-1]):
|
|
333
337
|
alpha = int(150 * (i / len(self.player_trail)))
|
|
334
338
|
surf = pygame.Surface((40, 40), pygame.SRCALPHA)
|
|
@@ -120,6 +120,7 @@ class StarGuardian:
|
|
|
120
120
|
self.flash_timer = 0
|
|
121
121
|
self.enemies = []
|
|
122
122
|
self.bullets = []
|
|
123
|
+
self.enemy_bullets = []
|
|
123
124
|
self.explosions = []
|
|
124
125
|
self.particles = []
|
|
125
126
|
self.player_trail = []
|
|
@@ -244,6 +245,33 @@ class StarGuardian:
|
|
|
244
245
|
self.invincible = INVINCIBLE_DURATION
|
|
245
246
|
self.add_explosion(self.player_x, self.player_y)
|
|
246
247
|
self.enemies.remove(e)
|
|
248
|
+
# BOSS 开火
|
|
249
|
+
if getattr(self, 'boss_fire_timer', 0) > 0:
|
|
250
|
+
self.boss_fire_timer -= 1
|
|
251
|
+
else:
|
|
252
|
+
for e in self.enemies:
|
|
253
|
+
if e.get('is_boss'):
|
|
254
|
+
self.enemy_bullets.append({'x': e['x'], 'y': e['y'] + e['radius'], 'speed_y': 5.0, 'radius': 8})
|
|
255
|
+
self.boss_fire_timer = 60
|
|
256
|
+
break
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
for eb in self.enemy_bullets[:]:
|
|
260
|
+
eb['y'] += eb['speed_y']
|
|
261
|
+
if eb['y'] > HEIGHT:
|
|
262
|
+
self.enemy_bullets.remove(eb)
|
|
263
|
+
continue
|
|
264
|
+
if math.hypot(self.player_x - eb['x'], self.player_y - eb['y']) < PLAYER_RADIUS + eb['radius']:
|
|
265
|
+
self.enemy_bullets.remove(eb)
|
|
266
|
+
if self.invincible <= 0:
|
|
267
|
+
self.lives -= 1
|
|
268
|
+
self.screen_shake = 15
|
|
269
|
+
if self.lives <= 0:
|
|
270
|
+
self.lives = 0
|
|
271
|
+
self.game_active = False
|
|
272
|
+
return
|
|
273
|
+
else:
|
|
274
|
+
self.invincible = INVINCIBLE_DURATION
|
|
247
275
|
|
|
248
276
|
self.enemy_spawn_timer -= 1
|
|
249
277
|
if self.enemy_spawn_timer <= 0:
|
|
@@ -302,6 +330,10 @@ class StarGuardian:
|
|
|
302
330
|
for b in self.bullets:
|
|
303
331
|
self.screen.blit(self.bullet_surface, (int(b['x']) - 6 + shake_x, int(b['y']) - 6 + shake_y))
|
|
304
332
|
|
|
333
|
+
for eb in self.enemy_bullets:
|
|
334
|
+
pygame.draw.circle(self.screen, (255, 0, 0), (int(eb['x']) + shake_x, int(eb['y']) + shake_y), eb['radius'])
|
|
335
|
+
pygame.draw.circle(self.screen, (255, 255, 255), (int(eb['x']) + shake_x, int(eb['y']) + shake_y), eb['radius'] // 2)
|
|
336
|
+
|
|
305
337
|
for i, (tx, ty) in enumerate(self.player_trail[:-1]):
|
|
306
338
|
alpha = int(150 * (i / len(self.player_trail)))
|
|
307
339
|
surf = pygame.Surface((40, 40), pygame.SRCALPHA)
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ed-game
|
|
3
|
+
Version: 4.0.0.dev1
|
|
4
|
+
Summary: Earth Defense Game
|
|
5
|
+
Author-email: qq-name <your@email.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://pypi.org/project/ed-game/
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.16
|
|
13
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
14
|
+
Classifier: Operating System :: MacOS
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Topic :: Games/Entertainment
|
|
17
|
+
Requires-Python: >=3.13
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: pygame-ce>=2.5.3
|
|
21
|
+
Requires-Dist: pyglet>=2.0
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
Installing:
|
|
25
|
+
```bash
|
|
26
|
+
pip install ed-game
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
or:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip3 install ed-game
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Usage:
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
import ed_game
|
|
39
|
+
ed_game.run()
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
ed-game dependencies:
|
|
43
|
+
|
|
44
|
+
setuptools>=77.3.4 (is build)
|
|
45
|
+
|
|
46
|
+
pygame-ce >= 2.5.3 (core of 2.x / 3.x /4.x)
|
|
47
|
+
|
|
48
|
+
pyglet >= 2.0 (core of 4.x New Game)
|
|
49
|
+
|
|
50
|
+
CPython >= 3.13
|
|
51
|
+
|
|
52
|
+
Earth Defense Game - A cross-platform shooter.
|
|
53
|
+
|
|
54
|
+
Windows / 2.x & 3.x: Uses a high-performance C++ extension for precise, ultra-slow enemy movement and fast collision detection.
|
|
55
|
+
|
|
56
|
+
Other platforms / 2.x & 3.x: Runs a 100% Pure Python fallback.
|
|
57
|
+
|
|
58
|
+
4.x New Game: A brand new implementation using the Pyglet library.
|
|
59
|
+
|
|
60
|
+
🆕 What's New in 4.0.0dev1
|
|
61
|
+
New Ed-Game Engine: Added a completely new implementation (ed_game.new) built with the Pyglet library, moving away from Pygame.
|
|
62
|
+
|
|
63
|
+
Early Access: Please note that this is an early dev release. There may be bugs and performance issues before 4.0.0rc1.
|
|
64
|
+
|
|
65
|
+
⚠️ Known Issues
|
|
66
|
+
We have identified runtime visual bugs in ed_game 4.0.0dev1 and ed_game 3.2.0.
|
|
67
|
+
|
|
68
|
+
These issues will be fixed in the upcoming ed_game 4.0.0dev2 and ed_game 3.2.1 (or 3.3.0).
|
|
@@ -4,11 +4,12 @@ README.md
|
|
|
4
4
|
edgame_core.cpp
|
|
5
5
|
pyproject.toml
|
|
6
6
|
src/ed_game/__init__.py
|
|
7
|
-
src/ed_game/edgame_core.dll
|
|
8
7
|
src/ed_game/game_1.py
|
|
9
8
|
src/ed_game/game_2.py
|
|
10
9
|
src/ed_game.egg-info/PKG-INFO
|
|
11
10
|
src/ed_game.egg-info/SOURCES.txt
|
|
12
11
|
src/ed_game.egg-info/dependency_links.txt
|
|
13
12
|
src/ed_game.egg-info/requires.txt
|
|
14
|
-
src/ed_game.egg-info/top_level.txt
|
|
13
|
+
src/ed_game.egg-info/top_level.txt
|
|
14
|
+
src/new/__init__.py
|
|
15
|
+
src/new/game.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .game import run
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import pyglet
|
|
2
|
+
from pyglet import shapes
|
|
3
|
+
from pyglet.window import key
|
|
4
|
+
import random
|
|
5
|
+
import math
|
|
6
|
+
|
|
7
|
+
WIDTH, HEIGHT = 1800, 1050
|
|
8
|
+
|
|
9
|
+
class NewGame:
|
|
10
|
+
def __init__(self):
|
|
11
|
+
self.window = pyglet.window.Window(WIDTH, HEIGHT, "Star Guardian 4.0.0dev1 (Pyglet)")
|
|
12
|
+
self.batch = pyglet.graphics.Batch()
|
|
13
|
+
|
|
14
|
+
self.player = shapes.Circle(WIDTH // 2, 100, 16, color=(62, 255, 250), batch=self.batch)
|
|
15
|
+
self.player_core = shapes.Circle(WIDTH // 2, 96, 6, color=(0, 204, 255), batch=self.batch)
|
|
16
|
+
|
|
17
|
+
self.bullets = []
|
|
18
|
+
self.enemies = []
|
|
19
|
+
self.particles = []
|
|
20
|
+
|
|
21
|
+
self.score = 0
|
|
22
|
+
self.lives = 3
|
|
23
|
+
self.boss_timer = 20.0
|
|
24
|
+
self.state = {"left": False, "right": False, "shoot": False, "cooldown": 0}
|
|
25
|
+
|
|
26
|
+
self.label_score = pyglet.text.Label('Score: 0', font_name='Arial', font_size=28, x=30, y=HEIGHT - 40, batch=self.batch, color=(0, 255, 255, 255))
|
|
27
|
+
self.label_lives = pyglet.text.Label('Lives: 3', font_name='Arial', font_size=28, x=WIDTH - 150, y=HEIGHT - 40, batch=self.batch, color=(255, 51, 102, 255))
|
|
28
|
+
self.label_status = pyglet.text.Label('Slow Galaxy', font_name='Arial', font_size=20, x=WIDTH//2, y=HEIGHT - 40, batch=self.batch, color=(255, 215, 0, 255), anchor_x='center')
|
|
29
|
+
|
|
30
|
+
self.window.push_handlers(self)
|
|
31
|
+
pyglet.clock.schedule_interval(self.update, 1/60.0)
|
|
32
|
+
pyglet.app.run()
|
|
33
|
+
|
|
34
|
+
def on_key_press(self, symbol, modifiers):
|
|
35
|
+
if symbol in (key.A, key.LEFT): self.state["left"] = True
|
|
36
|
+
if symbol in (key.D, key.RIGHT): self.state["right"] = True
|
|
37
|
+
if symbol in (key.SPACE, key.K, key.UP): self.state["shoot"] = True
|
|
38
|
+
if symbol == key.R: self.reset()
|
|
39
|
+
|
|
40
|
+
def on_key_release(self, symbol, modifiers):
|
|
41
|
+
if symbol in (key.A, key.LEFT): self.state["left"] = False
|
|
42
|
+
if symbol in (key.D, key.RIGHT): self.state["right"] = False
|
|
43
|
+
if symbol in (key.SPACE, key.K, key.UP): self.state["shoot"] = False
|
|
44
|
+
|
|
45
|
+
def reset(self):
|
|
46
|
+
self.score = 0
|
|
47
|
+
self.lives = 3
|
|
48
|
+
self.player.x, self.player.y = WIDTH // 2, 100
|
|
49
|
+
for b in self.bullets: b['node'].delete()
|
|
50
|
+
for e in self.enemies: e['node'].delete()
|
|
51
|
+
self.bullets.clear()
|
|
52
|
+
self.enemies.clear()
|
|
53
|
+
self.update_labels()
|
|
54
|
+
|
|
55
|
+
def update_labels(self):
|
|
56
|
+
self.label_score.text = f"Score: {self.score}"
|
|
57
|
+
self.label_lives.text = f"Lives: {self.lives}"
|
|
58
|
+
|
|
59
|
+
def on_draw(self):
|
|
60
|
+
self.window.clear()
|
|
61
|
+
self.batch.draw()
|
|
62
|
+
|
|
63
|
+
def update(self, dt):
|
|
64
|
+
if self.lives <= 0: return
|
|
65
|
+
|
|
66
|
+
if self.state["left"]: self.player.x -= 500 * dt
|
|
67
|
+
if self.state["right"]: self.player.x += 500 * dt
|
|
68
|
+
self.player.x = max(20, min(WIDTH - 20, self.player.x))
|
|
69
|
+
self.player_core.x = self.player.x
|
|
70
|
+
self.player_core.y = self.player.y - 4
|
|
71
|
+
|
|
72
|
+
self.state["cooldown"] -= dt
|
|
73
|
+
if self.state["shoot"] and self.state["cooldown"] <= 0:
|
|
74
|
+
b = shapes.Circle(self.player.x, self.player.y + 15, 5, color=(255, 255, 128), batch=self.batch)
|
|
75
|
+
self.bullets.append({"node": b, "vy": 900})
|
|
76
|
+
self.state["cooldown"] = 0.15
|
|
77
|
+
|
|
78
|
+
for b in self.bullets[:]:
|
|
79
|
+
b["node"].y += b["vy"] * dt
|
|
80
|
+
if b["node"].y > HEIGHT:
|
|
81
|
+
b["node"].delete()
|
|
82
|
+
self.bullets.remove(b)
|
|
83
|
+
|
|
84
|
+
self.boss_timer -= dt
|
|
85
|
+
if self.boss_timer <= 0:
|
|
86
|
+
self.boss_timer = 20.0
|
|
87
|
+
boss = shapes.Circle(random.randint(100, WIDTH - 100), HEIGHT + 50, 48, color=(180, 50, 255), batch=self.batch)
|
|
88
|
+
self.enemies.append({"node": boss, "hp": 50, "max_hp": 50, "vy": -15, "is_boss": True})
|
|
89
|
+
|
|
90
|
+
crown = shapes.Polygon([(boss.x - 20, boss.y + 40), (boss.x, boss.y + 60), (boss.x + 20, boss.y + 40)], color=(255, 215, 0), batch=self.batch)
|
|
91
|
+
bg_bar = shapes.Rectangle(boss.x - 40, boss.y + 55, 80, 6, color=(255, 50, 50), batch=self.batch)
|
|
92
|
+
fg_bar = shapes.Rectangle(boss.x - 40, boss.y + 55, 80, 6, color=(0, 255, 0), batch=self.batch)
|
|
93
|
+
boss["ui"] = {"crown": crown, "bg_bar": bg_bar, "fg_bar": fg_bar}
|
|
94
|
+
|
|
95
|
+
if random.random() < 0.03:
|
|
96
|
+
e = shapes.Circle(random.randint(20, WIDTH - 20), HEIGHT + 20, 12, color=(255, 58, 111), batch=self.batch)
|
|
97
|
+
self.enemies.append({"node": e, "hp": 1, "max_hp": 1, "vy": -80, "is_boss": False})
|
|
98
|
+
|
|
99
|
+
for e in self.enemies[:]:
|
|
100
|
+
e["node"].y += e["vy"] * dt
|
|
101
|
+
if e.get("is_boss") and "ui" in e:
|
|
102
|
+
ui = e["ui"]
|
|
103
|
+
ui["bg_bar"].x = e["node"].x - 40
|
|
104
|
+
ui["bg_bar"].y = e["node"].y + 55
|
|
105
|
+
ui["fg_bar"].x = e["node"].x - 40
|
|
106
|
+
ui["fg_bar"].y = e["node"].y + 55
|
|
107
|
+
ui["fg_bar"].width = 80 * (e["hp"] / e["max_hp"])
|
|
108
|
+
|
|
109
|
+
if math.hypot(self.player.x - e["node"].x, self.player.y - e["node"].y) < 16 + e["node"].radius:
|
|
110
|
+
self.lives -= 1
|
|
111
|
+
self.update_labels()
|
|
112
|
+
self.create_explosion(e["node"].x, e["node"].y)
|
|
113
|
+
if "ui" in e:
|
|
114
|
+
for u in e["ui"].values(): u.delete()
|
|
115
|
+
e["node"].delete()
|
|
116
|
+
self.enemies.remove(e)
|
|
117
|
+
if self.lives <= 0: return
|
|
118
|
+
continue
|
|
119
|
+
|
|
120
|
+
if e["node"].y < -100:
|
|
121
|
+
if "ui" in e:
|
|
122
|
+
for u in e["ui"].values(): u.delete()
|
|
123
|
+
e["node"].delete()
|
|
124
|
+
self.enemies.remove(e)
|
|
125
|
+
|
|
126
|
+
for b in self.bullets[:]:
|
|
127
|
+
for e in self.enemies[:]:
|
|
128
|
+
if math.hypot(b["node"].x - e["node"].x, b["node"].y - e["node"].y) < 5 + e["node"].radius:
|
|
129
|
+
e["hp"] -= 1
|
|
130
|
+
b["node"].delete()
|
|
131
|
+
self.bullets.remove(b)
|
|
132
|
+
|
|
133
|
+
if e["hp"] <= 0:
|
|
134
|
+
self.score += 200 if e.get("is_boss") else 10
|
|
135
|
+
self.update_labels()
|
|
136
|
+
self.create_explosion(e["node"].x, e["node"].y)
|
|
137
|
+
if "ui" in e:
|
|
138
|
+
for u in e["ui"].values(): u.delete()
|
|
139
|
+
e["node"].delete()
|
|
140
|
+
self.enemies.remove(e)
|
|
141
|
+
break
|
|
142
|
+
|
|
143
|
+
for p in self.particles[:]:
|
|
144
|
+
p["node"].x += p["vx"] * dt
|
|
145
|
+
p["node"].y += p["vy"] * dt
|
|
146
|
+
p["life"] -= dt
|
|
147
|
+
if p["life"] <= 0:
|
|
148
|
+
p["node"].delete()
|
|
149
|
+
self.particles.remove(p)
|
|
150
|
+
|
|
151
|
+
def create_explosion(self, x, y):
|
|
152
|
+
for _ in range(8):
|
|
153
|
+
p = shapes.Circle(x, y, random.uniform(2, 5), color=(255, random.randint(100, 200), 50), batch=self.batch)
|
|
154
|
+
self.particles.append({"node": p, "vx": random.uniform(-300, 300), "vy": random.uniform(-300, 300), "life": 0.5})
|
|
155
|
+
|
|
156
|
+
def run():
|
|
157
|
+
NewGame()
|
|
158
|
+
run()
|
ed_game-3.1.0/PKG-INFO
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: ed-game
|
|
3
|
-
Version: 3.1.0
|
|
4
|
-
Summary: Earth Defense Game
|
|
5
|
-
Author-email: qq-name <your@email.com>
|
|
6
|
-
License-Expression: MIT
|
|
7
|
-
Project-URL: Homepage, https://pypi.org/project/ed-game/
|
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.14
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.15
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.16
|
|
13
|
-
Classifier: Operating System :: Microsoft :: Windows
|
|
14
|
-
Classifier: Operating System :: MacOS
|
|
15
|
-
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
-
Classifier: Topic :: Games/Entertainment
|
|
17
|
-
Requires-Python: >=3.13
|
|
18
|
-
Description-Content-Type: text/markdown
|
|
19
|
-
License-File: LICENSE
|
|
20
|
-
Requires-Dist: pygame-ce>=2.5.3
|
|
21
|
-
Dynamic: license-file
|
|
22
|
-
|
|
23
|
-
Installing:
|
|
24
|
-
|
|
25
|
-
pip install ed-game
|
|
26
|
-
|
|
27
|
-
or:
|
|
28
|
-
|
|
29
|
-
pip3 install ed-game
|
|
30
|
-
|
|
31
|
-
Usage:
|
|
32
|
-
|
|
33
|
-
import ed_game
|
|
34
|
-
ed_game.run()
|
|
35
|
-
|
|
36
|
-
ed-game dependencies:
|
|
37
|
-
1. setuptools>=77.3.4 (is build)
|
|
38
|
-
2. pygame-ce >= 2.5.3 (core of ed-game) (Last version is 2.5.8)
|
|
39
|
-
3. CPython >= 3.13 (Support for Python 3.8, 3.9, 3.10, 3.11, and 3.12 has been dropped.)
|
|
40
|
-
|
|
41
|
-
Note: We will drop support for any Python version that has been in security-only mode for over a year.
|
|
42
|
-
|
|
43
|
-
Earth Defense Game - A cross-platform shooter.
|
|
44
|
-
- **Windows**: Uses a high-performance **C++ extension** for precise, ultra-slow enemy movement and fast collision detection.
|
|
45
|
-
- **Other platforms ( macOS / Linux / Android )**: Runs a 100% Pure Python fallback.
|
|
46
|
-
|
|
47
|
-
### 🆕 What's New in 3.1.0
|
|
48
|
-
- **On-Screen Touch Buttons**: Added virtual buttons for moving left/right and firing, fully playable on mobile and tablets.
|
|
49
|
-
- **Ultimate Nuke Button**: Added a screen-clearing Nuke button with a 120-second cooldown.
|
|
50
|
-
- **8-Bit Sound Effects**: Added code-generated retro sound effects for shooting and explosions.
|
|
51
|
-
- **Massive Optimization**: Removed all external font files to keep the package size under 1MB.
|
ed_game-3.1.0/README.md
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
Installing:
|
|
2
|
-
|
|
3
|
-
pip install ed-game
|
|
4
|
-
|
|
5
|
-
or:
|
|
6
|
-
|
|
7
|
-
pip3 install ed-game
|
|
8
|
-
|
|
9
|
-
Usage:
|
|
10
|
-
|
|
11
|
-
import ed_game
|
|
12
|
-
ed_game.run()
|
|
13
|
-
|
|
14
|
-
ed-game dependencies:
|
|
15
|
-
1. setuptools>=77.3.4 (is build)
|
|
16
|
-
2. pygame-ce >= 2.5.3 (core of ed-game) (Last version is 2.5.8)
|
|
17
|
-
3. CPython >= 3.13 (Support for Python 3.8, 3.9, 3.10, 3.11, and 3.12 has been dropped.)
|
|
18
|
-
|
|
19
|
-
Note: We will drop support for any Python version that has been in security-only mode for over a year.
|
|
20
|
-
|
|
21
|
-
Earth Defense Game - A cross-platform shooter.
|
|
22
|
-
- **Windows**: Uses a high-performance **C++ extension** for precise, ultra-slow enemy movement and fast collision detection.
|
|
23
|
-
- **Other platforms ( macOS / Linux / Android )**: Runs a 100% Pure Python fallback.
|
|
24
|
-
|
|
25
|
-
### 🆕 What's New in 3.1.0
|
|
26
|
-
- **On-Screen Touch Buttons**: Added virtual buttons for moving left/right and firing, fully playable on mobile and tablets.
|
|
27
|
-
- **Ultimate Nuke Button**: Added a screen-clearing Nuke button with a 120-second cooldown.
|
|
28
|
-
- **8-Bit Sound Effects**: Added code-generated retro sound effects for shooting and explosions.
|
|
29
|
-
- **Massive Optimization**: Removed all external font files to keep the package size under 1MB.
|
|
Binary file
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: ed-game
|
|
3
|
-
Version: 3.1.0
|
|
4
|
-
Summary: Earth Defense Game
|
|
5
|
-
Author-email: qq-name <your@email.com>
|
|
6
|
-
License-Expression: MIT
|
|
7
|
-
Project-URL: Homepage, https://pypi.org/project/ed-game/
|
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.14
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.15
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.16
|
|
13
|
-
Classifier: Operating System :: Microsoft :: Windows
|
|
14
|
-
Classifier: Operating System :: MacOS
|
|
15
|
-
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
-
Classifier: Topic :: Games/Entertainment
|
|
17
|
-
Requires-Python: >=3.13
|
|
18
|
-
Description-Content-Type: text/markdown
|
|
19
|
-
License-File: LICENSE
|
|
20
|
-
Requires-Dist: pygame-ce>=2.5.3
|
|
21
|
-
Dynamic: license-file
|
|
22
|
-
|
|
23
|
-
Installing:
|
|
24
|
-
|
|
25
|
-
pip install ed-game
|
|
26
|
-
|
|
27
|
-
or:
|
|
28
|
-
|
|
29
|
-
pip3 install ed-game
|
|
30
|
-
|
|
31
|
-
Usage:
|
|
32
|
-
|
|
33
|
-
import ed_game
|
|
34
|
-
ed_game.run()
|
|
35
|
-
|
|
36
|
-
ed-game dependencies:
|
|
37
|
-
1. setuptools>=77.3.4 (is build)
|
|
38
|
-
2. pygame-ce >= 2.5.3 (core of ed-game) (Last version is 2.5.8)
|
|
39
|
-
3. CPython >= 3.13 (Support for Python 3.8, 3.9, 3.10, 3.11, and 3.12 has been dropped.)
|
|
40
|
-
|
|
41
|
-
Note: We will drop support for any Python version that has been in security-only mode for over a year.
|
|
42
|
-
|
|
43
|
-
Earth Defense Game - A cross-platform shooter.
|
|
44
|
-
- **Windows**: Uses a high-performance **C++ extension** for precise, ultra-slow enemy movement and fast collision detection.
|
|
45
|
-
- **Other platforms ( macOS / Linux / Android )**: Runs a 100% Pure Python fallback.
|
|
46
|
-
|
|
47
|
-
### 🆕 What's New in 3.1.0
|
|
48
|
-
- **On-Screen Touch Buttons**: Added virtual buttons for moving left/right and firing, fully playable on mobile and tablets.
|
|
49
|
-
- **Ultimate Nuke Button**: Added a screen-clearing Nuke button with a 120-second cooldown.
|
|
50
|
-
- **8-Bit Sound Effects**: Added code-generated retro sound effects for shooting and explosions.
|
|
51
|
-
- **Massive Optimization**: Removed all external font files to keep the package size under 1MB.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|