当前位置: 首页>>代码示例>>Python>>正文


Python Event.post方法代码示例

本文整理汇总了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
开发者ID:jasonkotenko,项目名称:Boom-Engine,代码行数:41,代码来源:Objects.py

示例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
开发者ID:jasonkotenko,项目名称:Boom-Engine,代码行数:38,代码来源:Objects.py


注:本文中的Event.post方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。