473,765 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

2D map gaming Player V. Computer

8 New Member
I am working on a game kind of like chess but with only 1 piece per a player.

In the beginning they pick there stats(movement, HP, damage, and range of weapons). 10 pts to put where ever they like ranging from 1-6 per a stat

When hit hp is reduced by damage done. So i supose a for loop would be good for that as well

Weapons is how much +damage the weapons do

it is a 10 x 10 grid that i will use ascii. Yet I dont really get how you draw with ascii. Porbably an array i believe.

My game system im using will be based off of x, y. 0,0 top left 10,10 bottom right.

The M.I.M.E's (mechines in main engagement) as i call them can only shoot or move in the direction they are facing. So i was doing to use:

Q- rotate counter-clockwise
W- move forward
E- rotate clockwise

I was thinking maybe using a switch statement like

cout << "Enter a movemement. You have " << move << "moves left." <<endl;
cin >> choice;
switch(choice)
{
case 1://rotate counter-clockwise

case 2:// move forward

case 3: //rotate clockwise

default: // loop back around
}

Any action counts as a move. So i will use a for loop to acount of that part. for( int i= 0; i > move; i++)


What i do not understand is how do you move the MIME's across the field =/

as for weapons i was going to find a way to check the x,y cord of the other robot.
However i wanted to use two different weapons, a laser and a grenade.
Laser shoots straight based off of range 3-4 damage
and grenade is range -1 and does a 3x3 kill grid dealing 1-2 damage


At first the robot moves randomly around until he is "Within range" i was going to make his range based off his firing range of range+1 x range.


Extras!!!!:

These are things i really would kill to do but is not something i need.

LANDMINES!: place a mine at x,y when player is in the 4x4 box of the mine it goes boom dealing 1 damage

Saving the game file: Not a clue how to do this

Pillars/Block on the ground: i would guess a random Num generator 2 place the blocks maybe 2-4 then randoms 0-10,0-10.




Any help or a direction to a website about basic 2D game design would be much love. This is huge jump in what we have been doing in class which is basic user input so i am completely lost :(
Dec 1 '08 #1
7 1764
vmpstr
63 New Member
What I would do is to just write everything down, and take it one step at a time. First, generate and draw the field, then introduce the human player. Get some input, and move the player around. Introduce weapons, and make sure you can shoot at stationary things correctly. The last thing you should do is to introduce the AI, because it will be difficult, unless you just want it to move around randomly and shoot randomly.

Remember, one step at a time.

good luck.

P.S. If you have any specific questions, you are welcome to ask.

P.P.S. Searching for "game development tutorials" in google yields quite a few results that seem good.
Dec 1 '08 #2
CodecSmash49
8 New Member
Every google search i tried yeilded bad results. Most were about tic-tac-toe. Non dealt with using ascii to draw and board and play on it from user input.

:( could you offer a link or a book that would b good for this topic. I already tried 1 book but again it was about user input and displaying data nothing about a board playing field
Dec 2 '08 #3
vmpstr
63 New Member
I don't know any good references off the top of my head. This shouldn't be a difficult problem. To display a field (that is stored in an array), you just need two loops. At each iteration, you can check if that position corresponds with the player or the AI. If it does, then instead of drawing the field, you draw the symbol representing the player (or the AI). Likewise for various laser/grenades/mines, except you will want to keep those in an array (or some other container) and associate a "lifetime" with it. For instance, say a grenade explodes after 2 turns, then it has a lifetime of two, and whenever it reaches 0 it explodes. Mines have an infinite lifetime, until someone steps of them.

So, just think it through in this manner and start coding one step at a time: draw the field first, draw the characters, make the characters move, etc. When you get further in and start getting stuck, you can ask more questions here.

Again, any kind of reference isn't going to be tailored to your game. It's just going to be about _some_ game. But you learn from these references, nevertheless.

good luck
Dec 2 '08 #4
CodecSmash49
8 New Member
I've been banging my head against a wall but i've made progress!
I'm stuck at these points:
1) making the robot move at random when the player is in range engage them.
2) checking to see if the weapons hit(grenade/laser) I'm guessing checking player positon with the X,Y for grenade and X or Y for laser.
3)Displaying the ascii grid
4) Player = ascii 193- North 194-South 195- East 180- West. How do i display so they rotate as the player changes direct? I was guessing a IF loop.
5) same for the Computer as number 4
6)Randoming the stats for the robot so they = 10 and do not go over, but can go under.
7) Laser i was going to use '.' for the laser or ascii #220. How can i display so i shoots across the map
8)Grenade- was going to use ascii 177 to show the area the grenade hit in.

*not needed but i would also like 2 try and drop random walls*

