noLoop?
in
Programming Questions
•
1 years ago
Hello Processors! I am a student and working on a project for a communications class. My partner and I have seriously spent 4-5 hours on this thing we are STUCK on how to get our project to interact correctly with the mousePressed function. I am not an expert Processor, so our problem is a bit hard to explain but I will give it a shot...
Basically, we have a "map" and the things moving in the void draw area work fine until we click the mouse and the pictures appear on the map. We had to write in a noLoop function within the void mousePressed section because we wanted the pictures to stay there after the mouse was clicked (instead of just blinking when the mouse is clicked)... however, when we put the noLoop in the void mousePressed section (at the bottom) the things in the void draw section stop moving! I have looked around for tutorials on this particular problem and nothing seems to be giving me an answer... so, I am not sure if what we are trying to accomplish is even possible. Essentially, we wanted the pictures to appear one by one with each click of the mouse but I know that may be REALLY asking for a a lot... (however if you have suggestions that would just be amazing!) If you have any answers to our problem, help would be much appreciated, it would be really nice if those circles could keep moving AFTER the pictures appear with the click of the mouse... Maybe there is a "loop" function that would be useful in the void draw area? I am not certain... I've looked around for tutorials but I cannot find anything on the subject. Thank you so much for your help! I will paste the coding below, it is very lengthy but I have highlighted the troublesome areas!
CODE:
float a = 0.0;
int x = 90;
int y = 200;
int z = 780;
PFont fontA;
PImage b;
PImage c;
PImage d;
PImage e;
void setup ()
{
size (400, 800);
smooth ();
b = loadImage("walking.jpeg");
c = loadImage("elevator.jpeg");
d = loadImage("weird.jpeg");
e = loadImage("stacks.jpeg");
frameRate(10);
fontA = loadFont("AmericanTypewriter-CondensedLight-48.vlw");
//created in Tools in the Menu and placed in the data folder
// Set the font and its size (in units of pixels)
textFont(fontA, 48);
noLoop();
}
void draw(){
background (50, 132, 255);
fill (255);
textFont(fontA, 32);
fill(255);
text("Puzzled", y, 550);
fill (0);
text("by a", y, 600);
fill (255);
text("Rainy", y, 650);
fill (0);
text("Day", y, 700);
textFont(fontA, 24);
fill (255);
text ("with Chelsea & Chloe`", 120, 780);
pushMatrix ();
ellipse (280, 25, 12, 12);
textFont (fontA, 32);
fill(0);
text("click", 290, 35);
popMatrix ();
pushMatrix ();
fill (25);
z = z - 1;
if (z < 720) {
z = 780;
}
ellipse (25, z , 10, 10);
popMatrix();
stroke (0);
fill (255);
rect (20, 780, 10, 10);
noStroke( );
ellipse (10, 765, 10, 10);
ellipse (40, 770, 10, 10);
ellipse (50, 755, 10, 10);
stroke (0);
line (25, 780, 25, 720);
line (25, 720, 75, 720);
rect (75, 720, 10, 5);
rect (60, 720, 10, 5);
line (80, 720, 80, 680);
triangle (80, 680, 74, 680, 77, 670);
triangle (74, 680, 68, 680, 71, 670);
triangle (68, 680, 62, 680, 65, 670);
triangle (62, 680, 56, 680, 59, 670);
line (59, 680, 59, 620);
line (59, 620, 85, 590);
noFill();
stroke(0);
beginShape();
curveVertex(85, 590); // the first control point
curveVertex(85, 590); // is also the start point of curve
curveVertex(100, 570);
curveVertex(85, 550); // the last point of curve
curveVertex(85, 550); // is also the last control point
endShape();
noStroke ();
fill (0);
ellipse (85, 590, 5, 5);
noFill();
stroke(0);
beginShape();
curveVertex(85, 550); // the first control point
curveVertex(85, 550); // is also the start point of curve
curveVertex(60, 530);
curveVertex(85, 510); // the last point of curve
curveVertex(85, 510); // is also the last control point
endShape();
noFill();
stroke(0);
beginShape();
curveVertex(85, 510); // the first control point
curveVertex(85, 510); // is also the start point of curve
curveVertex(100,490);
curveVertex(85, 470); // the last point of curve
curveVertex(85, 470); // is also the last control point
endShape();
noFill();
stroke(0);
beginShape();
curveVertex(85, 470); // the first control point
curveVertex(85, 470); // is also the start point of curve
curveVertex(60, 450);
curveVertex(85, 430); // the last point of curve
curveVertex(85, 430); // is also the last control point
endShape();
noFill();
stroke(0);
beginShape();
curveVertex(85, 430); // the first control point
curveVertex(85, 430); // is also the start point of curve
curveVertex(100,410);
curveVertex(85, 390); // the last point of curve
curveVertex(85, 390); // is also the last control point
endShape();
noFill();
stroke(0);
beginShape();
curveVertex(85, 390);
curveVertex(85, 390);
curveVertex(60, 370);
curveVertex(85, 350);
curveVertex(85, 350);
endShape();
noFill();
stroke(0);
beginShape();
curveVertex(85, 350);
curveVertex(85, 350);
curveVertex(100, 330);
curveVertex(85, 310);
curveVertex(85, 310);
endShape();
noFill();
stroke(0);
beginShape();
curveVertex(85, 310);
curveVertex(85, 310);
curveVertex(60 , 290);
curveVertex(85, 270);
curveVertex(85, 270);
endShape();
noFill();
stroke(0);
beginShape();
curveVertex(85, 270);
curveVertex(85, 270);
curveVertex(100, 250);
curveVertex(85, 230);
curveVertex(85, 230);
endShape();
noFill();
stroke(0);
beginShape();
curveVertex(85, 230);
curveVertex(85, 230);
curveVertex(60, 210);
curveVertex(85, 190);
curveVertex(85, 190);
endShape();
fill (255);
x = x + 1;
if (x > 235) {
x = 90;
}
ellipse (x, 185, 10, 10);
noStroke ();
fill (232, 12, 122);
ellipse (50, 160, 25, 25);
ellipse (90, 140, 25, 25);
ellipse (30, 200, 25, 25);
stroke (0);
line (95, 185, 105, 185);
line (110, 185, 120, 185);
line (125, 185, 135, 185);
line (140, 185, 150, 185);
noFill ();
triangle (155, 185, 165, 185, 160, 175);
triangle (170, 185, 180, 185, 175, 175);
triangle (185, 185, 195, 185, 190, 175);
triangle (200, 185, 210, 185, 205, 175);
stroke (0);
fill (255);
ellipse (170, 150, 20, 15);
rect (200, 150, 25, 10);
fill(232, 12, 122);
triangle (215, 185, 225, 185, 220, 175);
triangle (215, 185, 225, 185, 220, 195);
noFill();
stroke (0);
ellipse (235, 185, 20, 20);
line (220, 200, 220, 210);
line (220, 215, 220, 225);
line (220, 230, 220, 240);
line (220, 245, 220, 255);
line (220, 260, 220, 270);
line (220, 275, 220, 285);
line (220, 285, 210, 285);
line (205, 285, 195, 285);
line (190, 285, 180, 285);
line (175, 285, 165, 285);
line (165, 285, 165, 295);
line (165, 300, 165, 310);
line (165, 315, 165, 325);
line (165, 330, 165, 340);
line (165, 345, 165, 355);
stroke (232, 12, 122);
line (165, 355, 350, 355);
stroke (0);
line(355, 360, 355, 370);
line(355, 375, 355, 385);
line (355, 390, 355, 400);
line (355, 405, 355, 415);
line (355, 420, 355, 430);
pushMatrix ();
loop ();
fill (0);
noStroke ( );
a = a + .01; // changes s value a little bit each loop
if (a > 1.0) {
a = 0;
}
rectMode(CENTER);
translate(355, 315);
scale(a); //set scale to the variable s, which increments with every loop because of code above
rect (0, 0, 10, 20);
translate(0,30);
rect (0, 0, 10, 20);
popMatrix ();
}
void mousePressed () {
noLoop();
image (c, 90, 655, c.width/10, c.height/10);
image (e, 30, 10, e.width/10, e. height/10);
image (d, 260, 140, d.width/10, d.height/10);
image (b, 210, 360, b.width/8, b.height/8);
}
1