Metadata-Version: 2.4
Name: WaliGame
Version: 2026.11.9
Summary: WaliGame - a Python game engine designed for educational purposes
Author-email: WaliGame Project <waligame@example.com>
Maintainer-email: WaliGame Maintainers <waligame@example.com>
License: MIT
Project-URL: PyPI, https://pypi.org/project/waligame/
Keywords: game,pygame,pymunk,education,game-engine
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Education
Classifier: Topic :: Games/Entertainment
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Operating System :: OS Independent
Classifier: Environment :: MacOS X
Classifier: Environment :: Win32 (MS Windows)
Classifier: Environment :: X11 Applications
Requires-Python: >=3.8.1
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: pygame>=2.5.0
Requires-Dist: pymunk>=6.5.0
Requires-Dist: pytmx>=3.32
Provides-Extra: dev
Requires-Dist: black>=23.0; extra == "dev"
Requires-Dist: flake8>=6.0; extra == "dev"
Requires-Dist: mypy>=1.0; extra == "dev"
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: twine>=4.0; extra == "dev"
Provides-Extra: docs
Requires-Dist: mkdocs>=1.4; extra == "docs"
Requires-Dist: mkdocs-material>=9.0; extra == "docs"
Dynamic: license-file

# 🎮 WaliGame 2026.11.9

> 面向少儿编程的 2D 游戏引擎。基座来自 **Walimaker 4.0.2**（MIT），
> 在其工程化架构上合并了 2026.11.1 的教学功能，并重命名为 **WaliGame**。
> 游戏代码里使用 `import waligame` / `from waligame import *`。
>
> 版本记录：`VERSION_LOG.md`（每次更新必须升版本号并记录）。

完整 API 参考见 `WaliGame API 文档.md`（安装包内）。

## 安装

```bash
# 本地 wheel
python -m pip install "waligame-2026.11.6-py3-none-any.whl"

# 依赖
python -m pip install "pygame>=2.5.0" "pymunk>=6.5.0" "pytmx>=3.32"
```

> `pymunk` 必须 **6.5+**（4.0.2 的物理/类型基础）；`pygame` 2.5+。

> **2026.11.6 安装器会先检测旧包**：`Walimaker`（含 2026.11.1 / 上游 4.0.2）
> 和最早的 `WalimakerPythonGameEngine`（2023.8.1）。
> 如果检测到，会询问是否卸载；选择“不卸载”会直接退出，不会安装 WaliGame。
> 选择“卸载”会先卸载旧包，再安装 WaliGame。

## 第一个游戏

```python
import waligame

waligame.setup(800, 600)
waligame.title("我的第一个 WaliGame 游戏")

player = waligame.Character("player.png", size=(40, 60), tag="player")
player.goto(0, 0)

while True:
    if waligame.key_pressed(waligame.K_RIGHT):
        player.velocity = (250, player.velocity[1])
    elif waligame.key_pressed(waligame.K_LEFT):
        player.velocity = (-250, player.velocity[1])
    else:
        player.velocity = (0, player.velocity[1])
    waligame.update()
```

也可以 `from waligame import *`，和旧版 Walimaker 的写法一致。

## 这一版保留/新增了什么

在 **4.0.2 的底子**上：

- `Object → GameObject → Character/Sensor/Wall/Mouse` 继承链
- 多世界 `World`、`setup(..., world=w2)`、`update(world=w2)`
- `ResourceManager`：图片 LRU、弱引用 mask 缓存、`preload()`
- 60 FPS + 固定物理步长累加器 + 防隧穿子步
- 相机 `shake` / `deadzone` / `zoom_to` / 平滑缩放
- 约束 `connect()` / `Spring()`、`TiledMap.create_objects()`
- 中文报错助手 `error_help`、字体回退 `fonts`
- 类型信息 `py.typed`、MIT 许可、src 布局

在 **2026.11.1 的教学功能**上：
- 兼容旧课件的星号导入：`from waligame import *` 也会带出 `random` / `time` / `os` / `math` / `sys` / `pygame`（旧 Walimaker 课件常用 `random.randint` 而不写 import）
- 主包内置 `Walimaker` 别名：安装 WaliGame 后，`from Walimaker import *` 等价于 `from waligame import *`。

- `every(秒, 函数)` / `after(秒, 函数)` / `clear_timers()` 计时器
- `tag="zombie"` + `find_all()` / `find()` / `collide_tag()`
- `clone()` 复制对象（模板做子弹/僵尸）
- `follow(目标, speed, stop)` / `stop_follow()`
- `on_screen` 判断是否在镜头内
- `Score` / `Label` 屏幕 HUD
- 没有物理体的对象也支持 `velocity`（像素/帧）
- DPI 适配默认关闭：`setup(宽, 高)`；需要 Windows 物理像素时 `setup(..., dpi_aware=True)`
- 控制台：隐藏 pygame/pymunk 横幅、第一帧打印
  `【欢迎使用 WaliGame 2026.11.6】游戏启动成功！`
- `get_angle` 兼容别名（新代码用 `angle`）
- 鼠标“按住”状态每帧维护：松手发生在滑梯/动画等没有查询鼠标的状态里，也不会再卡住
- 音频失败只警告一次并静音继续：`bgmusic` / `play_snd` / `music_*` 不再因没有音频设备而崩溃
- `key_just_pressed` / `key_just_released` 默认“任意一个”，
  `require_all=True` 恢复“全部按下”

## 典型用法

### 计时器 + 标签 + 碰撞

```python
import waligame
from waligame import *

setup(900, 600)

player = Character("player.png", size=(40, 60), tag="player")
zombie = Character("zombie.png", size=(40, 80), tag="zombie")
score = Score()

def shoot():
    bullet = Character("pea.png", tag="bullet")
    bullet.goto(player.pos)
    bullet.velocity = (8, 0)

every(1.2, shoot)

while True:
    for bullet in find_all("bullet"):
        hit = bullet.collide_tag("zombie")
        if hit:
            hit.kill()
            bullet.kill()
            score.add(10)
        elif not bullet.on_screen:
            bullet.kill()
    update()
```

### 复制模板

```python
template = Character("pea.png")
pea = template.clone()
pea.goto(player.pos)
pea.velocity = (8, 0)
```

### 没有物理体的角色

```python
bullet = Character("pea.png")   # 不传 size
bullet.velocity = (8, 0)         # 每帧 8 像素，不受重力，不会被推
```

### 多世界

```python
from waligame import World, setup, update

w2 = World()
setup(800, 600, world=w2)
update(world=w2)
```

## 通用联机房间

从 2026.11.6 起，WaliGame 提供通用局域网房间，不只为石头剪刀布写：

```python
from waligame import *

net = 联机("我的游戏", 最多人数=4)

if not net.大厅():
    raise SystemExit

setup(800, 600)

while True:
    for msg in net.收到():
        print(msg["玩家"], msg["内容"])

    net.发送({"type": "操作", "data": ...})
    update()
```

- `大厅()`：创建/查找房间、密码、玩家列表、房主开始；返回 `True` 表示开始。
- 创建房间可设置：房间号/房间名、最多人数、玩家名、密码。
- `net.是房主`、`net.玩家列表`、`net.我的编号`。
- `net.发送()` 发给其他玩家；`net.收到()` 返回 `{"玩家", "编号", "内容"}`。
- `大厅()` 要在 `setup()` 之前调用；大厅结束后再 `setup()`。
- 房主大厅会显示 `房间地址：IP:端口`，朋友找不到房间时用“直接输入 IP”。
- 只负责房间和消息转发；游戏规则由孩子写。
- `联机(..., 允许中途加入=True)` 支持游戏开始后加入；本版另附 `彩色食材大作战.py` 示例。

## 旧写法兼容

从 **2026.11.6** 起，`Walimaker` 别名直接内置在主 wheel 里：

```python
from Walimaker import *
# 等价于 from waligame import *
```

安装 WaliGame 就同时有了 `waligame` 和 `Walimaker`，不需要再单独安装 compat 包。

注意：如果环境里还装着旧的 `walimaker`（2026.11.1 或 PyPI 4.0.2），它的
`Walimaker/` 包目录会遮住别名；请先卸载旧包：

```powershell
python -m pip uninstall -y walimaker
```

## 音频

- `setup()` 会尝试 48000/44100、2/1 声道打开 mixer；全部失败时只打印一次
  `【WaliGame 音频提示】`，游戏继续静音运行。
- `bgmusic()` 返回 `True/False`；`play_snd()` / `music_*()` 在音频不可用时安全跳过。
- 需要判断音频状态时用：
  ```python
  from waligame import audio_available, ensure_audio, audio_info
  if audio_available:      # 动态反映当前 mixer 状态
      bgmusic("bgm.mp3")
  ensure_audio()           # 再尝试打开一次
  print(audio_info())      # 诊断信息
  ```
- 安装包的 `安装完在这里进行测试\音频诊断.py` 可打印 SDL 设备并尝试多种格式。

## 与 Walimaker 4.0.2 的差异

- 包名：`waligame`；发行名：`WaliGame`；版本：`2026.11.6`
- 新增上面列出的计时器、tag、clone、follow、on_screen、Score/Label、
  无物理体 velocity、DPI、欢迎语
- `get_angle` 保留为 `angle` 的兼容别名
- `key_just_pressed` 默认改为“任意一个”
- 控制台默认干净（pygame/pymunk 横幅、libpng 警告）

## 许可证与来源

WaliGame 基于 **Walimaker 4.0.2**（MIT，Copyright (c) 2026 Walimaker Project
Contributors）做了大幅修改与扩展。原始 MIT 许可证保留在 `LICENSE`，
来源说明见 `NOTICE`。4.0.2 的原始 README 保留为 `README_4.0.2.md` 供对照。
