Project: atomswarm / Class: Atom

Processing swarm classes with genetic and metabolic extensions.

Class: Atom

Represents a single swarming agent.


Variables

  • float x, y - position in 2D swarm space
  • float vx, vy - velocity in 2D (pixels/s)
  • float velocity - absolute scalar velocity (calculated each frame from vx/vy)
  • float age - agent's age (frames)
  • boolean alive - has agent died?
  • String name - name of agent/species (default "atom")
  • color col - colour of agent's inner ring
  • color ring_color - colour of agent's outer ring

Methods

Atom (AtomSwarm swarm)
Allocate a new agent in the given swarm. Must then be added to that swarm's agent list with swarm.add(atom).
void destroy()
Destroy the agent. Must then be removed from the swarm's agent list with swarm.remove(atom).
void trigger ()
Generate an arbitrary trigger event. Has no function in the Atom superclass, but is overriden to (say) generate sound output in its subclasses.
void set (String arg, int value)
Sets an arbitrary property of the agent. Has no function in the Atom superclass, but is overriden to set properties of the agent's Synth object in its subclasses.
void flash ()
void flash (float width)
void flash (float width, color color)
Causes the agent to flash visibly for the next frame only.
void set (String arg, int value)
Sets an arbitrary property of the agent. Has no function in the Atom superclass, but is overriden to set properties of the agent's Synth object in its subclasses.
void display ()
Draws the agent in the current display, including its flash and trail properties.
Atom nearestAtom ()
Returns the nearest agent with the current swarm.