You did this in one day? This is fast for a first game

Fullscreen works perfectly...
But it somehow looks non-smooth.
I downloaded the source,
looked at the game loop: Seems okey, checked.
let the code print the fps, compiled and started: FPS is a constant 62.
I guess your problem lies in the famous spikes.
Spikes are some frames which just accedently take much more time than they should. Then it
appears like it would be slower, but it isn't.
*looks at code again*
It seems like your "draw()" method in mainPong.java is "synchronized". Remove this keyword, it propably doesn't does what you want it to do.
One more thing:
To answer your question about random ball-launching:
Replace this:
1 2 3 4 5 6
| if(keyCode == KeyEvent.VK_SPACE){ ball.setVelocityX(3f); ball.setVelocityY(3f); startMsg = false; } |
With this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| if(keyCode == KeyEvent.VK_SPACE){ Random rand = new Random(); if (rand.nextBoolean() == true) { ball.setVelocityX(3f); } else { ball.setVelocityX(-3f); } if (rand.nextBoolean() == true) { ball.setVelocityY(3f); } else { ball.setVelocityY(-3f); } startMsg = false; } |
I think I don't have to explain it, as it should already be done in the comments.