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

RedObject
ExtensionExtension

fundamental object in the redUniverse toolkit

Description

Base for all other object like RedPendulum, RedParticle, RedBoid etc. Implements simplified physical laws. All objects register themselves in the world when created.

Class Methods

.new

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

Instance Methods

.update

Moves the object by updating the -loc, -vel and -accel instance variables.

.addForce

Adds a force ( RedVector ) to the -accel variable to push the object somewhere.

.gravityForce

Returns a scalar value representing the gravity force from another object within this world.

.frictionForce

Slows down velocity. Scalar.

.viscosityForce

Slows down velocity. Scalar.

.contains

Returns true if two objects touch. See -size below.

.containsLoc

Returns true if location ( RedVector ) is within the object.

.collide

Collision detection. Add acceleration vector to both objects if they touch.

Arguments:

redObj

Another red object.

safety

How many times the method should nudge objects apart.

Returns:

.world

A world ( RedWorld of any dimension) that currently holds this object. The object will add itself.

.loc

The current location ( RedVector of any dimension) within the world.

.vel

The current velocity ( RedVector of any dimension) that the object has.

.accel

A vector or scalar representing current acceleration.

.mass

A scalar. How hard it will be to move this object around. Used for gravity forces.

.size

A scalar. The distance from location to the outer border i.e. radius. Used for contains and rendering.

Examples