Results 1 to 7 of 7

Thread: if statement.....again...

  1. #1

    Thread Starter
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544

    if statement.....again...

    I can't get this if statement to work....I know it something with the {}.....

    PHP Code:
    if(ball.SCREEN_WIDTH ball.width )
    {
    xangle = -xangle;
    ball.xv xangle;
    ball.yv yangle;
    Move_BOB(&ball);
    }

    if(
    ball.<0)
    {
        
    xangle xangle;
        
    yangle yangle;
        
    ball.xv xangle;
        
    ball.yv yangle;
        
    Move_BOB(&ball);
    }
    if (
    ball.0)
    {
        
    xangle xangle;
        
    yangle yangle;
        
    ball.xv xangle;
        
    ball.yv yangle;
        
    Move_BOB(&ball);
    }

    if(
    ball.SCREEN_HEIGHT
    {
        
    xangle = -xangle;
        
    yangle = -yangle;
        
    ball.xv xangle;
        
    ball.yv yangle;
        
    Move_BOB(&ball);

    razor
    Software Engineer Student, Aalborg University, Denmark
    http://www.cs.auc.dk

    My email at AUC: will get a new email soon
    My website: http://www.razorsoftware.net


    Windows XP Pro/ Gentoo Linux (Laptop)
    Windows XP Pro (Home PC)

  2. #2
    Junior Member
    Join Date
    Oct 2002
    Location
    MI
    Posts
    23
    What doesn't work (i'd like to know what to look for)?

  3. #3
    Member
    Join Date
    Jun 2002
    Posts
    46
    Which if statement there are several? If it is the following if statement:
    Code:
    if(ball.x > SCREEN_WIDTH - ball.width )
    you may want to try
    Code:
    if(ball.x > (SCREEN_WIDTH - ball.width) )
    ISquishWorms

  4. #4

    Thread Starter
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544
    the problem is that is doesn't run any of them....
    razor
    Software Engineer Student, Aalborg University, Denmark
    http://www.cs.auc.dk

    My email at AUC: will get a new email soon
    My website: http://www.razorsoftware.net


    Windows XP Pro/ Gentoo Linux (Laptop)
    Windows XP Pro (Home PC)

  5. #5
    Member
    Join Date
    Jun 2002
    Posts
    46
    I know it something with the {}.....
    Your braces look fine to me, have you tried printing the value of ball.x before each if statement to check its contents? Have you also checked to see that it is not executing the code within the braces by placing a print statement within each of the if braces for example:

    Code:
    if(ball.x <0)
    {
        print "ball.x is less than zero.";
        xangle = xangle;
        yangle = yangle;
        ball.xv = xangle;
        ball.yv = yangle;
        Move_BOB(&ball);
    }
    ISquishWorms

  6. #6
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403
    if
    Move_BOB(&ball)
    changes the value of ball.x then more than one of your if statements may be executed. I would set them up as
    PHP Code:
    if(ball.SCREEN_WIDTH ball.width )
    {
    xangle = -xangle;
    ball.xv xangle;
    ball.yv yangle;
    Move_BOB(&ball);
    }

    else if (
    ball.<0)
    {
        
    xangle xangle;
        
    yangle yangle;
        
    ball.xv xangle;
        
    ball.yv yangle;
        
    Move_BOB(&ball);
    }
    else if (
    ball.0)
    {
        
    xangle xangle;
        
    yangle yangle;
        
    ball.xv xangle;
        
    ball.yv yangle;
        
    Move_BOB(&ball);
    }
    else if(
    ball.SCREEN_HEIGHT
    {
        
    xangle = -xangle;
        
    yangle = -yangle;
        
    ball.xv xangle;
        
    ball.yv yangle;
        
    Move_BOB(&ball);

    but that may not be it.
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

  7. #7
    Member
    Join Date
    Jun 2002
    Posts
    46
    Sunburnt, makes a very good point. I can not see anything wrong with the code I think it is more than likely the structuring of it and how you wish it to operate. This is partly why I suggested that you place print statements into the code as this would give you more of an understanding about what routes the code is currently taking and why.
    ISquishWorms

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width