ursina

pokepetterMIT活跃维护

用 Python 就能写 3D 和 2D 游戏的轻量引擎,API 简单,适合快速做原型、教学和小型独立游戏。

A 3D and 2D game engine for Python

暂无版本2,604star358fork同步于 2026-11-11 05:41 UTC

怎么上手

由 README 提炼,执行前请确认
pip install ursina
硬件要求按 README 说明

README 未说明具体显存或 GPU 型号要求;依赖 Panda3D 渲染,需能运行图形窗口的环境。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

用 Python 写 3D/2D 游戏的轻量引擎,几行代码就能开窗口跑起来

用 Python 就能写 3D 和 2D 游戏的轻量引擎,API 简单,适合快速做原型、教学和小型独立游戏。

核心能力

  • 用 Entity 一行创建带模型、颜色、碰撞体的物体
  • 内置 update 循环与 held_keys 键盘输入处理
  • 自带 3D 关卡编辑器与常用 prefab 组件
  • 提供程序化生成模型如 Cylinder、Quad、Terrain
  • 内置音频、字体与示例游戏可直接参考

容易踩的坑

需要 Python 3.10 或更新版本,旧版本无法安装;psd/blend 转换、剪贴板等为可选依赖,需另装 ursina[extras];部分系统要用 pip3 或 python3.xx -m pip 指定 Python 3。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

0 个版本

暂无 release 数据(可能没有发版,或尚未同步)。

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    ursina ʕ •ᴥ•ʔゝ□

    Website | Discord | Twitter | Patreon | Sponsor

    An easy to use game engine/framework for python.

    Banner

    Trailer

    Getting Started

    1. Install Python 3.10 or newer.

    2. Open cmd/terminal and type:

    pip install ursina
    

    To get the newest, in development version from GitHub, install it like this:

    pip install git+https://github.com/pokepetter/ursina.git
    

    If you want to easily edit the source, it's recommended to clone the git repo and pip install with --editable flag like this. Make sure you have git installed.

    git clone https://github.com/pokepetter/ursina.git
    cd ursina
    pip install --editable .
    

    Also install any of the optional dependencies you want from the list below, or install them all with:

    pip install ursina[extras]
    

    On some systems you might have to use pip3 instead of pip in order to use Python 3 and not the old Python 2. To use a specific Python version, use:

    python3.xx -m pip install ursina
    

    Where 3.xx is the version you want to target.

    Dependencies

    • python 3.10+
    • panda3d
    • pillow, for texture manipulation
    • psd-tools, for converting .psd files
    • blender, for converting .blend files
    • pyperclip, for copy/pasting

    Examples

    from ursina import *            # this will import everything we need from ursina with just one line.
    
    app = Ursina()
    ground = Entity(
        model = 'cube',
        color = color.magenta,
        z = -.1,
        y = -3,
        origin = (0, .5),
        scale = (50, 1, 10),
        collider = 'box',
        )
    
    app.run()                       # opens a window and starts the game.
    

    There are other examples in the samples folder, or in samples website

    How do I make a game?

    Ursina games are made by writing Python code. You can use any text editor you want, but personally I like to use Atom.

    1. Create an empty .py file called ursina_game.py
    2. Copy this text into your new file:
    from ursina import *           # this will import everything we need from ursina with just one line.
    
    app = Ursina()
    
    player = Entity(
        model = 'cube' ,           # finds a 3d model by name
        color = color.orange,
        scale_y = 2
        )
    
    def update():                  # update gets automatically called by the engine.
        player.x += held_keys['d'] * .1
        player.x -= held_keys['a'] * .1
    
    
    app.run()                     # opens a window and starts the game.
    
    1. Run this in the terminal start the game:

      python ursina_game.py
      

      ... or run it with your editor/IDE of choice.

    2. You can now move the orange box around with 'a' and 'd'!

      To close the window, you can by default, press control+shift+alt+q or press the red x.

    Documentation

    Found a bug? Posting it in Issues. Fixed a bug? Make a pull request.

    Project Structure

    ## Project Structure
    
    📁docs
        📃index.txt
        📃documentation.txt
        📃inventory_tutorial.txt
        ...
            # text files for the website. gets turned into .html files with sswg.
    
        📃cheat_sheet.html
            # auto generated documentation made with documentation_generator.py.
    
        📃tutorial_generator.py
            # turns specific .py files into .txt files, which can then be turned into .html by sswg.
            # this extracts the comments from the source files into description for that step and the code after into code blocks.
            # see platformer_tutorial.py for an example.
    
    📁samples               # small example games.
    
    📁ursina                # the actual ursina module.
        📁audio                 # built-in audio clips.
        📁editor                # the 3d level editor for ursina.
        📁fonts                 # built-in fonts.
        📁models                # .blend files, source files, for built-in 3d models.
            📁procedural            # classes for generating 3d models, like Cylinder, Quad and Terrain.
        📁models_compressed     # .blend files converted to .ursinamesh.
        📁prefabs               # higher level classes like Draggable, Slider, Sprite, etc.
    
        📃__init__.py
        📃application.py
        📃audio.py
        ...
            # ursina base modules, like code for Entity, input_handler, Text, window and so on.