Commit 22a0217d by BellCodeEditor

save project

parent 704b27d8
Showing with 14 additions and 9 deletions
import pygame
from pygame import locals
import random
pygame.init() # 初始化
# 创建一个窗口
screen = pygame.display.set_mode((1000, 600))
......@@ -10,8 +10,8 @@ pygame.display.set_caption("燕子没你我怎么活啊!")
background = pygame.image.load('bg.png') # 背景
road = pygame.image.load('road.png') # 路
stone = pygame.image.load('stone.png') # 石头
cacti = pygame.image.load('cacti.png') # 仙人掌
apple = pygame.image.load('bush.png') # 灌木丛
cati = pygame.image.load('cacti.png') # 仙人掌
bush = pygame.image.load('bush.png') # 灌木丛
hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero2.png'),
pygame.image.load('hero3.png'),
......@@ -23,9 +23,9 @@ y = 400
u = 10
douzou = "runing"
obstacle = random.choice([bush,stone,cati])
rext = obstacle.get_
rext.x =
rext.y =
rect = obstacle.get_rect
rect.x = 1000
rect.y = 500 - rect.height
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -47,9 +47,12 @@ while True:
u += 0.2
else:
douzou = "runing"
if rect.x <= 0 - rect.width:
obstacle = random.choice([bush,stone,cati])
rect = obstacle.get_rect
rect.x = 1000
rect.y = 500 - height
rect.x -= 8
yee = hero[index]
if douzou == "runing":
index += 1
......@@ -60,6 +63,7 @@ while True:
screen.blit(background, (0, 0))
screen.blit(road, (0, 500))
screen.blit(yee, (150, y))
screen.blit(obstacle,(rect.x,rect.y))
# 刷新画面
pygame.display.update()
FPS.tick(10)
\ 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