0 Replies - 638 Views - Last Post: 26 July 2017 - 10:17 PM

#1 jeimyrm  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 26-July 17

C Game - The Good Fight

Posted 26 July 2017 - 10:17 PM

Hi my friends i created and programmed a windows console game and i want to share it with you.

https://www.youtube.com/watch?v=vQoOvSgQkc8&t=

The game is about the epic battle of the Good and Evil forces.

You will need the rlutil.h header file you can search it typing "rlutil" in Google and you will find it, download and copy the file to
your main.c or main.cpp directory.

One more thing...there is a background music this program uses just skip it or delete that part inside the code and it will not be a problem anymore.

Now you just need to compile and run it!...Enjoy!!!

I made it using CodeBlocks here's the source code:

#include <stdio.h>
#include <stdlib.h>
#include "rlutil.h"
#include <time.h>
#include <windows.h>

#ifndef NULL
#define NULL 0
#endif

#define HP 200
#define GOOD 0
#define EVIL 1
#define BLKDELAY 1000000
#define MAXWARFRIENDS 6
#define MAXRAYS 5000000
#define HPDECREASEPER  10
#define SCOREUP        1000
#define MOVELEFT       1
#define MOVERIGHT      2
#define MOVEUPSHOOT    5
#define MOVEDOWNSHOOT  6

typedef unsigned char byte;

typedef struct {

    byte message;
    byte value; // I'm preserving this variable just in case, this value is always 1 when used!
    byte movecont;
    int oldtime;
    byte shootcont;

}aimove_t;

typedef struct {

    byte pos[2],oldpos[2];
    byte side;
    aimove_t aimove;

}wf_t;

typedef struct {

   byte pos[2];
   byte side;
   byte pray; // If the player shoots the current ray then set to 1 otherwise 0

}ray_t;

static ray_t rays[MAXRAYS];
static int rayscont=0;

void Intro(void) {

    int c=0;
    setColor(WHITE);
    for(;c<79;c++)printf("%c",219);
    printf("\n");
    for(c=0;c<79;c++)printf("%c",219);
    setColor(LIGHTBLUE);
    printf("\n");
    for(c=0;c<79;c++)printf("%c",219);
    printf("\n");
    for(c=0;c<79;c++)printf("%c",219);
    printf("\n");
    setColor(WHITE);
    for(c=0;c<29;c++)printf("%c",219);
    printf(" THE GOOD FIGHT ");
    for(c=0;c<34;c++)printf("%c",219);
    printf("\n");
    setBackgroundColor(WHITE);
    setColor(BLACK);
    printf("                                                                               \n");
    printf("             Created by: Jeimy R.M.    Programmed by: Jeimy R.M.               \n");
    printf("                                                                               \n");
    printf("%cYou are the only hope for you and your war friends. Don't let the other side  \n"
           "defeat you. Fight 'til death and show no mercy!!!.                             \n"
           "Your mission is to lead and protect your war friends to enter completely into  \n"
           "the enemy zone.%c                                                               \n",34,34);
    printf("                                                                               \n");
    printf("                         Press 'SPACEBAR' to Play...                           \n");
    setColor(LIGHTBLUE);
    for(c=0;c<79;c++) printf("%c",219);
    printf("\n");
    for(c=0;c<79;c++) printf("%c",219);
    printf("\n");
    setColor(WHITE);
    for(c=0;c<79;c++) printf("%c",219);
    printf("\n");
    for(c=0;c<79;c++) printf("%c",219);
    setColor(LIGHTBLUE);
    setBackgroundColor(WHITE);
}

static int score=0;
void DrawScore(void) {

    gotoxy(34,25);
    setBackgroundColor(BROWN);
    setColor(LIGHTGREEN);
    printf("SCORE: %0.6d",score);
    setBackgroundColor(BLACK);
}

void DrawGameStuff(void) {

    int c=0;
    int y=2;

    setColor(WHITE);
    gotoxy(14,1);
    for(;c<54;c++) printf("%c",219);
    printf("\n");
    for(c=0;c<23;c++) {
        gotoxy(14,y++);
        printf("%c",219);
    }
    for(c=0;c<53;c++) printf("%c",219);
    gotoxy(67,y=2);
    for(c=0;c<23;c++) {
        gotoxy(67,y++);
        printf("%c",219);
    }
    gotoxy(14,6);
    for(c=0;c<54;c++) printf("%c",219);
    gotoxy(40,y=1);
    for(c=0;c<23;c++) {
        gotoxy(40,y++);
        printf("%c",219);
    }
    gotoxy(25,3);printf("GOOD");gotoxy(52,3);setColor(LIGHTRED);printf("EVIL");setColor(WHITE);gotoxy(3,1);printf(".");gotoxy(12,1);printf(".");gotoxy(8,3);printf(".");gotoxy(4,5);printf(".");
    gotoxy(10,7);printf(".");gotoxy(3,9);printf(".");gotoxy(3,11);printf(".");gotoxy(10,13);printf(".");gotoxy(3,15);printf(".");gotoxy(7,17);printf(".");gotoxy(10,19);printf(".");
    gotoxy(2,21);printf(".");gotoxy(7,23);printf(".");gotoxy(75,2);printf(".");gotoxy(69,4);printf(".");gotoxy(78,4);printf(".");gotoxy(72,6);printf(".");gotoxy(75,8);printf(".");gotoxy(70,10);
    printf(".");gotoxy(79,10);printf(".");gotoxy(75,12);printf(".");gotoxy(70,14);printf(".");gotoxy(79,14);printf(".");gotoxy(75,16);printf(".");gotoxy(71,18);printf(".");gotoxy(73,20);
    printf(".");gotoxy(71,22);printf(".");gotoxy(79,22);printf(".");gotoxy(75,24);printf(".");
}

static int goodhp=HP,evilhp=HP;

void DrawHPs(void) {
    gotoxy(24,5);
    if(goodhp>99)
    printf("HP: %d%c",goodhp,37);
    else
    printf("HP: %d%c ",goodhp,37);
    gotoxy(50,5);
    setColor(LIGHTRED);
    if(evilhp>99)
    printf("HP: %d%c",evilhp,37);
    else
    printf("HP: %d%c ",evilhp,37);
    DrawGameStuff();
}

void SubstractHP(int side) {

    if(side==GOOD)
        goodhp-=HPDECREASEPER;

    if(side==EVIL)
        evilhp-=HPDECREASEPER;
}

static int blkdelay=0;
static byte onepcomvisi=1; // 0 - 1PCOM invisible , 1 - 1PCOM visible

void DrawFinalMsg(int ww) {

system("cls");
int c=0;
if(ww==0) {
    setColor(WHITE);
    for(;c<79;c++)printf("%c",219);
    printf("\n");
    for(c=0;c<79;c++)printf("%c",219);
    setColor(LIGHTBLUE);
    printf("\n");
    for(c=0;c<79;c++)printf("%c",219);
    printf("\n");
    for(c=0;c<79;c++)printf("%c",219);
    printf("\n");
    setColor(WHITE);
    for(c=0;c<23;c++)printf("%c",219);
    printf(" CONGRATULATIONS YOU WIN!!!!!! ");
    for(c=0;c<25;c++)printf("%c",219);
    printf("\n");
    for(c=0;c<79;c++)printf("%c",219);
    printf("\n");
    for(c=0;c<79;c++)printf("%c",219);
    printf("\n");
    for(c=0;c<79;c++)printf("%c",219);
    setColor(LIGHTBLUE);
    printf("\n");
    for(c=0;c<79;c++)printf("%c",219);
      printf("\n");
    for(c=0;c<79;c++)printf("%c",219);
    printf("\n");
    setColor(WHITE);
    for(c=0;c<79;c++)printf("%c",219);
    printf("\n");
    for(c=0;c<79;c++)printf("%c",219);
    printf("\n\n");

}else {
    setColor(WHITE);
    for(;c<79;c++)printf("%c",219);
    printf("\n");
    for(c=0;c<79;c++)printf("%c",219);
    setColor(LIGHTBLUE);
    printf("\n");
    for(c=0;c<79;c++)printf("%c",219);
    printf("\n");
    for(c=0;c<79;c++)printf("%c",219);
    printf("\n");
    setColor(WHITE);
    for(c=0;c<23;c++)printf("%c",219);
    printf(" OH ITS SO SAD YOU LOSE BUDDY! ");
    for(c=0;c<25;c++)printf("%c",219);
    printf("\n");
    for(c=0;c<79;c++)printf("%c",219);
    printf("\n");
    for(c=0;c<79;c++)printf("%c",219);
    printf("\n");
    for(c=0;c<79;c++)printf("%c",219);
    setColor(LIGHTBLUE);
    printf("\n");
    for(c=0;c<79;c++)printf("%c",219);
      printf("\n");
    for(c=0;c<79;c++)printf("%c",219);
    printf("\n");
    setColor(WHITE);
    for(c=0;c<79;c++)printf("%c",219);
    printf("\n");
    for(c=0;c<79;c++)printf("%c",219);
    printf("\n\n");
}
}

