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
Hide 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"
y = 400
yy = 30
roadx = 0
sjx = 600
sj = random.choice([stone,cacti,apple])
rect =sj.get_rect()
rect.x=1000
rect.y=500-rect.height
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -49,23 +52,23 @@ while True:
jumpS = "run"
yy = 30
# 将背景图画上去
if sjx == 600:
if rect.x == 1000:
sj = random.choice([stone,cacti,apple])
rect =sj.get_rect()
sjx = 1000+rect.width
sjy = 500-rect.height
rect.x = 1000
rect.y = 500-rect.height
screen.blit(background, (0, 0))
screen.blit(road, (roadx, 500))
screen.blit(hero[index], (150, y))
screen.blit(sj, (sjx, sjy))
sjx -= 5
if sjx < 0-rect.width:
sjx = 600
screen.blit(sj, (rect.x, rect.y))
rect.x -= 8
if rect.x < 0-rect.width:
rect.x = 1000
# 刷新画面
pygame.display.update()
FPS.tick(40)
FPS.tick(60)
if jumpS == "run":
index=(index+1)%5
roadx -= 5
roadx -= 8
if roadx == -1000:
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