Skip to content
Ong Ming Yang edited this page Aug 17, 2014 · 4 revisions

Map

Constructor

new Map(vertices)

Arguments

  1. object(index: Vector): Accepts a dictionary of vertices of the form index: vector where index is a unique numeric id and vector is an instance of THREE.Vector3.

Returns

A new map object.


Link tiles

map.link(from, to, direction)

Links two tiles together so that the player can cross from one tile to the other.

Arguments

  1. id: The index of the tile that is being linked from
  2. id: The index of the tile that is being linked to
  3. string('north', 'south', 'east', 'west'): The direction the tiles are being connected

Returns

None.


Change tiles

map.setTile(index, mesh)

Sets the mesh of the tile.

Arguments

  1. id: The index of the tile that is being set.
  2. THREE.Mesh: The mesh object to be applied to the tile.

Returns

None


Make interaction

map.onInteract(index, options)

options = {
  type: string
  callback: function
}

Binds an interaction object to a tile with id index.

Arguments

  1. id: The index of the tile that is being set.
  2. obj(type=string, callback = function(n)): The type of interaction and the callback that is triggered when the interaction is invoked.

Options

  1. type='click': Interaction is invoked upon clicking tile.
  2. type='trigger': Interaction is invoked upon stepping on tile.
  3. callback = function(n): The function that is invoked upon interaction. n refers to the number of times the interaction has been invoked.

Returns

None


Freeze Interaction

map.freezeInteraction(index)

Freezes the tile so that the player cannot interact with it.

Arguments

  1. id: The index of the tile that is to be frozen.

Returns

None


Unfreeze Interaction

map.unfreezeInteraction(index)

Unfreezes the tile so that the player can interact with it. Usually called after map.freezeInteraction.

Arguments

  1. id: The index of the tile that is to be unfrozen.

Returns

None


Declare Animations

map.declareAnimating(array)

Declares the vertices that will be animating. All animating vertices MUST be declared if not they will not animate.

Arguments

  1. array: An array of index values.

Returns

None


Make Animation

map.makeAnimation(index, options)

options = {
  description: string
  loop: function
  trigger: function
}

Binds an animation to a tile with id index.

Arguments

  1. id: The index of the tile that is being set.
  2. obj: Specifies the options for the animation

Options

  1. description=string: Describes the animation.
  2. loop=function(vertex, t): Animates the tile object vertex indefinitely given a global clock counter t. t is counted in seconds.
  3. trigger=function(vertex, t, controls): Animates the tile object vertex once when controls.triggered is set to true. The local clock t counts the number of seconds after that has happened. Need to call controls.done() after the animation is complete to reset the trigger.

Returns

None


Declare clones

map.setClones(object)

object = {
  id: clone1
  id: clone2
  ...
}

clone1 = {
  name: string
  description: string
  facing: direction
  vertex: id
}
...

Instantiates clones onto the map at tiles vertex facing direction direction.

Example

map.setClones
  0:
    name: "Fooman"
    description: "Has no distinguishing properties"
    facing: "north"
    vertex: 0
  1:
    name: "Barman"
    description: "Works at a tavern"
    facing: "north"
    vertex: 8

Narrate

Make narration

window.narrator.narrate(string)

Creates a narration to the player.

Arguments

  1. string: The message that is to be displayed/narrated to the reader.

Returns

None

Foo

Clone this wiki locally