Following the mouse and key presses
in
Programming Questions
•
11 months ago
Basically I had this code originally:
void setup() {
size(1080, 720);
}
void draw() {
if (mousePressed) {
fill(255);
} else {
fill(0);
}
noStroke();
ellipse(mouseX,mouseY,80,80);
}
Which makes the ellipse follow the mouse and stay on the screen I want this but the colours to be controlled through key presses rather than the mouse (I'm playing with speech software and motion controls so I can't have mouse click)
So I wrote this code:
// Click on the image to give it focus,
// and then press any key.
int black = 'b';
int white = 'w';
void setup() {
size (1600, 700);
}
void draw() {
fill(black, white);
}
void keyReleased() {
if (key == 'b') {
black = 0;
} else {
black = 255;
if (key == 'w') {
white = 255;
} else {
white = 0;
}
}
noStroke();
ellipse(mouseX,mouseY,80,80);
}
Which works with the key released (again can't be pressed because of voice software) and only places a ellipse where the mouse is rather than making a continuous line of them follow the mouse, any ideas how I could fix this?
Any help would really be appreciated.
1