Thanks for the suggestions. I have read through the various mousePressed, mouseX, mouseY, mouseMoved, etc tutorials several times. I’ve learned not to bother googling any of my Java questions because unless it’s on the Processing site it usually ends up confusing me more.
I hadn’t used the mousePressed yet because I was just trying to get my various colored boxes to light up as my mouse moved over them. I hadn’t gotten to the point of actually pressing the mouse button yet, (LOL baby steps). While it wasn’t going to be part of my final Simon Says game, I just wanted to see if I could flash the colors as the mouse moved over the colored panels.
The aggravating thing is that I can take this code:
void setup() {
size(100, 100);
noStroke();
}
void draw() {
background(126);
ellipse(mouseX, mouseY, 33, 33);
println(mouseX,mouseY);
}
Plug it into another Processing window, and it gives me exactly what I expect to happen. A little window opens and as I move my cursor around in it the circle moves, and I get the cursor coordinates in the text window.
But if I run my code I don’t get that. I get the cursor coordinates for my monitor, not the simon window.
To make this really funny. If I run my simon code, and get monitor coordinates. While I have that window open if I run the other circle code, I get the cursor coordinates for the little window in the Processing text area for the simon code. It’s hard to describe so here’s my one picture:
You can see the 99 89 coordinates are for the little test code window. Somehow by starting the 2nd code, (I assume my simon code is still running in the background), it all started to work. Note in the simon text window I ONLY get the coordinates for when I move the cursor around in the little window, not the whole monitor. I don’t understand how running the 2nd code fixes it.
Anyway, here is my (rather pathetic) code if someone wants to point out the very obvious thing I’m missing:
void setup(){
size (800,800);
noStroke();
}
void draw(){
String Quit="No";
import java.awt.*;
boolean redActive = false;
boolean greenActive = false;
boolean blueActive = false;
boolean yellowActive = false;
final int LIT = 255;
final int UNLIT = 150;
while (Quit=="No") {
Point p = MouseInfo.getPointerInfo().getLocation();
int x = p.x;
int y = p.y;
int rdnNum = int(random(4)); //ignore random for now
println(x,y,mouseX,mouseY, rdnNum);
if (x<=(width/2) && y<=(height/2)) {
redActive=true;
} else if (y>(height/2)) {
blueActive=true;
}
if (redActive) {
fill(LIT, 0, 0);
} else {
fill(UNLIT, 0, 0);
}
rect(0, 0, width / 2, height / 2);
if (greenActive) {
fill(0, LIT, 0);
} else {
fill(0, UNLIT, 0);
}
rect(width / 2, 0, width / 2, height / 2);
if (blueActive) {
fill(0, 0, LIT);
} else {
fill(0, 0, UNLIT);
}
rect(0, height / 2, width / 2, height / 2);
if (yellowActive) {
fill(LIT, LIT, 0);
} else {
fill(UNLIT, UNLIT, 0);
}
rect(width / 2, height / 2, width / 2, height / 2);
fill(5,5,5);
rect (width/3,height/3,width/3,height/3);
if (x>2000) {
Quit="Yes";
}
}
stop();
}