Hello Guys new to processing and having some issues with keycode
in
Programming Questions
•
11 months ago
hey guys I'm trying to make a simple movement with keyCode where I manipulate a square on the x and y plane but every time I press the key right it keep moving and never stop, I want it to just move for how long I hold the key down and once i release i want it to just stop in place and when i press another key change in direction here what I'm working with so far.
float x = 0; //x loc of square
float y = 0; //y loc of square
void setup();(
size(200,200)
}
void draw(){
fill(255);
rect(x,y,10,10);
if (key == CODED){
if (keyCode == RIGHT);
x = x + 1;
}
else {
x = x;
}
}
that how far I've gotten because the square just likes to run of the page. I would like some guidance in the right direction.
float x = 0; //x loc of square
float y = 0; //y loc of square
void setup();(
size(200,200)
}
void draw(){
fill(255);
rect(x,y,10,10);
if (key == CODED){
if (keyCode == RIGHT);
x = x + 1;
}
else {
x = x;
}
}
that how far I've gotten because the square just likes to run of the page. I would like some guidance in the right direction.
1