Commit 22cd3ea9 by BellCodeEditor

save project

parent 1d278a67
Showing with 13 additions and 3 deletions
import pygame
from pygame import locals
import random
pygame.init() # 初始化
# 创建一个窗口
screen = pygame.display.set_mode((1000, 600))
......@@ -21,12 +21,16 @@ x = 0
a="running"
y = 400
t=30
s=random.choice([stone,cacti,apple])
rect = s.get_rect()
rect.x=500
rect.y=500-rect.height
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
exit()
if event.type==locals.KEYDOWN:
if event.type==locals.KEYDOWN:
if event.key==locals.K_SPACE and a=="running":
a="up"
if a=="up":
......@@ -42,7 +46,13 @@ while True:
else:
a="running"
t=30
# if rect.x<0-rect.width:
# s=random.choice([stone,cacti,apple])
# rect = s.get_rect()
# rect.x=1000
# rect.y=500-rect.height
rect.x-=10
screen.blit(s, (rect.x, rect.y))
wukong = hero[x]
if a=="running":
x+=1
......
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