Class: Camera

rune.raycast.Camera(xopt, yopt, angleopt)

A world-space observer using Point coordinates. Positive angles turn clockwise. Navigation delegates collision to World; input and timing belong to game code.

Constructor

new Camera(xopt, yopt, angleopt)

Creates a new raycast Camera object.
Parameters:
Name Type Attributes Default Description
x number <optional>
0 Horizontal position in tiles.
y number <optional>
0 Vertical position in tiles.
angle number <optional>
0 Heading in radians, with zero pointing east.
Source:

Extends

Members

angle :number

Heading in radians, increasing clockwise.
Type:
  • number
Source:

fov :number

Horizontal field of view in radians.
Type:
  • number
Source:

radius :number

Collision radius in tiles, shared by movement and actor overlap queries.
Type:
  • number
Default Value:
  • 0.2
Source:

x :number

The horizontal coordinate of the point. The default value is 0.
Type:
  • number
Inherited From:
Source:

y :number

The vertical coordinate of the point. The default value is 0.
Type:
  • number
Inherited From:
Source:

Methods

angleTo(target) → {number}

Returns the direction from this point to a target in radians, between -pi and pi. Zero points along positive x. With screen coordinates, positive angles turn toward positive y. Neither point is modified. Returns zero when both points have the same coordinates.
Parameters:
Name Type Description
target rune.geom.Point Target point.
Inherited From:
Source:
Returns:
Direction to the target in radians.
Type
number

copyFrom(point) → {rune.geom.Point}

Copies the coordinates of the specified point to this point.
Parameters:
Name Type Description
point rune.geom.Point The point to copy coordinates from.
Inherited From:
Source:
Returns:
This point.
Type
rune.geom.Point

distance(point) → {number}

Returns the distance between the current and specified point.
Parameters:
Name Type Description
point rune.geom.Point The specified point.
Inherited From:
Source:
Returns:
Type
number

distanceSquared(point) → {number}

Returns the squared distance between the current and specified point without calculating a square root. Compare the result against a squared distance.
Parameters:
Name Type Description
point rune.geom.Point The specified point.
Inherited From:
Source:
Returns:
The squared distance between the points.
Type
number

interpolate(point, fractionopt, outputopt) → {rune.geom.Point}

Determines a point between two specified points. The parameter fraction determines where the new interpolated point is located relative to the two end points.
Parameters:
Name Type Attributes Description
point rune.geom.Point The second point.
fraction number <optional>
The level of interpolation between the two points.
output rune.geom.Point <optional>
Save results to this object.
Inherited From:
Source:
Returns:
The new, interpolated point.
Type
rune.geom.Point

move(world, strafe, forward, distance, radiusopt) → {undefined}

Moves forward/backward and sideways relative to the camera heading. Diagonal input cannot increase movement speed; smaller analog input is retained.
Parameters:
Name Type Attributes Description
world rune.raycast.World Collision world.
strafe number Positive input moves right.
forward number Positive input moves ahead.
distance number Travel distance in tiles.
radius number <optional>
Overrides this camera's collision radius for this move.
Source:
Returns:
Type
undefined

moveTowards(target, distance) → {rune.geom.Point}

Moves this point toward a target by at most the specified distance without passing it. The target is not modified. A distance of zero or less leaves this point unchanged. All coordinates and the distance use the same units.
Parameters:
Name Type Description
target rune.geom.Point Target point.
distance number Maximum distance to move for this call.
Inherited From:
Source:
Returns:
This point.
Type
rune.geom.Point

pick(world, rangeopt) → (nullable) {rune.raycast.Billboard|rune.raycast.Door}

Returns the nearest visible interactive billboard or doorway ahead of the observer.
Parameters:
Name Type Attributes Default Description
world rune.raycast.World World to query.
range number <optional>
64 Maximum distance in tiles.
Source:
Returns:
Type
rune.raycast.Billboard | rune.raycast.Door

set(x, y) → {rune.geom.Point}

Sets the horizontal and vertical coordinates of this point.
Parameters:
Name Type Description
x number The horizontal coordinate.
y number The vertical coordinate.
Inherited From:
Source:
Returns:
This point.
Type
rune.geom.Point

toString() → {string}

Returns a string that contains the values of the x and y coordinates.
Inherited From:
Source:
Returns:
The string representation of the coordinates.
Type
string

trace(world, rangeopt, outputopt, filteropt, scopeopt) → {Object}

Traces a shot or sight line straight ahead without changing the world. The result uses the same format and filtering as World.trace().
Parameters:
Name Type Attributes Default Description
world rune.raycast.World World to query.
range number <optional>
64 Maximum distance in tiles.
output Object <optional>
Reusable hit result.
filter function <optional>
Object eligibility callback.
scope Object <optional>
Callback scope.
Source:
Returns:
Type
Object

turn(angle) → {undefined}

Turns clockwise by the supplied angle, keeping the heading within [0, 2 pi).
Parameters:
Name Type Description
angle number Angle in radians.
Source:
Returns:
Type
undefined