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

Python超人-宇宙模拟器

上级 e03e0272
......@@ -6,6 +6,8 @@
# link :https://gitcode.net/pythoncr/
# python_version :3.9
# ==============================================================================
import time
from bodies import Sun, Mercury, Venus, Earth, Mars, Moon, Ceres, Jupiter, Saturn, Uranus, Neptune, Pluto, Asteroids
from common.consts import SECONDS_PER_WEEK, SECONDS_PER_DAY, SECONDS_PER_MONTH, SECONDS_PER_YEAR, AU
from sim_scenes.func import mayavi_run, ursina_run, create_sphere_sky
......@@ -101,6 +103,10 @@ if __name__ == '__main__':
# camera.look_at(sun.planet)
camera.rotation_z -= 90
# for i in range(10):
# time.sleep(0.1)
# create_asteroid()
# UniverseSimScenes.show_grid_axises()
asteroids.planet.enabled = False
......@@ -136,6 +142,25 @@ if __name__ == '__main__':
# ext_fun_for_method(planet, after_run_fun=alpha_animation)
def create_asteroid():
from ursina import Entity, color, Vec3
import math
import random
pos = moon.planet.position # + Vec3()
radius = moon.planet.position[2] + 40 * random.random() - 20 # * moon.distance_scale
asteroid = Entity(model='sphere', position=pos, color=color.white, scale=1.5)
asteroid.s_angle = 89.5
def rotation():
x = sun.planet.x + radius * math.cos(asteroid.s_angle)
z = sun.planet.z + radius * math.sin(asteroid.s_angle)
asteroid.position = (x, 10 * random.random() - 5, z)
speed = random.random() / 15
asteroid.s_angle += speed
asteroid.update = rotation
#
# def after_ready():
# from ursina import camera, Vec3
......@@ -158,11 +183,12 @@ if __name__ == '__main__':
set_alpha_animation(moon, 0.0, 1.0, 0.005)
setattr(moon, "years_6", True)
elif time_data.years > 8 and not hasattr(asteroids, "years_8"):
set_alpha_animation(asteroids, 0.0, 1.0, 0.01)
setattr(asteroids, "years_8", True)
if time_data.years > 8 and not hasattr(moon, "years_8"):
# set_alpha_animation(asteroids, 0.0, 1.0, 0.01)
for i in range(3):
create_asteroid()
if time_data.years > 11 and not hasattr(moon, "mars_rotation"):
setattr(asteroids, "years_8", True)
moon.planet.look_at(mars.planet)
radius = 12
d = distance(moon.planet, mars.planet.position)
......@@ -180,9 +206,9 @@ if __name__ == '__main__':
setattr(mars, "moon_angle", moon_angle + 0.08)
if moon_angle >= 110:
setattr(moon, "years_8", True)
setattr(moon, "mars_rotation", True)
print("moon_angle",moon_angle)
print("moon_angle", moon_angle)
elif hasattr(mars, "moon_angle") and not hasattr(moon, "earth_rotation"):
earth_target = earth.planet.main_entity
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册