本文整理匯總了Python中Event.post方法的典型用法代碼示例。如果您正苦於以下問題:Python Event.post方法的具體用法?Python Event.post怎麽用?Python Event.post使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Event
的用法示例。
在下文中一共展示了Event.post方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: update
# 需要導入模塊: import Event [as 別名]
# 或者: from Event import post [as 別名]
def update(self, level):
if not self.exploding:
return Item.update(self, level)
else:
size_diff = (self.radius - self.current_size)
self.current_size += Interface.tdiff * (size_diff + 0.5) * 2
if self.current_size >= self.radius:
if not self.hit_bomb:
level.explosion_links[self.explosion_index] = 0
return False
for pos in range(len(level.players) - 1, -1, -1):
player = level.players[pos]
xdiff = player.x - self.x
ydiff = player.y - self.y
if xdiff * xdiff + ydiff * ydiff <= self.current_size * self.current_size:
player.life -= 1
if player.life == 0:
Log.info("Killed " + player.name)
del level.players[pos]
if len(level.players) == 1:
Log.info(level.players[0].name + " wins the match!")
Event.post(Event.EVENT_MATCH_WON)
else:
Log.info("Damaged " + player.name)
for pos in range(len(level.items) - 1, -1, -1):
item = level.items[pos]
xdiff = item.x - self.x
ydiff = item.y - self.y
if xdiff * xdiff + ydiff * ydiff <= self.current_size * self.current_size:
if item.type == "Bomb":
if item is not self and not item.exploding:
self.hit_bomb = True
item.timeout(level, self.explosion_index)
else:
Log.info("Destroyed " + item.type)
del level.items[pos]
return True
示例2: timeout
# 需要導入模塊: import Event [as 別名]
# 或者: from Event import post [as 別名]
def timeout(self, level, linkindex = -1):
self.exploding = True
old_time = level.explosion_last
level.explosion_last = time()
if level.explosion_last - old_time <= .15:
level.explosion_counter += 1
else:
level.explosion_counter = 1
if level.explosion_counter > 4:
Event.post(Event.EVENT_CAMERA_SHAKE)
#self.radius *= 2.0
self.explosion_index = linkindex
if linkindex == -1:
for links in range(len(level.explosion_links)):
if level.explosion_links[links] == 0:
level.explosion_links[links] = 1
self.explosion_index = links
break
if self.explosion_index == -1:
level.explosion_links.append(1)
self.explosion_index = len(level.explosion_links) - 1
else:
for pos in range(len(level.items) - 1, -1, -1):
item = level.items[pos]
xdiff = item.x - self.x
ydiff = item.y - self.y
if xdiff * xdiff + ydiff * ydiff <= self.radius * self.radius:
if item.type == "Bomb":
if item is not self and not item.exploding:
self.hit_bomb = True
level.explosion_links[self.explosion_index] += 1
if level.explosion_links[self.explosion_index] > 4 and not self.hit_bomb:
Event.post(Event.EVENT_CAMERA_SHAKE)
self.radius *= 1.5
return True