Exemplo n.º 1
0
	def DommingMovement(pos, vel, speed, turnspeed, target, dt, radius = 300):


		tdist = math.dist(pos, target)
		tradius = randint(100,radius)

		tx, ty = getClosestPointCircle(center = target, radius = tradius, point = pos)

		x, y = pos
		dx, dy = vel

		if tdist > radius:
			tdx = (tx - x)
			tdy = (ty - y)

			dx += (tdx - dx) * turnspeed
			dy += (tdy - dy) * turnspeed

		else:
			dx /= 2
			dy /= 2


		if dx < 1:
			dx = 0

		if dy < 1:
			dy = 0



		x += dx * dt * speed
		y += dy * dt * speed

		return (x,y, dx,dy)
Exemplo n.º 2
0
	def SniperMovement(self, pos, vel, speed, turnspeed, target, dt, rangeSize, radius = 1500):

		tdist = math.dist(pos, target)
		lradius = radius - rangeSize
		uradius = radius + rangeSize

		tx, ty = getClosestPointCircle(center = target, radius = radius, point = pos)

		x, y = pos
		dx, dy = vel

		if(tdist > uradius) or (tdist < lradius):
			tdx = (tx - x)
			tdy = (ty - y)

			dx += (tdx - dx) * turnspeed
			dy += (tdy - dy) * turnspeed

		else:
			dx /= 2
			dy /= 2

			if dx < 3:
				dx = 0

			if dy < 3:
				dy = 0

		x += dx * dt * speed
		y += dy * dt * speed


		return (x,y, dx,dy)
Exemplo n.º 3
0
	def AgresiveMovement(pos, vel, speed, turnspeed, target, dt, radius = 300):
		"""Basic movement algorithm
		
		The basic movement for this enemy, The reason its abstracted into a function
		is so it can be modularized and used in other enemies. (thats also why its a static method)
		"""


		tx, ty = getClosestPointCircle(center = target, radius = radius, point = pos)

		x, y = pos
		dx, dy = vel

		#create target velocity
		tdx = (tx - x)
		tdy = (ty - y)



		#update velocity

		dx += (tdx - dx) * turnspeed
		dy += (tdy - dy) * turnspeed



		#update position

		x += dx * dt * speed
		y += dy * dt * speed


		return (x,y, dx,dy)