Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
8e61db6a
宇宙模拟器
项目概览
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看板
提交
8e61db6a
编写于
6月 10, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
e7f55fee
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
22 addition
and
9 deletion
+22
-9
sim_scenes/func.py
sim_scenes/func.py
+4
-1
sim_scenes/solar_system/sun_future_evolution.py
sim_scenes/solar_system/sun_future_evolution.py
+1
-1
simulators/ursina/entities/timer.py
simulators/ursina/entities/timer.py
+3
-1
simulators/ursina_simulator.py
simulators/ursina_simulator.py
+14
-6
未找到文件。
sim_scenes/func.py
浏览文件 @
8e61db6a
...
@@ -115,6 +115,7 @@ def ursina_run(bodies,
...
@@ -115,6 +115,7 @@ def ursina_run(bodies,
show_trail
=
False
,
show_trail
=
False
,
show_name
=
False
,
show_name
=
False
,
show_timer
=
False
,
show_timer
=
False
,
timer_enabled
=
False
,
save_as_json
=
None
,
save_as_json
=
None
,
view_closely
=
False
):
view_closely
=
False
):
"""
"""
...
@@ -128,6 +129,7 @@ def ursina_run(bodies,
...
@@ -128,6 +129,7 @@ def ursina_run(bodies,
@param show_trail: 是否显示拖尾
@param show_trail: 是否显示拖尾
@param show_name: 是否显示天体名称
@param show_name: 是否显示天体名称
@param show_timer: 是否显示计时器
@param show_timer: 是否显示计时器
@param timer_enabled: 计时器是否有效
@param save_as_json: 将所有天体的信息保存为 json 文件
@param save_as_json: 将所有天体的信息保存为 json 文件
@param view_closely: 是否近距离查看天体
@param view_closely: 是否近距离查看天体
@return:
@return:
...
@@ -170,6 +172,7 @@ def ursina_run(bodies,
...
@@ -170,6 +172,7 @@ def ursina_run(bodies,
cosmic_bg
=
cosmic_bg
,
cosmic_bg
=
cosmic_bg
,
show_grid
=
show_grid
,
show_grid
=
show_grid
,
show_timer
=
show_timer
,
show_timer
=
show_timer
,
timer_enabled
=
timer_enabled
,
bg_music
=
bg_music
,
bg_music
=
bg_music
,
view_closely
=
view_closely
)
view_closely
=
view_closely
)
...
@@ -222,7 +225,7 @@ def create_solar_system_bodies(ignore_mass=False, init_velocity=None):
...
@@ -222,7 +225,7 @@ def create_solar_system_bodies(ignore_mass=False, init_velocity=None):
Mercury
(
name
=
"水星"
,
size_scale
=
0.3e3
),
# 水星放大 300 倍,距离保持不变
Mercury
(
name
=
"水星"
,
size_scale
=
0.3e3
),
# 水星放大 300 倍,距离保持不变
Venus
(
name
=
"金星"
,
size_scale
=
0.3e3
),
# 金星放大 300 倍,距离保持不变
Venus
(
name
=
"金星"
,
size_scale
=
0.3e3
),
# 金星放大 300 倍,距离保持不变
Earth
(
name
=
"地球"
,
size_scale
=
0.3e3
),
# 地球放大 300 倍,距离保持不变
Earth
(
name
=
"地球"
,
size_scale
=
0.3e3
),
# 地球放大 300 倍,距离保持不变
Moon
(
name
=
"月球"
,
init_position
=
[
0
,
0
,
363104
+
AU
],
Moon
(
name
=
"月球"
,
init_position
=
[
0
,
0
,
363104
+
AU
],
size_scale
=
0.3e3
),
# 月球放大 300 倍,距离保持不变
size_scale
=
0.3e3
),
# 月球放大 300 倍,距离保持不变
Mars
(
name
=
"火星"
,
size_scale
=
0.3e3
),
# 火星放大 300 倍,距离保持不变
Mars
(
name
=
"火星"
,
size_scale
=
0.3e3
),
# 火星放大 300 倍,距离保持不变
# Asteroids(name="小行星群", size_scale=3.2e2,
# Asteroids(name="小行星群", size_scale=3.2e2,
...
...
sim_scenes/solar_system/sun_future_evolution.py
浏览文件 @
8e61db6a
...
@@ -56,5 +56,5 @@ if __name__ == '__main__':
...
@@ -56,5 +56,5 @@ if __name__ == '__main__':
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
# position = 左-右+、上+下-、前+后-
ursina_run
(
bodies
,
SECONDS_PER_YEAR
,
position
=
(
0
,
10
*
AU
,
-
10
*
AU
),
ursina_run
(
bodies
,
SECONDS_PER_YEAR
,
position
=
(
0
,
10
*
AU
,
-
10
*
AU
),
show_timer
=
True
,
timer_enabled
=
True
,
bg_music
=
"sounds/interstellar.mp3"
)
bg_music
=
"sounds/interstellar.mp3"
)
simulators/ursina/entities/timer.py
浏览文件 @
8e61db6a
...
@@ -16,12 +16,14 @@ from simulators.ursina.ursina_event import UrsinaEvent
...
@@ -16,12 +16,14 @@ from simulators.ursina.ursina_event import UrsinaEvent
class
Timer
(
Text
):
class
Timer
(
Text
):
def
__init__
(
self
):
def
__init__
(
self
,
show
=
True
):
# 创建一个文本对象来显示计时器的时间
# 创建一个文本对象来显示计时器的时间
super
().
__init__
(
text
=
' '
,
position
=
(
0.70
,
-
0.465
),
super
().
__init__
(
text
=
' '
,
position
=
(
0.70
,
-
0.465
),
origin
=
(
-
0.5
,
0.5
),
origin
=
(
-
0.5
,
0.5
),
font
=
UrsinaConfig
.
CN_FONT
,
background
=
True
)
font
=
UrsinaConfig
.
CN_FONT
,
background
=
True
)
UrsinaEvent
.
on_timer_changed_subscription
(
self
.
on_timer_changed
)
UrsinaEvent
.
on_timer_changed_subscription
(
self
.
on_timer_changed
)
if
not
show
:
self
.
enabled
=
False
def
on_timer_changed
(
self
,
time_data
:
TimeData
):
def
on_timer_changed
(
self
,
time_data
:
TimeData
):
self
.
text
=
time_data
.
time_text
self
.
text
=
time_data
.
time_text
...
...
simulators/ursina_simulator.py
浏览文件 @
8e61db6a
...
@@ -209,14 +209,14 @@ class UrsinaSimulator(Simulator):
...
@@ -209,14 +209,14 @@ class UrsinaSimulator(Simulator):
evolve_dt
=
evolve_dt
*
self
.
interval_fator
evolve_dt
=
evolve_dt
*
self
.
interval_fator
super
().
evolve
(
evolve_dt
)
super
().
evolve
(
evolve_dt
)
if
self
.
show_timer
:
if
self
.
show_timer
or
self
.
timer_enabled
:
timer
=
BodyTimer
()
timer
=
BodyTimer
()
timer
.
calc_time
(
evolve_dt
)
timer
.
calc_time
(
evolve_dt
)
def
create_timer
(
self
):
def
create_timer
(
self
,
show
=
True
):
from
simulators.ursina.entities.timer
import
Timer
from
simulators.ursina.entities.timer
import
Timer
# 创建一个文本对象来显示计时器的时间
# 创建一个文本对象来显示计时器的时间
self
.
timer
=
Timer
()
self
.
timer
=
Timer
(
show
)
return
self
.
timer
return
self
.
timer
def
cosmic_background
(
self
,
texture
=
'../textures/cosmic2.jpg'
):
def
cosmic_background
(
self
,
texture
=
'../textures/cosmic2.jpg'
):
...
@@ -262,6 +262,10 @@ class UrsinaSimulator(Simulator):
...
@@ -262,6 +262,10 @@ class UrsinaSimulator(Simulator):
if
"show_timer"
in
kwargs
:
if
"show_timer"
in
kwargs
:
self
.
show_timer
=
kwargs
[
"show_timer"
]
self
.
show_timer
=
kwargs
[
"show_timer"
]
self
.
timer_enabled
=
False
if
"timer_enabled"
in
kwargs
:
self
.
timer_enabled
=
kwargs
[
"timer_enabled"
]
if
view_closely
:
if
view_closely
:
# 近距离查看
# 近距离查看
if
isinstance
(
view_closely
,
float
):
if
isinstance
(
view_closely
,
float
):
...
@@ -314,9 +318,13 @@ class UrsinaSimulator(Simulator):
...
@@ -314,9 +318,13 @@ class UrsinaSimulator(Simulator):
if
cosmic_bg
is
not
None
and
os
.
path
.
exists
(
cosmic_bg
):
if
cosmic_bg
is
not
None
and
os
.
path
.
exists
(
cosmic_bg
):
self
.
cosmic_background
(
cosmic_bg
)
self
.
cosmic_background
(
cosmic_bg
)
if
self
.
show_timer
:
if
self
.
show_timer
:
self
.
create_timer
()
self
.
timer_enabled
=
True
# 创建和显示计时器
self
.
create_timer
(
True
)
elif
self
.
timer_enabled
:
# 创建计时器,但是不显示
self
.
create_timer
(
False
)
# 防止打开中文输入法
# 防止打开中文输入法
# self.switch_to_english_input_method()
# self.switch_to_english_input_method()
...
@@ -346,7 +354,7 @@ class UrsinaSimulator(Simulator):
...
@@ -346,7 +354,7 @@ class UrsinaSimulator(Simulator):
EditorCamera
(
ignore_paused
=
True
)
EditorCamera
(
ignore_paused
=
True
)
if
self
.
show_timer
:
if
self
.
show_timer
or
self
.
timer_enabled
:
UrsinaEvent
.
on_reset
()
UrsinaEvent
.
on_reset
()
UrsinaEvent
.
on_ready
()
UrsinaEvent
.
on_ready
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录