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

Python超人-宇宙模拟器

上级 5a7a24dc
......@@ -10,6 +10,8 @@ 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 objs import CoreValagaClas, ScifiGunship, SpaceShip, StarWarsSpeeder, SciFiBomber
from objs.battleship import BattleShip
from sim_scenes.func import mayavi_run, ursina_run, create_sphere_sky
from sim_scenes.universe_sim_scenes import UniverseSimScenes
from simulators.func import ext_fun_for_method
......@@ -34,6 +36,13 @@ class TheLostPlanetSim(UniverseSimScenes):
self.mars = Mars(size_scale=3e3, distance_scale=2.9)
self.jupiter = Jupiter(size_scale=0.68e3, distance_scale=1.12)
self.saturn = Saturn(size_scale=0.68e3, distance_scale=0.74)
self.ship = ScifiGunship(name="飞船", mass=1e30, color=(111, 140, 255),
init_position=self.mars.init_position,
init_velocity=[0, 0, 0],
size_scale=2e4, distance_scale=2.9).\
set_ignore_gravity(True).set_light_disable(True)
self.bodies = [
self.sun,
Mercury(size_scale=3e3, distance_scale=7.3), # 水星放大 4000 倍
......@@ -89,7 +98,7 @@ class TheLostPlanetSim(UniverseSimScenes):
else:
an = 0.4 + 0.3 * pow(2, planet_no - 2)
# print(body.name, an, body.position[2] / AU)
self.bodies += [self.ship]
self.step_index = 0
self.init_steps()
......@@ -291,6 +300,24 @@ class TheLostPlanetSim(UniverseSimScenes):
for a in self.asteroids:
self.set_alpha_animation(a, 1.0, 0.0, 0.01, is_destroy=True)
def ship_go_to_moon(self):
planet = self.ship.planet
origin_udpate = planet.update
def go_to_moon():
# origin_udpate()
self.ship.planet.look_at(self.moon.planet)
planet.position += planet.forward * 20
planet.rotation_x = 0
d = distance(planet, self.moon.planet)
if d < 2:
planet.update = lambda: None
planet.enabled = False
self.step_index += 1
planet.update = go_to_moon
def moon_fade_in(self):
"""
月球渐渐显示
......@@ -385,6 +412,7 @@ class TheLostPlanetSim(UniverseSimScenes):
(self.asteroid_fade_in, 3, 1),
(self.asteroid_fade_out, 3, 1),
(self.moon_fade_in, 3, 1),
# (self.ship_go_to_moon, -1, 1),
(self.moon_renovation, 10, -1),
(step_05, -1, -1),
(step_06, -1, -1),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册