Commit 464914e7 by BellCodeEditor

save project

parent 78e0bcf2
Showing with 27 additions and 6 deletions
import pygame
from pygame import locals
import random
filelist=" "
pygame.init() # 初始化
......@@ -18,10 +20,22 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')]
index = 0
backx=0
y=400
sd=0
nb="runing"
nb="running"
stone_x=1000
nm=random.choice([apple,stone,cacti])
rect=nm.get_rect()
rect.x=1000
rect.y=500-rect.height
while True:
if rect.x<0-rect.width:
nm=random.choice([apple,stone,cacti])
rect=nm.get_rect()
rect.x=1000
rect.y=500-rect.height
for event in pygame.event.get():
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
......@@ -46,14 +60,20 @@ while True:
nb="running"
y=400
sd=sd+1
if sd>=5:
sd=0
sb=hero[sd]
sb=hero[sd]
if nb=="running":
sd+=1
if sd>=5:
sd=0
# 将背景图画上去
screen.blit(background, (0, 0))
screen.blit(background, (backx, 0))
screen.blit(road, (0, 500))
screen.blit(sb, (150, y))
rect.x-=5
screen.blit(nm,(rect.x,rect.y))
pygame.display.set_caption("悟空酷跑")# 刷新画面
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