Commit e510a54a by BellCodeEditor

auto save

parent 747f783c
Showing with 21 additions and 4 deletions
import pygame
from pygame import locals
import random # 1.4
pygame.init() # 初始化
# 创建一个窗口
screen = pygame.display.set_mode((1000, 600))
......@@ -22,8 +22,14 @@ hero=[pygame.image.load('hero1.png'),
index = 0 # 1.1
y = 400 # 1.2
t = 30 # 1.3
stone_x = 1000 # 1.4
#stone_x = 1000 # 1.4
jumpState = 'runing' # 1.2
#+++++++++++++++++++++++++++++++++++++++++++++
obstacle = random.choice(([bush,stone,cacti])) # 1.4
rect = obstacle.get_rect()
rect.x = 1000
rect.y = 500-rect.height # 1.4
#+++++++++++++++++++++++++++++++++++++++++++++
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -71,8 +77,18 @@ while True:
#screen.blit(hero, (150, 400))
screen.blit(wukong, (150, 400)) # 1.1
screen.blit(wukong, (150, y)) # 1.2
#++++++++++++++++++++++++++++++++++++++++++++++++
#创建障碍物 1.4
if rect.x <= 0-rect.width:
obstacle=random.choice(([bush,stone,cacti]))
rect = obstacle.get_rect()
rect.x = 1000
rect.y = 500-rect.height
rect.x-=8 # 1.4
screen.blit(obstacle,(rect.x,rect.y)) # 1.4
#++++++++++++++++++++++++++++++++++++++++++++++++
# 刷新画面
stone_x -= 5 # 1.4
screen.blit(stone,(stone_x,400)) # 1.4
# stone_x -= 5 # 1.4
# screen.blit(stone,(stone_x,400)) # 1.4
pygame.display.update()
FPS.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