Commit 7472be62 by BellCodeEditor

save project

parent 614aa4fb
Showing with 6 additions and 5 deletions
...@@ -5,10 +5,10 @@ import random ...@@ -5,10 +5,10 @@ import random
class Block(pygame.sprite.Sprite): class Block(pygame.sprite.Sprite):
def __init__(self,image1,image2,image3): def __init__(self,image1,image2,image3):
super().__init__() super().__init__()
self.image = random.choice([bush, stone, cacti]) self.image = random.choice([image1,image2,image3])
self.rect = obstacle.get_rect() self.rect = self.image.get_rect()
self.rect.x = 1000 self.rect.x = 1000
self.rect.y = 500 - rect.height self.rect.y = 500 - self.rect.height
pygame.init() # 初始化 pygame.init() # 初始化
# 创建一个窗口 # 创建一个窗口
...@@ -34,7 +34,7 @@ obstacle=Block(stone,cacti,bush) ...@@ -34,7 +34,7 @@ obstacle=Block(stone,cacti,bush)
time=0 time=0
road_x=0 road_x=0
bg_x=0 bg_x=0
wukong=Wukong()
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:
...@@ -80,7 +80,7 @@ while True: ...@@ -80,7 +80,7 @@ while True:
# 创建障碍物对象 # 创建障碍物对象
obstacle=Block(stone,cacti,bush) obstacle=Block(stone,cacti,bush)
obstacle.rect.x -= 8 obstacle.rect.x -= 8
screen.blit(obstacle, (obstacle.rect.x, obstacle.rect.y)) screen.blit(obstacle.image, (obstacle.rect.x, obstacle.rect.y))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(60) 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