import mwpy_monstr

MWPYMonstr = mwpy_monstr.MWPYMonstr
MWPYGameObject = mwpy_monstr.MWPYGameObject
MWPYGameObjectType = mwpy_monstr.MWPYGameObjectType
MWPYGameObjectState = mwpy_monstr.MWPYGameObjectState




class MWPYStone(MWPYMonstr):
	def __init__(self, gameObjectType = MWPYGameObjectType['MWGOT_STONE']):
		MWPYMonstr.__init__(self, gameObjectType)
		self.emit_x = 0
		self.emit_y = 0
		self.life_rect_x = 1
		self.life_rect_y = 1
		self.start_state = 'AS_LEFT'
		self.first_update = True

	def do_update(self, delta, currenttime, world_dict):
		if self.first_update == True:
			self.emit_x = self.x
			self.emit_y = self.y
			self.first_update = False
			if self.start_state == 'AS_LEFT':
				self.vel_x = -self.velocity_factor
			else:
				self.vel_x = self.velocity_factor

		if self.vel_x <= 0:
			self.state = MWPYGameObjectState['AS_LEFT']
			self.vel_x = -self.velocity_factor
		elif self.vel_x > 0:
			self.state = MWPYGameObjectState['AS_RIGHT']
			self.vel_x = self.velocity_factor
		if self.x > self.life_rect_x or self.y > self.life_rect_y or self.x < (-2 * self.w) or self.y < (-2 * self.h):
			self.x = self.emit_x
			self.y = self.emit_y
			self.vel_y = 0
			if self.start_state == 'AS_LEFT':
				self.vel_x = -self.velocity_factor
			else:
				self.vel_x = self.velocity_factor


