Site hosted by Angelfire.com: Build your free website today!

The Osama Game

click here to download the .cpp file

click here to download the word document

//Khanh Dang
//This is a game that the user has to find certain coordinates on a plane.
//The points will represent Osama and his Taliban.

#include <iostream>
#include <conio.h>
using namespace std;
void main ()
{

int found[4]= {0};//elimination of correct possibilities.
int x = 0, y = 0;//direction the user moves.
int taliban = 0;//counts the Taliban found.
int osama = 0;//counts if osama is found.

char move;
cout<<"Try to find Osama and the Taliban: 3 Taliban & Osama are out there.\n";
cout<<"They are Northeast, Northwest, Southeast, and Southwest from where you start.\n";
cout<<"From where you start, there is a 5 mile radius, and each direction you go\n";
cout<<"represents 1 mile.\n";
cout<<endl;
cout<<"Your start point will be at (0,0)";
cout<<endl;

//loop to prompt user to keep entering directions.
while (move != 'q')
{
cout<<endl;
cout<<"Select one of the following to move:";
cout<<endl;
cout<<"n. (n)orth\n";
cout<<"s. (s)outh\n";
cout<<"e. (e)ast\n";
cout<<"w. (w)est\n";
cout<<"NOTE! To quit, press 'q'.\n";
cout<<endl;
cout<<"Direction choice: ";
cin>>move;
cout<<" ____________________________________________________________________\n";

//selection statement when user enters choice.
switch (move)
{
case 'n': ++y; cout<<endl; cout<<"Your new coordinate is "<<"("<<x<<","<<y<<")";
cout<<endl;
break;
case 's': --y; cout<<endl; cout<<"Your new coordinate is "<<"("<<x<<","<<y<<")";
cout<<endl;
break;
case 'e': ++x; cout<<endl; cout<<"Your new coordinate is "<<"("<<x<<","<<y<<")";
cout<<endl;
break;
case 'w': --x; cout<<endl; cout<<"Your new coordinate is "<<"("<<x<<","<<y<<")";
cout<<endl;
break;
case 'q': cout<<endl; x=0;y=0;cout<<"GOOD BYE!";
cout<<endl;
break;

default: cout<<"Invalid entry, TRY AGAIN PLEASE.";
}

//if user finds Osama or Taliban, notification appears.
if (x == 5 && y == 4)
cout<<endl,
cout<<" *****Now they are leaderless, you got Osama.*****\n";
if (x == 5 && y == 4)
++osama,++found[0];

if (x == 2 && y == -3)
cout<<endl,
cout<<" *****Splat!!! You got a Taliban.*****\n";
if (x == 2 && y == -3)
++taliban,++found[1];

if (x == -1 && y == 5)
cout<<endl,
cout<<" *****Splat!!! You got a Taliban.*****\n";
if (x == -1 && y == 5)
++taliban,++found[2];

if (x == -1 && y == -1)
cout<<endl,
cout<<" *****Splat!!! You got a Taliban.*****\n";
if (x == -1 && y == -1)
++taliban,++found[3];

//tells user which area is secure and which area to search.
if (found[0] == 1)
cout<<endl,
cout<<" ***The NORTH EASTERN area is SECURE, search the other areas.***",
found[0] = 0,x=0,y=0;


if (found[1] == 1)
cout<<endl,
cout<<" ***The NORTH WESTERN area is SECURE, search the other areas.***",
found[1] = 0;


if (found[2] == 1)
cout<<endl,
cout<<" ***The SOUTH EASTERN area is SECURE, search the other areas.***",
found[2] = 0;


if (found[3] == 1)
cout<<endl,
cout<<" ***The SOUTH WESTERN area is SECURE, search the other areas.***",
found[3] = 0;


//displays how many taliban were caught, and if osama was caught.
cout<<endl;
if (osama == 1)
cout<<" *You found "<<taliban<<" Taliban and Osama.*";
if (osama == 0)
cout<<" *You found "<<taliban<<" Taliban and Osama is still out there.*";
cout<<endl;
}
cout<<endl;
getch ();
}

NOTE!!! Not finished!!!