Commit 22cd3ea9 by BellCodeEditor

save project

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