static byte plypos[2]={5,5},oldplypos[2]={5,5};

void SetPlayerPos(int x,int y,int s) {

    if(oldplypos[0]!=plypos[0] || oldplypos[1]!=plypos[1]) {

        setColor(BLACK);
        setBackgroundColor(BLACK);
        gotoxy(oldplypos[0],oldplypos[1]);
        printf(" ");

        oldplypos[0]=plypos[0];
        oldplypos[1]=plypos[1];
    }
    if(s==1)
    setColor(LIGHTCYAN);
    else
    setColor(LIGHTMAGENTA);

    gotoxy(plypos[0],plypos[1]);
    printf("%c",2);
    setBackgroundColor(BLACK);
}

static wf_t warfriends[MAXWARFRIENDS];

void SetWarFriendPos(wf_t *warfriend) {


    if(warfriend->oldpos[0]!=warfriend->pos[0] || warfriend->oldpos[1]!=warfriend->pos[1]) {

        setColor(BLACK);
        setBackgroundColor(BLACK);
        gotoxy(warfriend->oldpos[0],warfriend->oldpos[1]);
        printf(" ");

        warfriend->oldpos[0]=warfriend->pos[0];
        warfriend->oldpos[1]=warfriend->pos[1];
    }
    if(warfriend->side==GOOD)
    setColor(WHITE);
    else
    setColor(LIGHTRED);

    gotoxy(warfriend->pos[0],warfriend->pos[1]);
    printf("%c",2);
    setBackgroundColor(BLACK);
}

void Copy2DVec(byte from[2],byte to[2]) {

    to[0]=from[0];to[1]=from[1];
}

void LoadWarFriends(void) {

    warfriends[0].pos[0]=21;
    warfriends[0].pos[1]=9;
    Copy2DVec(warfriends[0].pos,warfriends[0].oldpos);
    warfriends[0].side=GOOD;
    warfriends[0].aimove.message=warfriends[0].aimove.movecont=warfriends[0].aimove.shootcont=0;
    warfriends[0].aimove.value=1;
    warfriends[0].aimove.oldtime=GetTickCount();

    warfriends[1].pos[0]=21;
    warfriends[1].pos[1]=14;
    Copy2DVec(warfriends[1].pos,warfriends[1].oldpos);
    warfriends[1].side=GOOD;
    warfriends[1].aimove.message=warfriends[1].aimove.movecont=warfriends[1].aimove.shootcont=0;
    warfriends[1].aimove.value=1;
    warfriends[1].aimove.oldtime=GetTickCount();

    warfriends[2].pos[0]=21;
    warfriends[2].pos[1]=19;
    Copy2DVec(warfriends[2].pos,warfriends[2].oldpos);
    warfriends[2].side=GOOD;
    warfriends[2].aimove.message=warfriends[2].aimove.movecont=warfriends[2].aimove.shootcont=0;
    warfriends[2].aimove.value=1;
    warfriends[2].aimove.oldtime=GetTickCount();

    warfriends[3].pos[0]=59;
    warfriends[3].pos[1]=9;
    Copy2DVec(warfriends[3].pos,warfriends[3].oldpos);
    warfriends[3].side=EVIL;
    warfriends[3].aimove.message=warfriends[3].aimove.movecont=warfriends[3].aimove.shootcont=0;
    warfriends[3].aimove.value=1;
    warfriends[3].aimove.oldtime=GetTickCount();

    warfriends[4].pos[0]=59;
    warfriends[4].pos[1]=14;
    Copy2DVec(warfriends[4].pos,warfriends[4].oldpos);
    warfriends[4].side=EVIL;
    warfriends[4].aimove.message=warfriends[4].aimove.movecont=warfriends[4].aimove.shootcont=0;
    warfriends[4].aimove.value=1;
    warfriends[4].aimove.oldtime=GetTickCount();

    warfriends[5].pos[0]=59;
    warfriends[5].pos[1]=19;
    Copy2DVec(warfriends[5].pos,warfriends[5].oldpos);
    warfriends[5].side=EVIL;
    warfriends[5].aimove.message=warfriends[5].aimove.movecont=warfriends[5].aimove.shootcont=0;
    warfriends[5].aimove.value=1;
    warfriends[5].aimove.oldtime=GetTickCount();

    int c=0;
    for(c=0;c<MAXRAYS;c++) {
        rays[c].pos[0]=rays[c].pos[1]=0;
        rays[c].side=0;
        rays[c].pray=0;
    }
}

void UnloadWarFriends(void) {

    int c=0;
    for(;c<MAXWARFRIENDS;c++) {

        warfriends[c].oldpos[0]=warfriends[c].oldpos[1]=0;
        warfriends[c].pos[0]=warfriends[c].pos[1]=0;
        warfriends[c].side=warfriends[c].aimove.message=warfriends[c].aimove.value=warfriends[c].aimove.movecont=warfriends[c].aimove.shootcont=warfriends[c].aimove.oldtime=0;
    }
}

void UnloadRays(void) {

    int c=0;
    for(;c<MAXRAYS;c++) {
        rays[c].pos[0]=rays[c].pos[1]=0;
        rays[c].side=rays[c].pray=0;
    }
}

void WarFriend(wf_t *wfp) {

    if(wfp->side==GOOD) {

            if(wfp->pos[0]>66) {
                SubstractHP(EVIL);
                wfp->pos[0]=21;
                wfp->pos[1]=14;
                if((rand()%2+1)==1)
                wfp->aimove.message=MOVERIGHT;
            }

    }else {

          if(wfp->pos[0]<15) {
            SubstractHP(GOOD);
            wfp->pos[0]=59;
            wfp->pos[1]=14;
            if((rand()%2+1)==1)
            wfp->aimove.message=MOVELEFT;
          }
    }

    SetWarFriendPos(wfp);
}


void ShootRay(ray_t *r) {

    if(r->side==1) {

       if(r->pos[0]==76) {

        setColor(BLACK);
        gotoxy(r->pos[0],r->pos[1]);
        printf(" ");
       }

      if(r->pos[0]<76) {
        setColor(WHITE);
        gotoxy(++r->pos[0],r->pos[1]);
        printf("%c",223);
        setColor(BLACK);

        gotoxy(r->pos[0]-1,r->pos[1]);
        printf(" ");
        }

    }else{

        if(r->pos[0]==6) {

        setColor(BLACK);
        gotoxy(r->pos[0],r->pos[1]);
        printf(" ");
       }

      if(r->pos[0]>6) {
        setColor(LIGHTRED);
        gotoxy(--r->pos[0],r->pos[1]);
        printf("%c",223);
        setColor(BLACK);

        gotoxy(r->pos[0]+1,r->pos[1]);
        printf(" ");
        }
    }
}

static byte aitemp[MAXWARFRIENDS]={0,0,0,0,0,0}; // TEMP AI messages buffer...

void GetNextMoveForAll(void) {

    // *******************************************
    // THE MAIN WF AI FUNCS ARE: Shoot and Enter *
    // *******************************************

    int transval=0,c=0;

    // Remember #1: Good side only goes to the right.
    //              Evil side only goes to the left.
    //                                No going back.

    // GENERATING MESSAGES...
    c=rand()%3+1;
    if(c==1)
        aitemp[0]=MOVEUPSHOOT;
    else if(c==2)
        aitemp[0]=MOVEDOWNSHOOT;
    else
        aitemp[0]=MOVERIGHT;

    c=rand()%3+1;
    if(c==1)
        aitemp[1]=MOVEUPSHOOT;
    else if(c==2)
        aitemp[1]=MOVEDOWNSHOOT;
    else
        aitemp[1]=MOVERIGHT;

    c=rand()%3+1;
    if(c==1)
        aitemp[2]=MOVEUPSHOOT;
    else if(c==2)
        aitemp[2]=MOVEDOWNSHOOT;
    else
        aitemp[2]=MOVERIGHT;

    c=rand()%3+1;
    if(c==1)
        aitemp[3]=MOVEUPSHOOT;
    else if(c==2)
        aitemp[3]=MOVEDOWNSHOOT;
    else
        aitemp[3]=MOVELEFT;

    c=rand()%3+1;
    if(c==1)
        aitemp[4]=MOVEUPSHOOT;
    else if(c==2)
        aitemp[4]=MOVEDOWNSHOOT;
    else
        aitemp[4]=MOVELEFT;

    c=rand()%3+1;
    if(c==1)
        aitemp[5]=MOVEUPSHOOT;
    else if(c==2)
        aitemp[5]=MOVEDOWNSHOOT;
    else
        aitemp[5]=MOVELEFT;

    //Applying new messages...
    for(c=0;c<MAXWARFRIENDS;c++) {

    warfriends[c].aimove.message=aitemp[c];
    transval=1;
    if(warfriends[c].side==GOOD ) {

        if(warfriends[c].aimove.message==MOVELEFT) {

                // CALCULAMOS
                if(1>warfriends[c].pos[0]-15)
                    transval=warfriends[c].pos[0]-15;
        }

    }else {

         if(warfriends[c].aimove.message==MOVERIGHT) {

                // CALCULAMOS
                if(1>66-warfriends[c].pos[0])
                    transval=66-warfriends[c].pos[0];

         }
    }

    if(warfriends[c].aimove.message==MOVEUPSHOOT) {

            // CALCULAMOS
            if(1>warfriends[c].pos[1]-7)
                   transval=warfriends[c].pos[1]-7;

    }

    if(warfriends[c].aimove.message==MOVEDOWNSHOOT) {

            // CALCULAMOS
            if(1>23-warfriends[c].pos[1])
                   transval=23-warfriends[c].pos[1];
    }

    warfriends[c].aimove.value=transval;
    warfriends[c].aimove.movecont=0;
    warfriends[c].aimove.shootcont=0;
    }
}

void MakeNextMove(int wfindex) {

    switch(warfriends[wfindex].aimove.message) {

    case MOVELEFT:
         if(warfriends[wfindex].aimove.movecont!=warfriends[wfindex].aimove.value) {
            warfriends[wfindex].pos[0]--;
            warfriends[wfindex].aimove.movecont++;
        }
        break;

    case MOVERIGHT:
        if(warfriends[wfindex].aimove.movecont!=warfriends[wfindex].aimove.value) {
            warfriends[wfindex].pos[0]++;
            warfriends[wfindex].aimove.movecont++;
        }
        break;

    case MOVEUPSHOOT:
        if(warfriends[wfindex].aimove.movecont!=warfriends[wfindex].aimove.value) {
            warfriends[wfindex].pos[1]--;
            warfriends[wfindex].aimove.movecont++;

            if(GetTickCount()-warfriends[wfindex].aimove.oldtime>800) {
            rays[rayscont].pos[0]=warfriends[wfindex].pos[0];
            rays[rayscont].pos[1]=warfriends[wfindex].pos[1];
            rays[rayscont].side=warfriends[wfindex].side+1;
            rayscont++;
            warfriends[wfindex].aimove.oldtime=GetTickCount();
            }

        }
        break;

    case MOVEDOWNSHOOT:
         if(warfriends[wfindex].aimove.movecont!=warfriends[wfindex].aimove.value) {
            warfriends[wfindex].pos[1]++;
            warfriends[wfindex].aimove.movecont++;

            if(GetTickCount()-warfriends[wfindex].aimove.oldtime>800) {
            rays[rayscont].pos[0]=warfriends[wfindex].pos[0];
            rays[rayscont].pos[1]=warfriends[wfindex].pos[1];
            rays[rayscont].side=warfriends[wfindex].side+1;
            rayscont++;
            warfriends[wfindex].aimove.oldtime=GetTickCount();
            }

        }
        break;
    }
}

