Commit 07c690b4 by BellCodeEditor

auto save

parent b9be7b4e
Showing with 3 additions and 11 deletions
...@@ -3,14 +3,7 @@ from pygame import locals ...@@ -3,14 +3,7 @@ from pygame import locals
import random import random
pygame.init() # 初始化 pygame.init() # 初始化
class Block(pygame.sprite.Sprite): # 创建一个窗口
def _init_(self,image,image2,image3)
super()_init()
self.image=random.choice(image,image2,image3)
self.rect = self.image.get_rect()
self.rect.x = 1000
self.rect.y = 500 - rect.rect.height
screen = pygame.display.set_mode((1000, 600)) screen = pygame.display.set_mode((1000, 600))
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数) FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
pygame.display.set_caption("悟空酷跑") pygame.display.set_caption("悟空酷跑")
...@@ -67,7 +60,7 @@ while True: ...@@ -67,7 +60,7 @@ while True:
if index >= 5: if index >= 5:
index = 0 index = 0
# 将背景图画上去 # 将背景图画上去
bg -=2 bg -=8
screen.blit(background, (bg, 0)) # 远处背景 screen.blit(background, (bg, 0)) # 远处背景
if bg <= -1000: if bg <= -1000:
bg = 0 bg = 0
...@@ -77,9 +70,8 @@ while True: ...@@ -77,9 +70,8 @@ while True:
road_x = 0 road_x = 0
screen.blit(wukong, (150, y)) # 悟空 screen.blit(wukong, (150, y)) # 悟空
if obstacle.rect.x <= 0-obstacle.rect.width: # 障碍物消失 if rect.x <= 0-rect.width: # 障碍物消失
# 创建障碍物对象 # 创建障碍物对象
obstacle = random.choice([bush,stone,cacti]) obstacle = random.choice([bush,stone,cacti])
rect = obstacle.get_rect() rect = obstacle.get_rect()
rect.x = 1000 rect.x = 1000
......
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