import mwpy_gameobject
import time

MWPYGameObject = mwpy_gameobject.MWPYGameObject
MWPYGameObjectType = mwpy_gameobject.MWPYGameObjectType
MWPYGameObjectState = mwpy_gameobject.MWPYGameObjectState
clock = time.clock


class MWPYTeleport(MWPYGameObject):
	def __init__(self, gameObjectType = MWPYGameObjectType['MWGOT_TELEPORT']):
		MWPYGameObject.__init__(self, gameObjectType)
		self.current_time = 0
		self.max_life_time = 0
		self.is_flash = False

	def enable(self):
		self.is_enable = True
		self.is_flash = True
		self.current_time = 0

	def can_render(self):
		return self.is_flash
	def can_update(self):
		return self.is_enable

	#call then teleport cast to screen
	def do_update(self, delta, currenttime, world_dict):
		self.current_time += delta
		d = self.current_time
		if (d > self.max_life_time):
			self.disable()
		elif (d / self.max_life_time > 0.7):
			d = int(d * 10)
			if ( (d % 2) == 0):
				self.is_flash = True
			else:
				self.is_flash = False



