Commit 15a7aed2 by BellCodeEditor

save project

parent 4127e0fa
Showing with 14 additions and 4 deletions
......@@ -2,7 +2,7 @@ import pygame
from pygame import locals
from pygame.time import Clock as TIME
from pygame.display import set_mode,set_caption,update
from pygame.image import
from pygame.image import load
from random import choice
pygame.init() # 初始化
......@@ -14,7 +14,7 @@ background = load('bg.png') # 背景
road_img = load('road.png') # 路
stone_img = load('stone.png') # 石头
cacti_img = load('cacti.png') # 仙人掌
apple_img = load('bush.png') # 灌木丛
bush_img = load('bush.png') # 灌木丛
hero_img = [load('hero1.png'),
load('hero2.png'),
load('hero3.png'),
......@@ -24,10 +24,11 @@ index = 0
jumpState = "runing"
y = 400
t = 30
obstacle = choice([stone_img,cacti_img,bush_img])
obstacle_list = [stone_img,cacti_img,bush_img]
obstacle = choice(obstacle_list)
rect = obstacle.get_rect()
rect.x = 1000
rect.y = 500 - rect.widgh
rect.y = 500 - rect.width
while True:
for event in pygame.event.get():
......@@ -60,10 +61,18 @@ while True:
else:
index = 4
hero = hero_img[index]
if rect.x <= 0 - rect.width:
obstacle = choice(obstacle_list)
rect = obstacle.get_rect()
rect.x = 1000
rect.y = 500 - rect.height
rect.x -= 8
# 将背景图画上去
screen.blit(background, (0, 0))
screen.blit(road_img, (0, 500))
screen.blit(hero, (150, y))
screen.blit(obstacle,(rect.x,rect.y))
# 刷新画面
update()
TIME().tick(60)
\ 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