Sunday, October 3, 2010

Multiplayer mode completed.

the following are prototype program for applying multiplayer mode in our game. The design is not well-structured because I just editing the important working original code to become multiplayer in 2 hour until 12 pm 03/OCT/2010 that is last night. I am crazy to think that I can complete it simply by turning on techno song and expect ideas to flow in while writing it. Well, a miracle happened that it worked somehow. The question trivia is still in progress, as i still want 70 questions in the program to ensure better randomness.

//Trying for multiplayer
#include <iostream>
#include <conio.h>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <ctype.h>
//#define MAX 100 //using 100 is wasting resources
using namespace std;

struct GAME
{                            //struct definition
char menu[15];
};
//global variables
const int row=9,col=8;
int i,j,current_i,current_j,step;
GAME advGame[4];
int no_menu;
int hp=20, mp=20, ehp=30, move, emove;
const int size_question=40;//to make it really random, try to get around 70 questions
int LimitBattle=35; //limiting battle to only 35
int LimitRest = 20; //limiting resting to only 20

struct WORLD                                       //world of the game
{
    char* board[row][col];                         //the board, or the playing field
    int game_element[row][col];                    //1 resting,2 question,3 portal/jump,4 battle
}world;                                            //note: make game_element at [0][0],[row-1][col-1] = 0

struct QUESTIONS
{
string q;
char ans;
int status; //keep status of being answer or not. if already use, value 1
}questions[size_question];

//function prototypes
int dice(void);
void intBoard(void);
void intgame_element(void);
void displayBoard(void);
//void initialMenu(GAME advGame[4]);
void GameStart(int player);
//void S_player(void);
//void M_player(void);                            
//void newGame(void);
//void guideline(void);
//void credit(void);
//void selectMenu(int no_menu);
//void displayMenu(GAME advGame[]);
void wait(float seconds);
void win(void);
int question(void);
void initializeQuestion (void);
void initializeStatus (void);

void slowstepsBoard2(int step);
int hp2=20, mp2=20;
void rest(int turn);
void portal(int turn);
int battle (int turn);
int player;
void lose(int turn);
void slowstepsBoard(int step);
int current_i2,current_j2;

main ()
{
     player=2;
     GameStart(player);
     system("PAUSE");
}

void GameStart(int player)
{
int no_menu,turn;
intBoard();
intgame_element();
initializeQuestion ();
   system("cls");
   cout<<"\n GAME START !!!...GOOD LUCK"<<endl;                                 //initialize board
   displayBoard();
   if (player==2)
   {
   turn=1;
   current_i2=0,current_j2=0;
   while (strcmp(world.board[8][7],"  P 1  ")!=0||strcmp(world.board[8][7],"  P 2  ")!=0)
   {
      if (turn==1)
         {goto labelsingle;}
      else if (turn ==2)
      {cout<<" Press any key to roll the dice.";
      getch();                                                     //display board
      step=dice();                               //get dice value and save as step
      system("cls");
      slowstepsBoard2(step);
      cout<<endl<<" Your dice value: "<<step<<endl;
      switch (world.game_element[current_i2][current_j2])
      {
             case 1:
                  cout<<endl<<"Resting Place"<<endl;
                  rest(turn);
                  break;
             case 2:
                  cout<<endl<<"Question"<<endl;
                  question();
                  break;
             case 3:
                  cout<<endl<<"Portal"<<endl;
                  portal(turn);
                  break;
             case 4:
                  cout<<endl<<"Battle"<<endl;
                  battle(turn);
                  world.board[(current_i2)][(current_j2)]="  P 2  ";
                  cout << endl;
                  displayBoard();
                  break;
      }
      world.board[current_i][current_j]="  P 1  ";
      world.board[current_i2][current_j2]="  P 2  ";
      displayBoard();}
      labelreturn:
      if (turn==1)
       turn =2;
      else if (turn==2)
       turn=1;
   }              
   }
   else
   { turn = 0;
   while(strcmp(world.board[8][7],"  P 1  ")!=0)
   {
      labelsingle:
      cout<<" Press any key to roll the dice.";
      getch();                                                     //display board
      step=dice();                               //get dice value and save as step
      system("cls");
      slowstepsBoard(step);                          //move P1 on board according to the step
      //display dice value
     cout<<endl<<" Your dice value: "<<step<<endl;
      switch (world.game_element[current_i][current_j])
      {
             case 1:
                  cout<<endl<<"Resting Place"<<endl;
                  rest(turn);
                  break;
             case 2:
                  cout<<endl<<"Question"<<endl;
                  question();
                  break;
             case 3:
                  cout<<endl<<"Portal"<<endl;
                  portal(turn);
                  break;
             case 4:
                  cout<<endl<<"Battle"<<endl;
                  battle(turn);
                  world.board[(current_i)][(current_j)]="  P 1  ";
                  if((player==2))
                  {world.board[current_i2][current_j2]="  P 2  ";}
                  cout << endl;
                  displayBoard();
                  break;
      }
      if(turn == 1) {goto labelreturn;}
   }
  
   win();
   cout<<" Congratulation !!!..You Finish The Game..."<<endl
       <<" See You Again..Thank You."<<endl<<" Back to Game Menu "<<endl;
   }//else
   system("PAUSE");
   system("cls");
   //displayMenu(advGame);
   //cout<<"\n Enter Number: ";             //choose menu
   //cin>>no_menu;
   //system("cls");
   //selectMenu(no_menu);
}

