Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
5552d087
宇宙模拟器
项目概览
Python_超人
/
宇宙模拟器
通知
19
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
宇宙模拟器
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
5552d087
编写于
7月 04, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
ada551d3
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
33 addition
and
3 deletion
+33
-3
sim_scenes/func.py
sim_scenes/func.py
+4
-0
sim_scenes/science/speed_of_light_3d.py
sim_scenes/science/speed_of_light_3d.py
+10
-2
simulators/ursina/ursina_event.py
simulators/ursina/ursina_event.py
+15
-0
simulators/ursina_simulator.py
simulators/ursina_simulator.py
+4
-1
未找到文件。
sim_scenes/func.py
浏览文件 @
5552d087
...
...
@@ -307,11 +307,15 @@ def create_3d_card(left=-.885, top=0.495, width=0.02, height=0.02):
position
=
(
left
,
top
,
0
)
)
panel
.
switch_flag
=
0
def
switch_color
():
if
panel
.
color
==
color
.
black
:
panel
.
color
=
color
.
white
panel
.
switch_flag
=
1
else
:
panel
.
color
=
color
.
black
panel
.
switch_flag
=
0
panel
.
switch_color
=
switch_color
...
...
sim_scenes/science/speed_of_light_3d.py
浏览文件 @
5552d087
...
...
@@ -98,12 +98,18 @@ def on_timer_changed(time_data: TimeData):
distance
=
round
(
init
.
light_ship
.
position
[
2
]
/
AU
,
4
)
text
=
init
.
arrived_info
.
replace
(
"${distance}"
,
"%.4f AU"
%
distance
)
init
.
text_panel
.
text
=
text
.
replace
(
"${speed}"
,
str
(
round
(
velocity
/
LIGHT_SPEED
,
1
))
+
"倍光速"
)
init
.
_3d_card
.
switch_color
()
light_ship
.
switch_position
()
# if time_data.total_seconds > 20:
# wait_for(0.03)
def
on_before_evolving
(
evolve_args
):
init
.
_3d_card
.
switch_color
()
light_ship
.
switch_position
()
if
init
.
_3d_card
.
switch_flag
==
1
:
evolve_args
[
"evolve_dt"
]
=
0.0
# 订阅重新开始事件
# 按键盘的 “O” 重置键会触发 on_reset
UrsinaEvent
.
on_reset_subscription
(
on_reset
)
...
...
@@ -113,6 +119,8 @@ UrsinaEvent.on_ready_subscription(on_ready)
# 运行中,每时每刻都会触发 on_timer_changed
UrsinaEvent
.
on_timer_changed_subscription
(
on_timer_changed
)
UrsinaEvent
.
on_before_evolving_subscription
(
on_before_evolving
)
def
body_arrived
(
body
):
# # 到达每个行星都会触发,对光速飞船进行加速,超光速前进(使用未来曲率引擎技术)
...
...
simulators/ursina/ursina_event.py
浏览文件 @
5552d087
...
...
@@ -36,6 +36,8 @@ class UrsinaEvent:
UrsinaEvent
.
on_body_size_changed_callback
=
[]
# 逐步演变触发的订阅事件
UrsinaEvent
.
on_evolving_callback
=
[]
# 逐步演变触发前的订阅事件
UrsinaEvent
.
on_before_evolving_callback
=
[]
# 计时器触发的订阅事件
UrsinaEvent
.
on_timer_changed_callback
=
[]
...
...
@@ -78,6 +80,19 @@ class UrsinaEvent:
for
f
in
UrsinaEvent
.
on_evolving_callback
:
f
(
evolve_dt
)
@
staticmethod
def
on_before_evolving_subscription
(
fun
):
UrsinaEvent
.
on_before_evolving_callback
.
append
(
fun
)
@
staticmethod
def
on_before_evolving_unsubscription
(
fun
):
UrsinaEvent
.
on_before_evolving_callback
.
remove
(
fun
)
@
staticmethod
def
on_before_evolving
(
evolve_args
):
for
f
in
UrsinaEvent
.
on_before_evolving_callback
:
f
(
evolve_args
)
@
staticmethod
def
on_application_run_callback_subscription
(
fun
):
UrsinaEvent
.
on_application_run_callback
.
append
(
fun
)
...
...
simulators/ursina_simulator.py
浏览文件 @
5552d087
...
...
@@ -224,7 +224,10 @@ class UrsinaSimulator(Simulator):
UrsinaEvent
.
on_evolving
(
evolve_dt
)
# interval_fator 能让更新天体运行状态(位置、速度)更精确
evolve_dt
=
evolve_dt
*
self
.
interval_fator
super
().
evolve
(
evolve_dt
)
evolve_args
=
{
"evolve_dt"
:
evolve_dt
}
UrsinaEvent
.
on_before_evolving
(
evolve_args
)
# if evolve_args["evolve_dt"] > 0:
super
().
evolve
(
evolve_args
[
"evolve_dt"
])
if
self
.
show_timer
or
self
.
timer_enabled
:
timer
=
BodyTimer
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录