Commit 82cad0d6 by BellCodeEditor

save project

parent 77fb11e3
Showing with 13 additions and 4 deletions
...@@ -9,6 +9,15 @@ class Block(pygame.sprite.Sprite): ...@@ -9,6 +9,15 @@ 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 Player(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))
...@@ -29,6 +38,7 @@ lu_x=0 ...@@ -29,6 +38,7 @@ lu_x=0
shan_x=0 shan_x=0
index = 0 index = 0
y = 400 y = 400
time = 0
jumpState = "runing" jumpState = "runing"
t = 30 t = 30
aa=Block(bush,cacti,stone) aa=Block(bush,cacti,stone)
...@@ -75,12 +85,12 @@ while True: ...@@ -75,12 +85,12 @@ while True:
screen.blit(wukong, (150, y)) # 悟空 screen.blit(wukong, (150, y)) # 悟空
if aa.rect.x <= 0-aa.rect.width: # 障碍物消失 if aa.rect.x <= 0-aa.rect.width: # 障碍物消失
# 创建障碍物对象
aa=Block(bush,cacti,stone) aa=Block(bush,cacti,stone)
aa.rect.x -= 8 aa.rect.x -= 8
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(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