提交 d781ef11 编写于 作者: 三月三net's avatar 三月三net

Python超人-宇宙模拟器

上级 d312a416
......@@ -146,7 +146,7 @@ def get_acceleration_info(acceleration):
acc_value = acceleration
acc_m = acc_value * 1000 # 加速度的值(m/s²)
# "\n\n当前速度:%s km/s" % "{:.3f}".format(velocity).rjust(6, "0")
if acc_m >= 0.01:
acc_info = "%.2f m/s²" % (acc_m)
elif acc_m >= 0.00001:
......@@ -155,6 +155,7 @@ def get_acceleration_info(acceleration):
# acc_info = "%.2fμm/s²" % (acc_m * 1000 * 1000)
else:
acc_info = "0 m/s²"
return acc_info
......
......@@ -92,8 +92,8 @@ class EarthOrbitStoppedSim(UniverseSimScenes):
replace("${velocity}", "0"). \
replace("${acceleration}", "0")
sky = create_sphere_sky(scale=10000)
sky.rotation_y = 180
self.sky = create_sphere_sky(scale=10000)
self.sky.rotation_y = 180
# sky.rotation_x = 20
# sky.rotation_z = -65
......@@ -103,9 +103,10 @@ class EarthOrbitStoppedSim(UniverseSimScenes):
self.venus_orbit_line = create_orbit_line(self.sun, self.venus, thickness=3, alpha=0.3)
def show_message(self, msg):
ControlUI.current_ui.show_message(msg, font="fonts/DroidSansFallback.ttf", close_time=-1)
ControlUI.current_ui.show_message(msg, font="fonts/DroidSansFallback.ttf", close_time=6)
def on_timer_changed(self, time_data: TimeData):
self.sky.rotation_z += 0.005
# 摄像机时时刻刻看向地球
camera_look_at(self.earth, rotation_z=0)
# 获取地球当前的位置,让摄像机跟随地球
......@@ -121,13 +122,13 @@ class EarthOrbitStoppedSim(UniverseSimScenes):
distance = distance - self.sun.radius - self.earth.radius
if distance > 100000000:
distance_str = "%s亿" % round(distance / 100000000.0, 2)
distance_str = "%.2f亿" % round(distance / 100000000.0, 2)
# elif distance > 10000000:
# distance_str = "%s千万" % round(distance / 10000000.0, 2)
# elif distance > 1000000:
# distance_str = "%s百万" % round(distance / 1000000.0, 2)
elif distance > 10000:
distance_str = "%s万" % round(distance / 10000.0, 2)
distance_str = "%.2f万" % round(distance / 10000.0, 2)
else:
distance_str = round(distance, 2)
......@@ -138,7 +139,7 @@ class EarthOrbitStoppedSim(UniverseSimScenes):
self.text_panel.text = self.arrived_info. \
replace("${distance}", "0 km"). \
replace("${acceleration}", "%s" % acceleration_info). \
replace("${velocity}", "%s km/s" % round(velocity, 2)) \
replace("${velocity}", "%.2f km/s" % round(velocity, 2)) \
+ "\n\n" + msg
self.show_message(msg)
application.pause()
......@@ -216,7 +217,7 @@ class EarthOrbitStoppedSim(UniverseSimScenes):
self.text_panel.text = self.arrived_info. \
replace("${distance}", "%s km" % distance_str). \
replace("${acceleration}", "%s" % acceleration_info). \
replace("${velocity}", "%s km/s" % round(velocity, 2))
replace("${velocity}", "%.2f km/s" % round(velocity, 2))
if __name__ == '__main__':
......@@ -248,7 +249,8 @@ if __name__ == '__main__':
# 订阅事件后,上面的函数功能才会起作用
# 运行中,每时每刻都会触发 on_timer_changed
UrsinaEvent.on_timer_changed_subscription(sim.on_timer_changed)
UniverseSimScenes.set_window_size((1400, 700))
# UniverseSimScenes.set_window_size((1400, 700))
UniverseSimScenes.set_window_size((1920, 1079), False)
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册