Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int key_pressed;
- PFont f;
- String yourtext = "";
- String saved = "";
- void setup() {
- size(800, 800);
- f = loadFont("GentiumBookBasic-BoldItalic-20.vlw");
- }
- void draw() {
- background(0, 36, 255);
- int indent = 400;
- // Set the font and fill for text
- textFont(f);
- fill(0);
- // Display everything
- text("Now to really blow your mind- \nCheck out this numeral replacement. ", indent, 40);
- text(yourtext,indent-300,150);
- text(yourtext,indent-300,1200);
- }
- void keyPressed() {
- if ((key >= 65 && key < 90) | (key >= 97 && key < 122)){
- key_pressed = (key + 1);
- }
- else if (key == 91 | key == 122) {
- key_pressed = 65;
- }
- // If the return key is pressed, save the String and clear it
- if (key == '\n' ) {
- saved = yourtext;
- // String is cleared by setting it equal to ""
- yourtext = "";
- } else {
- //Otherwise, concatenate the String
- // Each character typed by the user is added to the end of the String variable.
- yourtext = yourtext + key_pressed;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement