Commit 5e618b4c by BellCodeEditor

save project

parent 13fb4abb
Showing with 9 additions and 6 deletions
import pygame import pygame
from pygame import locals,display,init from pygame import locals,display,init
from pygame import event as _event
from pygame.time import Clock as TIME from pygame.time import Clock as TIME
from pygame.image import load from pygame.image import load
from pygame.sprite import * from pygame.sprite import Sprite,Group,collide_rect
from random import choice,randint from random import choice,randint
init() # 初始化 init() # 初始化
...@@ -56,7 +57,7 @@ block_list = Group() ...@@ -56,7 +57,7 @@ block_list = Group()
game_state = True game_state = True
while True: while True:
for event in pygame.event.get(): for event in _event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
exit() exit()
...@@ -66,12 +67,11 @@ while True: ...@@ -66,12 +67,11 @@ while True:
jumpState = "up" jumpState = "up"
# 悟空造型 # 悟空造型
wukong = Player(hero[index]) wukong = Player(hero[index])
if game_state:
if jumpState == "runing": # 跑步状态下 if jumpState == "runing": # 跑步状态下
index += 1 index += 1
if index >= 5: if index >= 5:
index = 0 index = 0
if game_state == True:
pass
if jumpState == "up": # 起跳状态 if jumpState == "up": # 起跳状态
if t > 0: if t > 0:
y -= t y -= t
...@@ -109,6 +109,10 @@ while True: ...@@ -109,6 +109,10 @@ while True:
screen.blit(sprite.image,(sprite.rect.x,sprite.rect.y)) screen.blit(sprite.image,(sprite.rect.x,sprite.rect.y))
if sprite.rect.x <= 0-sprite.rect.width: if sprite.rect.x <= 0-sprite.rect.width:
sprite.kill() sprite.kill()
if collide_rect(wukong,sprite):
screen.blit(gameover,(400,200))
game_state = False
# 刷新画面 # 刷新画面
display.update() display.update()
TIME().tick() TIME().tick()
\ No newline at end of file
{"第1名": 0, "第2名": 0, "第3名": 0}
\ 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