Commit d89e2968 by BellCodeEditor

save project

parent 2742489a
Showing with 8 additions and 14 deletions
...@@ -2,13 +2,7 @@ import pygame ...@@ -2,13 +2,7 @@ import pygame
from pygame import locals from pygame import locals
import random import random
class Block(pygame.sprite.Sprite):
def __init__(self,image1,image2,image3):
super().__init__()
self.image=random.choice([image1,image2,image3])
self.rect=self.image.get_rect()
self.rect.x=1000
self.rect.y=500-self.rect.height
pygame.init() # 初始化 pygame.init() # 初始化
# 创建一个窗口 # 创建一个窗口
screen = pygame.display.set_mode((1000, 600)) screen = pygame.display.set_mode((1000, 600))
...@@ -31,7 +25,7 @@ index = 0 ...@@ -31,7 +25,7 @@ index = 0
y = 400 y = 400
jumpState = "runing" jumpState = "runing"
t = 30 t = 30
aa=Block(bush,cacti,stone)
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
...@@ -64,13 +58,13 @@ while True: ...@@ -64,13 +58,13 @@ while True:
if index >= 5: if index >= 5:
index = 0 index = 0
# 将背景图画上去 # 将背景图画上去
shan_x -=2 shan_x -= 1
if shan_x <-1000: if shan_x < -1000:
shan_x=0 shan_x = 0
screen.blit(background, (shan_x, 0)) # 远处背景 screen.blit(background, (shan_x, 0)) # 远处背景
lu_x -=8 lu_x -= 8
if lu_x <-1000: if lu_x < -1000:
lu_x=0 lu_x = 0
screen.blit(road, (lu_x, 500)) # 路 screen.blit(road, (lu_x, 500)) # 路
screen.blit(wukong, (150, y)) # 悟空 screen.blit(wukong, (150, y)) # 悟空
......
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