Commit 89140d06 by BellCodeEditor

auto save

parent 29f1e1bd
Showing with 13 additions and 4 deletions
...@@ -7,6 +7,14 @@ class Block(pygame.sprite.Sprite): ...@@ -7,6 +7,14 @@ class Block(pygame.sprite.Sprite):
super().__init__() super().__init__()
self.image=random.choice([image1,image2,image3]) self.image=random.choice([image1,image2,image3])
self.rect=self.image.get_rect() self.rect=self.image.get_rect()
class Block(pygame.sprite.Sprite):
def __init__(self,image1,image2,image3):
super().__init__()
self.image=random.choice([image1,image2,image3])
self.rect=self.image.get_rect()
self.rect.x=150
self.rect.y=400
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() # 初始化
...@@ -31,6 +39,7 @@ index = 0 ...@@ -31,6 +39,7 @@ index = 0
y = 400 y = 400
jumpState = "runing" jumpState = "runing"
t = 30 t = 30
gamestate=True
aa=Block(bush,cacti,stone) aa=Block(bush,cacti,stone)
while True: while True:
...@@ -42,7 +51,7 @@ while True: ...@@ -42,7 +51,7 @@ while True:
if jumpState == "runing": if jumpState == "runing":
if event.key == locals.K_SPACE: if event.key == locals.K_SPACE:
jumpState = "up" jumpState = "up"
wukong=player(hero[index])
if jumpState == "up": # 起跳状态 if jumpState == "up": # 起跳状态
if t > 0: if t > 0:
y -= t y -= t
...@@ -63,7 +72,7 @@ while True: ...@@ -63,7 +72,7 @@ while True:
index += 1 index += 1
if index >= 5: if index >= 5:
index = 0 index = 0
# 将背景图画上去 # 将背景图画上去
shan_x -=2 shan_x -=2
if shan_x <-1000: if shan_x <-1000:
shan_x=0 shan_x=0
...@@ -83,4 +92,4 @@ while True: ...@@ -83,4 +92,4 @@ while True:
screen.blit(aa.image, (aa.rect.x, aa.rect.y)) screen.blit(aa.image, (aa.rect.x, aa.rect.y))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(70) FPS.tick(60)
\ No newline at end of file \ 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