Class: Zyps::FleeAction

Inherits:
TimedAction show all
Defined in:
lib/zyps/actions.rb

Overview

Flees from the target, but obeys law of inertia.

Instance Attribute Summary

Attributes inherited from TimedAction

#clock, #rate

Attributes inherited from Action

#started

Instance Method Summary collapse

Methods inherited from TimedAction

#copy, #delta, #initialize, #start, #stop

Methods inherited from Action

#copy, #initialize, #start, #started?, #stop

Constructor Details

This class inherits a constructor from Zyps::TimedAction

Instance Method Details

#do(actor, targets) ⇒ Object

Accelerate away from the first target, but limited by turn rate.



121
122
123
124
125
126
127
128
# File 'lib/zyps/actions.rb', line 121

def do(actor, targets)
	return if targets.empty?
	#Apply thrust to the creature's movement vector, adjusted by elapsed time.
	actor.vector += Vector.new(
		delta,
		Utility.find_angle(actor.location, targets[0].location) + 180
	)
end