Commit 338bba90 by BellCodeEditor

save project

parent d0f3448c
Showing with 9 additions and 8 deletions
...@@ -2,6 +2,7 @@ import pygame ...@@ -2,6 +2,7 @@ import pygame
from pygame import locals from pygame import locals
import random import random
pygame.init() # 初始化 pygame.init() # 初始化
group = pygame.sprite.Group()
class Books(pygame.sprite.Sprite): class Books(pygame.sprite.Sprite):
def __init__(self,image1,image2,image3): def __init__(self,image1,image2,image3):
super().__init__() super().__init__()
...@@ -24,16 +25,16 @@ hero = [pygame.image.load('hero1.png'), ...@@ -24,16 +25,16 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero3.png'), pygame.image.load('hero3.png'),
pygame.image.load('hero4.png'), pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')] pygame.image.load('hero5.png')]
#变量
index = 0 index = 0
y = 400 y = 400
t = 35 t = 35
road_x = 0 road_x = 0
beijing_x = 0 beijing_x = 0
time = 0
jump = "running" jump = "running"
#rect = cacti.get_rect()
#rect.x = 1000
#rect.y = 455 - rect.width
obstacle=Books(stone,cacti,apple) obstacle=Books(stone,cacti,apple)
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:
...@@ -76,11 +77,11 @@ while True: ...@@ -76,11 +77,11 @@ while True:
screen.blit(road, (road_x, 500)) screen.blit(road, (road_x, 500))
screen.blit(wukong, (150, y)) screen.blit(wukong, (150, y))
#障碍物 #障碍物
if obstacle.rect.x < 0-obstacle.rect.width: #if obstacle.rect.x < 0-obstacle.rect.width:
obstacle = Books(stone,cacti,apple) # obstacle = Books(stone,cacti,apple)
else: #else:
obstacle.rect.x -= 8 # obstacle.rect.x -= 8
screen.blit(obstacle.image,(obstacle.rect.x, obstacle.rect.y)) #screen.blit(obstacle.image,(obstacle.rect.x, obstacle.rect.y))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
......
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