tyler.dahle 0 Newbie Poster
void boss_animation()
{       

    for (int i = 0; i < 4; i++){
        if( ! boss[i].drawable)
            continue;
    //Puts image of character on screen based on inputs from struct
    readimagefile(boss[i].frames[boss[i].currentFrame],
        boss[i].xCoord,
        boss[i].yCoord,
        boss[i].xCoord + boss[i].charWidth,
        boss[i].yCoord + boss[i].charHeight );

    boss[i].currentFrame++; //increments the "frame" by one, thus only animating one image at a time
    if(boss[i].currentFrame == boss[i].animationFrames){
        boss[i].currentFrame = 0;} //When frame 4 is reached, it resorts back to first frame and restarts
        //character[i].drawable = 0;}

    boss[i].xCoord += boss[i].xMove;
    boss[i].yCoord += boss[i].yMove;    
    }       

        for (int i = 4; i < 8; i++){
        if( ! boss[i].drawable)
            continue;

    if(i == 4){
        while(boss[i].xCoord < 733) {
            //Puts image of character on screen based on inputs from struct
    readimagefile(boss[i].frames[boss[i].currentFrame],
        boss[i].xCoord,
        boss[i].yCoord,
        boss[i].xCoord + boss[i].charWidth,
        boss[i].yCoord + boss[i].charHeight );

    boss[i].currentFrame++; //increments the "frame" by one, thus only animating one image at a time
    if(boss[i].currentFrame == boss[i].animationFrames){
        boss[i].currentFrame = 0;}
    boss[i].xCoord = boss[i].xCoord + 10;}}
    else if(i == 5){
        while(boss[i].xCoord > 30){
            //Puts image of character on screen based on inputs from struct
    readimagefile(boss[i].frames[boss[i].currentFrame],
        boss[i].xCoord,
        boss[i].yCoord,
        boss[i].xCoord + boss[i].charWidth,
        boss[i].yCoord + boss[i].charHeight );

    boss[i].currentFrame++; //increments the "frame" by one, thus only animating one image at a time
    if(boss[i].currentFrame == boss[i].animationFrames){
        boss[i].currentFrame = 0;}
    boss[i].xCoord = boss[i].xCoord - 10;}}
    else if(i == 6){
        while(boss[i].yCoord > 60){
            //Puts image of character on screen based on inputs from struct
    readimagefile(boss[i].frames[boss[i].currentFrame],
        boss[i].xCoord,
        boss[i].yCoord,
        boss[i].xCoord + boss[i].charWidth,
        boss[i].yCoord + boss[i].charHeight );

    boss[i].currentFrame++; //increments the "frame" by one, thus only animating one image at a time
    if(boss[i].currentFrame == boss[i].animationFrames){
        boss[i].currentFrame = 0;}
    boss[i].yCoord = boss[i].yCoord - 10;}}
    else if(i == 7){
        while(boss[i].yCoord < 682){
            //Puts image of character on screen based on inputs from struct
    readimagefile(boss[i].frames[boss[i].currentFrame],
        boss[i].xCoord,
        boss[i].yCoord,
        boss[i].xCoord + boss[i].charWidth,
        boss[i].yCoord + boss[i].charHeight );

    boss[i].currentFrame++; //increments the "frame" by one, thus only animating one image at a time
    if(boss[i].currentFrame == boss[i].animationFrames){
        boss[i].currentFrame = 0;}
    boss[i].yCoord = boss[i].yCoord + 10;}}


    //putimage(0, 0, bkimage, COPY_PUT);
    //Sleep(10);
    }   
}

void playBoss(){
    int olddirection = 0, newdirection = 0;
    int bossDirection;
    int health = 500;
    int activate = 0;
    initSectors2();
    initSectors3();
    do {
        bossDirection = rand() % 4;
        if(bossDirection == 0)
            newdirection = 0;
        if(bossDirection == 1)
            newdirection = 1;
        if(bossDirection == 2)
            newdirection = 2;
        if(bossDirection == 3)
            newdirection = 3;
        if(boss[newdirection].xCoord == character[newdirection].xCoord || boss[newdirection].yCoord == character[newdirection].yCoord){
            if(newdirection == 0){
                newdirection = 4;}
            else if(newdirection == 1){
                newdirection = 5;}
            else if(newdirection == 2){
                newdirection = 6;}
            else if(newdirection == 3){
                newdirection = 7;}
        }


    if(olddirection != newdirection){
        boss[newdirection].xCoord = boss[olddirection].xCoord;
        boss[newdirection].yCoord = boss[olddirection].yCoord;

        boss[olddirection].drawable = 0;
        boss[newdirection].drawable = 1;
        boss[newdirection].currentFrame = 0;
        if(newdirection == 0 || newdirection == 1 || newdirection == 2 || newdirection == 3){
        olddirection = newdirection;}
    }
    checkSectorsBoss();
    shadowballSectors();
    boss_animation();
    Sleep(70);
        check_boss();
    activate = 1;
    }
    while(health > 0);

}

So these are my functions that handle my character direction and what animation to perform for such direction. What I am attemtping to do now is somehow, when boss hits character stop animation and character loses health. When i=4 through i=7 is boss shooting.

Ok, I guess my exact problem is shooting AT character, then stop animation on contact with character. What I have now allows boss to shoot... but its just a sporadic shoot haha... I am thinking do some sort of check for when boss crosses xCoord path with character or yCoord path with character, shoot in such direction, but then I have hit roadblocks with how to implement this.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.