Commit 776fe9c8 by BellCodeEditor

save project

parent 080ee70a
Showing with 10 additions and 1 deletions
......@@ -4,6 +4,9 @@ import random
pygame.init() # 初始化
# 创建一个窗口
class Block(pygame.sprite.Sprite):
def __init__(self,image1,image2,image3):
super().__init__()
screen = pygame.display.set_mode((1000, 600))
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
pygame.display.set_caption("悟空酷跑")
......@@ -22,6 +25,10 @@ index = 0
y = 400
jumpState = "runing"
t = 30
be_x=0
road_x=0
obstacle = Block(bush,cacti,stone)
obstacle = random.choice([bush, stone, cacti])
rect = obstacle.get_rect()
rect.x = 1000
......@@ -68,7 +75,9 @@ while True:
rect = obstacle.get_rect()
rect.x = 1000
rect.y = 500 - rect.height
rect.x -= 8
if obstacle.rect.x <=0-obstacle.rect.width
obstacle = Block(bush,cacti,stone)
obstacle.rect.x -= 8
screen.blit(obstacle, (rect.x, rect.y))
# 刷新画面
pygame.display.update()
......
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