Commit 6c194057 by BellCodeEditor

save project

parent 5b137ef2
Showing with 18 additions and 3 deletions
...@@ -6,7 +6,6 @@ pygame.init() # 初始化 ...@@ -6,7 +6,6 @@ pygame.init() # 初始化
screen = pygame.display.set_mode((1000, 600)) screen = pygame.display.set_mode((1000, 600))
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数) FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
# 载入图片 # 载入图片
pygame.display.
background = pygame.image.load('bg.png') # 背景 background = pygame.image.load('bg.png') # 背景
road = pygame.image.load('road.png') # 路 road = pygame.image.load('road.png') # 路
stone = pygame.image.load('stone.png') # 石头 stone = pygame.image.load('stone.png') # 石头
...@@ -21,6 +20,7 @@ obstacle=random.choice([bush,stone,cacti]) ...@@ -21,6 +20,7 @@ obstacle=random.choice([bush,stone,cacti])
rect=obstacle.get_rect() rect=obstacle.get_rect()
rect.x=1000 rect.x=1000
rect.y=500-rect.height 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:
...@@ -64,4 +64,19 @@ while True: ...@@ -64,4 +64,19 @@ while True:
rect.x-=8 rect.x-=8
screen.blit(obstacle,(rect.x,rect.y)) screen.blit(obstacle,(rect.x,rect.y))
pygame.display.update() pygame.display.update()
FPS.tick(30) FPS.tick(30)
\ No newline at end of file """
while True:
if j=="up":
if t>0:
y-=t
t-=2
else:
j='down'
print(y)
if j=="down":
if t<=30:
y+=t
t+=2
else:
j='runing'
\ 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