Commit 5071298d by BellCodeEditor

save project

parent 79c04a49
Showing with 13 additions and 4 deletions
...@@ -9,7 +9,15 @@ class Block(pygame.sprite.Sprite): ...@@ -9,7 +9,15 @@ class Block(pygame.sprite.Sprite):
self.rect=self.image.get_rect() self.rect=self.image.get_rect()
self.rect.x=1000 self.rect.x=1000
self.rect.y=500-self.rect.height self.rect.y=500-self.rect.height
class class Wukong(pygame.sprite.Sprite):
def __init__(self,wk_image):
super().__init__()
self.=wk_image
self.rect=self.image[0].get_rect()
self.rect.x=150
self.rect.y=400
pygame.init() # 初始化 pygame.init() # 初始化
# 创建一个窗口 # 创建一个窗口
...@@ -42,6 +50,8 @@ obs.rect.y = 500 - obs.rect.height ...@@ -42,6 +50,8 @@ obs.rect.y = 500 - obs.rect.height
block_list=pygame.sprite.Group() block_list=pygame.sprite.Group()
block_list.add(obs) block_list.add(obs)
time=0 time=0
wuk=Wukong(hero)
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:
...@@ -67,7 +77,7 @@ while True: ...@@ -67,7 +77,7 @@ while True:
t =30 t =30
# 悟空造型 # 悟空造型
wukong = hero[index]
if jumpState == "runing": # 跑步状态下 if jumpState == "runing": # 跑步状态下
index += 1 index += 1
if index >= 5: if index >= 5:
...@@ -83,7 +93,7 @@ while True: ...@@ -83,7 +93,7 @@ while True:
road_x=0 road_x=0
screen.blit(road, (road_x, 500)) # 路 screen.blit(road, (road_x, 500)) # 路
screen.blit(wukong, (150, y)) # 悟空 screen.blit(wuk.image[index], (150, y)) # 悟空
time+=1 time+=1
if time>=60: if time>=60:
time=0 time=0
...@@ -94,7 +104,6 @@ while True: ...@@ -94,7 +104,6 @@ while True:
for i in block_list: for i in block_list:
i.rect.x-=8 i.rect.x-=8
screen.blit(i.image, (i.rect.x, i.rect.y)) screen.blit(i.image, (i.rect.x, i.rect.y))
if pygame.sprite.col
if i.rect.x<0-i.rect.width: if i.rect.x<0-i.rect.width:
i.kill() i.kill()
# 刷新画面 # 刷新画面
......
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