Commit 381bbcb7 by BellCodeEditor

auto save

parent 52bae3ac
Showing with 21 additions and 16 deletions
...@@ -9,6 +9,14 @@ class Block (pygame.sprite.Sprite): ...@@ -9,6 +9,14 @@ 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
class Wu(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
pygame.init() # 初始化 pygame.init() # 初始化
# 创建一个窗口 # 创建一个窗口
screen = pygame.display.set_mode((1000, 600)) screen = pygame.display.set_mode((1000, 600))
...@@ -19,11 +27,11 @@ road = pygame.image.load('road.png') # 路 ...@@ -19,11 +27,11 @@ road = pygame.image.load('road.png') # 路
stone = pygame.image.load('stone.png') # 石头 stone = pygame.image.load('stone.png') # 石头
cacti = pygame.image.load('cacti.png') # 仙人掌 cacti = pygame.image.load('cacti.png') # 仙人掌
bush = pygame.image.load('bush.png') # 灌木丛 bush = pygame.image.load('bush.png') # 灌木丛
hero = [pygame.image.load('stone.png'), hero = [pygame.image.load('hero1.png'),
pygame.image.load('stone.png'), pygame.image.load('hero2.png'),
pygame.image.load('stone.png'), pygame.image.load('hero3.png'),
pygame.image.load('stone.png'), pygame.image.load('hero4.png'),
pygame.image.load('stone.png')] pygame.image.load('hero5.png')]
pygame.display.set_caption("一只猴的回家路") pygame.display.set_caption("一只猴的回家路")
index = 0 index = 0
heroLength = len(hero) heroLength = len(hero)
...@@ -32,7 +40,6 @@ y = 400 ...@@ -32,7 +40,6 @@ y = 400
t = 30 t = 30
d = 30 d = 30
f = 30 f = 30
g = 150
block_list = pygame.sprite.Group() block_list = pygame.sprite.Group()
time = 0 time = 0
road_x = 0 road_x = 0
...@@ -73,7 +80,7 @@ while True: ...@@ -73,7 +80,7 @@ while True:
else: else:
state = "e" state = "e"
if state == "e" : if state == "e" :
if d <= 34: if d <= 30:
y -= t y -= t
d += 2 d += 2
f -= 2 f -= 2
...@@ -88,21 +95,19 @@ while True: ...@@ -88,21 +95,19 @@ while True:
state = "runing" state = "runing"
#d #d
if state == "d" : if state == "d" :
if g > 0: if d > 0:
y -= d y -= d
d -= 2 d -= 2
g -= 10
else: else:
state = "q" state = "q"
if state == "q" : if state == "q" :
if g <= 300: if d <= 30:
d = 30 d += 2
f = 0 f -= 2
g -= 10
else: else:
state = "g" state = "o"
if state == "g" : if state == "o":
if g <= 30: if f <= 30:
y += f y += f
f += 2 f += 2
else: else:
......
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