Commit 2a1a4a20 by BellCodeEditor

save project

parent 0945c955
Showing with 30 additions and 7 deletions
import pygame
from pygame import locals
import random
pygame.init() # 初始化
# 创建一个窗口
......@@ -13,6 +13,13 @@ road = pygame.image.load('road.png') # 路
stone = pygame.image.load('stone.png') # 石头
cacti = pygame.image.load('cacti.png') # 仙人掌
apple = pygame.image.load('bush.png') # 灌木丛
z=random.choice([stone,cacti,apple])
rect=z.get_rect()
rect.x=1000
rect.y=500-rect.width
if rect.x<=0-rect.width:
z=ramdom.choue([stone,cacti,applee])
rect=z.get_rect()
hero=[pygame.image.load('hero1.png'),
......@@ -25,6 +32,7 @@ hero=[pygame.image.load('hero1.png'),
m = 0
jumpstate="runing"
y=400
t=30
while True:
hero1=hero[m]
......@@ -43,15 +51,28 @@ while True:
exit()
if jumpstate=="up":
if y>150:
y=y-5
if t>0:
y-=t
t-=2
else:
jumpstate="down"
if jumpstate=="down":
if y<400:
y=y+5
jumpstate = "down"
print (t)
print(jumpstate)
if jumpstate =="down":
if t<=30:
y = y+t
t = t+2
else:
jumpstate="runing"
t=30
rect=z.get_rect()
rect.x=1000
rect.y=500-rect.width
if rect.x<=0-rect.width:
z=ramdom.choue([stone,cacti,applee])
rect=z.get_rect()
......@@ -59,6 +80,7 @@ while True:
screen.blit(background, (0, 0))
screen.blit(road, (0, 500))
screen.blit(hero1, (150, y))
screen.blit(z,(rect.x,rect.y))
# 刷新画面
pygame.display.update()
FPS.tick(60)
\ 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