The basic Concept of Gotoxy
#include<iostream>
#include<stdio.h>
#include<windows.h>
#include<conio.h>
using namespace std;
int key_press();
int food();
int wall();
void AltEnter();
int reset();
void gotoxy(int,int);
HANDLE hStdout;
void gotoxy (short x , short y){
COORD pos = {x , y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE) , pos);}
int main()
{
int x[100],y[100],i,length=10,score=0,j,k,z=999;
wall();
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
//AltEnter(); //for full screen
gotoxy(20,20); printf("Press a key to continue....");
getch();
system("cls");
wall(); //to make bo
// int x=35, y=15;
wall(); //to make boundary..
for(i=length;i>=0;i--){ //snake position
x[i]=45-i;
y[i]=20;}
// char dash;
// do{
wall();
for(int i=length-1;i>=0;i--){ //for making snake structure..
gotoxy(x[i],y[i]);
printf("*"); }
gotoxy(x[0],y[0]);printf("#");
gotoxy(x[length-1],y[length-1]); printf(" ");
wall();
// dash=getch();
// if(dash=='a') x--;
// if(dash=='d') x++;
// if(dash=='s') y--;
// if(dash=='f') y++;
// system("cls");
// }
// }while(1);
return 0;
}
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;
}
0 comments:
Post a Comment