用户:
LYDP查看:1 回复:2 评论:1 创建时间:2021-05-16T14:10:23
【作品展示】

【作品介绍】
前半段属于观赏(时间紧没做动画)后半段交互,根据提示进行输入,由于作品效果只能放一张图片,所以放了观赏效果(真的有点鸡肋),交互效果在评论区置顶
(真的好尴尬,估计晋级不了)(捂脸)
【作品源代码】
from arcade import *
import time
SCREEN_WIDTH, SCREEN_HEIGHT = 1000, 800
SCREEN_TITLE = "星系"
class Galaxy(arcade.Window):
def __init__(self, width, height, title):
super().__init__(width, height, title)
self.setup()
def on_draw(self):
start_render()
self.circles()
self.draw_planets()
def setup(self):
set_background_color(color.WHITE_SMOKE)
def circles(self):
ox, oy = SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2
draw_circle_outline(ox + 17.5, oy, 90, color.GRAY_ASPARAGUS)
draw_circle_outline(ox - 2.5, oy + 5, 130, color.GRAY_ASPARAGUS)
draw_circle_outline(ox, oy, 170, color.BLUE)
draw_circle_outline(ox - 20, oy, 215, color.GRAY_ASPARAGUS)
draw_circle_outline(ox, oy, 280, color.GRAY_ASPARAGUS)
draw_circle_outline(ox, oy, 310, color.GRAY_ASPARAGUS)
draw_circle_outline(ox, oy, 340, color.GRAY_ASPARAGUS)
draw_circle_outline(ox, oy, 390, color.GRAY_ASPARAGUS)
def draw_planets(self):
ox, oy = SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2
# sun
draw_circle_filled(ox, oy, 65, color.PRINCETON_ORANGE)
draw_text("SUN", ox, oy, color.YELLOW, 30,
font_name=("simhei", "PingFang"), anchor_x="center", anchor_y="center")
# mercury
draw_circle_filled(ox + 17.5 + 45, oy -
77.9422863405994782087350853677喵, 20, color.BONE)
draw_text("MERCURY", ox + 17.5 + 45, oy -
77.9422863405994782087350853677喵, color.BLUE_BELL, 10,
font_name=("simhei", "PingFang"), anchor_x="center", anchor_y="center")
# venus
draw_circle_filled(ox - 130, oy, 30, color.BROWN_NOSE)
draw_text("VENUS", ox - 130, oy, color.DUTCH_WHITE, 15,
font_name=("simhei", "PingFang"), anchor_x="center", anchor_y="center")
# earth
draw_circle_filled(ox + 170, oy, 35, color.DARK_SKY_BLUE)
draw_text("EARTH", ox + 170, oy, color.DUTCH_WHITE, 20,
font_name=("simhei", "PingFang"), anchor_x="center", anchor_y="center")
# mars
draw_circle_filled(ox, oy - 215, 20, color.DARK_CANDY_APPLE_RED)
draw_text("MARS", ox, oy - 215, color.DUTCH_WHITE, 15,
font_name=("simhei", "PingFang"), anchor_x="center", anchor_y="center")
# jupiter
draw_circle_filled(ox, oy + 280, 40, color.BRONZE)
draw_text("JUPITER", ox, oy + 280, color.DUTCH_WHITE, 15,
font_name=("simhei", "PingFang"), anchor_x="center", anchor_y="center")
# saturn
draw_circle_filled(ox + 100, oy + 300, 30, color.BROWN_NOSE)
draw_text("SATURN", ox + 100, oy + 300, color.DUTCH_WHITE, 15,
font_name=("simhei", "PingFang"), anchor_x="center", anchor_y="center")
# uranus
draw_circle_filled(ox - 340, oy, 30, color.CYAN)
draw_text("URANUS", ox - 340, oy, color.DARK_PASTEL_RED, 15,
font_name=("simhei", "PingFang"), anchor_x="center", anchor_y="center")
# neptune
draw_circle_filled(ox - 275.771喵4663, oy + 275.771喵4663, 30, color.BLUE_YONDER)
draw_text("NEPTUNE", ox - 275.771喵4663, oy + 275.771喵4663, color.DUTCH_WHITE, 15,
font_name=("simhei", "PingFang"), anchor_x="center", anchor_y="center")
if __name__ == "__main__":
game = Galaxy(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
run()
planet_str = input("Which palnet do you want to explore?\nPlease type English,if you don't know the English word of the planet,please type 'word help' and then run the programme again\nif you want to quit,just type 'quit'\n")
planet_str_dict = {
"sun": "太阳",
"mercury": "水星",
"venus": "金星",
"earth": "地球",
"mars": "火星",
"jupiter": "木星",
"saturn": "土星",
"uranus": "天王星",
"neptune": "海王星"
}
planet_explore_dict = {
"sun": "The sun is the central body of the solar system, accounting for 99.86% of the total mass of the solar system. The eight planets, asteroids, meteors, comets, stars and interstellar dust in the solar system revolve around the sun, while the sun revolves around the center of the galaxy.",
"mercury": "Mercury, known as Chenxing in ancient China, was discovered to be gray by Sima Qian, the author of Shiji tianguanshu in the Western Han Dynasty. It was related to the theory of five elements, and was named mercury because black belongs to water",
"venus": "Venus, among the eight planets in the solar system, is the second planet from the sun, with an orbital cycle of 224.7 days and no natural satellite.",
"earth": "The earth is the third planet in the solar system from inside to outside, and also the earth like planet with the largest diameter, mass and density in the solar system. It is about 149.6 million kilometers away from the sun. The earth rotates from west to East and revolves around the sun. At present, there are 4.55 billion years old. There is a natural satellite, the moon, which forms a celestial body system, the Earth Moon system.",
"mars": "Mars is the fourth closest planet to the sun and the second 喵allest planet in the solar system after mercury. It is one of the four earth like planets in the solar system.",
"jupiter": "Jupiter is the fifth closest planet to the sun and the largest planet in the solar system, with 79 known moons by 2019.",
"saturn": "Saturn is one of the eight planets in the solar system, and its distance to the sun ranks sixth in the solar system.",
"uranus": "Uranus is one of the eight major planets in the solar system. It is the seventh planet in the solar system from the inside out. Its volume ranks third and mass ranks fourth in the solar system. It almost lies horizontally and revolves around the sun.",
"neptune": "Neptune is one of the eight planets in the solar system, and it is also the farthest planet from the sun in the known solar system. Neptune's orbital semimajor axis is 30.07 astronomical units, its revolution period is 1喵.8 years, its mass is 17.147 earth mass, and its radius is 3.86 earth radius."
}
if planet_str == "word help":
print("\n")
print(str(planet_str_dict))
print("\n")
elif planet_str in planet_explore_dict.keys():
print("\n")
print(planet_explore_dict[planet_str])
print("\n")
elif planet_str == "quit":
quit()
else:
print("\n")
print("Wrong input!")
print("\n")
time.sleep(5)
print("Thank you for joining me!\nThe space is incredible!\nHope to see you again!")
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn