If the game is running at 60 FPS you are displaying as many frames as the screen can show. Increasing the FPS of the game further is out of the question, as it will increase the speed of everything in the game PLUS making the game require better hardware to run. What you want to do to achieve faster movement is just to increase the movement speed of the player, right? I haven’t been able to figure out how you actually move the player (e.g. update it’s coordinates based on input, TL;DR it all you know…) so I can’t tell you exactly how to do it in your code, but you should do movement like this:
if(upKeyDown){
player.y -= delta * moveSpeed;
}
//Very similar code for all the other directions
- player.y is the current position of the player (you’ll probably not write it exactly like this (public access), but whatever)
- moveSpeed is a variable that decides the speed of movement (DR. OBVIOUS TO THE RESCUE).
- delta is the time since the last update, which should be calculated universally for all objects in the game in the game loop.
I think you should add delta calculation to your game loop:
long time = System.currentTimeMillis();
while (!endGame)
{
do
{
do
{
try
{
long currentTime = System.currentTimeMillis();
/*Delta = time passed since last update. Also, cast to int, as I doubt that delta will ever exceed Integer.MAX_VALUE... xD*/
int delta = (int)(currentTime - time);
time = currentTime;
update(delta); //Update the game based on how long time has passed.
render();
}
catch (Exception ex)
{
System.err.println("Game Update Error: " + ex);
}
try
{
Thread.sleep(rest);
}
catch (Exception ex)
{
System.out.println("Can't sleep!");
}
} while (buffer.contentsRestored());
buffer.show();
} while (buffer.contentsLost());
}
All your update methods should take an int delta parameter, and use it to determine how far to move things each update. Doing it like this also makes sure that the game runs at the same speed, regardless of how fast the computer running the game is. Even though the game only runs at 30FPS for example, the objects would make double as long “jumps” each update so they will move the same distance in the same time.
I hope things have cleared up a bit. xD