Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <conio.h>
- #include <cstdlib>
- using namespace std;
- class Snake_Int
- {
- public:
- int x=0, y=0;
- void Moves(int a, int b);
- char Key;
- }Snake;
- void Snake_Int::Moves(int a, int b)
- {
- system("CLS");
- for (int i = 0; i < b; ++i)
- cout << "\n";
- cout << setw(a);
- cout << "0" ;
- }
- int main()
- {
- Snake_Int Snake;
- i:
- Snake.Key = getch();
- switch(Snake.Key)
- {
- case 's':
- {
- Snake.Moves(Snake.x,++Snake.y);
- break;
- }
- case 'w':
- {
- Snake.Moves(Snake.x,--Snake.y);
- break;
- }
- case 'a':
- {
- Snake.Moves(--Snake.x,Snake.y);
- break;
- }
- case 'd':
- {
- Snake.Moves(++Snake.x,Snake.y);
- break;
- }
- }
- goto i;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement