RedWorld:
Filter:
redUniverse/Classes (extension) | Red > redUniverse

RedWorld
ExtensionExtension

fundamental object in the redUniverse toolkit

Description

Base for all other worlds like RedWorld1, RedWorld2, RedWorld3. Implements simplified physical laws.

Class Methods

.new

Create a new world. See class source for more information on defaults.

Instance Methods

.add

Manually add an object to this world. Usually never needed.

.remove

Manually remove an object from this world.

.contain

Wrap an object around world dimensions. i.e. in a world without borders - going out on the right side brings the object back on the left.

.contains

Check if an object is within world dimensions. Used for detecting wall bounce.

Returns:

.neighbours

Returns an Array of objects that are in the surrounding locations. Only useful when working with discrete worlds. e.g. cellular automata.

NOTE: Subclasses will treat the neighborhood at world borders differently. e.g. RedWorld3 filters out.

.surroundingLocations

Returns an Array of RedVector objects representing the surrounding locations. Only useful when working with discrete worlds. e.g. cellular automata.

NOTE: Subclasses will treat the neighborhood at world borders differently. e.g. RedWorld3 filters out.

.dim

Size of this world ( RedVector of any dimension). i.e. the world can have any number of dimensions.

.gravity

World gravity ( RedVector of any dimension) for each dimension.

.maxVel

Scalar with maximum velocity. i.e. 'speed of light' for this world.

.damping

A scalar. The cost of running into walls etc.

.objects

An Array of all objects currently in this world.

.surroundings

An Array containing arrays with a size that matches the current world dimensions. Only useful when working with discrete worlds. e.g. cellular automata.

.surroundingArea

An Integer specifying how far the surroundings will stretch. A 1 here (the default) lists only the adjacent locations. e.g. a 1 gives 8 locations in the surroundings array if the world is 2D, while 2 gives 24 and 3 48. In a 3D world 1 gives 26, 2 124 and 3 342.

Examples