Human JS

High level functions

Human.prototype.say(string)

  • string - What the human should say. Required.

Allows the Human to speak.

Human.prototype.wave()

The human waves it's "main" hand, in a welcoming manner.

Human.prototype.dance(type)

  • type - The type of dance to perform. Optional.

The human dances one of the three dances: robot, sway and travolta.

Human.prototype.robot()

The human dances the robot.

Human.prototype.sway(times)

  • times - The number of times to sway. Optional.

The human sways side to side.

Human.prototype.travolta(times)

  • times - The number of times to point up. Optional.

The human mimics John Travolta in Saturday Night Fever.

Human.prototype.clap(times)

  • times - The number of times to clap. Optional.

The human claps his/her hands together.

Human.prototype.tapFoot(times, side)

  • times - The number of times to clap. Optional.
  • side - Which side to tap foot on ('left' or 'right'). Optional.

The human taps his/her foot on the ground.

Human.prototype.handsOnHips(numOfSeconds)

  • numOfSeconds - The number of seconds to have hands of hips. Optional.

The human places both hands on his/her hips.

Human.prototype.scratchHead(side)

  • side - Which side to scratch head on ('left' or 'right'). Optional.

The human scratches the top of his/her head.

Human.prototype.punchAir()

The human punches the air in celebration.

Human.prototype.brushShoulder(side)

  • side - Which side shoulder to brush. Optional.

The human brushes it's shoulder because he's/she's cool like that.

Human.prototype.shrug()

The human shrugs his/her shoulders. How rude.

Human.prototype.airGuitar()

The human plays the air guitar. Rock on!

Properties and Support functions

Human.x

The x value of the Human's position.

Human.y

The y value of the Human's position.

Human.gender

The gender of the Human. 'male' or 'female'.

Human.orientation

The side preference of the Human. 'left' or 'right'.

Human.universe

The universe in which the Human operates. Optional.

Human.name

The name of the Human.

Human.saying

What the human is currently saying.

Human.behaviour

An object of various lower-priority settings.

Human.points

The details of the various points on the Human's skeleton.

Human.defaults

The default details of the various points on the Human's skeleton.

Human.getCoor(point, addPosition)

  • point - The name of the point on the skeleton.
  • addPosition - Boolean on whether to add the Human's position to the coordinate.

Returns a coordinate for the given point.

Human.eventListeners

The current event listeners.

Human.doing

Array of what Human is doing.

Human.fireEvent(event, value, sf)

  • event - What the human is doing. e.g. 'wave', 'dance', etc.
  • value - Any value to pass on to listener. Optional.
  • sf - Whether this is start of event, or the end (i.e. finish).

Iterates through all Humans in universe, calling any eventListeners that meet the given requirements.

Human.addListener(event, func, rules)

  • event - What to listen for. e.g. 'wave', 'dance', etc.
  • func - Function to perform on event
  • rules - Object containing rules of when to fire. Valid properties: justMe, when

Adds the given details to human's current event listeners. Listeners listen to other humans in universe unless justMe is set to true (Default: false). Listeners will fire at start and finish of action, unless when is set to 'start' or 'finish' (Default: 'any').

Human.removeListener(event)

  • event - What event to remove listener for.

Removes the given details from human's current event listeners. Listeners listen to other humans in universe.

Human.on(event, func)

  • event - What to listen for. e.g. 'wave', 'dance', etc.
  • func - Function to perform on event

Adds the given details to human's current event listeners. on Listeners listen to callee only. on Listeners will fire at start and finish of action.

Human.onStart(event, func)

  • event - What to listen for. e.g. 'wave', 'dance', etc.
  • func - Function to perform on event

Adds the given details to human's current event listeners. onStart Listeners listen to callee only. onStart Listeners will fire at start of action only.

Human.onFinish(event, func)

  • event - What to listen for. e.g. 'wave', 'dance', etc.
  • func - Function to perform on event

Adds the given details to human's current event listeners. onFinish Listeners listen to callee only. onFinish Listeners will fire at end of action only.

Human.removeListener(event)

  • event - What event to remove listener for.

Removes the given details from human's current event listeners. Listeners listen to other humans in universe.

Human.startDoing(act, value)

  • act - What the human is doing. e.g. 'wave', 'dance', etc.
  • value - Some value to pass on to eventListeners. Optional.

Adds act to Human's doing list, and fires relevant listeners.

Human.finishDoing(act, value)

  • act - What the human is doing. e.g. 'wave', 'dance', etc.
  • value - Some value to pass on to eventListeners. Optional.

Removes act from Human's doing list, and fires relevant listeners.

Human.isDoing(act)

  • act - What the human is supposedly doing. e.g. 'wave', 'dance', etc.

Returns whether or not Human is doing given act.

Human.perform(tasks, done)

  • tasks - Array of tasks to do.[ { timer: 10, func: function(cb) {} } ]
  • done - Function to call when completed. Optional.

A way of timing steps between several actions. Each object in the tasks array should have a timer value (the number of milliseconds since last step to wait before doing this step) and func (what to do during that step).

Human.tween(point, newValue, time, cb)

  • point - The name of the point on the skeleton.
  • newValue - What to change the value to.
  • time - How long to take in milliseconds. Optional.
  • cb - Function to call when completed. Optional

Slowly moves the point to the new value over the given time. This means that movement is fluid looking rather than robotic and jagged.

Human.multiTween(arr, clbck)

  • arr - Arr of objects containing information on what to change, and how long.
  • clbck - Function to call when completed. Optional

Tweens multiple points at once.

Human.pointToCoor(pointName, targetCoor, timer, intersectPoint)

  • pointName - The name of the point on the skeleton.
  • targetCoor - Coordinate of where to place point.
  • timer - How long to take if output is being used for MultiTween. Optional.
  • intersectPoint - Which intersect point to use. Optional

Moves given point to given coordinate. Moves 2 points to get position right (e.g. if moving rightWrist, rightElbow will also move).

Human.reset()

Sets points values back to default.