import mwpy_gameobject

MWPYGameObject = mwpy_gameobject.MWPYGameObject
MWPYGameObjectType = mwpy_gameobject.MWPYGameObjectType
MWPYGameObjectState = mwpy_gameobject.MWPYGameObjectState




class MWPYActor(MWPYGameObject):
	def __init__(self, gameObjectType = MWPYGameObjectType['MWGOT_ACTOR']):
		MWPYGameObject.__init__(self, gameObjectType)
		self.state = MWPYGameObjectState['AS_LEFT']
		self.mass = 1
		#specific data
		self.last_state = self.state
		self.islife = True
		self.isfreeze = False
		self.velocity_factor = 0.0
		self.is_actor = True

	def do_update(self, delta, currenttime, world_dict):
		state_candidat = 0
		if self.vel_y > 0.1:
			state_candidat = MWPYGameObjectState['AS_DOWN']
		if self.vel_y < 0.1:
			state_candidat = MWPYGameObjectState['AS_UP']
		if self.vel_x < 0:
			state_candidat = MWPYGameObjectState['AS_LEFT']
			self.vel_x = -self.velocity_factor
		if self.vel_x > 0:
			state_candidat = MWPYGameObjectState['AS_RIGHT']
			self.vel_x = self.velocity_factor
		self.state = state_candidat


	def is_actor(self):
		if self.gameObjectType == MWPYGameObjectType['MWGOT_ACTOR']:
			return True
		return False

	def kill(self):
	       self.islife = False
	       self.disable()

	def freeze(self):
		self.mass = 0
		self.isfreeze = True
