public void moveBall()
{
if (x + xa < 0)
xa = game.speed;
else if (x + xa > game.getWidth() - DIAMETER)
xa = -game.speed;
else if (y + ya < 0)
ya = game.speed;
else if (y + ya > game.getHeight() - DIAMETER)
game.gameOver();
else if (collision())
{
ya = -1;
y = game.racquet.getTopY() - DIAMETER;
}
}
public void keyPressedSpace(KeyEvent e)
{
if (e.getKeyCode() == KeyEvent.VK_SPACE)
{
x = x + xa;
y = y + ya;
}
}
I was stuck with this.
I am a super newbie.
first time to try to program game with the help of the tutorials.
and now I want to try to challenge myself and to start it when I pressed the SPACE BAR.
It is like PINBALL where you need to press the SPACE BAR first.
everytime I put the KEYLISTENER and I pressed the SPACE BAR
nothing happens.
Please help me thanks.