Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
太阳系三体模拟器
提交
47cb71fb
太阳系三体模拟器
项目概览
Python_超人
/
太阳系三体模拟器
通知
1263
Star
135
Fork
133
代码
文件
提交
分支
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看板
提交
47cb71fb
编写于
3月 17, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
太阳系三体模拟器
上级
c4b029ee
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
46 addition
and
43 deletion
+46
-43
simulators/ursina/ursina_event.py
simulators/ursina/ursina_event.py
+2
-2
simulators/ursina/ursina_ui.py
simulators/ursina/ursina_ui.py
+44
-41
未找到文件。
simulators/ursina/ursina_event.py
浏览文件 @
47cb71fb
# -*- coding:utf-8 -*-
# title :ursina天体运行模拟器
# description :ursina天体运行模拟器
# title :ursina天体运行模拟器
事件传递
# description :ursina天体运行模拟器
事件传递
# author :Python超人
# date :2023-02-11
# link :https://gitcode.net/pythoncr/
...
...
simulators/ursina/ursina_ui.py
浏览文件 @
47cb71fb
...
...
@@ -92,7 +92,7 @@ class UrsinaUI:
self
.
slider_run_speed_factor
,
self
.
slider_control_speed_factor
),
ignore_paused
=
True
,
color
=
color
.
rgba
(
0.0
,
0.0
,
0.0
,
0.5
),
popup
=
True
),
ignore_paused
=
True
,
color
=
color
.
rgba
(
0.0
,
0.0
,
0.0
,
0.5
)
#
, popup=True
)
self
.
sec_per_time_switch
.
x
=
-
0.5
self
.
on_off_switch
.
x
=
-
0.2
...
...
@@ -101,19 +101,21 @@ class UrsinaUI:
wp
.
x
=
0.6
# wp.scale_x + 0.1
# wp.x = 0#wp.panel.scale_x / 2 * wp.scale_x
self
.
wp
=
wp
self
.
wp
.
enabled
=
False
def
__init__
(
self
):
self
.
ui_component_init
()
# self.pause
_handler = Entity(ignore_paused=True)
self
.
settings
_handler
=
Entity
(
ignore_paused
=
True
)
# 加载中文字体文件
# text_time_scale = "1"
# self.text_time_scale_info = None
# self.pause_handler.input = self.pause
_handler_input
self
.
settings_handler
.
input
=
self
.
settings
_handler_input
# self.show_text_time_scale_info()
# key_info_str = "退出[按2次ESC] 方位控制[鼠标QWEASD] 开始暂停[空格] 控制倍率[Tab - +]"
# key_info = Text(text=key_info_str, position=(-0.8, 0.5), origin=(-1, 1), background=True)
key_info_str
=
"按[空格]设置"
key_info
=
Text
(
text
=
key_info_str
,
font
=
UrsinaConfig
.
CN_FONT
,
position
=
(
-
0.5
,
0.5
),
origin
=
(
-
1
,
1
),
background
=
True
)
# # self.show_button()
# slider_text = Text(text='自转速度', scale=1, position=(-0.6, 0.3))
# slider = Slider(scale=0.5, position=(-0.6, 0), min=0, max=10, step=1, text=slider_text)
...
...
@@ -125,7 +127,8 @@ class UrsinaUI:
UrsinaConfig
.
show_trail
=
False
def
bodies_button_list_click
(
self
,
item
):
print
(
"select->"
,
item
)
if
item
is
not
None
:
print
(
"select->"
,
item
)
destroy
(
self
.
bodies_button_list
)
...
...
@@ -134,7 +137,7 @@ class UrsinaUI:
if
len
(
results
)
>
0
:
sub_name
,
bodies
=
results
[
0
]
# print(results[0])
button_dict
=
{}
button_dict
=
{
"[关闭]"
:
lambda
:
self
.
bodies_button_list_click
(
None
)
}
for
body
in
bodies
:
def
callback_action
(
b
=
body
):
...
...
@@ -185,8 +188,8 @@ class UrsinaUI:
text_time_scale
=
"控制倍率:"
+
str
(
application
.
time_scale
).
ljust
(
4
,
" "
)
text_time_scale_info
=
Text
(
text
=
text_time_scale
,
position
=
(
-
0.8
,
0.5
),
origin
=
(
-
1
,
1
),
background
=
True
)
def
show_button
(
self
):
b
=
Button
(
scale
=
(
0
,
.
25
),
text
=
'zzz'
)
#
def show_button(self):
#
b = Button(scale=(0, .25), text='zzz')
# if key == "escape":
# if mouse.locked:
...
...
@@ -195,40 +198,40 @@ class UrsinaUI:
# sys.exit()
# 按空格键则暂停
def
pause
_handler_input
(
self
,
key
):
def
settings
_handler_input
(
self
,
key
):
import
sys
time_scales
=
[
0.05
,
0.1
,
0.2
,
0.5
,
1
,
5
,
10
,
20
,
30
]
if
key
==
"escape"
:
sys
.
exit
()
# print(key)
elif
key
==
'space'
:
application
.
paused
=
not
application
.
paused
# Pause/unpause the game.
elif
key
==
'tab'
:
# application.time_scale 属性控制游戏时间流逝的速度。
# 具体来说,它是一个浮点数,用于调整游戏时间流逝速度的比例,其默认值为 1.0,表示正常速度。
# 当你将它设置为小于 1.0 的值时,游戏时间会变慢,而设置为大于 1.0 的值时,游戏时间则会变快。
for
idx
,
time_scale
in
enumerate
(
time_scales
):
if
float
(
application
.
time_scale
)
==
time_scale
:
if
idx
<
len
(
time_scales
)
-
1
:
application
.
time_scale
=
time_scales
[
idx
+
1
]
break
else
:
application
.
time_scale
=
time_scales
[
0
]
elif
key
==
'+'
:
UrsinaConfig
.
run_speed_factor
*=
2
elif
key
==
"= up"
:
UrsinaConfig
.
body_spin_factor
*=
2
# if application.time_scale in time_scales:
# idx = time_scales.index(application.time_scale)
# if idx < len(time_scales) - 1:
# application.time_scale = time_scales[idx + 1]
elif
key
==
'-'
:
UrsinaConfig
.
run_speed_factor
*=
0.5
elif
key
==
"- up"
:
UrsinaConfig
.
body_spin_factor
*=
0.5
# if application.time_scale in time_scales:
# idx = time_scales.index(application.time_scale)
# if idx > 0:
# application.time_scale = time_scales[idx - 1]
self
.
show_text_time_scale_info
()
self
.
wp
.
enabled
=
not
self
.
wp
.
enabled
# application.paused = not application.paused # Pause/unpause the game.
# elif key == 'tab':
# # application.time_scale 属性控制游戏时间流逝的速度。
# # 具体来说,它是一个浮点数,用于调整游戏时间流逝速度的比例,其默认值为 1.0,表示正常速度。
# # 当你将它设置为小于 1.0 的值时,游戏时间会变慢,而设置为大于 1.0 的值时,游戏时间则会变快。
# for idx, time_scale in enumerate(time_scales):
# if float(application.time_scale) == time_scale:
# if idx < len(time_scales) - 1:
# application.time_scale = time_scales[idx + 1]
# break
# else:
# application.time_scale = time_scales[0]
# elif key == '+':
# UrsinaConfig.run_speed_factor *= 2
# elif key == "= up":
# UrsinaConfig.body_spin_factor *= 2
# # if application.time_scale in time_scales:
# # idx = time_scales.index(application.time_scale)
# # if idx < len(time_scales) - 1:
# # application.time_scale = time_scales[idx + 1]
# elif key == '-':
# UrsinaConfig.run_speed_factor *= 0.5
# elif key == "- up":
# UrsinaConfig.body_spin_factor *= 0.5
# # if application.time_scale in time_scales:
# # idx = time_scales.index(application.time_scale)
# # if idx > 0:
# # application.time_scale = time_scales[idx - 1]
#
# self.show_text_time_scale_info()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录