Commit fcfcb96e by BellCodeEditor

save project

parent f13a6bd1
Showing with 15 additions and 2 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
pygame.init() # 初始化 pygame.init() # 初始化]\
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
# 创建一个窗口 # 创建一个窗口
screen = pygame.display.set_mode((1000, 600)) screen = pygame.display.set_mode((1000, 600))
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数) FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
...@@ -32,6 +40,9 @@ y = 400 ...@@ -32,6 +40,9 @@ y = 400
jumpState = "runing" jumpState = "runing"
t = 30 t = 30
aa=Block(bush,cacti,stone) aa=Block(bush,cacti,stone)
time = 0
gamestate = True
block_list=pygame.sprite.Group()
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
...@@ -70,10 +81,12 @@ while True: ...@@ -70,10 +81,12 @@ while True:
screen.blit(background, (bg_x, 0)) # 远处背景 screen.blit(background, (bg_x, 0)) # 远处背景
road_x-=8 road_x-=8
if road_x<-1000: if road_x<-1000:
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(wukong, (150, y)) # 悟空
time += 1
if time
if aa.rect.x <= 0-aa.rect.width: # 障碍物消失 if aa.rect.x <= 0-aa.rect.width: # 障碍物消失
# 创建障碍物对象 # 创建障碍物对象
aa=Block(bush,cacti,stone) aa=Block(bush,cacti,stone)
......
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