""" A simple animation showing the revolution of eight planets , use arcade Making of arcade game module , install Arcade Please use pip install arcade --user. A
simple animation to simulate the rotation of eight planets is made by using
Arcade module. To install Arcade, use PIP install arcade--user. """ __author__
= "lixingqiu" __date__ = "2019/3/8" import time import math import arcade
import random SCREEN_WIDTH = 1350 SCREEN_HEIGHT = 780 SCREEN_TITLE = "eight
planet planets " class Planet(arcade.Sprite): def
__init__(self,image,a,b,angle,speed): """image: Shape picture ,a:Long axis Long halfshaft ,b:semi-minor
axis Short halfshaft ,angle: Initial angle """ super().__init__(image) self.center_x = SCREEN_WIDTH / 2
self.center_y = SCREEN_HEIGHT / 2 self.direction = angle #
custom direction, Do not use the original attribute angle self.a = a self.b = b self.speed = speed def
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)) # Calculate the starting coordinates according to the elliptic parameter equation 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): """ Inherited from window MyGame class . """ def
__init__(self, width, height, title): super().__init__(width, height, title)
arcade.set_background_color(arcade.color.WHITE) def setup(self): """
Here is the setting of each object in the game """ self.planet_list = arcade.SpriteList() # New role list , For unified rendering #
Background role generation pass # Sun character generation pass # Planetary character generation pass for i in range(8): # generate 8 Planets angle =
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) # New planet
self.planet_list.append(aplanet) # Add to all planet list def update(self, x):
""" Update game logic per frame """ self.planet_list.update() self.sun.update_animation() def
on_draw(self): """ Render screen """ arcade.start_render() # Start drawing background 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()
 

Technology
©2019-2020 Toolsou All rights reserved,
airflow Timed tasks + Time setting +cron expression Dijkstra Algorithmic Python realization - Shortest path problem ElementUI In the select Of label value python primitive -- lock LockGo language Array initialization and basic operations C Language confession practice small program ( Suitable for beginners ) Summary of artificial intelligence algorithm vue monitor Treeselect Change of options el-select At the same time label and value value iPhone 12 price , Configure full exposure : Cut it off 64GB, Battery 2227mAh start