Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

Administrator / pygame_lesson8_diy4

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Snippets
  • Members
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Commit 25acad74 authored a year ago by BellCodeEditor's avatar BellCodeEditor
Browse files
Options
  • Browse Files
  • Download
  • Email Patches
  • Plain Diff

save project

parent 037c7d48
Hide whitespace changes
Inline Side-by-side
Showing with 9 additions and 27 deletions
  • my_game.py
my_game.py
View file @ 25acad74
......@@ -8,9 +8,8 @@ class Block(pygame.sprite.Sprite):
self.image=random.choice([image1,image2,image3])
self.rect=self.image.get_rect()
self.rect.x=1000
self.rect.y=500-self.rect.heig
self.rect.y=500-self.rect.height
pygame.init() # 初始化
# 创建一个窗口
screen = pygame.display.set_mode((1000, 600))
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
......@@ -34,8 +33,6 @@ jumpState = "runing"
t = 30
aa=Block(bush,cacti,stone)
Block_list=pygame.sprite.Group()
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -46,16 +43,6 @@ while True:
if event.key == locals.K_SPACE:
jumpState = "up"
# 悟空造型
wukong = hero[index]
if jumpState == "runing": # 跑步状态下
index += 1
if index >= 5:
index = 0
if gamestate==True:
if jumpState == "up": # 起跳状态
if t > 0:
y -= t
......@@ -70,7 +57,12 @@ if gamestate==True:
jumpState = "runing"
t =30
# 悟空造型
wukong = hero[index]
if jumpState == "runing": # 跑步状态下
index += 1
if index >= 5:
index = 0
# 将背景图画上去
shan_x -=2
if shan_x <-1000:
......@@ -86,18 +78,8 @@ if gamestate==True:
# 创建障碍物对象
aa=Block(bush,cacti,stone)
aa.rect.x -= 8
time+=1
if time>=60:
time=0
num=random.randint(0,50)
if num>20:
obstacle=Block(bush,cacti,stone)
Block_list.add
if pygame.sprite.collide_rect(wukong,sprite):
gemeover = pygame.image.load('gameover.png')
screen.blit(gameover,(400,200))
gamestate=Flase
screen.blit(aa.image, (aa.rect.x, aa.rect.y))
# 刷新画面
pygame.display.update()
......
This diff is collapsed. Click to expand it.
  • Write
  • Preview
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