欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

红灯检测动画

发布时间:2024/5/15 编程问答 32 豆豆
生活随笔 收集整理的这篇文章主要介绍了 红灯检测动画 小编觉得挺不错的,现在分享给大家,帮大家做个参考.
from pygame import * from sys import *init() font.init()screen = display.set_mode((680,742)) display.set_caption("红灯检测")x=0 y=642 is_green = True n = 300print(60*60*365*100)while True:for a in event.get():if a.type == QUIT:quit()exit() screen.blit(image.load("操场.png"),(0,0))b = image.load("汽车.png").convert()b.set_colorkey((255,255,255))for a in range(3):screen.blit(b,(x+100*a,y))if is_green:screen.blit(image.load("红绿灯.png"),(340,0))else:screen.blit(image.load("红绿灯-副本(1).png"),(340,0))screen.blit(font.SysFont("simhei",50).render(str(n//30),0,(255,255,255)),(436,85))if is_green:x += 10else:x = 0if x > 680: x = 0 if n == 0 and is_green:is_green = Falsen = 300elif n == 0 and is_green == False :is_green = Truen = 300n -= 1time.Clock().tick(30)display.flip()

总结

以上是生活随笔为你收集整理的红灯检测动画的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。