Commit cd19c690 by BellCodeEditor

save project

parent 948c1aca
Showing with 13 additions and 2 deletions
import pygame
from pygame import locals
import random
pygame.init() # 初始化
# 创建一个窗口
screen = pygame.display.set_mode((1000, 600))
......@@ -21,7 +21,10 @@ index = 0
y = 400
state = "running"
t = 30
ob=random.choice([stone,cacti,apple])
ob_res=ob.get_rect()
ob_res.x=1000
ob_res.y=500-ob_res.height
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -53,6 +56,13 @@ while True:
screen.blit(background, (0, 0))
screen.blit(road, (0, 500))
screen.blit(wukong, (150, y))
ob_res.x-=30
if ob_res.x<0-ob_res.width:
ob=random.choice([stone,cacti,apple])
ob_res=ob.get_rect()
ob_res.x=1000
ob_res.y=500-ob_res.height
screen.blit(ob,(ob_res.x,ob_res.y))
# 刷新画面
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