simple animation to simulate the rotation of eight planets is made by using
= "lixingqiu" __date__ = "2019/3/8" import time import math import arcade
import random SCREEN_WIDTH = 1350 SCREEN_HEIGHT = 780 SCREEN_TITLE = "eight
__init__(self,image,a,b,angle,speed): """image:造型图片,a：Long axis长半轴，b：semi-minor
axis短半轴，angle：初始角度""" super().__init__(image) self.center_x = SCREEN_WIDTH / 2
self.center_y = SCREEN_HEIGHT / 2 self.direction = angle #

update(self): """ Calculating Initial Coordinates Based on Elliptic Parametric
Equation""" self.direction = self.direction + 365 / self.speed self.direction =
self.direction % 360 x = SCREEN_WIDTH / 2 + self.a *
math.cos(math.radians(self.direction)) # 根据椭圆参数方程算起始坐标 y = SCREEN_HEIGHT / 2 +
self.b * math.sin(math.radians(self.direction)) self.center_x = x self.center_y
= y super().update() class MyGame(arcade.Window): """ 继承自窗口的MyGame类. """ def
__init__(self, width, height, title): super().__init__(width, height, title)

self.angle_list[i] a,b = self.ab_list[i] image = self.planets_image[i] speed =
self.days[i] aplanet = Planet(image,a,b,angle,speed) # 新建行星
self.planet_list.append(aplanet) # 添加到所有行星列表 def update(self, x):
"""每帧更新游戏内在逻辑""" self.planet_list.update() self.sun.update_animation() def
on_draw(self): """渲染屏幕 """ arcade.start_render() # 开始画背景 self.background.draw()
self.sun.draw() self.planet_list.draw() def main(): """ Main method """ window
= MyGame(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE) window.setup() arcade.run()
if __name__ == "__main__": main()