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

太阳系三体模拟器

上级 f95351fe
......@@ -227,10 +227,17 @@ class ControlHandler(EventHandler):
elif key == '-' or key == "- up":
self.slider_decrease(self.ui.slider_run_speed_factor)
elif key == 'n':
import math
# min=0.01, max=20
# # ', up' < > '. up' n m
self.slider_decrease(self.ui.slider_control_speed_factor, 10)
self.ui.slider_control_speed_factor.current_step = self.ui.slider_control_speed_factor.value/2
self.slider_decrease(self.ui.slider_control_speed_factor, self.ui.slider_control_speed_factor.current_step)
print(self.ui.slider_control_speed_factor.current_step)
elif key == 'm':
self.slider_increase(self.ui.slider_control_speed_factor, 10)
self.ui.slider_control_speed_factor.current_step = self.ui.slider_control_speed_factor.value
self.slider_increase(self.ui.slider_control_speed_factor, self.ui.slider_control_speed_factor.current_step)
print(self.ui.slider_control_speed_factor.current_step)
def slider_increase(self, slider, step=50):
"""
......@@ -239,7 +246,7 @@ class ControlHandler(EventHandler):
@param step:
@return:
"""
run_speed_factor = slider.value + slider.step * step
run_speed_factor = slider.value + step
if run_speed_factor > slider.max:
run_speed_factor = slider.max
slider.value = run_speed_factor
......@@ -252,7 +259,7 @@ class ControlHandler(EventHandler):
@param step:
@return:
"""
value = slider.value - slider.step * step
value = slider.value - step
if value < slider.min:
value = slider.min
slider.value = value
......
......@@ -30,10 +30,11 @@ class ControlUI(UiPanel):
self.no_trail_button_text = "○ "
self.trail_button_text = "○--"
self.slider_body_spin_factor = UiSlider(text='自转速度', min=0.01, max=30, default=1)
self.slider_body_spin_factor = UiSlider(text='自转速度', min=0.01, max=5, default=1)
self.slider_body_size_factor = UiSlider(text='天体缩放', min=0.1, max=100, step=0.1, default=1)
self.slider_run_speed_factor = UiSlider(text="运行速度", min=0.01, max=80, default=1)
self.slider_control_speed_factor = UiSlider(text="控制速度", min=0.01, max=20, default=application.time_scale)
self.slider_control_speed_factor = UiSlider(text="控制速度", min=0.01, max=20,
step=0.1, default=application.time_scale)
self.slider_trail_length = UiSlider(text="拖尾长度", min=30, max=500, step=10, default=UrsinaConfig.trail_length)
self.on_off_switch = SwithButton((self.pause_button_text,
......
......@@ -285,9 +285,16 @@ class Planet(Entity):
self.clear_trails()
if hasattr(self, "name_text"):
# 计算相机和实体之间的距离
distance = (camera.world_position - self.world_position).length()
# 根据距离设置文本缩放比例
d = (camera.world_position - self.name_text.world_position).length()
if d < self.scale_x * 1.22:
self.name_text.visible = False
else:
self.name_text.visible = True
# print(d, self.name_text.text, self.scale_x ,self.scale_x*1.23)
# # 计算相机和实体之间的距离
# distance = (camera.world_position - self.world_position).length()
# # 根据距离设置文本缩放比例
# self.name_text.scale = distance / 10
def follow_parent(self):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册