Skip to content

Commit af8a30d

Browse files
committed
更新代码:添加CNAME文件和.gitattributes文件
1 parent 8025357 commit af8a30d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+2888
-862
lines changed

.editorconfig

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
root = true
2+
3+
# all files
4+
[*.go]
5+
indent_style = tab
6+
indent_size = 4
7+
insert_final_newline = true
8+
9+
[*.py]
10+
indent_style = space
11+
indent_size = 4
12+
13+
[Makefile]
14+
indent_style = tab
15+
16+
[*.js]
17+
charset = utf-8
18+
indent_style = space
19+
indent_size = 4
20+
21+
[*.json]
22+
indent_style = space
23+
indent_size = 2
24+
25+
[*.yml]
26+
indent_style = space
27+
indent_size = 2

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
web/sighttraining.apk filter=lfs diff=lfs merge=lfs -text
2+

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,5 @@ cython_debug/
159159
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160160
#.idea/
161161
.DS_Store
162+
web/*.apk
163+
web/*.zip

CNAME

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
spacedefense.talkincode.net

MANIFEST.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
global-exclude .DS_Store
3+
include Readme.md
4+
recursive-include spacedefense/assets *

Makefile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# 定义变量
2+
DIST_DIR=dist
3+
BUILD_DIR=build
4+
BUILD_CMD=python setup.py sdist bdist_wheel
5+
CLEAN_CMD=rm -rf $(DIST_DIR) $(BUILD_DIR) *.egg-info
6+
WHL_FILE=$(wildcard $(DIST_DIR)/*.whl)
7+
PACKAGE_NAME=sight-training
8+
UPLOAD_CMD=twine upload $(DIST_DIR)/*
9+
10+
# 默认目标
11+
.PHONY: all
12+
all: clean build
13+
14+
# 构建项目
15+
.PHONY: build
16+
build: clean
17+
$(BUILD_CMD)
18+
19+
# 清理构建产物
20+
.PHONY: clean
21+
clean:
22+
find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch
23+
$(CLEAN_CMD)
24+
25+
# 安装包
26+
.PHONY: install
27+
install:
28+
@if [ -z "$(WHL_FILE)" ]; then \
29+
echo "No .whl file found in $(DIST_DIR). Please run 'make build' first."; \
30+
else \
31+
pip install $(WHL_FILE); \
32+
fi
33+
34+
# 卸载包
35+
.PHONY: uninstall
36+
uninstall:
37+
pip uninstall -y $(PACKAGE_NAME)
38+
39+
# 上传包到 PyPI
40+
.PHONY: upload
41+
upload:
42+
$(UPLOAD_CMD)
43+
44+
app:
45+
pyinstaller spacex01.spec
46+
47+
# 帮助信息
48+
.PHONY: help
49+
help:
50+
@echo "Available commands:"
51+
@echo " build - Build the package."
52+
@echo " clean - Remove build artifacts."
53+
@echo " install - Install the package using the built wheel file."
54+
@echo " uninstall - Uninstall the package."
55+
@echo " upload - Upload the package to PyPI."
56+
@echo " all - Clean the build environment and then build the package."
57+
@echo " help - Show this help message."

README.md

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,92 @@
1-
# SpaceDefense
2-
Space Defense is a vision training game for children with amblyopia!
1+
## SpaceDefense 太空保卫战
2+
3+
![SpaceDefense](https://raw.githubusercontent.com/jamiesun/images/master/default/54iDr9.png)
4+
5+
在浩瀚的宇宙中,隐藏着无数的奥秘与危险。一股来自远古的力量正在悄然觉醒,它们的目的只有一个——摧毁所有文明。宇宙之中的和平正面临前所未有的威胁,而你,作为太空保卫战系列的核心,被赋予了守卫家园、保护宇宙和平的重大任务。你将驾驶着自己的战斗机,与恶势力展开一场史诗般的太空战争。为了胜利,除了勇气和决心,你还需要策略和技巧。
6+
7+
### 在线体验版
8+
9+
- [https://spacedefense.talkincode.net/](https://spacedefense.talkincode.net/)
10+
11+
### 游戏特色
12+
13+
- **精彩纷呈的太空战斗**:体验紧张刺激的太空对决,让玩家在宇宙的壮观景象中体验速度与激情的碰撞。
14+
- **丰富多样的战舰选择**:游戏提供多种不同功能的战舰,每种战舰都有独特的技能和升级路径,玩家可以根据自己的战斗风格和需要进行选择和定制。
15+
- **视觉和听觉的双重盛宴**:精心设计的游戏界面和背景音乐,将玩家完全拉入一个充满科幻风格的太空世界。
16+
- **激励玩家的积分系统**:通过击败敌人和完成任务,玩家可以获得积分,用于升级和增强自己的战舰。
17+
- **多样化的敌人与AI**:从侵略性的小型飞船到庞大的母舰,战斗中的敌人多种多样,AI的设计使得每一场战斗都充满挑战。
18+
- **简单易懂,深度丰富**:易于上手的操作让玩家快速融入游戏,丰富的系统和策略让游戏长久玩下去依然充满乐趣。
19+
20+
### 操作说明
21+
22+
使用键盘 1,2,3,4,5,进行战斗操作, 左右键移动, 支持索尼 PS4/5手柄
23+
24+
1. 速射机炮,定向发射, 速度快,无法跟踪制导, 可升级最高6连发, 升级到一定级别可以同时发射干扰弹
25+
2. 制导机炮,伤害高,自动跟踪敌人战机,无法定向发射,升级后可2连发
26+
3. 发射干扰弹,伤害低, 但是可以拦截敌人普通炮弹
27+
4. 呼叫战斗无人机, 可吸引敌人火力,为我方主舰掩护,伤害一般
28+
5. 发射巡航导弹,高伤害, 并且产生冲击波,清除范围内所有炮弹, 两段加速,有较长的发射延时, 并且需要大量能量点数
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+
准备好了吗?勇士,让我们在『SpaceDefense 太空保卫战』中书写属于你的传奇吧!
58+
59+
60+
## 快速开始
61+
62+
- pip 安装
63+
64+
```bash
65+
pip install spacedefense
66+
```
67+
68+
- 源码安装
69+
70+
```bash
71+
git clone git@github.com:talkincode/spacedefense.git
72+
cd spacedefense
73+
74+
pip install .
75+
```
76+
77+
安装完成后, 输入 `spacedefense` 即可开始太空保卫战游戏
78+
79+
80+
- 参数说明
81+
82+
```bash
83+
options:
84+
-h, --help 显示帮助信息
85+
-D, --debug Debug 模式.
86+
-t, --train 视力训练模式, CAM 光栅风格轮换.
87+
设置游戏分辨率。
88+
-l {x,xx,xxx}, --level {x,xx,xxx}
89+
设置游戏难度级别
90+
```
91+
92+

bg.py

Lines changed: 0 additions & 44 deletions
This file was deleted.

build.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
test -d web || mkdir web
4+
test -d build/spacedefense && rm -rf build/spacedefense
5+
mkdir -p build/spacedefense/spacedefense/assets/images
6+
mkdir -p build/spacedefense/spacedefense/assets/sounds
7+
8+
cp -r spacedefense/* build/spacedefense/spacedefense/
9+
10+
rm -f build/spacedefense/main.py
11+
cp wasm.py build/spacedefense/main.py
12+
13+
rm -fr build/spacedefense/spacedefense/__pycache__
14+
15+
python -m pygbag --build build/spacedefense
16+
python3 -m pygbag --archive build/spacedefense/main.py
17+
18+
cp build/spacedefense/build/web/index.html web/index.html
19+
cp build/spacedefense/build/web/build/spacedefense.apk web/build/spacedefense.apk
20+
cp build/spacedefense/build/web.zip web/web.zip
21+
rm -fr build/spacedefense

favicon.png

19.4 KB
Loading

keytest.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import pygame
2+
import sys
3+
4+
# 初始化 Pygame
5+
pygame.init()
6+
7+
# 设置窗口大小
8+
window_size = (640, 480)
9+
screen = pygame.display.set_mode(window_size)
10+
11+
# 设置窗口标题
12+
pygame.display.set_caption("Joystick Test")
13+
14+
# 初始化手柄
15+
pygame.joystick.init()
16+
17+
# 尝试连接第一个手柄
18+
if pygame.joystick.get_count() > 0:
19+
joystick = pygame.joystick.Joystick(0)
20+
joystick.init()
21+
print(f"Detected joystick: {joystick.get_name()}")
22+
else:
23+
print("No joysticks detected.")
24+
sys.exit()
25+
26+
# 字体设置用于显示按键信息
27+
font = pygame.font.Font(None, 36)
28+
29+
# 游戏主循环
30+
running = True
31+
while running:
32+
for event in pygame.event.get():
33+
if event.type == pygame.QUIT:
34+
running = False
35+
36+
# 检测手柄按键事件
37+
if event.type == pygame.JOYBUTTONDOWN:
38+
print(f"joy {event.joy} Joystick button {event.button} pressed.")
39+
screen.fill((0, 0, 0)) # 清屏
40+
text = font.render(f"Button {event.button} pressed", True, (255, 255, 255))
41+
screen.blit(text, (100, 100))
42+
pygame.display.flip() # 更新屏幕显示
43+
elif event.type == pygame.JOYAXISMOTION:
44+
# PS4手柄中,L2 通常映射到轴2,但可能因驱动或配置不同而有所变化
45+
print(f"joy {event.joy} JOYAXISMOTION {event.axis} VALUE: {event.value:.2f}")
46+
47+
# if event.axis == 2:
48+
# print(f"L2 position: {event.value}")
49+
# text_surface = font.render(f'L2 position: {event.value:.2f}', True, (255, 255, 255))
50+
# screen.blit(text_surface, (50, 150))
51+
52+
53+
pygame.quit()

main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from spacedefense import task1
1+
from spacedefense import runapp
22

3-
if __name__ == "__main__":
4-
task1.main()
3+
if __name__ == '__main__':
4+
runapp()

setup.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env python3
2+
3+
from setuptools import setup, find_packages
4+
5+
readme = """
6+
spacedefense is a game for children's amblyopia training.
7+
"""
8+
9+
setup(
10+
name="spacedefense",
11+
version="0.1.0",
12+
author="jett.wang",
13+
author_email="jamiesun.net@gmail.com",
14+
description="spacedefense is a game for children's amblyopia training",
15+
long_description=readme,
16+
long_description_content_type="text/markdown",
17+
packages=find_packages(),
18+
include_package_data=True,
19+
classifiers=[
20+
"Programming Language :: Python :: 3",
21+
"License :: OSI Approved :: MIT License",
22+
"Operating System :: OS Independent",
23+
],
24+
install_requires=[
25+
"pygame==2.5.1",
26+
"python-dotenv>=1.0.1"
27+
],
28+
python_requires='>=3.10',
29+
entry_points={
30+
"console_scripts": [
31+
"spacedefense = spacedefense:runapp"
32+
]
33+
},
34+
)

spacedefense.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import asyncio
2+
3+
async def main():
4+
from spacedefense.game import AsyncSpaceDefense
5+
await AsyncSpaceDefense().start_game()
6+
7+
8+
if __name__ == "__main__":
9+
asyncio.run(main())

0 commit comments

Comments
 (0)