Advertisement
Guest User

Help with c++

a guest
Aug 15th, 2012
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <stdio.h>
  4. #include <windows.h>
  5.  
  6. using namespace std;
  7.  
  8. /*
  9. This is the map.
  10.  
  11. X = 4
  12. Y = 3
  13.  
  14. @XXX
  15. XXXX
  16. XXXX
  17.  
  18. */
  19.  
  20. int mainLoop()
  21. {
  22.     int y = 0; // PLayer Y
  23.     int x = 0; //Player X
  24.     int xMax = 3;
  25.     int yMax = 2;
  26.     int xMin = 0;
  27.     int yMin = 0;
  28.  
  29.     string dir;
  30.     string name; // Used later
  31.  
  32.     bool endGame = false;
  33.  
  34.     while(endGame == false)
  35.     {
  36.         cout << x << y << endl;
  37.         printf("\nEnter a L or R for Left and Right: ");
  38.         cin >> dir;
  39.  
  40.         if(dir == "L" && x >= xMin && x <= xMax)
  41.         {
  42.             printf("You Went Left");
  43.             x--;
  44.         }
  45.         else if(dir == "R" && x <= 3 && x >= 0)
  46.         {
  47.             printf("You Went Right");
  48.             x++;
  49.         }
  50.         else
  51.         {
  52.             printf("You can't go that way.");
  53.         }
  54.     }
  55.  
  56.  
  57. }
  58.  
  59. int main()
  60. {
  61.  
  62.     mainLoop();
  63.  
  64.     return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement