Skip to main content

AI驱动的物理游戏引擎 - 聚合设计

Project description

NexusFine - AI驱动的物理游戏引擎

中文名:聚合设计

一个 AI 驱动的物理游戏引擎,可以快速构建子弹下落、球类运动等 2D/3D 物理小游戏。

特性:

  • AI 驱动 - 使用 AI 进行物理计算
  • 简单易用 - 几行代码即可创建游戏
  • 2D/3D 支持 - 自动适配维度
  • 档位调节 - A/B/C 三档性能调节
  • 模块化设计 - 子弹、球、云、蒸汽
  • 参数可调 - 重力、地面位置、反弹系数等
  • 四周碰撞 - Ball 支持左右墙壁反弹

安装: pip install NexusFine

快速开始: from nexusfine import NF a = "SK-XXXXXXX" NF(a) # X轴 NF(a) # Y轴 NF(a, a) # 构建 2D 系统 NF("Game.exe") # 启动游戏

物理对象使用: from nexusfine import NF, NB, NC, NS

子弹 - 2D 直线运动 + 重力

bullet = NF.Bullet(x=0, y=10, vx=5, vy=0, gravity=300) bullet.update(0.016) print(f"x={bullet.x:.2f}, y={bullet.y:.2f}")

球 - 2D 弹跳运动(支持四周墙壁)

ball = NB.Ball(x=0, y=5, radius=10, gravity=300, bounce=0.8, ground_y=600) ball.vx = 3 ball.update(0.016, 800, 600) # 传入窗口宽高,自动处理四周碰撞

云 - 2D 飘动

cloud = NC.Cloud(x=0, y=5, vx=0.5, vy=0.1) cloud.update(0.016)

蒸汽 - 3D 扩散(由 NF 提供)

steam = NF.Steam(x=0, y=0, z=0, rise_speed=0.5, diffusion=0.3) steam.update(0.016)

模块说明: NF - 子弹,2D (X, Y),提供 Bullet()、Steam() NB - 球,2D (X, Y),提供 Ball()(支持四周碰撞) NC - 云,2D (X, Y),提供 Cloud() NS - 配置系统,提供档位调节功能(config / apply)

物理对象参数: Bullet(x=0, y=0, vx=5, vy=0, gravity=300)

  • x: 初始X位置,默认 0
  • y: 初始Y位置,默认 0
  • vx: 水平速度,默认 5
  • vy: 垂直速度,默认 0
  • gravity: 重力加速度(像素/秒²),默认 300

Ball(x=0, y=0, radius=10, gravity=300, bounce=0.8, ground_y=600)

  • x: 初始X位置,默认 0
  • y: 初始Y位置,默认 0
  • radius: 球半径,默认 10
  • gravity: 重力加速度(像素/秒²),默认 300
  • bounce: 反弹系数,默认 0.8
  • ground_y: 地面Y坐标,默认 600

Cloud(x=0, y=0, vx=0.5, vy=0.1)

  • x: 初始X位置,默认 0
  • y: 初始Y位置,默认 0
  • vx: 水平速度,默认 0.5
  • vy: 垂直速度,默认 0.1

Steam(x=0, y=0, z=0, rise_speed=0.5, diffusion=0.3)

  • x: 初始X位置,默认 0
  • y: 初始Y位置,默认 0
  • z: 初始Z位置,默认 0
  • rise_speed: 上升速度,默认 0.5
  • diffusion: 扩散幅度,默认 0.3

更新方法: 所有物理对象都有 update(dt=0.016) 方法

  • dt: 时间步长,默认 0.016(60帧/秒)
  • Ball.update(dt, width, height): 传入窗口宽高自动处理四周碰撞
  • 返回: {"x": x, "y": y, ...}

使用示例: 子弹: from nexusfine import NF a = "SK-XXXXXXX" NF(a); NF(a); NF(a, a) bullet = NF.Bullet(x=0, y=10, vx=5, vy=0) for i in range(10): bullet.update(0.1) print(f"x={bullet.x:.2f}, y={bullet.y:.2f}")

球(含四周碰撞): from nexusfine import NB a = "SK-XXXXXXX" NB(a); NB(a); NB(a, a) ball = NB.Ball(x=400, y=300, radius=20, gravity=0, bounce=0.85, ground_y=600) ball.vx = 5 for i in range(10): ball.update(0.1, 800, 600) # 自动处理左右墙壁 print(f"x={ball.x:.2f}, y={ball.y:.2f}")

蒸汽(3D): from nexusfine import NF a = "SK-XXXXXXX" NF(a); NF(a); NF(a); NF(a, a, a) steam = NF.Steam(x=0, y=0, z=0, rise_speed=0.5, diffusion=0.3) for i in range(10): steam.update(0.1) print(f"x={steam.x:.2f}, y={steam.y:.2f}, z={steam.z:.2f}")

高级功能(档位调节): from nexusfine import NF, NS a = "SK-XXXXXXX"

方式1:传统方式

config = NS.config("NF", mode="A", duration=20) NF.set_mode("A") NF("x_axis") NF("y_axis") NF(config, "x_axis", "y_axis")

方式2:直接应用(0.2.5+ 新增)

NS.apply(NF, mode="C", duration=60) NF("x_axis") NF("y_axis") NF("Game.exe")

档位说明: A - 高性能模式(精度高) B - 平衡模式(精度适中) C - 省电模式(速度快)

依赖: Python >= 3.6 requests >= 2.25.0

更新日志: v0.2.9 (2026-06-21)

  • Ball 支持四周墙壁碰撞:update(dt, width, height)
  • 重力、弹跳、地面、天花板、左右墙壁全自动处理
  • 文档完善

v0.2.8 (2026-06-20)

  • 修复贴地抖动问题

v0.2.7 (2026-06-20)

  • 物理参数可配置

v0.2.3 (2026-06-20)

  • 新增物理对象:Bullet、Ball、Cloud、Steam

v0.2.0 (2026-06-20)

  • 新增档位调节功能

v0.1.0 (2026-06-19)

  • 首次发布

许可证:MIT License

作者:bengtiaotiao

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nexusfine-0.2.9.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nexusfine-0.2.9-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file nexusfine-0.2.9.tar.gz.

File metadata

  • Download URL: nexusfine-0.2.9.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for nexusfine-0.2.9.tar.gz
Algorithm Hash digest
SHA256 05d68cae4dbc1e076d2cef5d64dafa1efb8effe13d6d216131c331a06b0fceeb
MD5 52899bb8649e8e9e58625f1317efb774
BLAKE2b-256 e617d1cf8d356c67ce71591286f996eb1e92c71ae2e8dda3c9395d256968045e

See more details on using hashes here.

File details

Details for the file nexusfine-0.2.9-py3-none-any.whl.

File metadata

  • Download URL: nexusfine-0.2.9-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for nexusfine-0.2.9-py3-none-any.whl
Algorithm Hash digest
SHA256 edcbcc49713e93be84b3dfda55bf84a0def777cf3c602025e2d52e7c3b7c4052
MD5 142903be167cabedeb34d59b27482dfb
BLAKE2b-256 9a11b5bf7ff899caec4c5e1b10275d28a34444b5150be375798cb5db14475cf8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page