Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - JulianOri

Pages: [1]
1
Graphics / Change movement direction?
« on: June 24, 2014, 05:17:46 pm »
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!  :D


Pages: [1]
anything