Java Reference
In-Depth Information
synchronized(this) {
while (paused) {
wait();
}
}
}
catch(InterruptedException ex) {}
}
}
public void setPaused(boolean b)
{
synchronized(this) {
paused = b;
notify();
}
}
private void moveCat() {
int keyStates = getKeyStates();
int x, y;
x = cat.getX();
y = cat.getY();
if ((keyStates & LEFT_PRESSED) != 0) {
x -= cat.getWidth()/4;
}
if ((keyStates & RIGHT_PRESSED) != 0) {
x += cat.getWidth()/4;
}
if ((keyStates & UP_PRESSED) != 0) {
y -= cat.getHeight()/4;
}
if ((keyStates & DOWN_PRESSED) != 0) {
y += cat.getHeight()/4;
}
if ( x < 0 ) x = 0;
if ( y < 0 ) y = 0;
if(x>board.getWidth() - cat.getWidth() )
x = board.getWidth() - cat.getWidth();
if(y>board.getHeight() - cat.getHeight() )
y = board.getHeight() - cat.getHeight();
cat.setPosition(x,y);
}
 
Search WWH ::




Custom Search