Commit 5675bd19 by BellCodeEditor

save project

parent 13b43e35
Showing with 14 additions and 2 deletions
import pygame
from pygame import locals
import random
pygame.init() # 初始化
# 创建一个窗口
......@@ -22,6 +23,11 @@ y=400
jumpState='running'
zl=30
z=random.choice([stone,cacti,apple])
rect=z.get_rect()
rect.x=1000
rect.y=500-rect.height
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -43,12 +49,18 @@ while True:
else:
jumpState = 'running'
zl=30
#if jumpState=='up' or jumpState=='down':
if rect.x<0-rect.width:
z=random.choice([stone,cacti,apple])
rect=z.get_rect()
rect.x=1000
rect.y=500-rect.height
rect.x-=8
# 将背景图画上去
screen.blit(background, (0, 0))
screen.blit(road, (0, 500))
screen.blit(hero[index], (150, y))
screen.blit(z, (rect.x, rect.y))
if jumpState=='running':
index+=1
if index>4:
......
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