Commit 4f14d5c6 by BellCodeEditor

save project

parent 6e16def6
Showing with 13 additions and 2 deletions
......@@ -25,6 +25,13 @@ class Block(pygame.sprite.Sprite):
self.rect=self.image.get_rect()
self.rect.x=1000
self.rect.y=500-self.rect.height
class Player(pygame.sprite.Sprite):
def __init__(self,image):
super().__init__()
self.image=image
self.rect=self.image.get_rect()
self.rect.x=150
self.rect.y=400
index = 0
y = 400
jumpState = "runing"
......@@ -35,6 +42,7 @@ dg_x=0
block_list=pygame.sprite.Group()
time=0
num=0
gamestate=True
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -60,7 +68,7 @@ while True:
t =30
# 悟空造型
wukong = hero[index]
wukong = Player(hero[index])
if jumpState == "runing": # 跑步状态下
index += 1
if index >= 5:
......@@ -74,7 +82,7 @@ while True:
if road_x<-1000:
road_x=0
screen.blit(road, (road_x, 500)) # 路
screen.blit(wukong, (150, y)) # 悟空
screen.blit(wukong.image, (150, y)) # 悟空
# 障碍物消失
# 创建障碍物对象
......@@ -88,6 +96,8 @@ while True:
for sprite in block_list:
sprite.rect.x -= 16
screen.blit(sprite.image, (sprite.rect.x,sprite.rect.y))
if spirte.rect.x <= 0-sprite.rect.y:
sprite.kill()
# 刷新画面
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