用户:
爱吃737的GE90查看:0 回复:0 评论:0 创建时间:2022-04-23T17:01:20
【作品展示】

【作品介绍】
自己看去吧
【作品源代码】
import sys
import pygame
from pygame.locals import *
def main():
pygame.init()
screen =pygame.display.set_mode((600,300))
pygame.display.set_caption("birdy123w")
font =pygame.font.SysFont(None,36)
text0 =""
text1 =""
while True:
pygame.event.pump()
#pygame.event.get()
#pygame.event.wait()
#pygame.event.poll()
#pygame.event.clear()
buttons=pygame.mouse.get_pressed()
pos=pygame.mouse.get_pos()
text0="mouseposition"+str(pos)
if buttons[0]:
text0 +=" left mouse key pressed"
elif buttons[1]:
text0 +=" middle key pressed"
elif buttons[2]:
text0 +=" right mouse key pressed"
#handle keboard input
keys =pygame.key.get_pressed()
if keys[K_q]:
sys.exit()
elif keys[K_a]:
text1="key a pressed on the keyboard."
elif keys[K_b] and [K_c]:
text1="key b and c are pressed on the keyboard."
elif keys[K_0]:
text1 = "key 0 pressed on the keyboard."
elif keys[K_1]:
text1 = "key 1 pressed on the keyboard."
else:
text1=""
text0_surface=font.render(text0,True,(225,0,0))
text1_surface = font.render(text1,True,(0,0,225))
screen.fill((255,255,255))
screen.blit(text0_surface,(10,50))
screen.blit(text1_surface, (10, 150))
pygame.display.flip()
if __name__ == "__main__":
main()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn