aqui les dejo el codigo. y pues nose si me explique bien.
Código:
//---------------------------------Librerias------------------------------------ #include <stdlib.h> #include <stdio.h> #include <conio.h> #include <ctype.h> #include <stdarg.h> #include <time.h> #include <dos.h> #include <string.h> #include <clx.h> //------------------------Codigo ASCII para el mapa----------------------------- #define MAXBUFF 256 #define M1 186 #define M2 187 #define M3 188 #define M4 201 #define M5 200 #define M7 178 #define M6 205 //------------------------------------------------------------------------------ struct arma { int fa, ca, fb, cb; }; //------------------------------Prototipos-------------------------------------- imprimir(int map[26][28], int i, int j); int menu(); void armas(int map[25][28],arma A); //---------------------------------Main----------------------------------------- void main () { int i, j, op, tecla; int map[25][28]={ {5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,6}, {3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3}, {3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3}, {3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3}, {3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3}, {3,0,0,0,0,0,0,0,0,0,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3}, {3,0,0,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2}, {3,0,0,0,0,0,0,0,0,0,2,0,2,2,2,2,2,2,2,2,0,0,0,0,2,0,0,3}, {3,0,0,2,2,2,0,0,0,0,2,0,0,0,0,0,0,0,0,2,0,0,0,0,2,0,0,3}, {3,0,0,2,0,2,0,0,0,0,2,2,2,2,2,2,2,0,0,2,0,0,0,0,2,0,0,3}, {3,0,0,2,0,2,0,0,0,0,0,0,0,0,0,0,2,0,0,2,0,0,0,0,2,0,0,3}, {3,0,0,2,0,2,2,2,2,2,0,0,0,0,0,0,2,0,0,2,0,0,0,0,2,0,0,3}, {2,2,2,2,0,0,0,0,0,2,0,0,0,0,0,0,2,0,0,2,0,2,2,2,2,0,0,3}, {3,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,2,0,0,2,0,2,0,0,0,0,0,3}, {3,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,2,0,0,2,0,2,0,0,0,0,0,3}, {3,0,0,0,0,0,0,0,0,2,0,2,2,2,2,2,2,0,0,2,0,2,0,0,0,0,0,3}, {3,0,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,3}, {3,0,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,3}, {3,0,0,0,0,0,0,0,0,2,2,2,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,3}, {3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,3}, {3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,3}, {3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,0,0,0,3}, {3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3}, {3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3}, {7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,4} }; op=menu(); while(op!=4){ switch (op){ case 1:clrscr(); arma A; armas(map, A); getch(); break; case 2:clrscr(); printf(" Pequeña version del juego Tower Defense,\n juego el cual consiste evitar que las unidades enemigas cruzen el mapa,\n esto lo haras con la ayuda de dos tipos de armas:\n el + que te dispara a todos lados y el L que te dispara a la izquierda y arriba"); getch(); break; case 3:getch(); break; } tecla = 0; tecla = getch(); if(tecla == 27){ op=menu(); } } getch(); } //--------------------------------Funciones------------------------------------- imprimir(int map[26][28], int i, int j) { for(i=0;i<25;i++) { printf("\n"); for(j=0;j<28;j++) { textcolor(GREEN); if(map[i][j]==0) cprintf("%c", M7); textcolor(YELLOW); if(map[i][j]==1) cprintf("%c",M6); if(map[i][j]==2) cprintf(" "); if(map[i][j]==3) cprintf("%c",M1); if(map[i][j]==4) cprintf("%c",M3); if(map[i][j]==5) cprintf("%c",M4); if(map[i][j]==6) cprintf("%c",M2); if(map[i][j]==7) cprintf("%c",M5); if(map[i][j]==8) printf("+"); if(map[i][j]==9) printf("L"); } } return 0; } int menu(){ int op; clrscr(); printf("\t\t*** Tower Defense ***\n\n"); printf("\t\t*** MENU ***\n\n"); printf("\t\t1. Nuevo Juego\n"); printf("\t\t2. Ayuda\n"); printf("\t\t3. Salir\n"); do{ scanf("%d",&op); }while(op!=1 && op!=2 && op!=3); return op; }//menu void armas(int map[25][28],arma A) { int tecla, x, band, i, j; char r; tecla = 0; A.fa=2; A.ca=2; map[A.fa][A.ca]=8; imprimir(map,i,j); int w=0; for(w=0;w<3;w++) { printf("Desea poner otra arma"); r=tolower(getch()); fflush(stdin); scanf("%c",&r); if(r == 's'); while(!kbhit() || tecla==0){//investigar funcion kbhit band=0; //me indica si hubo un cambio tecla=getch(); tecla=getch(); if(tecla==32){ w++; break; } if(tecla==72 && A.fa>0 && map[A.fa-1][A.ca]!=2){ //sube map[A.fa][A.ca]=0; A.fa--; band=1; }//if if(tecla==80 && A.fa<28 && map[A.fa+1][A.ca]!=2){ //baja map[A.fa][A.ca]=0; A.fa++; band=1; }//if if(tecla==77 && A.ca<28 && map[A.fa][A.ca+1]!=2){ //derecha map[A.fa][A.ca]=0; A.ca++; band=1; }//if if(tecla==75 && A.ca>0 && map[A.fa][A.ca-1]!=2){ //izquierda map[A.fa][A.ca]=0; A.ca--; band=1; }//if if(map[A.fa][A.ca]==0) map[A.fa][A.ca]=8; if(band){ //-- Imprime el campo de juego clrscr(); imprimir(map,i,j); //---- fin de impresion del tablero }//if band tecla=0; }//while kbhit } }