Commit cbe8c51c by BellCodeEditor

save project

parent 3d1447bc
Showing with 19 additions and 3 deletions
import pygame import pygame
from pygame import locals from pygame import locals
t=0
state='running'
pygame.init() # 初始化 pygame.init() # 初始化
# 创建一个窗口 # 创建一个窗口
screen = pygame.display.set_mode((1000, 600)) screen = pygame.display.set_mode((1000, 600))
...@@ -19,9 +20,24 @@ index = 0 ...@@ -19,9 +20,24 @@ index = 0
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:# 接收到退出事件后退出程序
# 接收到退出事件后退出程序
exit() exit()
if event.type==locals.KEYDOEN:
if state==running:
if event.key==locals.K_SPACE:
state=='up'
if state=='up':
if t>0:
y-=t
t-=2
else:
state='down'
if state=='down':
if t<0:
y+=t
t+=2
else:
state='running'
# 将背景图画上去 # 将背景图画上去
wukong='hero1.png' wukong='hero1.png'
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
......
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