生机勃勃的农场_ 花花草草的小世界

python自然编程生机勃勃的农场
让Python程序描述一下大自然,本程序更关键的是要有好的素材与搭配等.
下面是部分代码预览:

"""
   生机勃勃的农场.py
   太阳升起来了,绿茵草地上的花朵们充满生机,小狗在来会走动,还有发财树在等着你去摇一摇.
"""
import os
from turtle import *
from animation import *
from time import sleep
from random import choice,randint
from sprite import Sprite as Karaoke


"""一、新建屏幕,如需要渐变效果,需要许多张背景图切换"""
width,height = 1024,768
halfwidth,halfheight = width//2,height//2
screen = Screen()
screen.delay(0)
screen.setup(width,height)
screen.bgcolor("black")
sleep(1)
screen.bgpic("background.png")
screen.title("我的农场")


"""二、画太阳"""
draw_turtle = Turtle(visible=False,shape='circle')
draw_turtle.penup()
draw_turtle.goto(250,-250)
draw_turtle.color("red","red")
draw_turtle.shapesize(5,5)
draw_turtle.st()
for i in range(50):
    draw_turtle.sety(draw_turtle.ycor() + 10)
    draw_turtle.stamp()
    sleep(0.01)
    draw_turtle.clear()
    screen.update()

draw_turtle.stamp()
draw_turtle.ht()
for i in range(12):
    draw_turtle.fd(100)
    draw_turtle.pendown()
    draw_turtle.fd(50)
    draw_turtle.penup()
    draw_turtle.bk(150)
    draw_turtle.right(30)
    sleep(0.01)

"""三、花的动画"""
cwd = os.getcwd() + os.sep

f0path = cwd + "花" + os.sep + "淡黄花" + os.sep
flower0_images = [f0path + "黄"+ str(i) + ".gif" for i in range(1,7)] 
[screen.addshape(image) for image in flower0_images]  #注册到屏幕形状列表
flower0 = Animation(flower0_images,400,-200,200)         
flower0.alt_image() 


screen.mainloop()

如需要查看完整源代码,请扫码付款:

VIP免费查看

已有0人支付

本站所有作品,教程等皆为原创,盗版必究。一旦付款,表示同意本站知识付费原则:数字商品,不支持退款。亦可直接向微信号scratch8付款购买。QQ群免费教学群:225792826 (提供真实姓名可入群)
李兴球的博客_Python创意编程技术前沿 » 生机勃勃的农场_ 花花草草的小世界

学本领,探索更大的世界!

李兴球博客 风火轮编程主页