Commit c7c9cba7 by BellCodeEditor

save project

parent a73f3e43
Showing with 9 additions and 41 deletions
import pygame import pygame
from pygame import locals from pygame import locals
import random
pygame.init() # 初始化 pygame.init() # 初始化
# 创建一个窗口 # 创建一个窗口
...@@ -17,6 +18,10 @@ hero1 = pygame.image.load('hero2.png') ...@@ -17,6 +18,10 @@ hero1 = pygame.image.load('hero2.png')
hero2 = pygame.image.load('hero3.png') hero2 = pygame.image.load('hero3.png')
hero3 = pygame.image.load('hero4.png') hero3 = pygame.image.load('hero4.png')
hero4 = pygame.image.load('hero5.png') hero4 = pygame.image.load('hero5.png')
rondomNum = random.choice([stone,cacti,apple])
rondomRect = rondomNum.get_rect()
rondomRect.x = 1000
rondomRect.y = 500-rondomRect.height
modeList = [hero,hero1,hero2,hero3,hero4] modeList = [hero,hero1,hero2,hero3,hero4]
index = 0 index = 0
y=400 y=400
...@@ -35,7 +40,7 @@ while True: ...@@ -35,7 +40,7 @@ while True:
if event.key == locals.K_SPACE: if event.key == locals.K_SPACE:
status="up" status="up"
if status=="up": if status=="up":
if y =30: if y >150:
y -=5 y -=5
else: else:
status="down" status="down"
...@@ -50,6 +55,9 @@ while True: ...@@ -50,6 +55,9 @@ while True:
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
screen.blit(road, (0, 500)) screen.blit(road, (0, 500))
screen.blit(wukong, (150, y)) screen.blit(wukong, (150, y))
rondomRect.x-=8
screen.blit(rondomNum,(rondomRect.x,rondomRect.y))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(20) FPS.tick(20)
...@@ -57,43 +65,3 @@ while True: ...@@ -57,43 +65,3 @@ while True:
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