Commit a8c1e0e7 by BellCodeEditor

save project

parent 9512b357
Showing with 10 additions and 3 deletions
......@@ -3,13 +3,20 @@ from pygame import locals
import random
pygame.init()
class Block():
class Block(pygame.sprite.Sprite):
def __init__(self,image1,image2,image3):
super().__init__()
self.image=random.choice([image1,image2,image3])
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=1000
# 初始化
# 创建一个窗口
screen = pygame.display.set_mode((1000, 600))
......@@ -61,7 +68,7 @@ while True:
t =30
# 悟空造型
wukong = hero[index]
wukong = Player(hero[index])
if jumpState == "runing": # 跑步状态下
index += 1
if index >= 5:
......@@ -77,7 +84,7 @@ while True:
# 远处背景
screen.blit(road, (road_x, 500))
# 路
screen.blit(wukong, (150, y))
screen.blit(wukong.image, (150, y))
time+=1
if time>60:
time=0
......
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