Results 1 to 8 of 8

Thread: xangle <> 0

Threaded View

  1. #1

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

    xangle <> 0

    Hi!
    How do I prevent my xangle variable from equaling 0.....

    Here is some of my code:

    PHP Code:
    int Game_Main(void *parms)
    {

    // check of user is trying to exit
    if (KEY_DOWN(VK_ESCAPE))
        
    PostMessage(main_window_handleWM_DESTROY,0,0);
    // Move paddle left
    if (KEY_DOWN(VK_LEFT)) {
        
    lkpress true;
        if (
    paddle.>5) {
            
    paddle.paddle.-4;
            
    Move_BOB(&paddle);
        }
    } else if(
    KEY_DOWN(VK_RIGHT)) {        // Move paddle right
        
    rkpress true;
        if(
    paddle.paddle.width  SCREEN_WIDTH) {
            
    paddle.paddle.+4;
            
    Move_BOB(&paddle);
            
        }
    }

    // start the timing clock
    Start_Clock();

    // clear the drawing surface
    DD_Fill_Surface(lpddsback0);

    Draw_BOB(&paddle,lpddsback);
    Draw_BOB(&ball,lpddsback);
    for (
    int draw 0draw<28draw++)
    Draw_BOB(&box[draw],lpddsback);

    ball.xv xangle;
    ball.yv yangle;
    Move_BOB(&ball);

    //the ball is going outside the screen
    if(ball.<= 0) {
        
    lasthit LAST_HIT_LEFT;
        
    xangle = -xangle;
    }
    if( 
    ball.>= SCREEN_WIDTH ball.width ){
        
    lasthit LAST_HIT_RIGHT;
        
    xangle = -xangle;
    }

    // the ball is going outside the screen
    if(ball.<= 0) {
        
    lasthit LAST_HIT_TOP;
        
            
    yangle = -yangle;
        
        if(
    xangle <0){
            
    xangle xangle;
        }
        if(
    xangle 0){
            
    xangle = -xangle;
        }
    }

    if(
    ball.SCREEN_HEIGHT){
        
        
    yangle = -yangle;
    }
    // the ball has hit the paddle
    if(Collision_BOBS(&ball,&paddle)){
        
    yangle=-yangle// change direction
        
    lasthit LAST_HIT_BOTTOM;
            
        
    // This collision detection determine where the ball hits the paddle and 
        // calculates a new direction

        
    if(ball.== paddle.&& ball.== paddle.height){
            if(
    lkpress){
                if(
    xangle 0){
                    
    xangle = -3.5;
                    
    lkpress =false;
                }
                else if(
    xangle <0){
                    
    xangle 3.5;
                    
    lkpress false;
                }
            }
        }
            if(
    ball.paddle.&& paddle.<=19){
                if(
    xangle >0){
                
    xangle 2;
                }
                else if(
    xangle <0){
                    
    xangle = -2;
                }
            
            }
            
            if(
    ball.paddle.+19 && paddle.<=38){
                if(
    xangle 0){
                
    xangle 1;
                }
                else if(
    xangle <0){
                    
    xangle = -1;
                }
            }
            if(
    ball.>= paddle.+38 && paddle.<=57){
                if(
    xangle 0){
                
    xangle 0.5;
                }
                else if(
    xangle 0){
                    
    xangle = -0.5;
                }
            }

            if(
    ball.paddle.+57 && paddle.<=76){
                if(
    xangle 0){
                
    xangle = -0.5;
                }
                else if(
    xangle 0){
                    
    xangle 0.5;
                }

            }
            if(
    ball.paddle.+76 && paddle.<=95){
                if(
    xangle <0){
                
    xangle =-1;
                }
                else if(
    xangle >0){
                    
    xangle 1;
                }

            }
            if(
    ball.paddle.+95 && paddle.<115){
                
                if(
    xangle <0){
                
    xangle = -2;
                }
                else if(
    xangle >0){
                    
    xangle 2;
                }
            }
            
            if(
    ball.== paddle.paddle.width  && ball.== paddle.height){
            if(
    rkpress){
                if(
    xangle 0){
                    
    xangle = -3.5;
                    
    rkpress false;
                }
                else if(
    xangle >0){
                    
    xangle 3.5;
                    
    rkpress false;
                }
            }
        }
            

    }






    // flip the surfaces
    DD_Flip();


    // sync to 10ish fps
    Wait_Clock(10);

    // Perform collision detection with the blocks
    for(counter 0counter<28counter++)
    if(
    Collision_BOBS(&ball,&box[counter])){
        if(
    xangle 0){
            
    xangle xangle;
            
            
        }
        if(
    xangle 0){
            
    xangle = -xangle;
            
        }
        if(
    xangle ==0){
            if(
    lasthit == LAST_HIT_LEFT){
                
    xangle=+rand()%2;
            }
            if(
    lasthit == LAST_HIT_RIGHT){
                
    xangle=-rand()%-2;
            }
        }

        if(
    yangle 0){
            
    yangle = -yangle;
        }
        if(
    yangle 0){
            
    yangle yangle;
        }
    }
        
    // return success
    return(1);

    // end Game_Main 
    Last edited by CyberCarsten; Nov 13th, 2002 at 04:19 PM.
    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)

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