numberBox a,b,c,d,e,f,g,j; PFont font; int countmax = 200; int counts = 0; float w = 800; float h = 600; float [] o = {0,0,0,0,0,0,0,0,0,0}; //float [] c = {0,0,0,0,0,0,0,0,0,0}; String[] nresponse = {"","","","","","","","",""}; String lastInput = new String(); void setup() { size(int(w),int(h)); font = loadFont("Arial-Black-48.vlw"); a = new numberBox(170,140, 100,50); //Distance b = new numberBox(600,160,100,50); //correct answer c = new numberBox(170,200,100,50); //Time 260 100 d = new numberBox(600,60,100,50); //Name input e = new numberBox(170,60,100,50); //Hypothesis f = new numberBox(170,260,100,50); //Speed 200 100 // g = new numberBox(170, 280,100,50); j = new numberBox(3.6*w/10,6*h/10,100,50); } void draw() { background(200); stroke(100); strokeWeight(3); //line(3*w/10+100,1.925*h/10,1.65*w/10+100,1.925*h/10); //line(1.65*w/10+100,1.925*h/10,1.65*w/10+100,1.925*h/10+50); textSize(20); fill(100); text("Player Number:",400,90); // text("Hover your mouse over a box to enter numbers.",10,500); // text("If the box is orange, the program is reading your input.",10,530); text("Hypothesis",30,90); text("ft/sec" , 290, 90); text("Distance", 45,175); text("ft",290, 175); text(" Time", 45, 240); text("seconds",290, 240); text("Speed (ft/sec)", 16, 300); text("ft/sec", 290, 300); int value = 0; fill(204, 102, 0); rect(400,160,170,50); fill(204, 102, 0); rect(400,220,170,50); fill(255, 255, 255); text("Calculate", 430,193); fill(255, 255, 255); text("Clear", 455,253); a.display(nresponse[0],0.3,a.o); d.display(nresponse[3],0.3,d.o); e.display(nresponse[4],0.3, e.o); f.display(nresponse[5],0.3,f.o); // g.display(nresponse[6]),0.3); // j.display(float(nresponse[7]),0.3); a.mouseMoved(); c.mouseMoved(); d.mouseMoved(); e.mouseMoved(); f.mouseMoved(); // g.mouseMoved(); // j.mouseMoved(); // a.o = 1; o[0] = a.o; o[1] = b.o; o[2] = c.o; o[3] = d.o; // o[4] = e.o; o[5] = f.o; // o[6] = g.o; o[7] = j.o; b.display(nresponse[1],0.3,1); c.display(nresponse[2],0.3,o[2]); //println(int(float(lastInput))); if (int(float(lastInput)) > 0) { nresponse[3] = str(int(nresponse[3])-1); if (int(float(lastInput)) == int(nresponse[2])/int(nresponse[1])){ nresponse[3] = str(int(nresponse[3])+2); } println(int(lastInput)); println(int(nresponse[1])/int(nresponse[2])); nresponse[1] = str(int(random(1,10))); nresponse[2] = str(int(nresponse[1])*int(random(1,10))); nresponse[4] = str(0); nresponse[5] = str(0); //counts = 0; } if (float(nresponse[1]) > 0) { if (float(nresponse[1])!=(float(nresponse[5]))) { //If the answer is WRONG println("WooOOOps"); textSize(30); text("That answer doesn't seem correct, try again", 10, 450); textSize(40); } } if (float(nresponse[1]) == (float(nresponse[5]))) { //If the answer is correct, display Correct! println("YAY"); text("Correct! Add 5 points to your score", 50, 500); /*if (counts > countmax) { counts = 0; nresponse[1] = str(int(random(1,10))); nresponse[2] = str(int(nresponse[1])*int(random(1,10))); nresponse[3] = str(int(nresponse[3])-1); nresponse[4] = str(0); nresponse[5] = str(0); }*/ if (abs(float(nresponse[4])-(float(nresponse[1]))) < .25){ textSize(30); text("Add 1 Bonus point for an accurate Hypothesis!", 40, 550); textSize(40); /* if (int(nresponse[3]) == 10) { fill(100); rect(0,0,w,h); textSize(40); fill(255); text("Good work!",w/2,h/2); delay(1000); nresponse[3] = ""; }*/ counts++; lastInput = ""; } } } void mousePressed(){ if(mouseX >400 && mouseX <570 && mouseY >160 && mouseY<210) { nresponse[1] = str(float(nresponse[0])/float(nresponse[2])); //MATH EQUATION SHIT } if(mouseX >400 && mouseX <570 && mouseY >220 && mouseY<270) { nresponse[1] = " "; //CLEAR BUTTON nresponse[0] = " "; nresponse[2] = " "; nresponse[3] = " "; nresponse[4] = " "; nresponse[5] = " "; } } void keyPressed() { for (int i = 0; i<8;i++) { if (o[i]==1) { if (key >= '0' && key <= '9') { nresponse[i]+=char(key); if (abs(float(nresponse[i]))>float(100)){ nresponse[i] = nresponse[i].substring(0,nresponse[i].length()-1); } } else if(key == '.') { nresponse[i]+=char(key); if (abs(float(nresponse[i]))>float(100)){ nresponse[i] = nresponse[i].substring(0,nresponse[i].length()-1); } } else if(key == ENTER || key == RETURN) { lastInput = nresponse[i] = nresponse[i] + key; nresponse[i] = ""; } else if(key == BACKSPACE && nresponse[i].length() > 0) { nresponse[i] = nresponse[i].substring(0, nresponse[i].length() - 1); } } if (key == '+') { countmax += 10; println("+"); } if (key == '-') { countmax -= 10; println("-"); } } }