Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Int

By: caitlinorbanek on Dec 15th, 2011  |  syntax: None  |  size: 1.06 KB  |  views: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. int key_pressed;
  2.  
  3. PFont f;
  4.  
  5.  
  6. String yourtext = "";
  7.  
  8.  
  9. String saved = "";
  10.  
  11. void setup() {
  12.   size(800, 800);
  13.   f = loadFont("GentiumBookBasic-BoldItalic-20.vlw");
  14.  
  15.  
  16.  
  17. }
  18.  
  19. void draw() {
  20.   background(0, 36, 255);
  21.   int indent = 400;
  22.  
  23.   // Set the font and fill for text
  24.   textFont(f);
  25.   fill(0);
  26.  
  27.   // Display everything
  28.   text("Now to really blow your mind- \nCheck out this numeral replacement.  ", indent, 40);
  29.   text(yourtext,indent-300,150);
  30.   text(yourtext,indent-300,1200);
  31.  
  32.  
  33.  
  34. }
  35.  
  36.  
  37.  
  38. void keyPressed() {
  39.  
  40.   if ((key >= 65 && key < 90) | (key >= 97 && key < 122)){
  41.                 key_pressed = (key + 1);
  42.         }
  43.         else if (key == 91 | key == 122) {
  44.                 key_pressed = 65;
  45.         }
  46.  
  47.   // If the return key is pressed, save the String and clear it
  48.  if (key == '\n' ) {
  49.    saved = yourtext;
  50.     // String is cleared by setting it equal to ""
  51.     yourtext = "";
  52.   } else {
  53.     //Otherwise, concatenate the String
  54.     // Each character typed by the user is added to the end of the String variable.
  55.     yourtext = yourtext + key_pressed;
  56.   }
  57. }