0
public void update(float deltaTime){

        position.x = position.x + (ballSpeed* deltaTime);
        position.y = position.y + (ballSpeed* deltaTime);
}

The code above is part of my update method where i basically get the ball to move around the screen, and when it hits the walls it bounces off.

However i put the value of 'ballSpeed' to be 10, it moves fine. Increase it to 30 and it practically doesn't move. Increased it to 120 and it moves slightly faster but not as fast as when the value is 10.

I'm not sure why it does this. Any one help ?

rekoDolph
  • 813
  • 1
  • 9
  • 31
  • Tried to denug output position.x/y to console ? Also, whats the type of it and how is time measured (seconds?) – Manuel Arwed Schmidt Sep 08 '14 at 09:17
  • Ensure that `ballSpeed` is float value – Metaphore Sep 08 '14 at 10:45
  • i guess, what @Metaphore said will be the problem. Make sure, that `ballspeed`, as well as `position.x` and `position.y` are all `float`s. If not, the result is treated as an `int` and therefore fraction digis are cut off. – Robert P Sep 08 '14 at 13:35
  • cheers guys, not working on it at the moment but when i get back to it ill let you know how it goes. much appreciated :)) – rekoDolph Sep 08 '14 at 18:06

0 Answers0