Essays.club - Ensayos gratis, notas de cursos, notas de libros, tareas, monografías y trabajos de investigación
Buscar

Juego en c++ creado por mi

Enviado por   •  15 de Noviembre de 2017  •  1.466 Palabras (6 Páginas)  •  440 Visitas

Página 1 de 6

...

gotoxy(x,y+6);printf(" %c%c%c%c%c",31,254,254,254,31);

}

void personage::borrar(){

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(" ");

}

void personage::controlar(){

if (kbhit()){

borrar();

tecla = getch() ;

if (tecla == ARRIBA and y >3)y--;

if (tecla == DERECHA && x <42 )x++;

if (tecla == ABAJO && y <43)y++;

if (tecla == IZQUIERDA && x >16)x--;

dibujar();

}

}

void personage::vidas(){

gotoxy(50,1);cout<<"vidas "<<v;

}

class enemigo{

public:

int x1,y1 ;

enemigo ( int _xe,int _ye): x1 (_xe),y1(_ye){}

void poner();

void mover();

void explocion(class personage &n);

};

void enemigo::poner(){

gotoxy(x1,y1);printf("%c",31);

}

void enemigo::mover(){

gotoxy(x1,y1);

printf(" ");

y1++;

if(y1 > 48){

x1 = rand()%30 + 18 ;

y1 = 4;

}

poner();

}

void enemigo::explocion(class personage &n){

if (x1 == n.x and y1 == n.y or x1 == n.x+1 and y1 == n.y or x1 == n.x+2 and y1 == n.y or x1 == n.x+3 and y1 == n.y or x1 == n.x+4 and y1 == n.y or x1 == n.x+5 and y1 == n.y or x1 == n.x+6 and y1 == n.y){

x1 = rand()%11+5 ;

y1 = 2;

v = v - 1;

}

else if(v == 0){

fin=true;

gotoxy(26,10);

}

}

int main (){

cout<<" Car Game "<<endl;

cout<<"Press ’si’ to play"<<endl;

cin>> aaa;

do{

system ("color 2E");

personage n(30,40);

n.dibujar();

enemigo e1(19,3);

while(!fin)

{

tiempo();

n.vidas();

e1.mover();e1.explocion(n);

n.controlar();

n.controlar();

n.controlar();

n.controlar();

...

Descargar como  txt (6.1 Kb)   pdf (71.6 Kb)   docx (13.3 Kb)  
Leer 5 páginas más »
Disponible sólo en Essays.club