void AI_Moves(void) {

    GetNextMoveForAll();

    MakeNextMove(0);
    MakeNextMove(1);
    MakeNextMove(2);
    MakeNextMove(3);
    MakeNextMove(4);
    MakeNextMove(5);

}

int main(void)
{
    // ----------------------------------------------
    int ps=0; // 1 - GOOD , 2 - EVIL
    int whowins=-1; // 0 - 1P , 1 - COM
    srand(time(NULL));
    int c=0;
    long rayplydelay=GetTickCount();
    // ----------------------------------------------
    SetConsoleTitle("The Good Fight");
    PlaySound("music.wav", NULL, SND_LOOP | SND_ASYNC);
    // ----------------------------------------------

    LoadWarFriends();

    // INTRO SCREEN:
    Intro();
    while(1) {
        if(GetAsyncKeyState(VK_SPACE)) break;
    }

    setBackgroundColor(BLACK);
    system("cls");
    // ----------------------------------------------
    // GAME SCREEN:
    ps=rand()%2+1;

    if(ps==1) {

       plypos[0]=32;plypos[1]=14;
       oldplypos[0]=plypos[0];oldplypos[1]=plypos[1];

    }else {

       plypos[0]=48;plypos[1]=14;
       oldplypos[0]=plypos[0];oldplypos[1]=plypos[1];
    }


    while(1) {

        if(blkdelay++==BLKDELAY) {

            if(ps==1) {

            if(onepcomvisi==1) {
                setBackgroundColor(BLACK);
                gotoxy(35,3);
                //setColor(WHITE);
                printf("  ");
                gotoxy(63,3);
                //setColor(LIGHTRED);
                printf("   ");
                onepcomvisi=0;

            }else {

                gotoxy(35,3);
                setColor(WHITE);
                printf("1P");
                gotoxy(63,3);
                setColor(LIGHTRED);
                printf("COM");
                onepcomvisi=1;
            }

            }else {

            if(onepcomvisi==1) {
                setBackgroundColor(BLACK);
                gotoxy(35,3);
                //setColor(WHITE);
                printf("   ");
                gotoxy(63,3);
                //setColor(LIGHTRED);
                printf("  ");

                onepcomvisi=0;
            }else {

                gotoxy(35,3);
                setColor(WHITE);
                printf("COM");
                gotoxy(63,3);
                setColor(LIGHTRED);
                printf("1P");
                onepcomvisi=1;
            }

            }
            //-----------------------------
            // HERE WE DRAW THINGS AGAIN:
            DrawGameStuff();
            DrawHPs();
            DrawScore();

            if(GetAsyncKeyState(VK_LEFT)) {

             if(plypos[0]>15)
                plypos[0]--;
            }
            if(GetAsyncKeyState(VK_RIGHT)) {

                if(plypos[0]<66)
                plypos[0]++;
            }
            if(GetAsyncKeyState(VK_UP)) {

                if(plypos[1]>7)
                plypos[1]--;
            }
            if(GetAsyncKeyState(VK_DOWN)) {
                if(plypos[1]<23)
                plypos[1]++;
            }

            AI_Moves();

            if(GetTickCount()-rayplydelay>400) {

              if(GetAsyncKeyState(VK_SPACE)) {

                rays[rayscont].pos[0]=plypos[0];
                rays[rayscont].pos[1]=plypos[1];
                rays[rayscont].side=ps;
                rays[rayscont].pray=1;
                rayscont++;
              }

              rayplydelay=GetTickCount();
            }

            SetPlayerPos(plypos[0],plypos[1],ps);

            for(c=0;c<MAXWARFRIENDS;c++)
                WarFriend(&warfriends[c]);

            for(c=0;c<rayscont;c++) {

                // CHEKING IF THE PLAYER HAS BEEN KILLED...
                if(ps==1) {

                    if(rays[c].side==2) {

                            if(plypos[0]==rays[c].pos[0] && plypos[1]==rays[c].pos[1])
                              goto FINAL;
                    }

                }else {

                    if(rays[c].side==1) {

                     if(plypos[0]==rays[c].pos[0] && plypos[1]==rays[c].pos[1])
                              goto FINAL;
                    }

                }

                // CHECKING IF A RAY STRIKES INTO A WAR FRIEND...
                if(rays[c].side==1) {

                    if( (rays[c].pos[0]==warfriends[3].pos[0] && rays[c].pos[1]==warfriends[3].pos[1]) ) {

                       warfriends[3].pos[0]=59;
                       warfriends[3].pos[1]=14;

                       warfriends[3].aimove.message=MOVELEFT;

                       if(rays[c].pray==1)
                        score+=SCOREUP;
                    }

                    if( (rays[c].pos[0]==warfriends[4].pos[0] && rays[c].pos[1]==warfriends[4].pos[1]) ) {
                       warfriends[4].pos[0]=59;
                       warfriends[4].pos[1]=14;

                       warfriends[4].aimove.message=MOVELEFT;

                       if(rays[c].pray==1)
                        score+=SCOREUP;

                    }

                    if( (rays[c].pos[0]==warfriends[5].pos[0] && rays[c].pos[1]==warfriends[5].pos[1]) ) {
                       warfriends[5].pos[0]=59;
                       warfriends[5].pos[1]=14;

                       warfriends[5].aimove.message=MOVELEFT;

                       if(rays[c].pray==1)
                        score+=SCOREUP;
                    }

                }else {

                    if( (rays[c].pos[0]==warfriends[0].pos[0] && rays[c].pos[1]==warfriends[0].pos[1]) ) {

                       warfriends[0].pos[0]=21;
                       warfriends[0].pos[1]=14;

                       warfriends[0].aimove.message=MOVERIGHT;

                       if(rays[c].pray==1)
                        score+=SCOREUP;
                    }

                    if( (rays[c].pos[0]==warfriends[1].pos[0] && rays[c].pos[1]==warfriends[1].pos[1]) ) {

                       warfriends[1].pos[0]=21;
                       warfriends[1].pos[1]=14;

                       warfriends[1].aimove.message=MOVERIGHT;

                       if(rays[c].pray==1)
                        score+=SCOREUP;

                    }

                    if( (rays[c].pos[0]==warfriends[2].pos[0] && rays[c].pos[1]==warfriends[2].pos[1]) ) {
                       warfriends[2].pos[0]=21;
                       warfriends[2].pos[1]=14;

                       warfriends[2].aimove.message=MOVERIGHT;

                       if(rays[c].pray==1)
                        score+=SCOREUP;
                    }
                }
                ShootRay(&rays[c]);
            }

            //-----------------------------
            blkdelay=0;
        }

    if(ps==1) {

        if(goodhp<1) {
           whowins=1;
           break;
        }

        if(evilhp<1) {
           whowins=0;
           break;
        }

    }else {

        if(goodhp<1) {
           whowins=0;
           break;
        }
        if(evilhp<1) {
           whowins=1;
           break;
        }
    }
    }
    // ----------------------------------------------

FINAL:

    DrawFinalMsg(whowins);
    UnloadWarFriends();
    UnloadRays();

    system("pause");
    return 0;
}



Is This A Good Question/Topic? 0
  • +

Page 1 of 1