A lightweight 2D/3D game engine based on Ursina
Reason this release was yanked:
有严重bug,无法使用reb(255,0,0)设置颜色;Critical bug: rgb(255,0,0) color setting fails
Project description
帮助文档(中文版)
- 创建窗口
PyToolsgr.OS(OS) # Windows , MacOS , Linux
game = PyToolsgr.game(分辨率数组,是否全屏,窗口标题,是否可以调整窗口大小,最大帧率,是否显示帧率,是否开启物理引擎,2d或3d)
2D 模式 '''python from PyToolsgr import * PyToolsgr.OS('Windows') # 或MacOS , Linux
x = (1080,720) # 窗口大小 all = True # 是否全屏 title = 'PyToolsgr' # 窗口标题 y = True # 是否可以调整窗口大小 fps = 60 # 最大帧率 fpsx = True # 是否显示帧率 phy = True # 是否开启物理引擎 mode = '2d' # 2d或3d
game = PyToolsgr.game(x,all,title,y,fps,fpsx,phy,mode)
PyToolsgr.beijing((0,0,0)) # 背景颜色
b1 = PyToolsgr.New("Block",(100,100) # 显示大小,rgb(0,0,0),(0,0)#创建位置,phy_ = (100,100)#碰撞大小)
png1 = PyToolsgr.New("PNG",(100,100)#大小,(0,0)#创建位置)
t1 = PyToolsgr.New("Text",(100,100)#大小,(0,0)#创建位置,text="Hello World",font_size=30)
p1 = PyToolsgr.New("Player",(100,100)#大小,(0,0)#创建位置,"player.png"#玩家贴图)
PyToolsgr.look(p1) # 显示
PyToolsgr.look_n(p1) # 隐藏
PyToolsgr.look_a([p1,b1]) # 显示多个对象 PyToolsgr.look_n_a([p1,b1]) # 隐藏多个对象 PyToolsgr.set_pos(p1,(100,100)) # 设置位置 PyToolsgr.set_pos_a([p1,b1],(100,100)) # 设置多个对象位置
game.run() '''
from bilibili:方块之巢 youtube:Block_Nest
Help Documentation (English Version)
- Create Window
PyToolsgr.OS(OS) # Windows , MacOS , Linux
game = PyToolsgr.game(resolution_array,fullscreen,window_title,resizable,max_fps,show_fps,enable_physics,2d_or_3d)
2D Mode '''python from PyToolsgr import * PyToolsgr.OS('Windows') # or MacOS , Linux
x = (1080,720) # window size all = True # fullscreen title = 'PyToolsgr' # window title y = True # resizable fps = 60 # max fps fpsx = True # show fps phy = True # enable physics mode = '2d' # 2d or 3d
game = PyToolsgr.game(x,all,title,y,fps,fpsx,phy,mode)
PyToolsgr.beijing((0,0,0)) # background color
b1 = PyToolsgr.New("Block",(100,100) # display size,rgb(0,0,0),(0,0)#creation position,phy_ = (100,100)#collision size)
png1 = PyToolsgr.New("PNG",(100,100)#size,(0,0)#creation position)
t1 = PyToolsgr.New("Text",(100,100)#size,(0,0)#creation position,text="Hello World",font_size=30)
p1 = PyToolsgr.New("Player",(100,100)#size,(0,0)#creation position,"player.png"#player texture)
PyToolsgr.look(p1) # show
PyToolsgr.look_n(p1) # hide
PyToolsgr.look_a([p1,b1]) # show multiple objects PyToolsgr.look_n_a([p1,b1]) # hide multiple objects PyToolsgr.set_pos(p1,(100,100)) # set position PyToolsgr.set_pos_a([p1,b1],(100,100)) # set position for multiple objects
game.run() '''
from bilibili:Block Nest youtube:Block_Nest# PyToolsgr - 2D/3D Game Engine based on Ursina
PyToolsgr是一个基于Ursina的轻量级2/3D游戏引擎,旨在简化游戏开发流程,提供直观的API和丰富的功能。
特性
- 🎮 简单易用的2D/3D游戏开发API
- 🚀 基于Ursina引擎,继承其高性能和灵活性
- 📦 开箱即用的游戏对象和组件系统
- 🎨 内置精灵、动画、粒子效果支持
- 🎯 碰撞检测和物理系统
- 🎵 音频管理
- 📱 跨平台支持(Windows, MacOS, Linux)
- 📖 详细的文档和示例
安装
通过pip安装PyToolsgr:
pip install PyToolsgr
快速开始
创建窗口
from PyToolsgr import PyToolsgr
# 设置操作系统
PyToolsgr.OS('Windows')
# 窗口参数
resolution = (1080, 720) # 窗口大小
fullscreen = False # 是否全屏
title = 'PyToolsgr' # 窗口标题
resizable = True # 是否可以调整窗口大小
fps_limit = 60 # 最大帧率
show_fps = True # 是否显示帧率
physics = True # 是否开启物理引擎
mode = '2d' # 2d或3d
# 创建游戏窗口
game = PyToolsgr.game(
resolution=resolution,
fullscreen=fullscreen,
title=title,
resizable=resizable,
fps_limit=fps_limit,
show_fps=show_fps,
physics=physics,
mode=mode
)
# 运行游戏
game.run()
核心概念
- 有2个模式
- 复杂模式:可以有更强的功能但是更难
- 极简模式:新手能轻松上手不需要看复杂的文档
游戏对象
"player" 玩家 "NPC" 游戏NPC “block”方块,一个基本单位,不一定是正方形 "PNG" PNG 的贴图
帮助文档
1. 创建窗口
PyToolsgr.OS(OS) # Windows , MacOS , Linux
game = PyToolsgr.game(分辨率数组,是否全屏,窗口标题,是否可以调整窗口大小,最大帧率,是否显示帧率,是否开启物理引擎,2d或3d)
2. 设置背景颜色
PyToolsgr.beijing((0,0,0)) # 背景颜色,如黑色
3. 创建游戏对象
# 创建方块
b1 = PyToolsgr.New("Block",(100,100),position=(0,0),color=color.red,phy_=(100,100))
# 创建PNG
png1 = PyToolsgr.New("PNG",(100,100),position=(1,0),texture="image.png")
# 创建文本
t1 = PyToolsgr.New("Text",(100,100),position=(0,1),text="Hello World",font_size=30)
# 创建玩家
p1 = PyToolsgr.New("Player",(100,100),position=(-1,0),texture="player.png")
4. 显示/隐藏对象
PyToolsgr.look(p1) # 显示单个对象
PyToolsgr.look_n(p1) # 隐藏单个对象
PyToolsgr.look_a([p1,b1]) # 显示多个对象
PyToolsgr.look_n_a([p1,b1]) # 隐藏多个对象
5. 设置对象位置
PyToolsgr.set_pos(p1,(100,100)) # 设置单个对象位置
PyToolsgr.set_pos_a([p1,b1],(100,100)) # 设置多个对象位置
完整示例代码:
from PyToolsgr import *
PyToolsgr.OS('Windows') # 或MacOS , Linux
x = (1080,720) # 窗口大小
all = True # 是否全屏
title = 'PyToolsgr' # 窗口标题
y = True # 是否可以调整窗口大小
fps = 60 # 最大帧率
fpsx = True # 是否显示帧率
phy = True # 是否开启物理引擎
mode = '2d' # 2d或3d
game = PyToolsgr.game(x,all,title,y,fps,fpsx,phy,mode)
PyToolsgr.beijing((0,0,0)) # 背景颜色
b1 = PyToolsgr.New("Block",(100,100),position=(0,0),color=color.red,phy_=(100,100))
png1 = PyToolsgr.New("PNG",(100,100),position=(1,0))
t1 = PyToolsgr.New("Text",(100,100),position=(0,1),text="Hello World",font_size=30)
p1 = PyToolsgr.New("Player",(100,100),position=(-1,0),texture="white_cube")
PyToolsgr.look(p1) # 显示
PyToolsgr.look_n(p1) # 隐藏
PyToolsgr.look_a([p1,b1]) # 显示多个对象
PyToolsgr.look_n_a([p1,b1]) # 隐藏多个对象
PyToolsgr.set_pos(p1,(100,100)) # 设置位置
PyToolsgr.set_pos_a([p1,b1],(200,200)) # 设置多个对象位置
game.run()
许可证
cfk 使用 MIT 许可证,详情请查看 LICENSE 文件。
鸣谢
联系方式
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytoolsgr-0.0.2.tar.gz.
File metadata
- Download URL: pytoolsgr-0.0.2.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0a72edc294623996d60cc3cb4cc657f7ca9acbb1bf011c40dc316a54e8fd37d
|
|
| MD5 |
3e0c36c67784977b120371bcd882eae9
|
|
| BLAKE2b-256 |
255b3d6c5f039fd60abd382be57027f74b8c332cacaf2d2d9b6741518b6a6764
|
File details
Details for the file pytoolsgr-0.0.2-py3-none-any.whl.
File metadata
- Download URL: pytoolsgr-0.0.2-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e821061b8d1126e32a05c64cd6f833a1929db11feaa6012ca6fa2682e4314f8
|
|
| MD5 |
274c8a093ec5ed5cb413cdf1975d4cae
|
|
| BLAKE2b-256 |
f186177f8b3cd7d28289e044258fc2147d0a640633fe1dcbcee8e98009b4e7f4
|