无所不能的python没想到还能画星空,现在就让我们来画一个

from turtle import *
from random import random,randint
screen = Screen()
width ,height = 800,600
screen.setup(width,height)
screen.title("模拟3D星空")
screen.bgcolor("black")
screen.mode("logo")
screen.delay(0)#这里要设为0,否则很卡
t = Turtle(visible = False,shape='circle')
t.pencolor("white")
t.fillcolor("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画星空的代码相关推荐

  1. 用python画星空的代码_用python画星空源代码是什么?_后端开发

    用python画星空源代码是什么? 用python画星空源代码是 from turtle import * from random import random,randint screen = Scr ...

  2. 用python画星空的代码简单-【Python】手把手教你绘制星空旅游线路图

    0 前言 5月是美国的毕业季,我家领导也即将毕业了,我们将在美国进行为期两周的毕业旅行.其实类似这样的航线图我以前也用PPT绘制过,给领导用于发朋友圈,虽然总体能表达出意思,但是效果不能让自己满意,见 ...

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

    用python画星空源代码是什么? 用python画星空源代码是from turtle import * from random import random,randint screen = Scre ...

  4. python绘制月亮_用python画月亮的代码是什么?

    用python画月亮的代码是什么? 用python画月亮的代码是import turtle as t t.screensize(800,600,"#483d8b")#画布尺寸和颜色 ...

  5. 用python画月亮的代码-用python画月亮的代码是什么?

    用python画月亮的代码是什么? 用python画月亮的代码是import turtle as t t.screensize(800,600,"#483d8b")#画布尺寸和颜色 ...

  6. python画星空的程序_用python画星空源代码是什么?

    用python画星空源代码是什么? 用python画星空源代码是from turtle import * from random import random,randint screen = Scre ...

  7. python绘制星空_用python画星空源代码是什么?

    用python画星空源代码是什么? 用python画星空源代码是from turtle import * from random import random,randint screen = Scre ...

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

    7mr少儿编程网-Scratch_Python_教程_免费儿童编程学习平台 用python画星空源代码是什么?7mr少儿编程网-Scratch_Python_教程_免费儿童编程学习平台 用python ...

  9. python源代码制作星空_用python画星空源代码是什么?

    用python画星空源代码是什么? 用python画星空源代码是 from turtle import *from random import random,randintscreen = Scree ...

最新文章

  1. oracle lz压缩,LZ:Oracle热备期间过量Redo生成控制
  2. 深入理解 Linux的 I/O 系统
  3. 作业三_C#中的观察者模式解析
  4. ubuntu使用root权限登录的设置方法
  5. 福昕熊雨前:PDFium开源项目的背后
  6. lintcode433 岛屿的个数
  7. mysql用binlog恢复数据_利用mysql的binlog恢复数据
  8. python回归分析预测模型_在Python中如何使用Keras模型对分类、回归进行预测
  9. 车险赔付率分析报告_车险综合改革出台:下调附加费用率,三者限额提至千万...
  10. 垃圾回收机制GC知识再总结兼谈如何用好GC(转)
  11. python_14 多态,封装,反射
  12. webgame源码下载及网页游戏开发资源精华集合
  13. ROON1.8无法找到asio驱动的解决办法
  14. PDF转ONENOTE的方法
  15. legion--一款开源,易用,扩展性强的半自动化渗透测试工具
  16. Angular-路由设置
  17. 使用Power BI时常见的几个问题(持续更新)
  18. cordova 微信支付
  19. Ubuntu 22.04 LTS 是史诗级的版本?
  20. Blender新手入门试水作品:Low poly版敲击兽

热门文章

  1. 快慢指针追逐法寻找单链表中环的起点
  2. Python中类方法定义及常用的实现方式
  3. 在html中怎样调节边框的长度,CSS边框长度控制功能的实现
  4. python 弹球游戏
  5. 如何利用miniDP转DP线实现MacBook air投屏镜像
  6. 微信服务商商户进件php,关于微信服务商特约商户进件的问题
  7. 深度学习应用6.3波士顿房价模型改进
  8. 打印机常见故障解决参考方法
  9. 前端路由 与 后端路由
  10. 一文看尽2018全年AI技术大突破