Commit 8ca7ec04 by BellCodeEditor

save project

parent ffec4fde
Showing with 12 additions and 5 deletions
import pygame import pygame
from pygame import locals from pygame import locals
import random import random
D=0
F=0
pygame.init() # 初始化 pygame.init() # 初始化
# 创建一个窗口 # 创建一个窗口
screen = pygame.display.set_mode((1000, 600)) screen = pygame.display.set_mode((1000, 600))
...@@ -58,8 +59,14 @@ while True: ...@@ -58,8 +59,14 @@ while True:
if index >= 5: if index >= 5:
index = 0 index = 0
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) # 远处背景 F-=2
screen.blit(road, (0, 500)) # 路 if F<=-1000:
F=0
screen.blit(background, (F, 0))
D-=8
if D<=-1000:
D=0 # 远处背景
screen.blit(road, (D, 500)) # 路
screen.blit(wukong, (150, y)) # 悟空 screen.blit(wukong, (150, y)) # 悟空
if rect.x <= 0-rect.width: # 障碍物消失 if rect.x <= 0-rect.width: # 障碍物消失
...@@ -72,4 +79,4 @@ while True: ...@@ -72,4 +79,4 @@ while True:
screen.blit(obstacle, (rect.x, rect.y)) screen.blit(obstacle, (rect.x, rect.y))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(60) FPS.tick(20)
\ 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