Any help or other problems you see i will love you for LIFE!

Expand|Select|Wrap|Line Numbers
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include "color.h"
  4. #include <conio.h>
  5.  
  6. using namespace std;
  7. using namespace Petter;
  8.  
  9. void title();
  10. void credits();
  11. void intro();
  12. void instructions();
  13. int menu(char arrayGrid[][21]);
  14. void displayGrid(char arrayGrid[][21]);
  15. void begin();
  16. void yourTank();
  17. void yourTankRotate();
  18. void compTank();
  19. void compTankRotate();
  20. void stats();
  21. void compStats();
  22. void shootL();
  23. void shootG();
  24. void shieldLeft();
  25. void move();
  26. void hit();
  27. void direction();
  28.  
  29.  
  30.  
  31. int main(int argc, char *argv[])
  32. {
  33.     //yourTank;
  34.     //compTank;
  35.  
  36.     //yourTankY =2;
  37.     //yourTankX = 2;
  38.     //compTankY = 19;
  39.     //compTankX = 19; 
  40.  
  41.     char arrayGrid[21][21]={
  42.                         {201,205,209,205,209,205,209,205,209,205,209,205,209,205,209,205,209,205,209,205,187},
  43.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  44.                         {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
  45.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  46.                         {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
  47.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  48.                         {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
  49.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  50.                         {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
  51.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  52.                         {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
  53.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  54.                         {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
  55.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  56.                         {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
  57.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  58.                         {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
  59.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  60.                         {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
  61.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  62.                         {200,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,188},
  63.                         };
  64.  
  65.  
  66.     title();
  67.     credits();
  68.     cout << endl;
  69.     cout << endl;
  70.     menu(arrayGrid);
  71.  
  72.  
  73.     system("PAUSE");
  74.     return EXIT_SUCCESS;
  75. }
  76. void title()
  77. {
  78.     cout << endl;
  79.     cout << endl;
  80.     cout << endl;
  81.     cout << endl;
  82.     cout <<  "\t\t\t" <<RED << " WELCOME TO M.I.M.E WARS!!!!!!!" << NORMAL << endl;   
  83. }
  84. void credits()
  85. {
  86.     cout << endl;
  87.     cout << endl;
  88.     cout << endl;
  89.     cout << endl;
  90.     cout << "\t\t\tCreated by: Michael Meyer" << endl;
  91.     cout << "\t\t\tWith Help from: Mountain Dew" << endl;
  92. }
  93. int menu(char arrayGrid[][21])
  94. {
  95.     char choice;
  96.  
  97.     do
  98.     {
  99.  
  100.  
  101.     cout << "                                 :[b]ATTLE!:   " <<endl;
  102.     cout << "                                               " <<endl;
  103.     cout << "                                :[S]tory Line:" <<endl;
  104.     cout << "                                               " <<endl;
  105.     cout << "                               :[i]NSTRUCTIONS:" <<endl;
  106.     cout << "                                               " <<endl;
  107.     cout << "                              :[E]xit(chicken!?):    " <<endl;
  108.  
  109.     choice =getch(); // calls for input
  110.     switch(choice)
  111.     {
  112.                    case 'b':
  113.                         {
  114.                             begin();
  115.                         }
  116.                    break;
  117.                    case 's':
  118.                         {
  119.                             intro();
  120.                         }
  121.                    break;
  122.                    case 'i':
  123.                         {
  124.                             instructions();
  125.                         }
  126.                    break;
  127.                    case 'e':
  128.                    break;
  129.     } 
  130.     }
  131.     while(choice != 'e');  
  132.  
  133.     return 0;
  134. }
  135.  
  136. void instructions();
  137. {
  138.     cout << "\t\t\t\t Instructions" << endl << endl << endl;
  139.  
  140.             cout << "Player controls:" << endl;
  141.             cout << "W key: Progress the M.I.M.E forward, towards the way they are facing." << endl;
  142.             cout << "A key: Rotates the M.I.M.E left." << endl;
  143.             cout << "D key: Rotatest the M.I.M.E Counter right." << endl;
  144.             cout << "E key: Chooses to fire the M.I.M.E's Lazer." << endl;
  145.             cout << "Q key: Chooses to lob a M.I.M.E's Grenade." << endl;     
  146.     }
  147. void into();
  148. {
  149.     cout << "\t\t\t\t Introduction" << endl << endl << endl;
  150.             cout << "\tDuring the third World War a new breed of warefare was brought to life. M.I.M.E's were born to be a slave of men.";
  151.            Sleep(4000);
  152.             cout << " M.I.M.E, Mechines In Main Engagement, were a far more advance design of A.I.(Artificial Intelegence).";
  153.             Sleep(4000);
  154.             cout << "There mechines   were designed to lower human casualties, but instead turned and increase the   death toll.";
  155.             cout << endl;
  156.             Sleep(4000);
  157.             cout << "\tWhen the M.I.M.Es turned, it was nothing more then a silent killing of  those around them.";
  158.             Sleep(4000);
  159.             cout << "Man was once again forced back into traditional warfare of    opertaing there own mechines and demise.";
  160.             cout << endl;
  161.             cout << endl;
  162.             cout << endl;
  163.             Sleep(4000);
  164.             cout << "Who will win!?!?.........";
  165.             cout << endl;
  166.             cout << endl;    
  167. }
  168.  
  169. void displayGrid(char arrayGrid[][21] // display the grid + robots
  170. {
  171.  
  172. }
  173. void yourTank(); // your tank Green
  174. {
  175.  
  176. }
  177.  
  178. void yourTankRotate(); // Shows you tank rotating N, S, W, E
  179. {
  180.  
  181. }
  182.  
  183. void compTank(); // computer tank Red
  184. {
  185.  
  186. }
  187.  
  188. void compTankRotate(); // Shows computer tank rotating N, S, W, E
  189. {
  190.  
  191. }
  192.  
  193. void stats();
  194. {
  195.     int shield; // HP
  196.     int move; // actions per a round
  197.     int weapon; // +damage
  198.     int range; // how far your weapon shoots
  199.     int total = range + shield + weapon + move; // total stats cannot acceed 10
  200.     int remaining = 10 - range + shield + weapon + move; 
  201.  
  202.      cout << "Choose the stats you would like for your M.I.M.E., with a max total of 10." << endl;
  203.  
  204.      while(total != 10)
  205.      {
  206.          cout << "Choose 1-6 for your range of your weapon(" << remaining << " points left: ";
  207.          cin >> range;
  208.          while((cin == 0) || (range < 0))
  209.                     {
  210.                         cin.clear();
  211.                         cin.ignore(10000, '\n');
  212.                         cout << "Please enter the amount of range: ";
  213.                         cin >> range;
  214.                     }
  215.  
  216.          cout << "Choose 1-6 for your shields(" << remaining << " points left: ";
  217.          cin >> shield;
  218.          while((cin == 0) || (shield < 0))
  219.                     {
  220.                         cin.clear();
  221.                         cin.ignore(10000, '\n');
  222.                         cout << "Please enter amount for the shield: ";
  223.                         cin >> shiel;
  224.                     }
  225.  
  226.          cout << "Choose 1-6 for your weapon damage(" << remaining << " points left: ";
  227.          cin >> weapon;
  228.          while((cin == 0) || (weapon < 0))
  229.                     {
  230.                         cin.clear();
  231.                         cin.ignore(10000, '\n');
  232.                         cout << "Please enter the amount for the weapon: ";
  233.                         cin >> weapon;
  234.                     }
  235.  
  236.          cout << "Choose 1-6 for your movement speed(" << remaining << " points left: ";
  237.          cin >> move;
  238.          while((cin == 0) || (move < 0))
  239.                     {
  240.                         cin.clear();
  241.                         cin.ignore(10000, '\n');
  242.                         cout << "Please enter the amount for movement: ";
  243.                         cin >> move;
  244.                     }
  245.     }
  246. }
  247.  
  248. void compStats(); // stats MUST be random 1-6 cannot accede 10 total
  249. {
  250.     srand(time(0)); // int random number
  251.     int shield; // HP
  252.     int move; // actions per a turn
  253.     int weapon; // +damage
  254.     int range; // how far weapon can shoot
  255.     int total = range + shield + weapon + move;
  256.  
  257.     cout << "The computers stats are as shown: " << endl
  258.  
  259.     while(total != 10 )
  260.     {
  261.         range = (rand(0) % 6);
  262.         shield = (rand(0) % 6);
  263.         weapon = (rand(0) % 6);
  264.         move = (rand(0) % 6);
  265.     }
  266.  
  267.     cout << "Range is = " << range << endl;
  268.     cout << "Shield is = " << shield << endl;
  269.     cout << "Weapon is = " << weapon << endl;
  270.     cout << "Movement is = " << move << endl;
  271. }
  272.  
  273. void shootL(); // direct shot 2 damage
  274. {
  275.  
  276. }
  277.  
  278. void shootG(); // Area of affect dmg 3x3 1 dmg
  279. {
  280.  
  281. }
  282.  
  283. void shieldLeft(); // remaining life points
  284. {
  285.      int yourShield;
  286.      int compShield;
  287.  
  288.      cout << "Your shield left is: " << yourShield << endl;
  289.  
  290.      cout << "The computers shield left is: " << compShield << endl;
  291. }
  292.  
  293. void direction(); // which direction you are facing to determine which way you can move
  294. {                 // face must remain 1-4
  295.     int face = 1;
  296.     char direction;
  297.  
  298.     if( face = 1)
  299.         {
  300.                direction = "North";
  301.         }
  302.     else if(face = 2)
  303.         {
  304.             direction = "West";
  305.         }
  306.     else if(face = 3)
  307.         {
  308.             direction = "South";    
  309.         }
  310.     else(face = 4)
  311.         {
  312.             direction = "East"    
  313.         }
  314.     cout << "You are facing: " << direction << endl;
  315. }
  316.  
  317. void move(); // Move you forward
  318. {
  319.      int choice;
  320.      int moveX;
  321.      int moveY;
  322.  
  323.      cout << "Choose a movement command." << endl;
  324.      cin >> choice
  325.  
  326.      switch(choice)
  327.      {
  328.         case w: // move forward adding 1 to X or Y axis based on direction facing 
  329.             while(x != 0 && x != 21 && y != 0 && y != 21)
  330.             {
  331.                 if(int face = 2 || face = 4)
  332.                     {
  333.                         yourTankX + 1 = moveX;    
  334.                     }   
  335.                 else(int face = 1 || face = 3)
  336.                     {
  337.                         yourTankY + 1 = moveY;
  338.                     } 
  339.             }
  340.  
  341.         case a: // rotates you to the left subtracting 1 from face
  342.  
  343.  
  344.         case d: // rotates you to the right adding 1 to face
  345.  
  346.  
  347.         case e: // fires THE LAZER! 
  348.             hit();
  349.  
  350.         case q:  // Lobs the grenade
  351.             hit();
  352.      }
  353. }
  354.  
  355. void hit() // determines if the weapons hit
  356. {
  357.  
  358. }
  359.  
  360.  
Dec 9 '08 #5
JosAH
11,448 Recognized Expert MVP
Your code doesn't compile: I see a lot of functions that go like this:

Expand|Select|Wrap|Line Numbers
  1. void func(); { ... }
  2.  
Leave out that semi colon.

kind regards,

Jos
Dec 9 '08 #6
CodecSmash49
8 New Member
i've managed to get most my functions done. I'm not to sure on how to display the grid array so i can refresh the screen each time a robot moves.

If you see any other problems please let me know, this is my first multi function assignment =/

Expand|Select|Wrap|Line Numbers
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include "color.h"
  4. #include <conio.h>
  5.  
  6. using namespace std;
  7. using namespace Petter;
  8.  
  9. void title();
  10. void credits();
  11. void intro();
  12. void instructions();
  13. int menu(char arrayGrid[][21]);
  14. void displayGrid(char arrayGrid[][21]);
  15. void begin();
  16. void yourTank();
  17. void yourTankRotate();
  18. void compTank();
  19. void compTankRotate();
  20. void stats();
  21. void compStats();
  22. void yourShootL();
  23. void compShootL();
  24. void shootG();
  25. void shieldLeft();
  26. void move();
  27. void hitLaser();
  28. void hitGrenade();
  29. void direction();
  30. void tankFace();
  31.  
  32.  
  33.  
  34. int main(int argc, char *argv[])
  35. {
  36.     //yourTank;
  37.     //compTank;
  38.  
  39.     //yourTankY =2;
  40.     //yourTankX = 2;
  41.     //compTankY = 19;
  42.     //compTankX = 19; 
  43.     //int compShield; // HP
  44.     //int compMove; // actions per a turn
  45.     //int compWeapon; // +damage
  46.     //int compRange; // how far weapon can shoot
  47.     //int compTotal = compRange + compShield + compWeapon + compMove; 
  48.     //int yourShield;// HP
  49.     //int yourMove; // actions per a round
  50.     //int yourWeapon; // +damage
  51.     //int yourRange; // how far your weapon shoots
  52.     //int yourTotal = yourRange + yourShield + yourWeapon + yourMove; // total stats cannot acceed 10
  53.     //int yourRemaining = 10 - yourRange + yourShield + yourWeapon + yourMove;
  54.     //int yourFace;
  55.     //char action;
  56.     char arrayGrid[][21]={
  57.                         {201,205,209,205,209,205,209,205,209,205,209,205,209,205,209,205,209,205,209,205,187},
  58.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  59.                         {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
  60.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  61.                         {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
  62.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  63.                         {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
  64.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  65.                         {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
  66.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  67.                         {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
  68.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  69.                         {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
  70.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  71.                         {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
  72.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  73.                         {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
  74.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  75.                         {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
  76.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  77.                         {200,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,188},
  78.                         };
  79.  
  80.  
  81.     title();
  82.     credits();
  83.     cout << endl;
  84.     cout << endl;
  85.     menu(arrayGrid);
  86.  
  87.  
  88.     system("PAUSE");
  89.     return EXIT_SUCCESS;
  90. }
  91. void title()
  92. {
  93.     cout << endl;
  94.     cout << endl;
  95.     cout << endl;
  96.     cout << endl;
  97.     cout <<  "\t\t\t" <<RED << " WELCOME TO M.I.M.E WARS!!!!!!!" << NORMAL << endl;   
  98. }
  99. void credits()
  100. {
  101.     cout << endl;
  102.     cout << endl;
  103.     cout << endl;
  104.     cout << endl;
  105.     cout << "\t\t\tCreated by: Michael Meyer" << endl;
  106.     cout << "\t\t\tWith Help from: Mountain Dew" << endl;
  107. }
  108. int menu(char arrayGrid[][21])
  109. {
  110.     char choice;
  111.  
  112.     do
  113.     {
  114.  
  115.  
  116.     cout << "                                 :[b]ATTLE!:   " <<endl;
  117.     cout << "                                               " <<endl;
  118.     cout << "                                :[S]STORY LINE:" <<endl;
  119.     cout << "                                               " <<endl;
  120.     cout << "                               :[i]NSTRUCTIONS:" <<endl;
  121.     cout << "                                               " <<endl;
  122.     cout << "                              :[E]XIT(chicken!?):    " <<endl;
  123.  
  124.     choice =getch(); // calls for input
  125.     switch(choice)
  126.     {
  127.                    case 'b':
  128.                         {
  129.                             begin();
  130.                         }
  131.                    break;
  132.                    case 's':
  133.                         {
  134.                             intro();
  135.                         }
  136.                    break;
  137.                    case 'i':
  138.                         {
  139.                             instructions();
  140.                         }
  141.                    break;
  142.                    case 'e':
  143.                    break;
  144.     } 
  145.     }
  146.     while(choice != 'e');  
  147.  
  148.     return 0;
  149. }
  150.  
  151. void instructions()
  152. {
  153.     cout << "\t\t\t\t Instructions" << endl << endl << endl;
  154.  
  155.             cout << "Player controls:" << endl;
  156.             cout << "W key: Progress the M.I.M.E forward, towards the way they are facing." << endl;
  157.             cout << "A key: Rotates the M.I.M.E left." << endl;
  158.             cout << "D key: Rotatest the M.I.M.E Counter right." << endl;
  159.             cout << "E key: Chooses to fire the M.I.M.E's Lazer." << endl;
  160.             cout << "Q key: Chooses to lob a M.I.M.E's Grenade." << endl;     
  161.     }
  162. void into()
  163. {
  164.     cout << "\t\t\t\t Introduction" << endl << endl << endl;
  165.             cout << "\tDuring the third World War a new breed of warefare was brought to life. M.I.M.E's were born to be a slave of men.";
  166.            Sleep(4000);
  167.             cout << " M.I.M.E, Mechines In Main Engagement, were a far more advance design of A.I.(Artificial Intelegence).";
  168.             Sleep(4000);
  169.             cout << "There mechines   were designed to lower human casualties, but instead turned and increase the   death toll.";
  170.             cout << endl;
  171.             Sleep(4000);
  172.             cout << "\tWhen the M.I.M.Es turned, it was nothing more then a silent killing of  those around them.";
  173.             Sleep(4000);
  174.             cout << "Man was once again forced back into traditional warfare of    opertaing there own mechines and demise.";
  175.             cout << endl;
  176.             cout << endl;
  177.             cout << endl;
  178.             Sleep(4000);
  179.             cout << "Who will win!?!?.........";
  180.             cout << endl;
  181.             cout << endl;    
  182. }
  183.  
  184. void begin(char arrayGrid[][21])
  185. {
  186.     stats();
  187.     //displayGrid(arrayGrid[][21]);
  188.     cout << endl;
  189.     shieldLeft();
  190.     cout << endl;
  191.     direction();
  192.     cout << endl;
  193.     cout << endl;
  194.     move();
  195. }
  196. void displayGrid(char arrayGrid[][21]) // display the grid + robots
  197. {
  198.     cout << (char)      {201,205,209,205,209,205,209,205,209,205,209,205,209,205,209,205,209,205,209,205,187},
  199.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  200.                         {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
  201.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  202.                         {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
  203.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  204.                         {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
  205.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  206.                         {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
  207.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  208.                         {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
  209.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  210.                         {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
  211.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  212.                         {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
  213.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  214.                         {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
  215.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  216.                         {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
  217.                         {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
  218.                         {200,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,188},
  219.                         }; 
  220. }
  221. void yourTank() // your tank Green
  222. {
  223.  
  224. }
  225.  
  226. /*void yourTankRotate() // Shows you tank rotating N, S, W, E
  227. {
  228.     if(action == a)
  229.         {
  230.             yourFace - 1;
  231.  
  232.         }
  233.     else if(action == d)
  234.         {
  235.             yourFace - 1;
  236.         }
  237.     //yourTankFace(); 
  238. }
  239. */
  240. void compTank() // computer tank Red
  241. {
  242.  
  243. }
  244.  
  245. void compTankRotate() // Shows computer tank rotating N, S, W, E
  246. {
  247.  
  248. }
  249.  
  250. void stats()
  251. {
  252.    int yourShield; // HP
  253.    int yourMove; // actions per a round
  254.    int yourWeapon; // +damage
  255.    int yourRange; // how far your weapon shoots
  256.    int yourTotal = yourRange + yourShield + yourWeapon + yourMove; // total stats cannot acceed 10
  257.    int yourRemaining = 10 - yourRange + yourShield + yourWeapon + yourMove;
  258.  
  259.      cout << "Choose the stats you would like for your M.I.M.E., with a max total of 10." << endl;
  260.  
  261.      while(yourTotal != 10)
  262.      {
  263.          cout << "Choose 1-6 for your range of your weapon(" << yourRemaining << " points left: ";
  264.          cin >> yourRange;
  265.          while((cin == 0) || (yourRange < 0))
  266.                     {
  267.                         cin.clear();
  268.                         cin.ignore(10000, '\n');
  269.                         cout << "Please enter the amount of range: ";
  270.                         cin >> yourRange;
  271.                     }
  272.  
  273.          cout << "Choose 1-6 for your shields(" << yourRemaining << " points left: ";
  274.          cin >> yourShield;
  275.          while((cin == 0) || (yourShield < 0))
  276.                     {
  277.                         cin.clear();
  278.                         cin.ignore(10000, '\n');
  279.                         cout << "Please enter amount for the shield: ";
  280.                         cin >> yourShield;
  281.                     }
  282.  
  283.          cout << "Choose 1-6 for your weapon damage(" << yourRemaining << " points left: ";
  284.          cin >> yourWeapon;
  285.          while((cin == 0) || (yourWeapon < 0))
  286.                     {
  287.                         cin.clear();
  288.                         cin.ignore(10000, '\n');
  289.                         cout << "Please enter the amount for the weapon: ";
  290.                         cin >> yourWeapon;
  291.                     }
  292.  
  293.          cout << "Choose 1-6 for your movement speed(" << yourRemaining << " points left: ";
  294.          cin >> yourMove;
  295.          while((cin == 0) || (yourMove < 0))
  296.                     {
  297.                         cin.clear();
  298.                         cin.ignore(10000, '\n');
  299.                         cout << "Please enter the amount for movement: ";
  300.                         cin >> yourMove;
  301.                     }
  302.     }
  303. }
  304.  
  305. void compStats() // stats MUST be random 1-6 cannot accede 10 total
  306. {
  307.     srand(time(0)); // int random number
  308.     int total = 0;
  309.     int compRange;
  310.     int compShield;
  311.     int compWeapon;
  312.     int compMove;
  313.  
  314.     cout << "The computers stats are as shown: " << endl;
  315.  
  316.     while(total != 10 )
  317.     {
  318.         compRange = (rand() % 6) + 1;
  319.         total = compRange - 10;
  320.         compShield = (rand() % 6) + 1;
  321.         total = (compShield + compRange) - 10;
  322.         compWeapon = (rand() % 6) + 1;
  323.         total =(compShield + compRange + compWeapon) - 10;
  324.         compMove = (rand() % 6) + 1;
  325.         total =(compShield + compRange + compRange + compMove) - 10;
  326.     }
  327.  
  328.     cout << "Range is = " << compRange << endl;
  329.     cout << "Shield is = " << compShield << endl;
  330.     cout << "Weapon is = " << compWeapon << endl;
  331.     cout << "Movement is = " << compMove << endl;
  332. }
  333.  
  334.  
  335. void yourShootL() // direct shot 2 damage
  336. {
  337.     int face;
  338.     int yourTankX;
  339.     int yourRange;
  340.     int weaponX;
  341.     int yourTankY;
  342.     int weaponY;
  343.  
  344.     if( 2 == face || 4 == face)
  345.         {
  346.             weaponX = yourTankX + yourRange;
  347.         }
  348.     else if( 1 == face || 3 == face)
  349.         {
  350.              weaponY = yourTankY + yourRange;
  351.         }
  352.  
  353.  
  354.  
  355.      hitLaser();
  356. }
  357.  
  358. void compShootL() // direct shot 2 damage
  359. {
  360.     int face;
  361.     int compTankY;
  362.     int compTankX;
  363.     int weaponX;
  364.     int weaponY;
  365.     int compRange;
  366.  
  367.     if( 2 == face || 4 == face)
  368.         {
  369.              weaponX = compTankX + compRange;
  370.         }
  371.     else if ( 1 == face || 3 == face)
  372.         {
  373.              weaponY = compTankY + compRange;
  374.         }
  375.  
  376.  
  377.  
  378.      hitLaser();
  379. }
  380.  
  381. void shootG() // Area of affect dmg 3x3 1 dmg
  382. {
  383.     int face;
  384.     int yourTankX;
  385.     int yourRange;
  386.     int weaponX;
  387.     int yourTankY;
  388.     int weaponY;
  389.  
  390.     if( 2 == face || 4 == face)
  391.         {
  392.              weaponX = yourTankX + yourRange;
  393.         }
  394.     else if( 1 == face || 3 == face)
  395.         {
  396.              weaponY = yourTankY + yourRange;
  397.         }
  398.  
  399.     hitGrenade();
  400. }
  401.  
  402. void shieldLeft() // remaining life points
  403. {
  404.      int yourShield;
  405.      int compShield;
  406.  
  407.      cout << "Your shield left is: " << yourShield << endl;
  408.  
  409.      cout << "The computers shield left is: " << compShield << endl;
  410. }
  411.  
  412. void direction() // which direction you are facing to determine which way you can move
  413. {                 // face must remain 1-4
  414.     int yourFace;
  415.  
  416.     if( yourFace == 1)
  417.         {
  418.              cout << "You are facing North" ;
  419.         }
  420.     else if(yourFace == 2)
  421.         {
  422.              cout << "You are facing West";
  423.         }
  424.     else if(yourFace == 3)
  425.         {
  426.             cout << "You are facing South";    
  427.         }
  428.     else if(yourFace == 4)
  429.         {
  430.             cout << "You are facing East";    
  431.         }
  432.     else if( yourFace > 4 || yourFace < 1)
  433.     {
  434.         yourFace = 1;
  435.         cout << "You are facing North"; 
  436.     }
  437. }
  438.  
  439. void yourTankFace()
  440. {
  441.    int yourFace;
  442.  
  443.     if( yourFace == 1)//North
  444.         {
  445.               cout << GREEN << (char)193;
  446.         }
  447.     else if(yourFace == 2)//South
  448.         {
  449.             cout << GREEN << (char)194;
  450.         }
  451.     else if(yourFace == 3)//West
  452.         {
  453.             cout << GREEN << (char)180;    
  454.         }
  455.     else if(yourFace == 4)//East
  456.         {
  457.             cout << GREEN << (char)195;
  458.         }
  459. }
  460.  
  461. void compTankFace()
  462. {
  463.     int face;
  464.  
  465.     if( face = 1)//North
  466.         {
  467.             cout << RED << (char)193;
  468.         }
  469.     else if(face == 2)//South
  470.         {
  471.             cout << RED << (char)194;
  472.         }
  473.     else if(face == 3)//East
  474.         {
  475.             cout << RED << (char)180;
  476.         }
  477.     else if(face == 4)//West
  478.         {
  479.             cout << RED << (char)195;    
  480.         }    
  481. }
  482.  
  483. void move() // Move you forward
  484. {
  485.      int x;
  486.      int y;
  487.      int action;
  488.      int moveX;
  489.      int moveY;
  490.      int yourTankX;
  491.      int yourTankY;
  492.      int face;
  493.  
  494.  
  495.      cout << "Choose an action: 1 - Move Forward, 2 - Rotate Left, 3 - Rotate right, 4 - Fire Laser, 5 - Lob Grenade." << endl;
  496.      cin >> action;
  497.  
  498.      switch(action)
  499.      {
  500.         case 1: // move forward adding 1 to X or Y axis based on direction facing 
  501.             while( x != 0 && x != 21 && y != 0 && y != 21)
  502.             {
  503.                 if( 2== face || 4 == face)
  504.                     {
  505.                          moveX =yourTankX + 2;    
  506.                     }   
  507.                 else if ( 1 == face || 3 == face)
  508.                     {
  509.                          moveY = yourTankY + 2;
  510.                     } 
  511.             }
  512.             break;
  513.  
  514.         case 2: // rotates you to the left subtracting 1 from face
  515.              // yourTankRotate();
  516.               break;
  517.  
  518.         case 3: // rotates you to the right adding 1 to face
  519.               //yourTankRotate();
  520.               break;
  521.  
  522.         case 4: // fires THE LAZER! 
  523.               //shootL();
  524.               break;
  525.  
  526.         case 5:  // Lobs the grenade
  527.              //shootG();
  528.              break;
  529.  
  530.      }
  531. }
  532.  
  533. void hitLaser() // determines if the laser hit
  534. {
  535.     int weaponY;
  536.     int yourTankY;
  537.     int compTankY;
  538.     int weaponX;
  539.     int yourTankX;
  540.     int compTankX;
  541.  
  542.     if (weaponY == yourTankY || weaponY == compTankY)
  543.         {
  544.  
  545.             shieldLeft();
  546.         }
  547.     else if (weaponX == yourTankX || weaponX == compTankX)
  548.             {
  549.  
  550.                 shieldLeft();
  551.             }
  552.  
  553. }
  554.  
  555. void hitGrenade() // determines if the Grenade hits
  556. {
  557.     int weaponY;
  558.     int yourTankY;
  559.     int compTankY;
  560.     int weaponX;
  561.     int yourTankX;
  562.     int compTankX;
  563.  
  564.     if (weaponY + 3 == compTankY)
  565.         {
  566.  
  567.             shieldLeft();
  568.         }
  569.     else if (weaponX + 3 == compTankX)
  570.             {
  571.  
  572.                 shieldLeft();
  573.             }
  574. }
  575.  
Dec 11 '08 #7
CodecSmash49
8 New Member
Anyone able to help?
Dec 12 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

15
4490
by: Michael Rybak | last post by:
hi, everyone. I'm writing a 2-players game that should support network mode. I'm now testing it on 1 PC since I don't have 2. I directly use sockets, and both client and server do computations, the only data transfered is user mouse/kbd input. It works synchronously, but somehow, when I play in client window, both client and server have 17 fps, while when playing in server window, server has 44 fps while client ...
1
1550
by: jim figurski | last post by:
Hi, I have an American computer using windows XP. I recently bought a japanese game to help me learn japanese as I play. I installed the game sucessfully, but the letters are not displayed in "true" japanese. What I mean by that is, there are a few letters that actually are japanese combined with nonsensical characters. It resemebles the type of characters that are displayed if you select a japanese font other than the standard one...
1
1380
by: Ivan Weiss | last post by:
Hey all, I want to try to create a replacement Winamp (hopefully many are familiar with this) with only the features I need stripped down because I like the original software, but lately it has gone far from what I enjoy using) and the old software is no longer available. I want to create basically a simple media player than can play everything from mp3's to cd's to movie files. For now, I just want to start with audio and it is only...
1
1323
by: Darren Soo via .NET 247 | last post by:
Hi, wondering if anyone can help me out here. I wrote a VB.NETapplication with Windows Media Player embedded into theapplication. The player is suppose to start automatically whenthe application loads. I tried it on my computer and everythingworks perfectly. However, when I did a setup wizard project andinstalled it on another computer, the app started, I can hearthe sound of the movie, but there are no visuals. Anyone knowthe reason why? ...
2
4931
by: benmourra | last post by:
Hi all, I'm trying to create a web page using VS2005, ASP.NET 2.0, that will allow me to choose from a list of media files on my computer and then play my selection within an embedded Windows Media Player on the page. I've been able to eventually find out how to embed the player into the page by manually inserting code into the source view of my aspx file. It plays the file specified in the source view, but I'd like to be able to...
0
1185
by: tanv70 | last post by:
Hello, I am considering starting up my own online gaming site to include muti-player bingo, slots, keno, and possibly more. This will need to include player registration and password retrieval, scripts for the games to run smoothly, database for wins/losses, a My account area so players can edit information, e-commerce so I can actually make money from the site eventually, more? I know only basic web design and will need extensive...
0
1840
by: Jeff Rush | last post by:
At PyCon this year we're going to have a multi-day game programming clinic and challenge. This is a first-time event and an experiment to find those in the Python community who enjoy playing and creating games. Python has several powerful modules for the creation of games among which are PyGame and PyOpenGL. On Friday evening, Phil Hassey will give an introduction to his game Galcon, an awesome high-paced multi-player galactic...
0
2668
by: artsohc | last post by:
Hey Everyone, this is my first time posting so go easy on me. I am trying to hook up music-on-hold at the office I work at. I got all the music loaded and I got Windows Media Player working while the phones are on hold, but now I am trying to write a script that will allow Windows Media Player to run as a service so I can make it auto-start with out needing a user logged in on the computer. Also it would allow the music-on-hold to work if we...
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9399
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9833
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7378
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5275
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5421
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.