ursina_config.py 1.7 KB
Newer Older
三月三net's avatar
三月三net 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# -*- coding:utf-8 -*-
# title           :ursina天体运行模拟器
# description     :ursina天体运行模拟器
# author          :Python超人
# date            :2023-02-11
# link            :https://gitcode.net/pythoncr/
# python_version  :3.8
# ==============================================================================
# pip install -i http://pypi.douban.com/simple/ --trusted-host=pypi.douban.com ursina


class UrsinaConfig:
    # 常量定义
    # 天体缩放的因子(不能太大,否则无法容得下大数量级的天体)
    SCALE_FACTOR = 5e-10
    # 旋转因子为1,则为正常的转速
    ROTATION_SPEED_FACTOR = 1.0
三月三net's avatar
三月三net 已提交
18
    # ROTATION_SPEED_FACTOR = 0.01
三月三net's avatar
三月三net 已提交
19 20 21 22 23 24 25 26 27 28

    # 速度的倍数
    __run_speed_factor = 1.0

    # 天体自旋倍数
    __body_spin_factor = 1.0

    # 摄像机
    __camera_factor = 1.0

三月三net's avatar
三月三net 已提交
29 30
    __on_reset_funcs = []

三月三net's avatar
三月三net 已提交
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
    @property
    @classmethod
    def run_speed_factor(cls):
        return cls.__run_speed_factor

    @run_speed_factor.setter
    @classmethod
    def run_speed_factor(cls, value):
        cls.__run_speed_factor = value

    @property
    @classmethod
    def body_spin_factor(cls):
        return cls.__body_spin_factor

    @body_spin_factor.setter
    @classmethod
    def body_spin_factor(cls, value):
        cls.__body_spin_factor = value

三月三net's avatar
三月三net 已提交
51 52 53 54 55 56 57 58 59
    @classmethod
    def on_reset_subscription(cls, fun):
        cls.__on_reset_funcs.append(fun)

    @classmethod
    def on_reset(cls):
        for f in cls.__on_reset_funcs:
            f()

三月三net's avatar
三月三net 已提交
60 61 62 63 64 65 66 67

# 初始化
UrsinaConfig.run_speed_factor = 1.0
UrsinaConfig.body_spin_factor = 1.0

if __name__ == '__main__':
    UrsinaConfig.run_speed_factor = 2.0
    print(UrsinaConfig.run_speed_factor)