Commit e69633f2 by BellCodeEditor

save project

parent 047b7f73
Showing with 12 additions and 4 deletions
import pygame import pygame
import random
from pygame import locals from pygame import locals
pygame.init() # 初始化 pygame.init() # 初始化
...@@ -19,17 +20,13 @@ while True: ...@@ -19,17 +20,13 @@ while True:
if event.type == locals.QUIT: if event.type == locals.QUIT:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
exit() exit()
for event in pygame.event.get() for event in pygame.event.get()
if event.type == local.QUIT if event.type == local.QUIT
screen.blit(hero, (150, 400)) screen.blit(hero, (150, 400))
# 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(60) FPS.tick(60)
wukong = hero[index] wukong = hero[index]
indes += 1 indes += 1
if jumpState == "up": if jumpState == "up":
if y >150: if y >150:
y -= t y -= t
...@@ -42,3 +39,13 @@ while True: ...@@ -42,3 +39,13 @@ while True:
t +=2 t +=2
else: else:
jumpState = "runing" jumpState = "runing"
if rect.x <= 0-rect.width:
obstacle = random.choise([bush,stone,cacti])
rect = obstacle.get_rect
rect.x=1000
rect.y=500
rect.x-=8
screen.blit(obstacle,(rect.x,rect.y))
0
pygame.display.update
FPS.tick(30)
\ 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