I started working on my first proper game but reached a problem straight away. In short I have a game that runs most of the time at 60 fps. ( I am using Libgdx a popular Java framework) but my game object which has a constant velocity and is multiplied by delta, is not moving smoothly. I have tried turning vsync on and off but that does not help. My speed variable is -100, and it is only moving vertically downwards so it is pretty clear if it is moving jerkily or not. Here is my quite simple code:
public class Ball extends AbstractGameObject {
private TextureRegion tex = Assets.instance.ball;
private float speed;
public Drop(Vector2 pos, float speed) {
super(pos);
this.speed = speed;
width = 17;
height = 32;
type = Type.Ball;
}
@Override
public void update(float delta) {
pos.y = pos.y + (speed * delta);
rect.set(pos.x,pos.y,width,height);
}
@Override
public void render(SpriteBatch sb) {
sb.draw(tex, pos.x, pos.y, width, height);
}
public float getSpeed() {
return speed;
}
public void setSpeed(float speed) {
this.speed = speed;
}
}
It was previously of my understanding that by multiplying by the elapsed seconds since the last frame, it would guarentee smooth movement. Is thing wrong? If so, any suggestions on how to make it smoother?