Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
70bcc5dc
宇宙模拟器
项目概览
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看板
提交
70bcc5dc
编写于
12月 29, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
04ddaea2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
12 addition
and
1 deletion
+12
-1
sim_scenes/featured/jupiter_moon_protects_earth.py
sim_scenes/featured/jupiter_moon_protects_earth.py
+12
-1
未找到文件。
sim_scenes/featured/jupiter_moon_protects_earth.py
浏览文件 @
70bcc5dc
...
@@ -13,6 +13,7 @@ from common.consts import SECONDS_PER_MONTH, SECONDS_PER_YEAR, AU
...
@@ -13,6 +13,7 @@ from common.consts import SECONDS_PER_MONTH, SECONDS_PER_YEAR, AU
from
sim_scenes.func
import
ursina_run
,
camera_look_at
,
two_bodies_colliding
,
create_text_panel
,
create_sphere_sky
from
sim_scenes.func
import
ursina_run
,
camera_look_at
,
two_bodies_colliding
,
create_text_panel
,
create_sphere_sky
from
simulators.ursina.entities.body_timer
import
TimeData
,
BodyTimer
from
simulators.ursina.entities.body_timer
import
TimeData
,
BodyTimer
from
simulators.ursina.entities.entity_utils
import
create_directional_light
from
simulators.ursina.entities.entity_utils
import
create_directional_light
from
simulators.ursina.ursina_config
import
UrsinaConfig
from
simulators.ursina.ursina_event
import
UrsinaEvent
from
simulators.ursina.ursina_event
import
UrsinaEvent
import
random
import
random
import
math
import
math
...
@@ -98,6 +99,7 @@ class JupiterMoonProtectsEarthSim:
...
@@ -98,6 +99,7 @@ class JupiterMoonProtectsEarthSim:
init_position
=
pos
,
init_velocity
=
vel
,
gravity_only_for
=
gravity_only_for
init_position
=
pos
,
init_velocity
=
vel
,
gravity_only_for
=
gravity_only_for
)
)
rock
.
set_light_disable
(
True
)
rock
.
set_light_disable
(
True
)
rock
.
trail_color
=
(
255
,
255
,
255
)
# 给石头一个随机旋转的方向和值
# 给石头一个随机旋转的方向和值
rock
.
rotation
=
[
0
,
0
,
0
]
rock
.
rotation
=
[
0
,
0
,
0
]
rock
.
rotation
[
random
.
randint
(
0
,
2
)]
=
random
.
randint
(
90
,
200
)
/
100
rock
.
rotation
[
random
.
randint
(
0
,
2
)]
=
random
.
randint
(
90
,
200
)
/
100
...
@@ -192,6 +194,12 @@ class JupiterMoonProtectsEarthSim:
...
@@ -192,6 +194,12 @@ class JupiterMoonProtectsEarthSim:
j_protected_cnt
,
m_protected_cnt
)
j_protected_cnt
,
m_protected_cnt
)
self
.
text_panel
.
text
=
colliding_info
self
.
text_panel
.
text
=
colliding_info
self
.
camera_move
(
time_data
)
def
camera_move
(
self
,
time_data
):
from
ursina
import
camera
camera
.
position
+=
camera
.
left
*
0.1
camera_look_at
(
self
.
sun
)
def
on_ready
(
self
):
def
on_ready
(
self
):
from
ursina
import
application
from
ursina
import
application
...
@@ -218,6 +226,9 @@ if __name__ == '__main__':
...
@@ -218,6 +226,9 @@ if __name__ == '__main__':
# 设置计时器的最小时间单位为年
# 设置计时器的最小时间单位为年
BodyTimer
().
min_unit
=
BodyTimer
.
MIN_UNIT_YEARS
BodyTimer
().
min_unit
=
BodyTimer
.
MIN_UNIT_YEARS
UrsinaConfig
.
trail_type
=
"curve_line"
# UrsinaConfig.trail_type = "line"
UrsinaConfig
.
trail_length
=
30
sim
=
JupiterMoonProtectsEarthSim
(
comet_num
=
30
)
sim
=
JupiterMoonProtectsEarthSim
(
comet_num
=
30
)
...
@@ -229,7 +240,7 @@ if __name__ == '__main__':
...
@@ -229,7 +240,7 @@ if __name__ == '__main__':
# 使用 ursina 查看的运行效果
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
# position = 左-右+、上+下-、前+后-
ursina_run
(
sim
.
bodies
,
SECONDS_PER_MONTH
*
3
,
ursina_run
(
sim
.
bodies
,
SECONDS_PER_MONTH
*
3
0
,
position
=
(
AU
,
AU
*
5
,
-
AU
*
5
),
position
=
(
AU
,
AU
*
5
,
-
AU
*
5
),
cosmic_bg
=
''
,
cosmic_bg
=
''
,
show_grid
=
False
,
show_grid
=
False
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录