Code:
void playBoss(){ int olddirection = 0, newdirection = 0;
int bossDirection;
int health = 500;
//#pragma omp parallel for private(newdirection){
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;}
}
#pragma omp parallel for
for(int k = 0; k<20; k++){
boss_animation();
if(boss[newdirection].xCoord >36 || boss[newdirection].xCoord < 733 || boss[newdirection].yCoord > 60 || boss[newdirection].yCoord < 682){
newdirection++;
Sleep(10);}
check_boss();}
}
while(health > 0);
}
void boss_animation(){
int area = imagesize(0, 0, 799, 799);
bkimage = malloc(area);
getimage(0, 0, 799, 799, bkimage);
#pragma omp parallel for
for (int i = 0; i < 3; 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;
}
Ok, so what this does is animates my boss for my game. Right now all he does is run rapidly around the screen. For the sake of time this is all I am going to have him do :P. Then whenever he crosses paths of character (charx = bosx or chary = bossy coordinates) the boss will shoot something at the character (yet to be implemented).
But my issues are with using #pragma omp. My instructor tried showing this to our class in hopes it would help with our game, but I am still unable to have the boss going WHILE being able to control character. It can only do one or the other still.
I guess I am not sure where the best placement of these #pragma's would be to achieve simultaneous movements.