Hi! =)
I´m programming a little game where a ball flies through the window and when it hits the end of the window it shall change its direction. Here´s the code I´m using for this:
void Ball::update(float frametime)
{
if (pSpriteB->getPosition().y >= 9)
{
pSpriteB->move(-400 * frametime, -400 * frametime);
}
else if (pSpriteB->getPosition().y <= 9)
{
pSpriteB->move(400 * frametime, 400 * frametime);
}
}
But when the ball hits the window´s end, it just stops and vibrates a bit. What I thought was that the previous movement is still active and I have to end up this previous movement so that the new movement direction can be done without errors, but I didn´t find anything to end up a movement.
What shall I do? Why isn´t it moving correctly? Please help!