#include<windows.h>
#include<conio.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#define ROJO 12
#define COLOR_DEF 15
#define AMARILLO 14
#define VERDE 10
#define ROSA 13
void gotoxy(int x,int y);
void color(int x);
void terreno(int altura,int ancho);
void estrellas();
//*******************************************
void gotoxy(int x ,int y){COORD coord;
coord.X=x;
coord.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}
//********************************
void color(int x){WORD n;
n=x;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),n);
}
//************************************
void terreno(int altura,int ancho){color(72);
for(int i=0;i<ancho;i++){
gotoxy(i,altura);printf("%c",177); gotoxy(i,altura+1);printf("%c",43); gotoxy(i,altura+2);printf("%c",221); gotoxy(i,altura+3);printf("%c",178);
}
}
//------------titulo
class TITULO{ int x,y;
public:
TITULO(int _X,int _Y):x(_X),y(_Y){}; void letras();
};
void TITULO::letras(){ color(AMARILLO);
gotoxy(x,y); printf(" ##### "); gotoxy(x,y+1);printf("## # ## ## "); gotoxy(x,y+2);printf("## ## ## "); gotoxy(x,y+3);printf("## ###### ###### "); gotoxy(x,y+4);printf("## ## ## "); gotoxy(x,y+5);printf("## # ## ## "); gotoxy(x,y+6);printf(" ##### ");
}
//----------------------------------
class SOL{ int x,y;
public:
SOL(int _X,int _Y):x(_X),y(_Y){}; void letras();
};
void SOL::letras(){ color(AMARILLO);
gotoxy(x,y); printf(" #############"); gotoxy(x,y+1);printf(" ###############"); gotoxy(x,y+2);printf("################"); gotoxy(x,y+3);printf(" ###############"); gotoxy(x,y+4);printf(" ###############"); gotoxy(x,y+5);printf(" ##############"); gotoxy(x,y+6);printf(" ###########"); gotoxy(x,y+7);printf(" #######");
}
//-----------------------------------
class NAVE{int x;
int y;
public:
NAVE(int _x,int _y);
int X(){return x;} int Y(){return y;} void pintar();
void borrar();
void mover();
void explotar();
};
NAVE::NAVE(int _x,int _y){x=_x;
y=_y;
}
void NAVE::pintar(){color(9);
gotoxy(x,y); printf(" ^ ");gotoxy(x,y+1); printf(" *** ");gotoxy(x,y+2); printf("*****");
}
void NAVE::borrar(){
gotoxy(x,y); printf(" ");gotoxy(x,y+1);printf(" ");gotoxy(x,y+2);printf(" ");
}
void NAVE::explotar(){
borrar();
gotoxy(x, y); printf(" ** "); gotoxy(x, y + 1); printf(" **** "); gotoxy(x, y + 2); printf(" ** "); Sleep(20);
borrar();
Sleep(25);
gotoxy(x, y); printf(" * ** *"); gotoxy(x, y + 1); printf(" **** "); gotoxy(x, y + 2); printf(" * ** *"); Sleep(200);
borrar();
system("cls");
}
void NAVE::mover(){for(int i=0;i<5 && y>2;i++,y--){
pintar();
Sleep(25);
borrar();
}
if(y==2){ explotar();
}else{pintar();
}
}
//************************************
void estrellas(){color(ROJO);
gotoxy(15,15);printf("%c",15);color(AMARILLO);
gotoxy(10,1);printf("%c",15);color(VERDE);
gotoxy(20,5);printf("%c",15);color(ROJO);
gotoxy(19,16);printf("%c",15);color(VERDE);
gotoxy(15,2);printf("%c",15);color(AMARILLO);
gotoxy(10,5);printf("%c",15);color(VERDE);
gotoxy(20,5);printf("%c",15);color(ROJO);
gotoxy(19,20);printf("%c",15);color(ROJO);
gotoxy(15,15);printf("%c",15);color(AMARILLO);
gotoxy(10,4);printf("%c",15);color(VERDE);
gotoxy(3,9);printf("%c",15);color(ROJO);
gotoxy(19,25);printf("%c",15);color(VERDE);
gotoxy(16,2);printf("%c",15);color(AMARILLO);
gotoxy(10,5);printf("%c",15);color(VERDE);
gotoxy(28,6);printf("%c",15);color(ROJO);
gotoxy(30,10);printf("%c",15);color(ROJO);
gotoxy(30,15);printf("%c",15);color(AMARILLO);
gotoxy(29,1);printf("%c",15);color(VERDE);
gotoxy(20,25);printf("%c",15);color(ROJO);
gotoxy(34,18);printf("%c",15);color(VERDE);
gotoxy(15,30);printf("%c",15);color(AMARILLO);
gotoxy(37,25);printf("%c",15);color(VERDE);
gotoxy(40,25);printf("%c",15);color(ROJO);
gotoxy(39,20);printf("%c",15);
}
//**************************************
int main()
{ system("MODE CON: COLS=51 LINES=50"); NAVE nave1(5,40);
TITULO title(15,10);
SOL sole(35,0);
sole.letras();
terreno(46,50);
estrellas();
int y=0;
while(1){
nave1.mover();
y=nave1.Y();
if(y==2){ system("CLS"); title.letras();
break;
}
Sleep(100);
}
getch();
}
Comentarios sobre la versión: 0.1 (0)
No hay comentarios