def move_right(self):
		if not self.collision:
			#cannot change dir in the air
			return None
		(P, Q) = self.collision
		(x, y) = p.vsub(Q, P)
		if self.collision and x <= 0:
			if abs(x) >= abs(y):
				#surface angle leq 45, can move normally
				self.v = p.proj((self.maxImpulse, 0),
								p.vsub(self.collision[1], self.collision[0]))
			else:
				#surface angle > 45, cannot move easily
				self.v = (self.minImpulse, 0)
	def checkVertexCollision(self, wp, i):
		epsilon = 2
		P = self.LoC[i]
		R = (wp.x, wp.y)
		# check vertex collision with P
		checkDist = p.dist(P, R) <= wp.r + epsilon
		if checkDist:
			#move particle back to proper location
			self.calibrateParticleVertex(wp, P, R)
			L = len(self.LoC)
			Q = self.LoC[(i + 1) % L]
			S = self.LoC[(i - 1) % L]
			u = p.fixNorm(p.vsub(Q, P))
			v = p.fixNorm(p.vsub(P, S))
			w = p.vadd(u, v)
			if wp.isParticle:
				self.particleVertexCollision(wp, P)
			else:
				self.waveVertexCollision(wp, w)
			wp.collision = ((0, 0), w)
	def collision(self, wp):
		#check if in bounding box
		if not (self.minX - wp.r <= wp.x <= self.maxX + wp.r and self.minY - wp.r <= wp.y <= self.maxY + wp.r):
			return False
		epsilon = 2
		L = len(self.LoC)
		if self.inMe:
			inside = True	#still inside
			for i in xrange(L):
				P = self.LoC[i]
				Q = self.LoC[(i + 1) % L]
				R = (wp.x, wp.y)
				nextR = p.vadd((wp.x, wp.y), wp.v)
				det = p.det(P, Q, nextR)
				#if moving away from wall, continue
				if p.det(P, Q, R) >= det: continue
				inside &= (det <= p.dist(P, Q) * (epsilon - wp.r))
				if not inside: break #to retain values of P, Q
			if inside:
				return True #because collision
			#otherwise  check for internal reflection
			base = p.vsub(Q, P)
			if not p.refract(wp.v, base, self.rIndex, 1):
				wp.v = p.reflect(wp.v, base)
				return True
			#otherwise if not complete exit, return collision true
			if det < p.dist(P, Q) * wp.r:
				return True
			#otherwise complete exit, change angle
			self.inMe = False
			wp.v = p.fixNorm(p.refract(wp.v, p.vsub((0, 0), base), self.rIndex, 1), wp.maxSpeed)
			return False
		else:
			#check each individual side
			for i in xrange(L):
				if self.checkEdgeCollision(wp, i):
					return True
			for i in xrange(L):
				if self.checkVertexCollision(wp, i):
					return True
			return False
	def move_up(self):
		if not self.collision:
			#cannot jump in the air
			return False
		subprocess.Popen(["python", self.path + os.sep + "aud" + os.sep + "jump.py"])
		(P, Q) = self.collision
		(x, y) = p.vsub(Q, P)
		if self.collision and x <= 0 and abs(x) >= abs(y):
			#surface angle leq 45, can jump
			impDir = p.orthogonal((x, y))
			self.v = p.vadd(self.v, p.fixNorm(impDir, self.maxJump))
			self.collision = False
		return True
	def update(self):
		if not self.isActive:
			return None
		if p.dist(self.P, self.pathList[self.index]) < 2:
			#then near this position, guard moves towards next target
			self.index = (self.index + 1) % self.L
			self.target = self.pathList[self.index]
		dist = p.dist(self.P, self.target)
		direction = p.vsub(self.target, self.P)
		if direction[0] < 0:
			self.imgDir = 0
		elif direction[0] > 0:
			self.imgDir = 1
		move = p.fixNorm(direction, min(self.stride, dist))
		self.P = p.vadd(self.P, move)
	def draw(self, canvas, topCorner):
		(x, y) = self.P
		canvas.create_image(p.vsub(self.P, topCorner), image=self.img[self.imgDir])
	def draw(self, canvas, topCorner):
		canvas.create_image(p.vsub(self.P, topCorner), image=self.img)
	def draw(self, canvas, topCorner):
		(x, y) = p.vsub(self.P, topCorner)
		canvas.create_image(x, y, image=self.img)
	def calibrateParticleEdge(self, wp, P, Q, R):
		if wp.isParticle:
			base = p.vsub(Q, P)
			perPt = p.perPt(P, Q, R)
			#ensure particle not in wall
			(wp.x, wp.y) = p.vadd(perPt, p.fixNorm(p.orthogonal(base), wp.r))
	def waveEdgeCollision(self, wp, P, Q):
		wp.v = p.fixNorm(p.refract(wp.v, p.vsub(Q, P), 1, self.rIndex), wp.maxSpeed)
		wp.g = (0, 0)
		self.inMe = True
	def waveEdgeCollision(self, wp, P, Q):
		subprocess.Popen(["python", self.path + os.sep + "aud" + os.sep + "twang.py"])
		wp.v = p.reflect(wp.v, p.vsub(Q, P))
	def particleEdgeCollision(self, wp, P, Q):
		wp.v = (0, 0)
		if p.vsub(Q, P)[0] <= 0:
			#then collided from the top
			wp.g = p.proj(wp.gravity, p.vsub(Q, P))
	def calibrateParticleVertex(self, wp, P, R):
		(wp.x, wp.y) = p.vadd(P, p.fixNorm(p.vsub(R, P), wp.r))
	def particleVertexCollision(self, wp, P):
		R = (wp.x, wp.y)
		if p.vsub(R, P)[1] <= 0:
			wp.g = p.proj(wp.gravity, p.vsub(R, P))