Exemple #1
0
// Destructoras.
void destroySFighter (s_fighter & SF) {
   if (SF) {
      SF->body = NULL;
      destroyRect (SF->bodyParado);
      destroyRect (SF->bodyAgachado);
      destroyRect (SF->bodySaltando);
      delete [] SF->name;
      delete SF;
      SF = NULL;
   }
}
Exemple #2
0
//----------------------------------------------
void ttChar::update(){
   

    if (!bInSky) {
        if (character.getVelocity().x > 7) {
            character.setVelocity(7, character.getVelocity().y);
        }else if(character.getVelocity().x < -7){
            character.setVelocity(-7, character.getVelocity().y);
        }
    }else{
        if (character.getVelocity().x > 10) {
            character.setVelocity(10, character.getVelocity().y);
        }else if(character.getVelocity().x < -10){
            character.setVelocity(-10, character.getVelocity().y);
        }
    }
   

    dead();
    destroyRect();
    
    if (!bSwing) {
        getPos = character.getPosition();
    }
    
    
}
Exemple #3
0
//----------------------------------------------
void ttChar::update(){
    
    float x = 20;
    float scale = 10;

    if (charNum == 0) {
        if (accFroce->x > -0.15) {
            if (control->bTouch[0]&&control->bTouch[1]) {
                bDouPressed =true;
            }else if (control->bTouch[0] && !control->bTouch[1]) {
                character.addForce(ofPoint(-x,0), scale);
                bDouPressed =false;
                mirrorLeft = false;
            }else if (control->bTouch[1] && !control->bTouch[0]) {
                character.addForce(ofPoint(x,0), scale);
                bDouPressed =false;
                mirrorLeft = true;
            }else if(!control->bTouch[0] && !control->bTouch[1] && !bInSky){
//                character.setVelocity(0, character.getVelocity().y);
            }
            
        }
        
        
        if (character.getVelocity().x > 10) {
            character.setVelocity(10, character.getVelocity().y);
        }else if(character.getVelocity().x < -10){
            character.setVelocity(-10, character.getVelocity().y);
        }
    }
    
    if (charNum == 1) {
        if (accFroce->x < 0.15) {
            if (control->bTouch[2]&&control->bTouch[3]) {
                bDouPressed =true;
            }else if (control->bTouch[2]&&!control->bTouch[3]) {
                character.addForce(ofPoint(-x,0), scale);
                bDouPressed =false;
                mirrorLeft = true;
            }else if (control->bTouch[3]&& !control->bTouch[2]) {
                character.addForce(ofPoint(x,0), scale);
                bDouPressed =false;
                mirrorLeft = false;
            }else if(!control->bTouch[2]&&!control->bTouch[3]&&!bInSky){
//                character.setVelocity(0, character.getVelocity().y);
            }
        }
        
        if (character.getVelocity().x > 10) {
            character.setVelocity(10, character.getVelocity().y);
        }else if(character.getVelocity().x < -10){
            character.setVelocity(-10, character.getVelocity().y);
        }
    }
    
    
    dead();
    destroyRect();
    
    if (!bSwing) {
        getPos = character.getPosition();
    }
    
}
Exemple #4
0
//----------------------------------------------
void ttChar::update() {

    float x =20;
    float scale = 1000;
    float smallMove;
    float smallMoveSale = 1.2;

    if (charNum == 0) {
        if (bFixedMove==true) {
            control_A->bSmallLeft = false;
            control_A->bSmallRight = false;
            control_A->bLeft = false;
            control_A->bRight = false;

            if (bReset) {
                character.setVelocity(0, 0);
                bReset = false;
            }
        } else {

            bReset = true;

            if (control_A->diff.x>1||control_A->diff.x<-1) {
                smallMove = control_A->diff.x*smallMoveSale;
            }
            else
            {
                smallMove  = 0;
            }




            if (control_A->bLeft == true && character.getVelocity().x< 15)
            {
                character.addForce(ofVec2f(x,0), scale);
                control_A->bLeft = false;
                mirrorLeft = true;
            }
            else if(control_A->bRight == true && character.getVelocity().x> -15)
            {

                character.addForce(ofVec2f(-x,0), scale);
                control_A->bRight = false;
                mirrorLeft = false;
            } else if (control_A->bSmallLeft == true) {
                character.setVelocity(smallMove, 0);
                control_A->bSmallLeft = false;
                mirrorLeft = true;
            }

            else if(control_A->bSmallRight == true)
            {
                character.setVelocity(smallMove, 0);
                control_A->bSmallRight = false;
                mirrorLeft = false;
            }

        }

    }

    if(charNum  == 1) {
        if (bFixedMove == true) {
            control_B->bSmallLeft = false;
            control_B->bSmallRight = false;
            control_B->bLeft = false;
            control_B->bRight = false;
            if (bReset) {
                character.setVelocity(0, 0);
                bReset = false;
            }
        }
        else
        {

            bReset = true;

            if (control_B->diff.x>1||control_B->diff.x<-1) {
                smallMove = control_B->diff.x*smallMoveSale;
            } else {
                smallMove  = 0;
            }




            if (control_B->bLeft == true && character.getVelocity().x>-15)
            {
                character.addForce(ofVec2f(-x,0), scale);
                control_B->bLeft = false;
                mirrorLeft = true;
            }

            else if(control_B->bRight == true && character.getVelocity().x<15)
            {
                character.addForce(ofVec2f(x,0), scale);
                control_B->bRight = false;
                mirrorLeft = false;
            } else if (control_B->bSmallLeft == true)
            {

                character.setVelocity(smallMove, 0);
                control_B->bSmallLeft = false;
                mirrorLeft = true;
            }

            else if(control_B->bSmallRight == true) {

                character.setVelocity(smallMove, 0);
                control_B->bSmallRight = false;
                mirrorLeft = false;
            }

        }


    }


    if (bSwing) {

        swing();
    } else {
        getPos = character.getPosition();
        bHookIt = false;
    }

    dead();

    if (joints.empty()&&!rects.empty()) {
        alpha-=5;
    }

    if (alpha<=100) {
        destroyRect();
        alpha = 255;
        bDestroyRect = false;
    }
}