Interesting. Perhaps the current milliseconds returned from the System class might vary? This part is still a mystery on why it's movement vary from one computer to another.
Movement speed vary on different machines
Interesting. Perhaps the current milliseconds returned from the System class might vary? This part is still a mystery on why it's movement vary from one computer to another.
Keep in mind that unless you use interpolation the visual of movement may vary wildly between computers. For example even if you use a delta to move 10 meters in your game every second, one machine may loop 120 times a second, thus incrementing your visible position slightly each frame, the other may loop 40 times a second and although you will reach the same position, the movement will appear completely different.
Then again I'm not sure what you mean about the movement varying, is it just a visual difference or is it actually moving farther? If you multiply your movement by time it should be consistant between systems.
Also, you're citing the only difference as that the desktop is 64 bit while the laptop is 32, but it sounds to me like they probably vary a lot in performance and hardware as well.
I'm not sure why nobody mentioned the right way to handle delta time.
Try this. It should independent of FPS, and computer's speed.
long startTime = System.nanoTime(); ... public void update(long milliseconds) { // calculate delta time long time = System.nanoTime(); float deltaTime = (time - startTime)/1000000000.f; startTime = time; // Handle all of the ship logic // Update player position base on velocity position = position.add(velocity.multiply(deltaTime)); // movement code if(direction.equals("left")) { position.setX(position.getX() - speed*deltaTime ); // for example if speed = 100, then it will move 100 pixels per second. } else if(direction.equals("right")) { position.setX(position.getX() + speed*deltaTime ); } }
That method isn't necessarily the "right" way as it actually makes the speed of the system affect the result of the simulation rather than the speed at which the simulation runs. The Fix your timestep link posted by Matias describes a more robust way to handle updates and is worth reading. (variable timesteps work great for some games but once you start mixing in more advanced physics it can give you some rather "interesting" results)
Interesting. Perhaps the current milliseconds returned from the System class might vary? This part is still a mystery on why it's movement vary from one computer to another.