We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello, I am making a small game just for practice, and I noticed that while testing the game, the keyboard controls are very unresponsive. often if I switch from 1 key to another the character will stop dead for a little while before it starts moving in the new direction. I was just wondering if anyone had any advice for this? this is the portion where all the relevant commands are being handled.
`class person{ float x, y, speedX, speedY;
person(float _x, float _y){ x = _x; y = _y; }
void graphics(){ stroke(0); fill(255, 0, 0); ellipse(x, y, 50, 50); fill(0); ellipse(x + 17, y - 10, 10, 10); ellipse(x + 5, y - 10, 10, 10); ellipse(x+15, y + 5, 15, 5); }
void move(){ speedX = 5; speedY = 5; if ((keyPressed == true) && (key == 'w')){ y = y - speedY; }
if ((keyPressed == true) && (key == 's')){
y = y + speedY;
}
if((keyPressed == true) && (key == 'a')){
x = x - speedX;
}
if((keyPressed == true) && (key == 'd')){
x = x + speedX;
}
}
void boundary(){ if (x > 600 || x < 0){ speedX = 0; }
else{ speedX = 5; }
if (y > 400 || y < 0){ speedY = 0; }
else{ speedY = 5; } }
}`
Answers
this was a lot better formatted before I posted it XD
http://forum.Processing.org/two/discussion/8045/how-to-format-code-and-text
http://studio.ProcessingTogether.com/sp/pad/export/ro.91tcpPtI9LrXp