Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream.h>
- #include <conio.h>
- #include <windows.h>
- void gotoxy(int x, int y);
- void lftrght(char ch, int colStart, int row, int colFinish);
- void rghtlft(char ch, int colStart, int row, int colFinish);
- void topbot(char ch, int colStart, int row, int colFinish);
- void bottop(char ch, int colStart, int row, int colFinish);
- int main()
- {
- int left = 0;
- int right = 78;
- int bot= 12;
- int up= 12;
- for ( int snake=0; snake<39;snake++)
- {
- int left1=left-1;
- int right1= right+1;
- int bot1= bot-1;
- int up1= up-1;
- int col=left;
- gotoxy(col,up);
- cout<<">";
- Sleep(10);
- //bot
- col= right;
- gotoxy(col,bot);
- cout<<"<";
- Sleep(10);
- right--;
- left ++;
- col=left1;
- gotoxy(col,up);
- cout<<"*";
- Sleep(10);
- //bot
- col= right1;
- gotoxy(col,bot);
- cout<<"*";
- Sleep(10);
- }
- left = 0;
- right = 79;
- bot= 12;
- up= 12;
- int col=0;
- for ( int snake=0; snake<39;snake++)
- {
- col=left;
- gotoxy(col,up);
- cout<<" ";
- Sleep(10);
- //bot
- col= right;
- gotoxy(col,bot);
- cout<<" ";
- Sleep(10);
- right--;
- left ++;
- }
- gotoxy(right,bot);
- cout<<" ";
- Sleep(10);
- right--;
- gotoxy(right,bot);
- cout<<" ";
- Sleep(10);
- getch();
- for ( int bob=0; bob<30; bob++)
- {
- int top=10;
- int bottom=12;
- int left=38;
- int right= 42;
- for (int lol=0; lol<6;lol++)
- {
- //top border left to right
- lftrght('*', left,top,right);
- // border down the right side
- topbot('*', top,right,bottom);
- //bottom right to lrft
- rghtlft('*',right,bottom,left);
- // up the left side
- bottop('*', bottom,left,top);
- Sleep(100);
- top--;
- left--;
- right++;
- bottom++;
- top--;
- left--;
- right++;
- bottom ++;
- }
- for (int lol=0; lol<7;lol++)
- {
- //top border left to right
- lftrght(' ', left,top,right);
- // border down the right side
- topbot(' ', top,right,bottom);
- //bottom right to lrft
- rghtlft(' ',right,bottom,left);
- // up the left side
- bottop(' ', bottom,left,top);
- Sleep(100);
- top++;
- left++;
- right--;
- bottom--;
- top++;
- left++;
- right--;
- bottom --;
- }
- }
- getch();
- return 0;
- }
- void lftrght(char ch, int colStart, int row, int colFinish)
- {
- //top border left to right
- for (int col=colStart; col < colFinish;col++)
- {
- gotoxy(col,row);
- cout<<ch;
- }
- }
- void rghtlft(char ch, int colStart, int row, int colFinish)
- {
- //top border left to right
- for (int col=colStart; col >colFinish;col--)
- {
- gotoxy(col,row);
- cout<<ch;
- }
- }
- void topbot(char ch, int colStart, int row, int colFinish)
- {
- //top border left to right
- for (int col=colStart; col <colFinish;col++)
- {
- gotoxy(row,col);
- cout<<ch;
- }
- }
- void bottop(char ch, int colStart, int row, int colFinish)
- {
- //top border left to right
- for (int col=colStart; col>colFinish;col--)
- {
- gotoxy(row,col);
- cout<<ch;
- }
- }
- void gotoxy(int x, int y)
- {
- COORD coord;
- coord.X = x;
- coord.Y = y;
- SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement