Commit 5bd17e20 by BellCodeEditor

save project

parent bb623afd
Showing with 18 additions and 2 deletions
import pygame
from pygame import locals
import random
pygame.init() # 初始化
# 创建一个窗口
......@@ -18,10 +19,21 @@ hero2 = pygame.image.load('hero3.png')
hero3 = pygame.image.load('hero4.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]
if rondomRect.x<0-rondomRect.width:
rondomNum = random.choice([stone,cacti,apple])
rondomRect = rondomNum.get_rect()
rondomRect.x = 1000
rondomRect.y = 500-rondomRect.height
modelist = [hero,hero1,hero2,hero3,hero4]
status ="runing"
y=400
index = 0
while True:
......@@ -38,7 +50,7 @@ while True:
if event.key == locals.K_SPACE:
status="up"
if status == "up"
if status == "up":
if y>150:
y-=5
else:
......@@ -50,6 +62,9 @@ while True:
screen.blit(background, (0, 0))
screen.blit(road, (0, 500))
screen.blit(hero, (150, y))
rondomRect.x-=8
screen.blit(rondomNum,(rondomRect.x,rondomRect.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