0

I've implemented the paddle movement (and very basic code for the ball to move just one way for now) inside the said loop, but none of it works and I can't understand why that would be the case. Is it just that my code is completely wrong or do you think that something else is causing the issue?

// keep playing until game over
while (lives > 0 && bricks > 0)
{
    // check for event
    GEvent event = getNextEvent(MOUSE_EVENT);

    // if we heard one
    if(event != NULL)
    {
        // if event was mouse movement
        if(getEventType(event) == MOUSE_MOVED)
        {
            double x = getX(event) - getWidth(paddle) / 2;
            double y = PADDLE_Y;
            // only follow cursor along x-axis
            setLocation(paddle, x, y);
        }
    } 

    double velocity = 2.0;
    move(ball, velocity, 0);
}
  • Ball and paddle are visible, or? – Valentino Skobljanec Sep 12 '14 at 17:34
  • Yes, they're visible, everything - the ball, the paddle and the bricks - are visible, just not doing what they're supposed to do. – Alex Stafford Sep 12 '14 at 17:41
  • What your functions initBall and initPaddle returns? – Valentino Skobljanec Sep 12 '14 at 17:48
  • gdb the values of lives and bricks just before the while loop begins – lethaljd Sep 12 '14 at 20:09
  • Ok, I had the same problem with this part, I didn't return object correctly from the "Init" functions. Thanks so much Valentino! – user2549 Sep 20 '14 at 18:51

You must log in to answer this question.

Browse other questions tagged .