Commit cd3d987a by BellCodeEditor

save project

parent e46cca79
Showing with 11 additions and 0 deletions
import pygame import pygame
from pygame import locals from pygame import locals
import random
pygame.init() # 初始化 pygame.init() # 初始化
# 创建一个窗口 # 创建一个窗口
...@@ -19,10 +20,13 @@ hero4 = pygame.image.load('hero4.png') ...@@ -19,10 +20,13 @@ hero4 = pygame.image.load('hero4.png')
hero5 = pygame.image.load('hero5.png') hero5 = pygame.image.load('hero5.png')
y=400 y=400
h=[hero1,hero2,hero3,hero4,hero5] h=[hero1,hero2,hero3,hero4,hero5]
q=[stone,cacti,apple]
r=q[random.randint(0,2)]
x=0 x=0
index = 0 index = 0
j1='r' j1='r'
t=30 t=30
w=r.get_rect()
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:
...@@ -44,6 +48,12 @@ while True: ...@@ -44,6 +48,12 @@ while True:
else: else:
j1="r" j1="r"
t=30 t=30
if w.x<0-w.width:
r=q[random.randint(0,2)]
w=r.get_rect()
w.x=1000
w.y=500-w.height
w.x-=10
...@@ -56,6 +66,7 @@ while True: ...@@ -56,6 +66,7 @@ while True:
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
screen.blit(road, (0, 500)) screen.blit(road, (0, 500))
screen.blit(h[x], (150, y)) screen.blit(h[x], (150, y))
screen.blit(r,(w.x,w.y))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
......
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