I have pasted the main state underneath. Everytime i move my keyboard the object moves but it is refreshing the page. How do i make it so that the object does not refresh and it looks like the image trails and it eventually draws.
package javagame;
import org.lwjgl.input.*;
import org.newdawn.slick.*;
import org.newdawn.slick.state.*;
public class Menu extends BasicGameState{
public static String mouse = "MOUSE IS NOT ON THE SCREEN";
public static String keyBoard = "O";
public static int keyBoardX = 50;
public static int keyBoardY = 50;
public static int xPos;
public static int yPos;
public Menu (int state) {
}
// This method is just to initiate objects
public void init(GameContainer gameContainer, StateBasedGame stateBasedGame)
throws SlickException {
}
public void render(GameContainer gameContainer, StateBasedGame
stateBasedGame, Graphics g) throws SlickException {
g.drawString(mouse, xPos, 500 - yPos);
g.drawString(keyBoard, keyBoardX, keyBoardY);
}
public void update(GameContainer gameContainer, StateBasedGame
stateBasedGame, int delta) throws SlickException {
// keyboard
Input input = gameContainer.getInput();
if (input.isKeyDown(input.KEY_UP)) {
keyBoardY -= 1;
} else if (input.isKeyDown(input.KEY_DOWN)) {
keyBoardY += 1;
} else if (input.isKeyDown(input.KEY_LEFT)) {
keyBoardX -= 1;
} else if (input.isKeyDown(input.KEY_RIGHT)) {
keyBoardX += 1;
}
}
public int getID() {
return 0;
}
}