From fd77b60316d7906da40595218991368fa5ee795c Mon Sep 17 00:00:00 2001 From: march3 Date: Thu, 7 Dec 2023 18:40:37 +0800 Subject: [PATCH] =?UTF-8?q?Python=E8=B6=85=E4=BA=BA-=E5=AE=87=E5=AE=99?= =?UTF-8?q?=E6=A8=A1=E6=8B=9F=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sim_lab/the_lost_planet.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/sim_lab/the_lost_planet.py b/sim_lab/the_lost_planet.py index cc379a9..ec9047d 100644 --- a/sim_lab/the_lost_planet.py +++ b/sim_lab/the_lost_planet.py @@ -150,12 +150,12 @@ if __name__ == '__main__': 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 - + y = 10 * random.random() - 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.position = (x, y, z) + speed = random.random() / 100 asteroid.s_angle += speed asteroid.update = rotation @@ -172,6 +172,7 @@ if __name__ == '__main__': import math # print(time_data.years) if time_data.years > 1 and not hasattr(asteroids, "years_1"): + set_alpha_animation(asteroids, 0.0, 1.0, 0.01) setattr(asteroids, "years_1", True) elif time_data.years > 4 and not hasattr(asteroids, "years_5"): @@ -183,11 +184,15 @@ 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"): + if not hasattr(asteroids, "c_time"): + asteroids.c_time = time.time() + c_time = time.time() # set_alpha_animation(asteroids, 0.0, 1.0, 0.01) - for i in range(3): + if c_time - asteroids.c_time > 0.1: + asteroids.c_time = c_time create_asteroid() - if time_data.years > 11 and not hasattr(moon, "mars_rotation"): + if time_data.years > 30 and not hasattr(moon, "mars_rotation"): setattr(asteroids, "years_8", True) moon.planet.look_at(mars.planet) radius = 12 -- GitLab