用python画星空源代码是什么?

用python画星空源代码是什么?,第1张

概述用python画星空源代码是什么?

用python画星空源代码是什么?

用python画星空源代码是

from turtle import *from random import random,randintscreen = Screen()wIDth ,height = 800,600screen.setup(wIDth,height)screen.Title("模拟3D星空")screen.bg@R_404_6004@("black")screen.mode("logo")screen.delay(0)#这里要设为0,否则很卡t = Turtle(visible = False,shape='circle')t.pen@R_404_6004@("white")t.fill@R_404_6004@("white")t.penup()t.setheading(-90)t.goto(wIDth/2,randint(-height/2,height/2))stars = []for i in range(200):    star = t.clone()    s =random() /3    star.shapesize(s,s)    star.speed(int(s*10))    star.setx(wIDth/2 + randint(1,wIDth))    star.sety( randint(-height/2,height/2))    star.showturtle()    stars.append(star)while True:    for star in stars:        star.setx(star.xcor() - 3 * star.speed())    if star.xcor()<-wIDth/2:        star.hIDeturtle()        star.setx(wIDth/2 + randint(1,wIDth))        star.sety( randint(-height/2,height/2))        star.showturtle()

推荐教程:《python视频教程》 总结

以上是内存溢出为你收集整理的用python画星空源代码是什么?全部内容,希望文章能够帮你解决用python画星空源代码是什么?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1184151.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-03
下一篇 2022-06-03

发表评论

登录后才能评论

评论列表(0条)

保存