I'm trying to make a game where there are a number of balls bouncing (for now only with 45 degree angle) on a rectangular area and where you can controll a cursor moving horizontally or vertically in the same rectangular area.
The problem seems to be very simple, but there are a lot of things to care attention in order to have the best result.
There are 2 main targets that I would like to reach:
1-smooth movement of balls
2-very quick response to keypress event
Unfortunately two targets are in conflic each other, because if you want a smooth movement you have to repaint practically every loop inside a while statement, but in this way you don't leave spaces for response key.
If you put a sleep (also a sleep(5) !!) the balls movements becomes very slow, but unfortunately you don't get any improvements for the "response key problem".
There is to note that every step I don't clean all the screen but only the previous point where there was the balls, and then I repaint only the balls in the next position.
I have tried also to use fillRect insted balls image with the same results...
Also using keyRepeated, the time from one cursor movement and the other (especially after the first button press) is too slow for my taget.
I have to try to use more than one thread?
Every advice, also the smallest, will be very appreciated!!!
Many thanks in advance!