Commit e510a54a by BellCodeEditor

auto save

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