本文整理汇总了Python中ball.Ball.vProcess方法的典型用法代码示例。如果您正苦于以下问题:Python Ball.vProcess方法的具体用法?Python Ball.vProcess怎么用?Python Ball.vProcess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ball.Ball
的用法示例。
在下文中一共展示了Ball.vProcess方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: game_stage_001
# 需要导入模块: from ball import Ball [as 别名]
# 或者: from ball.Ball import vProcess [as 别名]
class game_stage_001():
def __init__(self):
pass
def vInit(self):
self.state = "INIT"
pygame.mixer.init()
pygame.mixer.music.load(os.path.abspath("data/bgm/zeoryma.mid"))
pygame.mixer.music.set_volume(0.5)
pygame.mixer.music.play(-1, 0.0)
self.background = pygame.image.load(os.path.abspath('data/image/background/stage1.png'))
#Init objects
self.ship = spaceShip()
self.ship.vInit()
self.ball = Ball()
self.ball.vInit()
self.ball.Enable = False
self.boss = Boss1()
self.boss.vInit()
self.boss.Enable = False
self.BlockMgr = BlockManager()
self.BlockMgr.vInit()
#init clock
self.clock = pygame.time.Clock()
#group sprites
#self.allSprites = pygame.sprite.Group(self.ship, self.boss, self.ball, self.BlockMgr.blocks, self.boss.bullet)
self.allSprites = pygame.sprite.Group(self.ship, self.ball, self.BlockMgr.blocks, self.boss.bullet)
self.space_dir = "IDLE"
self.mouse_move = False
self.mouse_pos = self.ship.fGetPos()
self.timer = 0
#load font
self.centerFont = pygame.font.Font(os.path.abspath("data/font/cpu.ttf"), 36)
self.bigfont = pygame.font.Font(os.path.abspath("data/font/cpu.ttf"), 120)
#center message
self.msg = ""
self.Message = self.bigfont.render("GET READY!!",True,( 255, 255, 255))
self.Message_rect = self.Message.get_rect()
self.Message_rect.center = (0,382)
self.state = "RUNNING"
#init score
self.score = 0
#Load BGM"
def vProcess(self):
self.clock.tick(30)
#print pygame.time.get_ticks()
self.text_surface = self.centerFont.render("SCORE : %15d" %self.score, True, (255,255,255))
en = self.ship.energy
if en < 0:
en = 0
self.energy_text = self.centerFont.render("ENERGY : %d" %self.ship.energy, True, (255,255,255))
#Tick the timer
self.timer += 1
##print self.timer
if self.Message_rect.center[0] <= 512:
self.Message_rect.center = (self.Message_rect.center[0]+18, self.Message_rect.center[1])
if self.timer >= 120 :
if self.Message_rect[0] < 1024:
if self.msg == "GAME OVER":
self.state = "GAME_OVER"
return
elif self.msg == "YOU WIN":
self.state = "END"
return
self.Message_rect.center = (self.Message_rect.center[0]+18, self.Message_rect.center[1])
if self.ship.state == "DEAD" and self.ship.frame == len(self.ship.imageDead)-1:
self.msg = "GAME OVER"
self.Message = self.bigfont.render("",True,( 255, 255, 255))
self.Message_rect.center = (512, 382)
if self.boss.life <= 0 and self.boss.state == "DEAD_LEFT":
self.msg = "YOU WIN"
self.Message = self.bigfont.render("",True,( 255, 255, 255))
self.Message_rect.center = (512, 382)
for event in pygame.event.get():
if event.type == QUIT:
exit()
if event.type == KEYDOWN :
#print pygame.key.name(275)
if event.key == 276:
self.space_dir = "LEFT"
self.mouse_move = False
elif event.key == 275:
self.space_dir = "RIGHT"
self.mouse_move = False
elif event.key == K_SPACE:
#.........这里部分代码省略.........