Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char key_pressed;
- PFont f;
- String yourtext = "";
- String saved = "";
- void setup() {
- size(800, 800);
- f = loadFont("GentiumBasic-16.vlw");
- }
- void draw() {
- background(255, 0, 0);
- int indent = 400;
- // Set the font and fill for text
- textFont(f);
- fill(0);
- // Display everything
- text("Type in this window to see a secret messaging code. \nTry not to feel too James Bond- it's just a computer. ", indent, 40);
- text(yourtext,indent-300,150);
- text(yourtext,indent-300,200);
- }
- void keyPressed() {
- if ((key >= 65 && key < 90) | (key >= 97 && key < 122)){
- key_pressed = (char)(key + 1);
- }
- else if (key == 91 | key == 122) {
- key_pressed = (char)65;
- }
- // If the return key is pressed, save the String and clear it
- if (key == '\n' ) {
- saved = yourtext;
- yourtext = "";
- } else {
- yourtext = yourtext + key_pressed;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement