Commit 4cb6e268 by BellCodeEditor

save project

parent 4f219b0f
Showing with 14 additions and 10 deletions
...@@ -23,8 +23,11 @@ jumpS = "run" ...@@ -23,8 +23,11 @@ jumpS = "run"
y = 400 y = 400
yy = 30 yy = 30
roadx = 0 roadx = 0
sjx = 600
sj = random.choice([stone,cacti,apple])
rect =sj.get_rect()
rect.x=1000
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:
...@@ -49,23 +52,23 @@ while True: ...@@ -49,23 +52,23 @@ while True:
jumpS = "run" jumpS = "run"
yy = 30 yy = 30
# 将背景图画上去 # 将背景图画上去
if sjx == 600: if rect.x == 1000:
sj = random.choice([stone,cacti,apple]) sj = random.choice([stone,cacti,apple])
rect =sj.get_rect() rect =sj.get_rect()
sjx = 1000+rect.width rect.x = 1000
sjy = 500-rect.height rect.y = 500-rect.height
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
screen.blit(road, (roadx, 500)) screen.blit(road, (roadx, 500))
screen.blit(hero[index], (150, y)) screen.blit(hero[index], (150, y))
screen.blit(sj, (sjx, sjy)) screen.blit(sj, (rect.x, rect.y))
sjx -= 5 rect.x -= 8
if sjx < 0-rect.width: if rect.x < 0-rect.width:
sjx = 600 rect.x = 1000
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(40) FPS.tick(60)
if jumpS == "run": if jumpS == "run":
index=(index+1)%5 index=(index+1)%5
roadx -= 5 roadx -= 8
if roadx == -1000: if roadx == -1000:
roadx = 0 roadx = 0
\ 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