Posted this on Slick Forum too but its just so mind boggling
public final class LolGame extends BasicGame {
float xPos = 100.0f;
float yPos = 100.0f;
float xChange = 4.0f;
float yChange = 5.0f;
public LolGame() {
super("Jitter in da house");
}
@Override
public void init(GameContainer gc) throws SlickException {
gc.setForceExit(true);
gc.setShowFPS(true);
gc.setClearEachFrame(true);
gc.setTargetFrameRate(60);
gc.setVSync(true);
}
public static void main(String[] args) throws SlickException {
AppGameContainer app = new AppGameContainer( new LolGame() );
app.setDisplayMode(800, 600, false);
app.start();
System.exit(0);
}
@Override
public void update(GameContainer gc, int delta) throws SlickException { }
@Override
public void render(GameContainer gc, Graphics g) throws SlickException {
g.setColor(Color.white);
g.fillOval(xPos, yPos, 20, 20);
xPos+=xChange;
yPos+=yChange;
if (xPos <= 0 || xPos >= gc.getWidth()) xChange = -xChange;
if (yPos <= 0 || yPos >= gc.getHeight()) yChange = -yChange;
}
}
this will jitter… why ?