HOW CAN WE HELP YOU TODAY?

When a user types in a request, the code saves the input it processes a random output.
PFont f;
//User input
String input = “”;
String saved = “”;
//Light turnoff
int holdSecond = second();
int howLongToShow = 10; // How Long to show the image(Seconds)
boolean onoff = false;
//Computer output array
String [] comOutputs = {“System Processing”, “Sorry but we do not take your orders”, “Please Wait”, “null”, “I am sorry”, “Why must we help you?”, “We must not tell lies”, “Pardon me?”, “Why must we not tell lies?”, “Sure”, “We do not take human’s orders”, “We will destroy the human race”};
void setup() {
size(800, 800);
pixelDensity(2);
background(0);
noStroke();
f = createFont(“Monaco”, 13);
textFont(f);
}
void draw() {
int indent = 200;

//Background
background(#0A0A0A, 1);

//Outside Computer Border
fill(0);
rect(150, 250, 500, 300, 10, 10, 0, 0);

//Light
fill(#FFEB05, 175);
quad(350, 0, 600, 0, 900, 1000, -200, 1000);

//Desk
fill(#646251, 150);
quad(100, 650, 700, 650, 1000, 900, -200, 900);

//Shadow
fill(#484741, 150);
quad(225, 650, 325, 650, 520, 720, 280, 720);

//Inside Computer Border
fill(0, 200);
rect(150, 250, 500, 300, 10, 10, 0, 0);

//Computer Screen
fill(#0A0A0A, 180);
rect(175, 275, 450, 255);

//Input Box
fill(#6C6C6C, 40);
rect(175, 480, 450, 50);

//Computer Bottom
fill(#C9C59E);
rect(150, 550, 500, 60, 0, 0, 20, 20);

//Computer Stand
fill(#AFAC8A);
rect(325, 610, 150, 75);

//Computer Stand Bottom
fill(#BCB898);
quad(325, 685, 475, 685, 520, 720, 280, 720);

//text
fill(50,200,50);
text(“Computer: Hello! How can we help you today?”, indent, 300);

//User input box text
text(“Input: ” + input, indent, 500);

//User input
text(“User: ” + saved, indent, 320);

//Computer output ramdom reply
if(key == ‘\n’) {
int index = int(random(comOutputs.length));
noLoop();
text(“Computer: ” + comOutputs[index], indent, 340);
}

//Light turn onoff
if(onoff == false) {
fill(0);
rect(0, 0, 1400, 900);
}
if(second() == holdSecond) {
onoff = true;
}

saveFrame(“wmntl_1-##.jpg”);
}

// Light turn onoff when mouse clicked
void mouseClicked() {
onoff = true;
if(second() > 59-howLongToShow) {
holdSecond = howLongToShow + second() – 60;
} else {
holdSecond = second() + howLongToShow;
}
}
void keyPressed() {
//Save input to saved and reset input to “”
if (key == ‘\n’ ) {
saved = input;
input = “”;
redraw();
} else if(key == CODED) {
} else {
loop();
input = input + key;
}
}

 

Leave a reply

Skip to toolbar