Hi
I have looked at this thread http://www.java-gaming.org/forums/index.php?topic=11443.0
Thats where I found the SystemTimer class, and how to use it.
This is what I do:
long delta = SystemTimer.getTime() - lastLoopTime;
lastLoopTime = SystemTimer.getTime();
System.out.println("delta: "+delta);
float oldy = gameview.getYOnMap();
float speed = 30.0f;
float bxmov = (speed * delta) / 1000; //pixels to move
System.out.println("bxmov: "+bxmov);
System.out.println("moving it: "+(int)bxmov);
gameview.setYOnMap((gameview.getYOnMap() - bxmov)); //set the new location
When I look at the console and the different delta’s it jumps alot up and down, everything from 18ms to 30ms and
this makes the movement look like many small movements then suddenly a big one…
If I just set it to move 1pixel each time without any movement timing its soo silky smooth. But since its 60fps even only 1 pixel pr frame is too fast…So
I need to time it to get slower movements.
Here’s the delta output from console:
timerTicksPerSecond: 1000
delta: 53575561
delta: 64
delta: 32
delta: 32
delta: 32
delta: 33
delta: 32
delta: 32
delta: 17
delta: 18
delta: 18
delta: 17
delta: 18
delta: 17
delta: 18
delta: 17
delta: 33
delta: 32
delta: 32
delta: 32
delta: 33
delta: 32
delta: 32
delta: 32
delta: 19
delta: 17
delta: 18
delta: 18
delta: 17
delta: 18
delta: 17
I tried to set the speed to 60, so that should be 1pixel pr frame but it still jumps up and down its not even close to how smooth it is
when I use only a static +1 movement each tick.
Anyone got any tips?