//======================================================================================================
//stepping around board player 2
void slowstepsBoard2(int step)
{
     //new code
     world.board[current_i2][current_j2]="       ";
     for (int count=0;count<=step;count++,current_j2++)
     {
        
         system("cls");
         if (current_i2==row||(current_i2==row&&current_j2==col))//when reach destination or over it, assign to
         {
         world.board[current_i2][current_j2]="       ";
         world.board[8][7]="  P 2  ";   //last destination and break out of loop
         if((player==2))
                  {world.board[current_i][current_j]="  P 1  ";}
         displayBoard();
         break;
         }
         if (current_j2>=col)
         {
current_j2=current_j2-col;
     current_i2++;
         }
         world.board[current_i2][current_j2]="  P 2  ";
         if((player==2))
                  {world.board[current_i][current_j]="  P 1  ";}
         displayBoard();
         world.board[current_i2][current_j2]="       ";
         wait(0.2);
     }//for
     current_j2--;
}

//======================================================================================================
//initialize board
void intBoard(void)
{
    for(i=0;i<row;i++)
     for(j=0;j<col;j++)
       world.board[i][j]    ="       ";
    world.board[0][0]        =" START ";
    world.board[row-1][col-1]="  END  ";
    current_i=0; current_j=0;
}
//======================================================================================================
//initialize game_element
void intgame_element(void)
{
     for (i=0;i<row;i++)
         for (j=0;j<col;j++)
       {
             int countLimitBattle=0;
             int countLimitRest=0;
             world.game_element[i][j]=rand() % 4 + 1;
             label4:
             if (world.game_element[i][j]==1)
             {
             if (countLimitRest==LimitRest)
                {world.game_element[i][j]=rand() % 4 + 1;
                goto label4;}
             else
              countLimitRest++;
             }
             label3:
             if (world.game_element[i][j]==4)
             {
             if (countLimitBattle==LimitBattle)
                {world.game_element[i][j]=rand() % 4 + 1;
                goto label3;}
             else
              countLimitBattle++;
             }
         }
world.game_element[row][col]=0; world.game_element[0][0]=0;
}
//======================================================================================================
//show game board
void displayBoard(void)
{
   world.board[0][0]=" START ";
   wait(0.2);
for(i=0;i<row;i++)
   { cout<<endl;
     for(j=0;j<(col);j++)
         cout<<"========";
      cout<<endl<<'|';
      if (i%2==1)
       for(j=(col-1);j>=0;j--)
         cout<<world.board[i][j]<<'|';
      else
       for(j=0;j<col;j++)
          cout<<world.board[i][j]<<'|';
   }
   cout<<endl;
   for(j=0;j<(col);j++)
         cout<<"========";
     cout<<endl;
}
//======================================================================================================
//======================================================================================================
//to slow down the display of the board
void wait(float seconds)
{
     //error converting clock_t from float
     //error didn't seems to affect gameplay
  clock_t endwait;
  endwait=clock()+seconds*CLOCKS_PER_SEC;
  while(clock()<endwait){}   // jarak antara nombor yang akan dipaparkan
}
//======================================================================================================
//resting function
void rest(int turn)
{
     //random comments in resting place element
     int randRest = (rand() % 2 + 1);
     switch (randRest)
     {
            case 1:
            cout << "You found a space cafe and decided to have a tea before proceed with your adventure."<<endl;
            break;
            case 2:
            cout << "You gazes at the beautiful starry scene in front of you before continuing your journey." <<endl;
            break;
     }
    
     if (turn==2)
     {
     hp2+=10; //resting increase hp
     if (hp2>100)
        hp2=100;
     cout << "Increase hp by 10.\nCurrent hp2: " << hp2 << endl;
     }//if
     else if (turn==1||turn==0)
     {
     hp+=10; //resting increase hp
     if (hp>100)
        hp=100;
     cout << "Increase hp by 10.\nCurrent hp: " << hp << endl;
     }//else
}
//======================================================================================================
//portal function
void portal(int turn)
{
     cout << "You are unlucky enough to get sucked in into a wormhole." << endl
          << "It sends you somewhere around the universe." << endl;
        
     int polarity=(rand() % 2 + 1);
     if (polarity==2)
          step=dice();
     else
          step=(-1)*dice();
        
     system("PAUSE");
     system("cls");
     if (turn==2)
     {
   world.board[(current_i2)][(current_j2)]="       ";
   current_j2=current_j2+step;
   if (current_j2>=col)
   {
current_j2=current_j2-col;
     current_i2++;
   }
   world.board[(current_i2)][(current_j2)]="  P 2  ";}
     else
     {
   world.board[(current_i)][(current_j)]="       ";
   current_j=current_j+step;
   if (current_j>=col)
   {
current_j=current_j-col;
     current_i++;
   }
   world.board[(current_i)][(current_j)]="  P 1  ";
   }
   displayBoard();
}
//======================================================================================================
//battle mode = battle()+win()+lose()
int battle(int turn)
{
    if (turn==2)
    {hp2+=1; //for first battle, hp will be 20. every next battle, hp increase by 1 simulating hp regeneration
    ehp=30;
    labelbattle2:
    mp2++; //mp regeneration
    cout << "Enemy HP: " << ehp << endl;
    cout << "Your  HP2: " <<  hp2 << endl;
    cout << "Your  MP2: " <<  mp2 << endl;
    cout << "(1) Attack" << endl;
    cout << "(2) Use Force[10MP]" << endl;
    cout << "(3) Heal[2MP]"<< endl;
  
    cin >> move;
    system("cls");
    if (move>=1&&move<=3)
    { cout << "Status:" << endl; wait(0.2);
        switch (move)
        {
            case 1:
                if ((rand() % 3 + 1)==1)
                   {cout<<"You managed to come close enough to punched him in the face.[ehp-1]"<<endl; ehp-=1;}
                else if ((rand() % 3 + 1)==2)        
                   {cout<<"You shot him from distance using your rifle.[ehp-2]"<<endl; ehp-=2;}
                else
                   {cout<<"You sliced him skillfully with your sword.[ehp-3]"<<endl; ehp-=3;}
                break;
            case 2:
                if (mp2>=10)
                {
                  int a=(rand() % 5 + 1);
                   cout<<"You used your force and pushed him back, hurting him in the process.[ehp-"<<a<<",mp2-10]"<<endl;
                   ehp-=a;
                   mp2-=10;
                }
                else
                {
                    cout<<"You don't have enough mp to use your force ability."<<endl;
                }
                break;
            case 3:
                if (mp2>=2)
                {
                cout<<"You patched yourself quickly in the midst of battle.[hp2+4,mp2-2]"<<endl;
                hp2+=4;
                mp2-=2;
                    if (hp2>100)
                       hp2=100;
                }
                else
                {
                    cout<<"You don't have enough mp to heal yourself."<<endl;
                }
            }//switch(move)
            wait(0.2);
        if (ehp<=0)
         {   win(); return 1;}
        else
        {
             emove=(rand() % 3 + 1);
             wait(0.2);
             if (emove==1)
             {   cout << "The enemy shot you using his laser rifle.[hp2-1]" << endl; hp2-=1;}
             else if (emove==2)        
             {   cout << "The enemy charged at you and pushed you onto the walls.[hp2-2]" <<endl; hp2-=2;}
             else if (emove==3)
             {   cout << "The enemy healed himself.[ehp+2]"<<endl; ehp+=2;}
             wait(0.2);
        }
    if (hp2<=0)
    {   lose(turn);
        return 0;}
    }//if (1<move<3
    else
    {
        cin.clear(); // reset the state bits back to goodbit so we can use ignore()
        cin.ignore(1000, '\n'); // clear out the bad input from the stream

        cerr<<"Wrong input. Enter 1,2 or 3."<<endl;
        wait(0.2);
       system("PAUSE");cout<<endl;
       system("cls");}
    goto labelbattle2;}//if
    else{
    hp+=1; //for first battle, hp will be 20. every next battle, hp increase by 1 simulating hp regeneration
    ehp=30;
    label:
    mp++; //mp regeneration
    cout << "Enemy HP: " << ehp << endl;
    cout << "Your  HP: " <<  hp << endl;
    cout << "Your  MP: " <<  mp << endl;
    cout << "(1) Attack" << endl;
    cout << "(2) Use Force[10MP]" << endl;
    cout << "(3) Heal[2MP]"<< endl;
  
    cin >> move;
    system("cls");
    if (move>=1&&move<=3)
    { cout << "Status:" << endl; wait(0.2);
        switch (move)
        {
            case 1:
                if ((rand() % 3 + 1)==1)
                   {cout<<"You managed to come close enough to punched him in the face.[ehp-1]"<<endl; ehp-=1;}
                else if ((rand() % 3 + 1)==2)        
                   {cout<<"You shot him from distance using your rifle.[ehp-2]"<<endl; ehp-=2;}
                else
                   {cout<<"You sliced him skillfully with your sword.[ehp-3]"<<endl; ehp-=3;}
                break;
            case 2:
                if (mp>=10)
                {
                  int a=(rand() % 5 + 1);
                   cout<<"You used your force and pushed him back, hurting him in the process.[ehp-"<<a<<",mp-10]"<<endl;
                   ehp-=a;
                   mp-=10;
                }
                else
                {
                    cout<<"You don't have enough mp to use your force ability."<<endl;
                }
                break;
            case 3:
                if (mp>=2)
                {
                cout<<"You patched yourself quickly in the midst of battle.[hp+4,mp-2]"<<endl;
                hp+=4;
                mp-=2;
                    if (hp>100)
                       hp=100;
                }
                else
                {
                    cout<<"You don't have enough mp to heal yourself."<<endl;
                }
            }//switch(move)
            wait(0.2);
        if (ehp<=0)
         {   win(); return 1;}
        else
        {
             emove=(rand() % 3 + 1);
             wait(0.2);
             if (emove==1)
             {   cout << "The enemy shot you using his laser rifle.[hp-1]" << endl; hp-=1;}
             else if (emove==2)        
             {   cout << "The enemy charged at you and pushed you onto the walls.[hp-2]" <<endl; hp-=2;}
             else if (emove==3)
             {   cout << "The enemy healed himself.[ehp+2]"<<endl; ehp+=2;}
             wait(0.2);
        }
    if (hp<=0)
    {   lose(turn);
        return 0;}
    }//if (1<move<3
    else
    {
        cin.clear(); // reset the state bits back to goodbit so we can use ignore()
        cin.ignore(1000, '\n'); // clear out the bad input from the stream

        cerr<<"Wrong input. Enter 1,2 or 3."<<endl;
        wait(0.2);
       system("PAUSE");cout<<endl;
       system("cls");}
    goto label;
    }//else
    }
//======================================================================================================
//win()
void win(void)
{
     cout<<endl<<"You win!" << endl;
     system("PAUSE");
}
//======================================================================================================
//lose()
void lose(int turn)
{
     cout<<endl<<"You lost...\nGAME OVER" << endl;
     if (player=2)
     {
        switch(turn)
        {case 2: cout<<"Player 1 Win,Player 2 Lose";break;
        case 1: cout<<"Player 2 Win,Player 1 Lose"; break;
        }
     }
        cout << endl;
          system("PAUSE");
          system("cls");
          main();
}
//======================================================================================================
//question functions-question(),initializeQuestion(),initializeStatus()
int question (void)
{
    while(1){
//label2:
int randomQuestion=( (rand()) % size_question); //randomize the questions
if (questions[randomQuestion].status==1)
  continue;//goto label2;
char answer;
cout<<questions[randomQuestion].q<<endl;
cout<<"Your answer: ";
cin>>answer;
answer=toupper(answer);
if (answer == questions[randomQuestion].ans)//...
{ cout<<endl<<"That's correct!"<<endl; questions[randomQuestion].status=1;
    return 1;
    }
else
cout<<endl<<"That's wrong..."<<endl;
system("Pause");
system("cls");}
//goto label2;
}
//=================
//list of questions
void initializeQuestion (void)
{
questions[0].q="There are many theories about the birth of our solar system. Which theory involves a passing star pulling dust and debris from the forming sun?\n\tA: Nebular Hypothesis\n\tB: Tidal Theory\n\tC: Collision Theory\n\tD: Protoplanet Hypothesis";
questions[0].ans='B';
questions[1].q="The planets make up what percentage of the mass in our solar system?\n\tA: 0.0135 %\n\tB: 0.135 %\n\tC: 1.35 %\n\tD: 13.5 %";
questions[1].ans='B';
  questions[2].q="What are the only two planets in our solar system without moons?\n\tA: Mercury & Venus\n\tB: Venus & Mars\n\tC: Uranus & Neptune\n\tD: Neptune & Pluto";
questions[2].ans='A';
questions[3].q="What is the name of Pluto's moon?\n\tA: Charon\n\tB: Phobus\n\tC: Pandora\n\tD: Nereid";
questions[3].ans='A';
questions[4].q="The three main parts of a comet are the nucleus, the tail, and the _____?\n\tA: Zenith\n\tB: Umbra\n\tC: Radiant\n\tD: Coma";
questions[4].ans='D';
questions[5].q="What year boasted the first woman in space?\n\tA: 1963\n\tB: 1968\n\tC: 1973\n\tD: 1983";
questions[5].ans='A';
questions[6].q="What is the term for the condition when three celestial bodies are arranged in a straight line?\n\tA: Occultation\n\tB: Parallax\n\tC: Syzygy\n\tD: Triple Transit";
questions[6].ans='C';
questions[7].q="Which of the following was discovered in 2002?\n\tA: Nereid\n\tB: Varuna\n\tC: Titan\n\tD: Quaoar";
questions[7].ans='D';
questions[8].q="What manned U.S. space program eventually put 12 men on the Moon?\n\tA: Apollo\n\tB: Gemini\n\tC: Mercury\n\tD: Voyager";
questions[8].ans='A';
questions[9].q="From 1978 to 1999, which planet was farthest from the Sun?\n\tA: Pluto\n\tB: Neptune\n\tC: Uranus\n\tD: Saturn";
questions[9].ans='B';
questions[10].q="What was the very first personal computer?\n\tA: TRS-80\n\tB: Commodore PET\n\tC: Kenbak-1\n\tD: Apple I";
questions[10].ans='C';
questions[11].q="What year was the word \"computer\" first used to describe a mechanical calculating device?\n\tA: 1897\n\tB: 1912\n\tC: 1926\n\tD: 1942";
    questions[11].ans='A';
questions[12].q="What was the first portable computer?\n\tA: Epson HX-20\n\tB: Cray I\n\tC: Osborne I\n\tD: IBM 5155";
    questions[12].ans='C';
questions[13].q="During the 1970s computer engineers at various research institutions began to utilize telecommunications technologies to link their computers together. This effort, the forefather of the modern Internet, was known as the ...\n\tA: INSTANET\n\tB: ARPANET\n\tC: ORDONET\n\tD: BAYONET";
    questions[13].ans='B';
questions[14].q="What was the first computer to defeat a world champion chess player?\n\tA: Chinook\n\tB: X3D Fritz\n\tC: Deep Blue\n\tD: A.L.I.C.E.";
    questions[14].ans='C';
questions[15].q="What computer device did Douglas Engelbart invent in 1963?\n\tA: Modem\n\tB: Mouse\n\tC: Floppy disk\n\tD: Microchip";
    questions[15].ans='B';
questions[16].q="What \"law\" describes the fact that, on average, computers have doubled in capacity every 18 to 24 months since 1900?\n\tA: Anderson's Law\n\tB: Moore's Law\n\tC: Jefferson's Law\n\tD: Bohr's Law";
    questions[16].ans='B';
questions[17].q="How many lines of code did the Windows 98 operating system contain?\n\tA: 4 million\n\tB: 9 million\n\tC: 18 million\n\tD: 40 million";
    questions[17].ans='C';
questions[18].q="What was the first commercially successful vector processor?\n\tA: Cray I\n\tB: HP-2115\n\tC: Altair 8800\n\tD: Apple I";
    questions[18].ans='A';
questions[19].q="What new product did Apple Computer launch with a $1.5 million commercial during the 1984 Super Bowl?\n\tA: Apple I\n\tB: Apple IIe\n\tC: Apple IIc\n\tD: Macintosh";
    questions[19].ans='D';
questions[20].q="Mt. Fuji is the highest point in what Asian country?\n\tA: Bangladesh\n\tB: Burma\n\tC: China\n\tD: Japan";
    questions[20].ans='D';
questions[21].q="What is western Asia's longest river?\n\tA: Tigris\n\tB: Euphrates\n\tC: Xi Jiang\n\tD: Kurobe";
    questions[21].ans='B';
questions[22].q="What tiny country, known to its inhabitants as Druk Yul (Land of the Thunder Dragon), is sandwiched between China and India?\n\tA: Bhutan\n\tB: Bangladesh\n\tC: Mongolia\n\tD: Burma";
    questions[22].ans='A';
questions[23].q="What mountain range runs along the northern border of India?\n\tA: Urul Mountains\n\tB: Tatra Mountains\n\tC: Xiao Hinggan Ling Mountains\n\tD: Himalayan Mountains";
    questions[23].ans='D';
questions[24].q="Korea is separated from Japan by what strait?\n\tA: Cheju\n\tB: Tsushima\n\tC: Gibraltar\n\tD: Bungo";
    questions[24].ans='B';
questions[25].q="What Chinese city is situated at the mouth of the Chang Jiang (Yangtze) River?\n\tA: Shanghai\n\tB: Beijing\n\tC: Taipei\n\tD: Changchun";
    questions[25].ans='A';
questions[26].q="What is the tallest mountain in Asia?\n\tA: Qogir\n\tB: Kangchenjunga\n\tC: Cho Oyu\n\tD: Mount Everest";
    questions[26].ans='D';
questions[27].q="Iran is slightly larger than what U.S. state?\n\tA: Rhode Island\n\tB: Montana\n\tC: Texas\n\tD: Alaska";
    questions[27].ans='D';
questions[28].q="What Japanese city is the site of the Peace Memorial Park and the eternal Peace Flame which is never to be extinguished until all nuclear weapons are dismantled?\n\tA: Hiroshima\n\tB: Nagasaki\n\tC: Tokyo\n\tD: Kyoto";
    questions[28].ans='A';
questions[29].q="What is the capital of Afghanistan?\n\tA: Teheran\n\tB: Kandahar\n\tC: Baghdad\n\tD: Kabul";
    questions[29].ans='D';
    questions[30].q="When was the idea of the atom first introduced?\n\tA: 450 B.C.\n\tB: 1050\n\tC: 1791\n\tD: 1942";
    questions[30].ans='A';
    questions[31].q="In 2004, what was discovered on the island of Flores in Indonesia?\n\tA: A living dinosaur\n\tB: Remains of a hobbit-sized human species\n\tC: A tribe whose members commonly live over 150 years\n\tD: A plant with a mammal-like brain";
    questions[31].ans='B';
    questions[32].q="An earthquake that measures 8 on the Richter Scale would be how many times stronger than an earthquake that measures 4 on the same scale?\n\tA: 2 times stronger\n\tB: 4 times stronger\n\tC: 1000 times stronger\n\tD: 10,000 times stronger";
    questions[32].ans='D';
    questions[33].q="What is the gestation period of an Hippopotamus?\n\tA: 4 months\n\tB: 8 months\n\tC: 12 months\n\tD: 16 months";
    questions[33].ans='B';
    questions[34].q="What physicist discovered that a wave's frequency changes when the source and the observer are in motion relative to one another?\n\tA: Max Planck\n\tB: Christian Doppler\n\tC: Enrico Fermi\n\tD: Albert Einstein";
    questions[34].ans='B';
    questions[35].q="In what type of matter are atoms most tightly packed?\n\tA: Solids\n\tB: Liquids\n\tC: Gases\n\tD: All are the same";
    questions[35].ans='A';
    questions[36].q="Which of the following means \"rain\" when added to a cloud's name?\n\tA: Alto\n\tB: Nimbus\n\tC: Strato\n\tD: Cirrus";
    questions[36].ans='B';
    questions[37].q="What is the longest river in the world?\n\tA: Amazon\n\tB: Nile\n\tC: Congo\n\tD: Chang Jiang";
    questions[37].ans='B';
    questions[38].q="How many brains did a Stegosaurus have?\n\tA: One\n\tB: Two\n\tC: Three\n\tD: None";
    questions[38].ans='A';
    questions[39].q="What instrument is used to measure wind speed?\n\tA: Anemometer\n\tB: Barometer\n\tC: Altimeter\n\tD: Fanometer";
    questions[39].ans='A';

    initializeStatus ();
}

void initializeStatus (void)
{
     for ( i=0; i<size_question; i++)
   questions[i].status=0;
}
//======================================================================================================
//dice function
int dice(void)
{
    return rand() % 6 + 1;
}
//stepping around board-slow motion
void slowstepsBoard(int step)
{
     //new code
     world.board[current_i][current_j]="       ";
     for (int count=0;count<=step;count++,current_j++)
     {
         system("cls");
         if (current_i==row||(current_i==row&&current_j==col))//when reach destination or over it, assign to
         {
         world.board[current_i][current_j]="       ";
         world.board[8][7]="  P 1  ";   //last destination and break out of loop
         if((player==2))
                  {world.board[current_i2][current_j2]="  P 2  ";}
         displayBoard();
         break;
         }
         if (current_j>=col)
         {
current_j=current_j-col;
     current_i++;
         }
         world.board[current_i][current_j]="  P 1  ";
         if((player==2))
                  {world.board[current_i2][current_j2]="  P 2  ";}
         displayBoard();
         world.board[current_i][current_j]="       ";
         wait(0.2);
     }//for
     current_j--;
}

No comments:

Post a Comment