RedObject fundamental object in the RedUniverse toolkit
base for all other object like RedPendulum, RedParticle, RedBoid etc. implements simplified physical laws. all objects register themselves in the world when created.
see also: RedWorld, RedUniverse
class methods:
*new(world, location, velocity, acceleration, mass, size)
create a new object. see class source for defaults.
instance methods:
update
moves the object by updating the loc, vel and accel instance variables.
addForce(force)
adds a force (RedVector) to the accel variable to push the object somewhere.
gravityForce(redObj)
returns a scalar value representing the gravity force from another object within this world.
frictionForce(constant)
slows down velocity. scalar
viscosityForce(constant)
slows down velocity. scalar
contains(redObj)
returns true if two objects touch. see size below
containsLoc(location)
returns true if location (RedVector) is within the object.
collide(redObj, safety)
collision detection. add acceleration vector to both objects if they touch. returns boolean.
safety is how many times the method should nudge objects apart. default is 3.
instance variables:
<>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 ie radius. used for contains and rendering.
a= RedWorld.new
b= RedObject(a)
a.objects
b.dump
//see examples folder