import mwpy_gameobject

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


class MWPYWater(MWPYGameObject):
	def __init__(self, gameObjectType = MWPYGameObjectType['MWGOT_WATER']):
		MWPYGameObject.__init__(self, gameObjectType)
	def can_render(self):
		return True
	def can_update(self):
		return True
	def do_update(self, delta, currenttime, world_dict):
		return None

	def update_sprites_state(self, state, offset_x, offset_y):
		pos_x = round( (self.x + offset_x) * mwpy_gameobject.ScrW) * mwpy_gameobject.InvScrW
		pos_y = round( (self.y + offset_y) * mwpy_gameobject.ScrH) * mwpy_gameobject.InvScrH
		#bridge can change width
		width = round(self.w * mwpy_gameobject.DblScrW) * mwpy_gameobject.InvScrW
		height = round(self.h * mwpy_gameobject.DblScrH) * mwpy_gameobject.InvScrH
		watersprite = None
		if(state in self.states_info):
			sprite_list = self.states_info[state]
			for si in sprite_list:
				if(si.name == "WaveSprite"):
					watersprite = si
				si.posx = pos_x - mwpy_gameobject.HalfInvScrW
				si.posy = pos_y - mwpy_gameobject.HalfInvScrH
				si.width = width
				si.height = height
			if(None != watersprite):
				watersprite.posy = round((self.y - 0.02 + offset_y) * mwpy_gameobject.ScrH) * mwpy_gameobject.InvScrH
				watersprite.height = round(0.02 * mwpy_gameobject.ScrH) * mwpy_gameobject.InvScrH
				watersprite.tex_w = 12.5 * watersprite.width
			return sprite_list
		return []
