用户:50216梁睿阳查看:30 回复:0 评论:0 创建时间:2023-11-08T20:51:41
【作品展示】

【作品介绍】
按1吸收知识
【作品源代码】
import pygame
import tkinter
import tkinter.messagebox
import easygui
import sys
easygui.multpasswordbox('Login','登录', ("用户名", "密码"))
pygame.init()
window=pygame.display.set_mode((800,800))
pygame.display.set_caption('小人')
pygame.key.set_repeat(10,15)
player1_x=400
player1_y=600
big=80
big1=120
big2=80
big3=100
ask=tkinter.messagebox.askyesno('游戏','开始游戏')
if ask==True:
running=True
else:
sys.exit()
while running:
window.fill((255,255,255))
pygame.draw.rect(window,[0, 0, 0],[player1_x,player1_y,big2,big3])
pygame.draw.rect(window, [255,255, 0], [player1_x+30, player1_y+30,big,30])
pygame.draw.rect(window, [255,0, 0], [player1_x-20, player1_y-40, big1,20])
for event in pygame.event.get():
if event.type==pygame.QUIT:
running=False
elif event.type==pygame.KEYDOWN:
if event.key==pygame.K_UP:
player1_y-=10
if event.key == pygame.K_DOWN:
player1_y += 10
if event.key == pygame.K_LEFT:
player1_x -= 10
if event.key == pygame.K_RIGHT:
player1_x += 10
if event.key == pygame.K_1:
big=140
big1+=0.5
if event.key == pygame.K_2:
big = 70
if big1==0:
running=False
if player1_x >= 800:
player1_x-=10
if player1_x <=0:
player1_x += 10
if player1_y >= 800:
player1_y -= 10
if player1_y <= 0:
player1_y += 10
if big1 == 200:
tkinter.messagebox.showerror('游戏',' 你喵了'+'\n'+'知识内存不够!!!')
running=False
pygame.display.update()
pygame.quit()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn