Gotoxy concept with example program
#include<iostream>
#include<conio.h>
#include<windows.h>
using namespace std;
void gotoxy (short x , short y){
COORD pos = {x , y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE) , pos);}
int wall(){
int xpos,ypos; //making wall...
for(xpos=1;xpos<=78;xpos++){
gotoxy(xpos,3);cout<<"#";
gotoxy(xpos,23);cout<<"#";
}
for(ypos=3;ypos<=23;ypos++){
gotoxy(1,ypos);cout<<"#";
gotoxy(78,ypos);cout<<"#";
}
return 0;
}
int main(){
wall();
for(int i=3;i<50;i++){
Sleep(300);
system("cls");
gotoxy(20,2);cout<<"S:0";
wall();
gotoxy(i,5);cout<<"===@";
}
return 0;
}
0 comments:
Post a Comment