用户:
屑雷神索尔查看:0 回复:1 评论:0 创建时间:2020-06-11T20:49:53
【作品展示】

【作品介绍】
什么?寥寥十几行代码就能模拟银河系,甚至全宇宙?这不可能的吧!!NONONONO!这个程序就能做到!!
(需提前安装vpython)
【作品源代码】
from vpython import *
from vpython import color
from random import randint,random
stars=[]
class Star(simple_sphere):
def __init__(self):
super().__init__(pos=vector(randint(-49, 49), randint(-49, 49), randint(-49, 49)),
color=vector(random(),random(),random()),v=vector(random(),random(),random()),radius=random())
def update(self):
self.pos+=self.v
def create_stars():
stars.append(Star())
i=0
while i<1000:
rate(100)
create_stars()
for star in stars:
star.update()
#_thread.start_new_thread(create_stars,())
while True:
for star in stars:
star.update()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn