Flying Words


  // Flying Words - Jim Bumgardner
  
  String[] words = {"pondering", "squarely", "pregnant", "paws", "scold", "cordiality", "cooler",
    "venturing", "variance", "hypothesis", "forefinger", "economic", "untimely",
    "dubious", "shepherds", "secular", "minimum", "pallor", "degrading",
    "fastidious", "desertion", "foretold", "heath", "discourage", "wintry",
    "wrenched", "peas", "raiment", "pensive", "reproof", "ankle", "flattened",
    "moore", "fisherman", "peninsula", "beholding", "identification", "wheeling",
    "maine", "unhappiness", "richmond", "frantically", "enhanced", "gorge",
    "extremities", "joyously", "stronghold", "hissed", "nut", "bowels",
    "repressed", "lending", "feasts", "cavern", "unfold", "memoirs", "onto",
    "invade", "ark", "structures", "forbids", "liver", "correctness", "abashed",
    "stumble", "clerical", "orchestra", "terrifying", "enchantment",
    "incomparable", "collapsed", "paler", "ballad", "recalls", "slack",
    "restraining", "motley", "rippling", "circled", "ardor", "lambs", "flapping",
    "shrug", "prettily", "avarice", "aforesaid", "educate", "glorified",
    "acquiescence", "acquitted", "dungeon",  "blasted", "objective", "persuading",
    "fray", "forts", "statistics", "gathers", "levelled", "moderately",
    "splashed", "mirrors", "infected", "vacancy", "furs", "mates", "grating",
    "precipitate", "confiding", "ton", "grazing", "dispositions", "partnership",
    "momentarily", "framework", "attorney", "regulating", "fathom", "nimble",
    "ravages", "surpassing", "quieted", "hitting", "sustaining", "practiced",
    "darkening", "walled", "withdrawal", "unawares", "exceptionally", "howard",
    "fiend", "queens", "horseman", "dictates", "quarry", "waged", "coral",
    "pleasanter", "badge", "assurances", "subsistence", "italians", "manned",
    "alphabet", "bower", "reposed", "preachers", "variously", "anticipating",
    "arabian", "melodious", "slate", "hourly", "bled", "dejected", "dreamt",
    "discordant", "stormed", "purchasing", "sap", "unreal", "parlour", "dam",
    "couples", "humblest", "postpone", "butterflies", "chaps", "yells", "paw",
    "freeze", "forfeit", "eclipse", "advertisements", "dozens", "quitting",
    "romances", "uphold", "drunkenness", "agonies", "guinea", "forge", "tearful",
    "twig", "dispatched", "windy", "tidy", "bitterest", "dogged", "wastes",
    "disconcerted", "irritable", "tunnel", "contentedly", "backing", "uniforms",
    "gunpowder", "mineral", "pigeons", "repel", "pail", "territories", "ransom",
    "stab", "draped", "redemption", "individually", "medicines", "azure", "bony",
    "scissors", "ma", "invariable", "supplement", "repulsed", "entreaty",
    "capitals", "forbearance", "adviser", "unavoidable", "raining", "enlighten",
    "holiness", "countenances", "untold", "coil", "mutilated", "dancers",
    "thankfulness", "buzzing", "armor", "spoiling", "narrower", "adhere",
    "ardently", "undergoing", "indomitable", "devoting", "friction", "thrive",
    "ravine", "diverse", "floats", "hazy", "twain", "aspire", "visage",
    "quarrelling", "womanly", "shields", "initiative", "disappointments",
    "elaborately", "civility", "disobedience", "splashing", "festivities",
    "disasters", "bustling", "vicissitudes", "monopoly", "helen", "raid",
    "marshes", "fitful", "consigned", "illustrates", "apprehensive",
    "conscientiously", "fabulous", "colleagues", "profited", "wharf",
    "grievances", "countryman", "laurels", "diversity", "monastery", "target",
    "pounded", "conspicuously", "myriads", "hostilities", "atrocious", "vase",
    "overturned", "redoubled", "mountainous", "swallowing", "layer", "adherents",
    "sparing", "parchment", "trampling", "imaginations", "laughingly",
    "fictitious", "jet", "widows", "picnic", "prospective", "valour", "absorb",
    "yankee", "chocolate", "courtiers", "canoe", "chasm", "biscuit", "stairway",
    "jars", "adjustment", "ancestral", "roving", "catholics", "psychological",
    "milder", "adapt", "woollen", "loathsome", "rowing", "barracks", "signing",
    "banker", "grunted", "slumbers", "garret", "midsummer", "ignoble", "savings",
    "substantially", "resuming", "fostered", "mane", "prophesied", "forfeited",
    "swan", "loosed", "fortifications", "gloriously", "vouchsafed", "oratory",
    "jovial", "crescent", "stinging", "stamps", "commissions", "lanterns",
    "caresses", "merest", "universities", "insurance", "draughts", "surmise",
    "rebuked", "valid", "barbarians", "revolted", "humbled", "emerald",
    "contradicted", "halfway", "marvels", "excel", "nervousness", "pier", "stall",
    "illustrating", "grades", "surly", "utensils", "chagrin", "colouring",
    "murders", "northwest", "widening", "pitiable", "keener", "kent", "devilish",
    "conventions", "carving", "studded", "mat", "dwarf", "weights", "youngster",
    "compels", "resounded", "dispatch", "fried", "completeness", "dismissal",
    "undecided", "aiding", "dimmed", "plied", "illumined", "extensively",
    "needing", "graphic", "embroidery", "glimmering", "sash", "sauntered",
    "sniffed", "grasses", "pitcher", "rapt", "unerring", "offences", "exiled",
    "sucked", "raced", "fig", "streaks", "halo", "religions", "rhetoric",
    "advising", "fraught", "canadian", "hampered", "riders", "profile", "incur",
    "excellency", "benediction", "gregory", "particles", "diminutive",
    "chemistry", "infants", "lounging", "knocks", "elated", "mien", "propped",
    "reverent", "antagonism", "wade", "exhaust", "unduly", "needy", "girlish",
    "hoarsely", "mortified", "hercules", "initials", "scar", "flowery",
    "reproduction", "absorption", "excelled", "stains", "facilitate", "modify",
    "slap", "grounded", "wig", "lavished", "magnified", "agility", "hugh",
    "sponge", "irishman", "cultivating", "stalked", "fumes", "metals", "arena",
    "augmented", "enjoined", "fibre", "flushing", "biscuits", "attends", "nick",
    "soaring", "follower", "boom", "surest", "rhine", "proclaiming", "snatching",
    "paramount", "alluring", "clambered", "loom", "poultry", "intoxication",
    "slaughtered", "perplexing", "impaired", "sleek", "patting", "conceited",
    "squirrel", "inventor", "notably", "swells", "ripened", "click", "ethics",
    "fairies", "adventurer", "summoning", "vocal", "jove", "scolded", "dwellers",
    "uniformity", "sarah", "prairie", "capacities", "unfriendly", "uttermost",
    "hens", "gear", "penance", "unbearable", "sewed", "legion", "disposing",
    "mistook", "prestige", "organic", "unparalleled", "invaders", "laboriously",
    "trench", "steeped", "distraction", "dipping", "groped", "slackened", "beak",
    "salutary", "summits", "intrusted", "inanimate", "flowering", "reiterated",
    "receding", "jagged", "adversity", "safeguard", "unacquainted", "stalks",
    "axes", "alps", "hip", "mortality", "perverse", "apathy", "weighs", "julius",
    "witnessing", "epithet", "childlike", "lunatic", "pretends", "convict",
    "oblivious", "restlessly", "yarn", "offense", "chests", "runaway",
    "dilapidated", "unfailing", "verdure", "cloudless", "ferry", "vista", "toll",
    "prettier", "unearthly", "enlist", "feudal", "penitent", "scarf", "encamped",
    "dedication", "mahogany", "relinquish", "residents", "salmon", "payments",
    "meditations", "tragedies", "sufferers", "concludes", "arnold", "smoky",
    "altars", "squadron", "pursuers", "sagacious", "abnormal", "bernard",
    "reeled", "strangled", "cherry", "planets", "combatants", "bunches",
    "feathered", "fearlessly", "therefrom", "canst", "precipitated", "likelihood",
    "potato", "conquests", "intensified", "columbus", "hairy", "slapped",
    "scrupulously", "immemorial", "buoyant", "graver", "warranted", "senator",
    "excesses", "invading", "complimentary", "turks", "highness", "factors",
    "vindictive", "shovel", "tenderest", "uncanny", "augustus", "propositions",
    "detection", "efficacy", "artful", "iniquity", "emancipation", "listless",
    "indolence", "lease", "purified", "grease", "unoccupied", "encounters",
    "treasurer", "hereby", "narrated", "revel", "impetus", "legislative",
    "wailed", "mexican", "disappoint", "impertinence", "abstraction", "pulls",
    "submissive", "surged", "falsely", "sheriff", "wilder", "underwent",
    "submitting", "prisons", "implicitly", "treasured", "sculpture", "spheres",
    "trailed", "impassioned", "exacted", "converts", "pepper", "coloring",
    "noiseless", "conflagration", "relatively", "maddened", "precincts", "versed",
    "quartered", "culprit", "tunes", "torments", "birch", "fairness", "unsteady",
    "terminate", "offender", "citadel", "ado", "compiled"};
  
  class WordSprite {
    String word;
    float  x, y;
    float  vx, vy;
    color  clr;
    float  wordWidth;
    
    WordSprite(String word, float x, float y)
    {
      this.word = word;
      this.x = x;
      this.y = y;
      this.vx = random(-2,2);
      this.vy = random(-2,2);
      clr = color( random(256), random(256), random(256) );
      wordWidth = textWidth(word);
    }
  
    void doMovement()
    {
      x = x + vx;
      y = y + vy;
      
      // Bouncy sprites
      if (x < -wordWidth/2)  vx = abs(vx);
      if (x > width+wordWidth/2)  vx = -abs(vx);
      if (y < 0)  vy = abs(vy);
      if (y > height+50)  vy = -abs(vy);
    }
  
    void render()
    {
      fill(clr);
      text(word, x, y);
    }
  }
  
  PFont font;
  
  int nbrWordSprites = 10;
  WordSprite[] mySprites;
  
  void setup()
  {
    size(500,500);
    smooth();
    font = createFont("Helvetica-Bold",72);
    textFont(font, 72);
    textAlign(CENTER);
  
    mySprites = new WordSprite[nbrWordSprites];
    for (int i = 0; i < nbrWordSprites; ++i) {
      String word = words[int(random(words.length))];
      float x = random(width);
      float y = random(height);
      mySprites[i] = new WordSprite(word, x, y);
    }
  
  }
  
  void draw()
  {
    noStroke();
    fill( 255, 20);
    rect(0,0,width,height);
  
    for (int i = 0; i < nbrWordSprites; ++i) {
      mySprites[i].doMovement();
      mySprites[i].render();
    }  
  }