Commit 1e4d1157 by BellCodeEditor

auto save

parent 7abeb754
Showing with 20 additions and 55 deletions
import pygame i=3
from pygame import locals username="python"
# 初始化pygame,为使用pygame做准备 userpassword="123456"
pygame.init()
body=pygame.image.load("body.png")
apple=pygame.image.load("apple.png")
right=pygame.image.load("right.png")
# 创建一个窗口
screen = pygame.display.set_mode((800,600))
FPS=pygame.time.Clock()
x,y=210,120
position=[(180,120),(180,90),(180,60),(x,y)]
while True: while True:
for event in pygame.event.get(): if i>0:
if event.type == locals.QUIT: A=input("输入用户名")
exit() B=input("输入密码")
if event.type == locals.KEYDOWN: i-=1
if event.type == locals.K_RIGHT and setheading != "left": if A==username and B==userpassword:
setheading = 'right' print("登录成功")
snake_head = right break
if event.type == locals.K_LEFT and setheading != "right": else:
setheading = 'left' if A!=username:
snake_head = left print("用户名错误")
if event.type == locals.K_UP and setheading != "down": continue
setheading = 'up' if B!=userpassword:
snake_head = up print("密码错误")
if event.type == locals.K_DOWN and setheading != "up": else:
setheading = 'down' print("账号锁定")
snake_head = down exit()
if aetheading == "right":
x += 30
elif aetheading == "left":
x += 30
elif aetheading == "up":
y += 30
elif aetheading == "down":
y += 30
x +=30
position.append((x,y))
position.pop(0)
for i in range(len(position)-1):
screen.bilt(body,position[i])
# screen.bilt(background,(0,0))
# screen.bilt(right,(x,y))
# screen.bilt(body,(180,120))
# screen.bilt(body,(180,90))
# screen.bilt(body,(180,60))
# screen.bilt(apple,(30,40))
pygame.display.update()
FPS.tick(3)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment