wardd
YaBB Newbies
Offline
Posts: 3
Iowa
Now I need a mouse routine?
Reply #3 - Oct 13th , 2006, 8:24am
Guys, Just to show I've used your advice I put the code I've developed so far below. Now I'm stuck on how to deal with the mouse. Before in METAL I had a procedure named GetAClick that I called when I wanted the program to wait for a mouse click and then return with the x and y coords. I'm not seeing a way to do this with Processing 0118. Can you help me on this one? Thanks for your time, d ward PImage MandMs[]; int Box[]; int Bag[]; int Cx[]; int Cy[]; int Guess[]; int Actual[]; int Diffs[]; boolean NewSet; int SetsPicked; void setup() { size (700,500); background(0); MandMs = new PImage[7]; MandMs[1] = loadImage("Red.jpg"); MandMs[2] = loadImage("Green.jpg"); MandMs[3] = loadImage("Blue.jpg"); MandMs[4] = loadImage("Brown.jpg"); MandMs[5] = loadImage("Yellow.jpg"); MandMs[6] = loadImage("Check.jpg"); Box = new int[101]; Actual = new int[6]; Bag = new int[21]; Cx = new int[21]; Cy = new int[21]; MainProgram(); } void MainProgram() { SetButtons(); MakeBox(); MakeBag(); PickCoords(); ShowBag(); } void draw(){ } void ShowBag() { for (int i=1; i<=20; i++) { image(MandMs[Bag[i]], Cx[i]*50, Cy[i]*50); } } void PickCoords() { int SetsPicked; int Newx; int Newy; boolean NewSet; int CxTemp, CyTemp; for (int i=1; i<=20; i++) { Cx[i]=0; Cy[i]=0; } SetsPicked = 0; while (SetsPicked <= 19) { CxTemp = round(random(11))+1; CyTemp = round(random(5))+1; NewSet = true; for (int i=1; i<=SetsPicked; i++) { if (CxTemp == Cx[i] && CyTemp == Cy[i]) { NewSet=false; } } if(NewSet==true) { SetsPicked = SetsPicked + 1; Cx[SetsPicked] = CxTemp; Cy[SetsPicked] = CyTemp; } } for (int i=1; i<=20; i++) { print (Cx[i]+" "+Cy[i]+"---"); } } void MakeBag() { for (int i=1; i<=20; i++) { Bag[i]=0; } for (int i=1; i<=20; i++) { int n = round(random(100)); Bag[i]=Box[n]; } } void MakeBox() { for (int i=0; i<100; i++) { Box[i]=0; } int a,b,c,d,e; a=0; b=0; c=0; d=0; e=0; while (a+b+c+d+e!=100) { a = round(random(1,50)); b = round(random(1,50)); c = round(random(1,50)); d = round(random(1,50)); e = round(random(1,50)); } Actual[1]=a; Actual[2]=b; Actual[3]=c; Actual[4]=d; Actual[5]=e; for (int i=1; i<=a; i++) { Box[i] = 1; } for (int i=a+1; i<=a+b; i++) { Box[i] = 2; } for (int i=a+b+1; i<=a+b+c; i++) { Box[i] = 3; } for (int i=a+b+c+1; i<=a+b+c+d; i++) { Box[i] = 4; } for (int i=a+b+c+d+1; i<=a+b+c+d+e; i++) { Box[i] = 5; } } void SetButtons() { image(MandMs[1],200,450); image(MandMs[2],250,450); image(MandMs[3],300,450); image(MandMs[4],350,450); image(MandMs[5],400,450); image(MandMs[6],450,450); }