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

Administrator / pygame_lesson7_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 4cb6e268 authored 3 years ago by BellCodeEditor's avatar BellCodeEditor
Browse files
Options
  • Browse Files
  • Download
  • Email Patches
  • Plain Diff

save project

parent 4f219b0f
Show whitespace changes
Inline Side-by-side
Showing with 14 additions and 10 deletions
  • my_game.py
my_game.py
View file @ 4cb6e268
...@@ -23,8 +23,11 @@ jumpS = "run" ...@@ -23,8 +23,11 @@ jumpS = "run"
y = 400 y = 400
yy = 30 yy = 30
roadx = 0 roadx = 0
sjx = 600
sj = random.choice([stone,cacti,apple])
rect =sj.get_rect()
rect.x=1000
rect.y=500-rect.height
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
...@@ -49,23 +52,23 @@ while True: ...@@ -49,23 +52,23 @@ while True:
jumpS = "run" jumpS = "run"
yy = 30 yy = 30
# 将背景图画上去 # 将背景图画上去
if sjx == 600: if rect.x == 1000:
sj = random.choice([stone,cacti,apple]) sj = random.choice([stone,cacti,apple])
rect =sj.get_rect() rect =sj.get_rect()
sjx = 1000+rect.width rect.x = 1000
sjy = 500-rect.height rect.y = 500-rect.height
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
screen.blit(road, (roadx, 500)) screen.blit(road, (roadx, 500))
screen.blit(hero[index], (150, y)) screen.blit(hero[index], (150, y))
screen.blit(sj, (sjx, sjy)) screen.blit(sj, (rect.x, rect.y))
sjx -= 5 rect.x -= 8
if sjx < 0-rect.width: if rect.x < 0-rect.width:
sjx = 600 rect.x = 1000
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(40) FPS.tick(60)
if jumpS == "run": if jumpS == "run":
index=(index+1)%5 index=(index+1)%5
roadx -= 5 roadx -= 8
if roadx == -1000: if roadx == -1000:
roadx = 0 roadx = 0
\ No newline at end of file
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