Advertisement
Guest User

Untitled

a guest
Oct 9th, 2015
112
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 <iomanip>
  3. #include <conio.h>
  4. #include <cstdlib>
  5.  
  6. using namespace std;
  7.  
  8. class Snake_Int
  9. {
  10.     public:
  11.     int x=0, y=0;
  12.     void Moves(int a, int b);
  13.     char Key;
  14.  
  15.  
  16. }Snake;
  17. void Snake_Int::Moves(int a, int b)
  18. {
  19.  
  20.    
  21.     system("CLS");
  22.  
  23.     for (int i = 0; i < b; ++i)
  24.         cout << "\n";
  25.  
  26.     cout << setw(a);
  27.     cout << "0" ;
  28.  
  29. }
  30.  
  31. int main()
  32. {
  33.     Snake_Int Snake;
  34.  
  35.     i:
  36.     Snake.Key = getch();
  37.  
  38.     switch(Snake.Key)
  39.     {
  40.         case 's':
  41.         {
  42.             Snake.Moves(Snake.x,++Snake.y);
  43.             break;
  44.         }
  45.         case 'w':
  46.         {
  47.             Snake.Moves(Snake.x,--Snake.y);
  48.             break;
  49.         }
  50.         case 'a':
  51.         {
  52.             Snake.Moves(--Snake.x,Snake.y);
  53.             break;
  54.         }
  55.         case 'd':
  56.         {
  57.             Snake.Moves(++Snake.x,Snake.y);
  58.             break;
  59.         }
  60.     }
  61.     goto i;
  62.     return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement