# -*- coding:utf-8 -*- # title :宇宙体 # description :模拟一个宇宙体 # author :Python超人 # date :2023-11-17 # link :https://gitcode.net/pythoncr/ # python_version :3.9 # ============================================================================== from bodies import Body class UniverseBody(Body): def __init__(self, name="宇宙体", mass=1.9891e35, init_position=[0, 0, 0], init_velocity=[0, 0, 0], color=(0, 0, 0), texture=None, density=1.408e20, size_scale=1.0, distance_scale=1.0, rotation_speed=0, ignore_mass=False, trail_color=None, show_name=False): params = { "name": name, "mass": mass, "init_position": init_position, "init_velocity": init_velocity, "density": density, "color": color, "texture": texture, "size_scale": size_scale * 10000, "distance_scale": distance_scale, "rotation_speed": rotation_speed, "ignore_mass": ignore_mass, "trail_color": trail_color, "show_name": show_name } super().__init__(**params) # self.set_resolution(50) self.set_ignore_gravity(True) self.set_light_disable(False) class OursUniverse(UniverseBody): def __init__(self, name="我们的宇宙", size_scale=1.0, init_position=[0, 0, 0], init_velocity=[0, 0, 0]): params = { "name": name, "mass": 1.9891e35, "init_position": init_position, "init_velocity": init_velocity, "density": 1.408e20, # "color": color, "texture": 'bg_pan.jpg', "size_scale": size_scale, # "distance_scale": distance_scale, # "ignore_mass": ignore_mass, # "trail_color": trail_color, # "show_name": show_name } super().__init__(**params) def create_universe_body(name, texture, size_scale=1.0, init_position=[0, 0, 0], init_velocity=[0, 0, 0]): params = { "name": name, "mass": 1.9891e35, "init_position": init_position, "init_velocity": init_velocity, "density": 1.408e20, # "color": color, "texture": texture, "size_scale": size_scale, } return UniverseBody(**params)