Quantcast
Channel: Comunidad Underground Hispana
Viewing all articles
Browse latest Browse all 11602

[Game++] Juegos Clásicos: Space Invaders

$
0
0


Taito era una pequeña compañía japonesa fundada en 1953 que había evolucionado desde el mercado de las máquinas de vending, a la creación de máquinas arcade, primero con clones de pong, y posteriormente con máquinas propias. Toshihiro Nishikado era uno de sus programadores, y para uno de sus diseños se le ocurrió la idea de un soldado parapetado tras unas trincheras, que disparara a filas de enemigos acercándose hacia él. Pero la compañía pensó que era demasiado violento, y que podía acarrear problemas, así que se decidió cambiar a los humanos por alienígeninas y naves espaciales.

De ese modo fue como nació Space Invaders en 1978, la recreativa que dio a conocer los videojuegos al mundo. Parapetado tras los escudos cósmicos, el jugador debe vencer a 4 filas de aliens que cada vez se aproximan a él más y más rápido. Pero su principal innovación estuvo en algo que durante años sería el leit-motiv de los videojuegos : el Hi-Score. Se abría la puerta al instinto de superación, a la partida perfecta, a batir el record que parece inabarcable, y al orgullo de colocar nuestra puntuación máxima en la memoria de la máquina.

También es destacable que hasta entonces el jugador jugaba por tiempo, mientras que Space Invaders otorgaba 3 vidas, por lo que los jugadores más hábiles podían pasar mucho más tiempo jugando.

Space Invaders fue un éxito absoluto, llegando a provocar que el gobierno nipón cuadriplicara la producción de monedas de yen, por la escasez que el juego estaba provocando.

Pero el juego no fue solo un éxito en Japón, sino que licenciado por Midway llegó a América con idénticos resultados : el videojuego salió de los bares y salones recreativos y dio el salto a las cafeterías, pizzerias y negocios varios : todo el mundo quería tener una máquina de Space Invaders.

Según Taito, Space Invaders ha facturado más de 500 millones de dólares a lo largo de su historia, dejando tras de si un reguero de historias más o menos verídicas : la chica que robó 5000$ a sus padres para gastarlos en la recreativa, el record de Eric Furrer, quien con 12 años jugó 38 horas y media seguidas logrando 1.114.000 puntos, o el juicio que iniciaron los habitantes de Mesquite (Texas) ante el tribunal supremo para solicitar la prohibición del juego en su población, por considerarlo nocivo para las mentes de los jóvenes.

Descripción

Space Invaders es un matamarciano clásico en dos dimensiones. El jugador controla un cañón que puede moverse a la derecha o izquierda y un botón de disparo. Tiene que ir destruyendo los extraterrestres invasores (de los cuales hay tres tipos: con forma de calamar, de cangrejo y de pulpo) que van acercándose a la tierra cada vez más rápidamente a medida que el jugador va destruyendo a los enemigos. Este ciclo se puede repetir en forma indefinida. Si los invasores llegan al cañón controlado por el jugador, el juego termina.

Cada cierto tiempo aparece en la pantalla, por encima de los invasores, un platillo volador que se mueve aleatoriamente de derecha a izquierda o de izquierda a derecha y que no agrega una puntuación definida, sino puntos extras en cantidades aleatorias. Además se tienen cuatros escudos de protección terrestre (más parecidos a búnkeres) que cubren al jugador del fuego alienígena, pero que son destruidos gradualmente por los disparos de los invasores y el cañón del jugador.

Codigo Fuente

Codigo en C con ASCII

Código:

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <windows.h>

int main()
{
    int sizey = 23;
    int sizex = 40;
    int x, y, yi;
    char world[sizey][sizex];
    char player = 'A';
    char playerLaser = '^';
    char enemy = 'M';
    char enemyShielded = 'O';
    char enemyLaser = 'U';
    char explosion = 'X';
    int score = 0;
    int victory = 1;
    int laserReady = 1;
    int enemyReady = 0;

    srand(time(NULL));

    /*welcome screen*/
    printf("\n \n    Welcome soldier! \n \n \n \n");
    Sleep(1000);
    printf("  Brave the COMMAND PROMPT INVADERS and come back a hero. \n \n \n \n");
    Sleep(2500);
    printf("  Your operating system is depending upon you. \n \n \n \n");
    Sleep(2500);
    printf("              Good luck.");
    Sleep(1000);
    printf("\n \n \n \n Press any key to start.");
    getch();

    /*initialise world*/
    int totalEnemies = 0;
    for (x = 0; x < sizex; x ++) {
        for (y = 0; y < sizey; y ++) {
            if ((y+1) % 2 == 0 && y < 7 && x > 4
            && x < sizex - 5 && x % 2 ==0) {
                world[y][x] = enemy;
                totalEnemies ++;
            }
            else if ((y+1) % 2 == 0 && y >= 7 && y < 9 && x > 4
            && x < sizex - 5 && x % 2 ==0){
                world[y][x] = enemyShielded;
                totalEnemies = totalEnemies + 2;
            }
            else {
                world[y][x] = ' ';
            }
        }
    }
    world[sizey - 1][sizex / 2] = player;
    int i = 1;
    char direction = 'l';
    char keyPress;
    int currentEnemies = totalEnemies;
    while(currentEnemies > 0 && victory) {
        int drop = 0;
        int enemySpeed = 1 + 10 * currentEnemies / totalEnemies;
        laserReady ++;

        /*display world*/
        system("cls");
        printf("    SCORE:    %d", score);
        printf("\n");
            for (y = 0; y < sizey; y ++) {
            printf("|");
                for (x = 0; x < sizex; x ++) {
                    printf("%c",world[y][x]);
                }
            printf("|");
            printf("\n");
            }

        /*laser time*/
        for (x = 0; x < sizex; x ++) {
            for (y = sizey-1; y >= 0; y --) {
                if (i%2 == 0 && world[y][x] == enemyLaser
                && (world[y+1][x] != enemy & world[y+1][x] != enemyShielded)){
                world[y+1][x] = enemyLaser;
                world[y][x] = ' ';
                }
                else if (i%2 == 0 && world[y][x] == enemyLaser
                && (world[y+1][x] == enemy | world[y+1][x] == enemyShielded)){
                    world[y][x] = ' ';
                }
            }
        }
        for (x = 0; x < sizex; x ++) {
            for (y = 0; y < sizey; y ++) {
                if ((i % 5) == 0 && (world[y][x] == enemyShielded
                | world[y][x] == enemy) && (rand() % 15) > 13
                && world[y+1][x] != playerLaser) {
                    for (yi = y+1; yi < sizey; yi ++) {
                        if (world[yi][x] == enemy
                        | world[yi][x] == enemyShielded) {
                            enemyReady = 0;
                            break;
                        }
                        enemyReady = 1;
                    }
                    if (enemyReady) {
                        world[y+1][x] = enemyLaser;
                    }
                }
                if (world[y][x] == playerLaser && world[y-1][x] == enemy) {
                    world[y][x] = ' ';
                    world[y-1][x] = explosion;
                    currentEnemies --;
                    score = score + 50;
                }
                else if (world[y][x] == playerLaser
                && world[y-1][x] == enemyShielded) {
                    world[y][x] = ' ';
                    world[y-1][x] = enemy;
                    currentEnemies --;
                    score = score + 50;
                }
                else if (world[y][x] == playerLaser
                && world[y-1][x] == enemyLaser) {
                    world[y][x] = ' ';
                }
                else if (world[y][x] == explosion) {
                    world[y][x] = ' ';
                }
                else if ((i+1) % 2 == 0 && world[y][x] == enemyLaser
                && world[y+1][x] == player) {
                    world[y+1][x] = explosion;
                    world[y][x] = ' ';
                    victory = 0;
                }
                else if (world[y][x] == playerLaser
                && world[y-1][x] != enemyLaser) {
                        world[y][x] = ' ';
                        world[y-1][x] = playerLaser;
                }
            }
        }

        /*update enemy direction*/
        for (y = 0; y < sizey; y ++) {
            if (world[y][0] == enemy) {
                direction = 'r';
                drop = 1;
                break;
            }
            if (world[y][sizex-1] == enemy){
                direction = 'l';
                drop = 1;
                break;
            }
        }

        /*update board*/
        if (i % enemySpeed == 0) {
            if (direction == 'l') {
                for (x = 0; x < sizex - 1; x ++) {
                    for (y = 0; y < sizey; y ++) {
                        if (drop && (world[y-1][x+1] == enemy
                            || world[y-1][x+1] == enemyShielded)){
                            world[y][x] = world[y-1][x+1];
                            world[y-1][x+1] = ' ';
                        }
                        else if (!drop && (world[y][x+1] == enemy
                            || world[y][x+1] == enemyShielded)) {
                            world[y][x] = world[y][x+1];
                            world[y][x+1] = ' ';
                        }
                    }
                }
            }
            else {
                for (x = sizex; x > 0; x --) {
                    for (y = 0; y < sizey; y ++) {
                        if (drop && (world[y-1][x-1] == enemy
                            || world[y-1][x-1] == enemyShielded)) {
                            world[y][x] = world[y-1][x-1];
                            world[y-1][x-1] = ' ';
                        }
                        else if (!drop && (world[y][x-1] == enemy
                            || world[y][x-1] == enemyShielded)) {
                            world[y][x] = world[y][x-1];
                            world[y][x-1] = ' ';
                        }
                    }
                }
            }
            for (x = 0; x < sizex; x ++) {
                if (world[sizey - 1][x] == enemy) {
                    victory = 0;
                }
            }
        }

        /*control player*/
        if(kbhit()){
            keyPress = getch();
        }
        else {
            keyPress = ' ';
        }
        if (keyPress == 'a') {
            for (x = 0; x < sizex; x = x+1) {
                if ( world[sizey-1][x+1] == player) {
                    world[sizey-1][x] = player;
                    world[sizey-1][x+1] = ' ';
                }
            }
        }

        if (keyPress == 'd') {
            for (x = sizex - 1; x > 0; x = x-1) {
                if ( world[sizey-1][x-1] == player) {
                    world[sizey-1][x] = player;
                    world[sizey-1][x-1] = ' ';
                }
            }
        }
        if (keyPress == 'm' && laserReady > 2) {
            for (x = 0; x < sizex; x = x+1) {
                if ( world[sizey-1][x] == player) {
                    world[sizey - 2][x] = playerLaser;
                    laserReady = 0;
                }
            }
        }
        i ++;
        Sleep(50);
    }
    system("cls");
        printf("    SCORE:    %d", score);
        printf("\n");
            for (y = 0; y < sizey; y ++) {
            printf("|");
                for (x = 0; x < sizex; x ++) {
                    printf("%c",world[y][x]);
                }
            printf("|");
            printf("\n");
            }
    Sleep(1000);
    system("cls");
    if (victory != 0) {
        printf("\n \n \n \n \n \n              CONGRATULATIONS! \n \n \n \n \n");
        Sleep(1000);
        printf("\n \n              Score: %d", score);
        Sleep(1000);
        int bonus = totalEnemies*20 - i;
        printf("\n \n              Bonus: %d", bonus);
        Sleep(1000);
        printf("\n \n              Total Score: %d", score + bonus);
        printf("\n \n \n \n              Well done");
        Sleep(1000);
        printf(", Hero.");
        Sleep(1000);
        getch();
    }
    else {
        printf("\n \n \n \n \n \n              You have failed.");
        Sleep(1000);
        printf("\n \n \n \n \n \n              Windows is doomed.");
        Sleep(1000);
        printf("\n \n              Final Score: %d", score);
        getch();
    }
}

Codigo en C con SDL

Código:

//known bugs
//some times the bullet wont go past through a base if it hits on the far left edge. cause unknowen
//its the same bug that i found in my invaders drawing code. using the objects own hitbox as the SDL_Rect
//as the destination rectangle to blit to. using a seperate local rect in the drawing code solves it.
#include <stdlib.h>
#include <stdio.h>
#include "SDL/SDL.h"

#define SCREEN_WIDTH 800
#define SCREEN_HEIGHT 600
#define E_WIDTH 30
#define WIDTH 600
#define HEIGHT 600
#define E_WIDTH 30
#define E_HEIGHT 30
#define P_WIDTH 30
#define P_HEIGHT 10
#define B_WIDTH 5
#define B_HEIGHT 15
#define P_BULLETS 1
#define E_BULLETS 3
#define BASE 4
#define BASE_WIDTH 60
#define BASE_HEIGHT 40

/*TODO
* Comment the hell out of this.
*/

enum colour_t {red, green, purple};
enum direction_t {left, right, stationary};
enum state_t {menu, options, game, game_over, pause};
enum ck_t {magenta, lime};

struct score_t {

        unsigned int shots;
        unsigned int points;
        unsigned int level;
};

struct saucer_t {
       
        SDL_Rect hitbox;
        unsigned int alive;
        enum direction_t direction;
};

struct enemy_t {

        SDL_Rect hitbox;
        enum colour_t colour;
        unsigned int alive;
        unsigned int points;
};

struct invaders_t {

        struct enemy_t enemy[5][10];
        enum direction_t direction;
        unsigned int killed;
        int speed;
        int state;
        int state_speed;
        Uint32 state_time;
};

struct base_t {

        SDL_Rect hitbox;
};

struct player_t {

        SDL_Rect hitbox;
        int lives;
};

struct bullet_t {
       
        SDL_Rect hitbox;
        unsigned int alive;
};

//global variables, for convenience.
static SDL_Surface *screen;
static SDL_Surface *title_screen;
static SDL_Surface *cmap;
static SDL_Surface *invadersmap;
static SDL_Surface *player_img;
static SDL_Surface *saucer_img;
static SDL_Surface *base_img[4];
static SDL_Surface *damage_img;
static SDL_Surface *damage_top_img;
static SDL_Surface *game_over_img;
struct score_t score;
struct invaders_t invaders;
struct saucer_t saucer;
struct base_t base[BASE];
struct player_t player;
struct bullet_t bullets[P_BULLETS];
struct bullet_t e_bullets[E_BULLETS];
unsigned int pause_len;
Uint32 pause_time;
enum state_t state;
Uint32 title_time;

void draw_string(char s[], int x, int y);
void pause_for(unsigned int len);

int load_image(char filename[], SDL_Surface **surface, enum ck_t colour_key);

//Initialize the score structure and game state
void init_score() {

        score.shots = 0;
        score.points = 0;
        score.level = 1;
}

//Initialize the enemies starting positions, direction, speed and colour
void init_invaders() {
       
        invaders.direction = right;
        invaders.speed = 1;
        invaders.state = 0;
        invaders.killed = 0;
        invaders.state_speed = 1000;
        invaders.state_time = SDL_GetTicks();

        int i,j;
        int x = 0;
        int y = 30;
       
        for (i = 0; i < 5; i++) {
       
                for (j = 0; j < 10; j++) {
               
                        invaders.enemy[i][j].alive = 1;
                        invaders.enemy[i][j].hitbox.x = x;
                        invaders.enemy[i][j].hitbox.y = y;
                        invaders.enemy[i][j].hitbox.w = E_WIDTH;
                        invaders.enemy[i][j].hitbox.h = E_HEIGHT;
                       
                        x += E_WIDTH + 15; // gap size
                       
                        if (i == 0) {
                               
                                invaders.enemy[i][j].colour = purple;
                                invaders.enemy[i][j].points = 30;
       
                        } else if (i >= 1 && i < 3) {
                       
                                invaders.enemy[i][j].colour = green;
                                invaders.enemy[i][j].points = 20;
               
                        } else {
               
                                invaders.enemy[i][j].colour = red;
                                invaders.enemy[i][j].points = 10;
                        }
                }
               
                x = 0; //reset line
                y += E_HEIGHT + 15;
        }
}

//Initialize the player starting position and dimensions
void init_player() {

        player.hitbox.x = (WIDTH / 2) - (P_WIDTH / 2);
        player.hitbox.y = HEIGHT - (P_HEIGHT + 10);
        player.hitbox.w = P_WIDTH;
        player.hitbox.h = P_HEIGHT;
        player.lives = 3;
}

//Initialize the bases starting position and dimensions
void init_bases() {

        int i;
        int base_total = BASE_WIDTH * 4;
        int space_left = WIDTH - base_total;
        int even_space = space_left / 5; // 5 gaps
        int x = even_space;
        int y = 500;

        for (i = 0; i < BASE; i++) {
               
                base[i].hitbox.x = x;
                base[i].hitbox.y = y;
                base[i].hitbox.w = BASE_WIDTH;
                base[i].hitbox.h = BASE_HEIGHT;
               
                x += BASE_WIDTH + even_space; //distance apart
        }

        load_image("base.bmp", &base_img[0], magenta);
        load_image("base.bmp", &base_img[1], magenta);
        load_image("base.bmp", &base_img[2], magenta);
        load_image("base.bmp", &base_img[3], magenta);
}

//Initialize the player bullets dimensions
void init_bullets(struct bullet_t b[], int max) {

        int i;

        for (i = 0; i < max; i++) {
       
                b[i].alive = 0;
                b[i].hitbox.x = 0;
                b[i].hitbox.y = 0;
                b[i].hitbox.w = B_WIDTH;
                b[i].hitbox.h = B_HEIGHT;
        }
}

//Initialize the saucer position and dimensions
void init_saucer() {

        saucer.hitbox.x = 0;       
        saucer.hitbox.y        = 0;
        saucer.hitbox.w        = 30;
        saucer.hitbox.h = 20;
        saucer.alive = 0;
        saucer.direction = right;
}

//Draw the background
void draw_background () {

        SDL_Rect src;

        src.x = 0;
        src.y = 0;
        src.w = screen->w;
        src.h = screen->h;
       
        SDL_FillRect(screen,&src,0);
}

//Draw the HUD
void draw_hud() {
       
        SDL_Rect r;
       
        r.x = WIDTH;
        r.y = 0;
        r.w = SCREEN_WIDTH - WIDTH;
        r.h = SCREEN_HEIGHT;

        SDL_FillRect(screen, &r, 41);
       
        char score_label[] = "Score";
        draw_string(score_label, WIDTH, 0);
       
        char score_num[10];
        snprintf(score_num, 10, "%d", score.points);
        draw_string(score_num, WIDTH, 20);

        char level[] = "Level";
        draw_string(level, WIDTH, 60);
       
        char level_num[2];
        snprintf(level_num, 2, "%d", score.level);
        draw_string(level_num, WIDTH, 80);
       
        char lives[] = "Lives";
        draw_string(lives, WIDTH, 120);
       
        char lives_num[2];
        snprintf(lives_num, 2, "%d", player.lives);
        draw_string(lives_num, WIDTH, 140);
       
        char author[] = "Coded by";
        draw_string(author, WIDTH, 540);
       
        char name[] = "J lambert";
        draw_string(name, WIDTH, 560);
}

//Draw the title screen
void draw_title_screen() {
       
        SDL_Rect src;
        SDL_Rect dest;

        src.x = 0;
        src.y = 0;
        src.w = title_screen->w;
        src.h = title_screen->h;

        dest.x = (SCREEN_WIDTH / 2) - (title_screen->w / 2);
        dest.y = 0;
        dest.w = title_screen->w;
        dest.h = title_screen->h;
       
        SDL_BlitSurface(title_screen, &src, screen, &dest);
}

//Draw the saucer if its alive
void draw_saucer() {

        SDL_Rect src;
       
        src.x = 0;
        src.y = 0;
        src.w = 30;
        src.h = 20;
       
        if (saucer.alive == 1) {
               
                SDL_BlitSurface(saucer_img, &src, screen, &saucer.hitbox);
        }
}

//Draw the invaders if there alive
void draw_invaders() {

        SDL_Rect src, dest;
        int i,j;
       
        src.w = E_WIDTH;
        src.h = E_HEIGHT;
       
        for (i = 0; i < 5; i++) {
               
                for (j = 0; j < 10; j++) {
                       
                        if (invaders.enemy[i][j].alive == 1) {
                               
                                //purple
                                if(i == 0) {       
                                       
                                        if (invaders.state == 0) {
                                               
                                                src.x = 0;
                                                src.y = 0;
                                       
                                        } else {
                                               
                                                src.x = 30;
                                                src.y = 0;                               
                                        }
                               
                                //green
                                } else if (i > 0 && i < 3) {
                                       
                                        if (invaders.state == 0) {
                                               
                                                src.x = 0;
                                                src.y = E_HEIGHT;

                                        } else {
                                               
                                                src.x = 30;
                                                src.y = E_HEIGHT;
                                        }

                                //red
                                } else {
                                       
                                        if (invaders.state == 0) {
                                       
                                                src.x = 0;
                                                src.y = E_HEIGHT * 2;
                                       
                                        } else {
                                       
                                                src.x = 30;
                                                src.y = E_HEIGHT * 2;       
                                        }
                                }

                                dest.x = invaders.enemy[i][j].hitbox.x;
                                dest.y = invaders.enemy[i][j].hitbox.y;
                                dest.w = invaders.enemy[i][j].hitbox.w;
                                dest.h = invaders.enemy[i][j].hitbox.h;
                               
                                SDL_BlitSurface(invadersmap, &src, screen, &dest);
                        }
                }
        }
}

//Draw the bases
void draw_bases() {

        SDL_Rect src;

        src.x = 0;
        src.y = 0;
        src.w = BASE_WIDTH;
        src.h = BASE_HEIGHT;

        int i;

        for(i = 0; i < BASE; i++) {
               
                SDL_BlitSurface(base_img[i], &src, screen, &base[i].hitbox);
        }
}

//Draw the player
void draw_player() {

        SDL_Rect src;

        src.x = 0;
        src.y = 0;
        src.w = P_WIDTH;
        src.h = P_HEIGHT;

        SDL_BlitSurface(player_img, &src, screen, &player.hitbox);
}

//Draw both the enemy and the players bullets if there alive
void draw_bullets(struct bullet_t b[], int max) {

        //Uint8 c = SDL_MapRGB(screen->format, 255, 255, 255);
        int i;


        for (i = 0; i < max; i++) {
       
                if (b[i].alive == 1) {
               
                        SDL_FillRect(screen, &b[i].hitbox, 255);
                }
        }
}

//Draw a char
int draw_char(char c, int x, int y) {

        SDL_Rect src;
        SDL_Rect dest;
        int i,j;
        char *map[] = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
                        "abcdefghijklmnopqrstuvwxyz",
                        "!@#$%^&*()_+{}|:\"<>?,.;'-=",
                        "0123456789"};

        src.x = 0;
        src.y = 0;
        src.w = 20;
        src.h = 20;
       
        dest.x = x;
        dest.y = y;
        dest.w = 20;
        dest.h = 20;

        for (i = 0; i < 4; i++) {
       
                for(j = 0; j < strlen(map[i]); j++) {
                       
                        if (c == map[i][j]) {
                       
                                SDL_BlitSurface(cmap, &src, screen, &dest);
                                return 0;
                        }

                        src.x += 20;
                }
       
                src.y += 20;//move down one line on the image file
                src.x = 0; //reset to start of line
        }

        return 0;
}

//Draw a string of chars
void draw_string(char s[], int x, int y) {

        int i;

        for (i = 0; i < strlen(s); i++) {
       
                draw_char(s[i],x,y);
                x += 20;
        }
}

//Draw Game Over message
void draw_game_over() {
               
        SDL_Rect src;
        SDL_Rect dest;

        src.x = 0;
        src.y = 0;
        src.w = game_over_img->w;
        src.h = game_over_img->h;

        dest.x = (WIDTH / 2) - (game_over_img->w / 2);
        dest.y = (HEIGHT / 2) - (game_over_img->h / 2);
        dest.w = game_over_img->w;
        dest.h = game_over_img->h;
       
        SDL_BlitSurface(game_over_img, &src, screen, &dest);
}

//Set invader movment speed
void set_invaders_speed() {

        switch (invaders.killed) {
               
                case 10:

                        invaders.speed = 2;
                        invaders.state_speed = 800;
                        break;
               
                case 20:

                        invaders.speed = 4;
                        invaders.state_speed = 600;
                        break;
               
                case 30:

                        invaders.speed = 8;
                        invaders.state_speed = 200;
                        break;
               
                case 40:

                        invaders.speed = 16;
                        invaders.state_speed = 0;
                        break;
        }
}

//Move positions of both enemy and player bullets on screen
int move_bullets(struct bullet_t b[], int max, int speed) {
       
        int i;

        for(i = 0; i < max; i++) {
       
                if (b[i].alive == 1) {
                       
                        b[i].hitbox.y += speed;
                       
                        if (b[i].hitbox.y <= 0) {
               
                                b[i].alive = 0;       
                        }
                       
                        if (b[i].hitbox.y + b[i].hitbox.h >= HEIGHT) {
               
                                b[i].alive = 0;       
                        }
                }
        }

        return 0;
}

//Move invaders down one space once the reach the edge
void move_invaders_down() {

        int i,j;

        for (i = 0; i < 5; i++) {
               
                for (j = 0; j < 10; j++) {
               
                        invaders.enemy[i][j].hitbox.y += 15;
                }
        }
}

//Move invaders based on there current direction
int move_invaders(int speed) {
       
        set_invaders_speed();
       
        int i,j;

        switch (invaders.direction) {
               
                case left:
               
                        for (i = 0; i < 10; i++) {
                       
                                for (j = 0; j < 5; j++) {
                               
                                        if (invaders.enemy[j][i].alive == 1) {
               
                                                if (invaders.enemy[j][i].hitbox.x <= 0) {
                                               
                                                        invaders.direction = right;
                                                        move_invaders_down();
                                                        return 0;
                                                }
                                               
                                                if (invaders.state_time + invaders.state_speed < SDL_GetTicks()) {
                                               
                                                        invaders.state_time = SDL_GetTicks();
                                                       
                                                        if (invaders.state == 1) {
                                                               
                                                                invaders.state = 0;

                                                        } else {
                                                               
                                                                invaders.state = 1;
                                                        }
                                                }
                                               
                                                //move invader speed number of pixels
                                                invaders.enemy[j][i].hitbox.x -= invaders.speed;
                                        }
                                }
                        }

                        break;

                case right:
                       
                        for (i = 9; i >= 0; i--) {
                       
                                for (j = 0; j < 5; j++) {
                               
                                        if (invaders.enemy[j][i].alive == 1) {
                                       
                                                if (invaders.enemy[j][i].hitbox.x + E_WIDTH >= WIDTH) {
                                       
                                                        invaders.direction = left;
                                                        move_invaders_down();
                                                        return 0;
                                                }
               
                                                if (invaders.state_time + invaders.state_speed < SDL_GetTicks()) {
                                               
                                                        invaders.state_time = SDL_GetTicks();

                                                        if (invaders.state == 1) {
                                                               
                                                                invaders.state = 0;

                                                        } else {
                                                               
                                                                invaders.state = 1;
                                                        }
                                                }
                                               
                                                invaders.enemy[j][i].hitbox.x += invaders.speed;
                                        }
                                }
                        }

                        break;

                default:
                        break;

        }

        return 0;
}

//Move player left or right
void move_player(enum direction_t direction) {

        if (direction == left) {
                       
                if (player.hitbox.x > 0) {
                       
                        player.hitbox.x -= 10;
                }

        } else if (direction == right) {

                if (player.hitbox.x + player.hitbox.w < WIDTH){

                        player.hitbox.x += 10;
                }
        }
}

//Move saucer based on there current direction
void move_saucer() {

        if (saucer.alive == 1) {

                if (saucer.direction == left) {
               
                        saucer.hitbox.x -= 5;

                        if (saucer.hitbox.x < 0) {
                               
                                saucer.alive = 0;
                                saucer.hitbox.x = 0;
                                saucer.direction = right;
                        }
                }

                if (saucer.direction == right) {
               
                        saucer.hitbox.x += 5;

                        if (saucer.hitbox.x + saucer.hitbox.w > WIDTH) {
                       
                                saucer.alive = 0;
                                saucer.hitbox.x = WIDTH - saucer.hitbox.w;
                                saucer.direction = left;
                        }
                }
        }
}

//Detect any collision between any two non rotated rectangles
int collision(SDL_Rect a, SDL_Rect b) {

        if (a.y + a.h < b.y) {
       
                return 0;
        }
                               
        if (a.y > b.y + b.h) {
                                       
                return 0;
        }
                               
        if (a.x > b.x + b.w) {
                                       
                return 0;
        }
                       
        if (a.x + a.w < b.x) {
                                       
                return 0;
        }

        return 1;
}

//Create damage to the base sprite for player and enemy bullet collisions
void bullet_base_damage(struct base_t *base, int b_num, struct bullet_t *bullet, int l) {

        int i;
        int x,y;
        SDL_Rect src;
        SDL_Rect dest;
                               
        SDL_LockSurface(base_img[b_num]);
        Uint8 *raw_pixels;

        raw_pixels = (Uint8 *) base_img[b_num]->pixels;
       
        int pix_offset;

        //bottom
        if (l == 0) {
       
                //how far from the left did the bullet hit the base sprite
                x = (bullet->hitbox.x + 3) - base->hitbox.x;

                //start from bottom of the base sprite
                y = base->hitbox.h - 1;

                for(i = 0; i < base->hitbox.h; i++) {
               
                        //the x calculation can get us to pixel column 60 when 59 is the maximum (0 - 59 is 60 pixels)
                        if (x >= BASE_WIDTH) {
                                x = BASE_WIDTH - 1;
                        }

                        pix_offset = y * base_img[b_num]->pitch  + x;       

                        //found part part of the base sprite that is NOT magenta(index)
                        //searching from the bottom up
                        if (raw_pixels[pix_offset] != 227) {
                                       
                                bullet->alive = 0;
                               
                                src.x = 0;
                                src.y = 0;
                                src.w = 11;
                                src.h = 15;

                                dest.x = x - 3;
                                dest.y = y - 14;
                                dest.w = 11;
                                dest.h = 15;
                               
                                SDL_UnlockSurface(base_img[b_num]);
                                SDL_BlitSurface(damage_img, &src, base_img[b_num], &dest);
                               
                                break;
                        }
                       
                        y--;
                }
        }
       
        //top
        if (l == 1) {

                //how far from the left did the bullet hit the base sprite
                x = (bullet->hitbox.x + 3) - base->hitbox.x;

                //start from top of the base sprite
                y = 0;
               
                for(i = 0; i < base->hitbox.h; i++) {
                       
                        //the x calculation can get us to pixel column 60 when 59 is the maximum (0 - 59 is 60 pixels)
                        if (x >= BASE_WIDTH) {
                                x = BASE_WIDTH - 1;
                        }

                        pix_offset = y * base_img[b_num]->pitch  + x;       
               
                        //found part part of the base sprite that is NOT magenta(index)
                        //searching from the top down
                        if (raw_pixels[pix_offset] != 227) {
                                       
                                bullet->alive = 0;
                       
                                src.x = 0;
                                src.y = 0;
                                src.w = 11;
                                src.h = 15;

                                dest.x = x - 3;
                                dest.y = y;
                                dest.w = 11;
                                dest.h = 15;
                               
                                SDL_UnlockSurface(base_img[b_num]);
                                SDL_BlitSurface(damage_top_img, &src, base_img[b_num], &dest);
                               
                                break;
                        }
                       
                        y++;
                }
        }

        SDL_UnlockSurface(base_img[b_num]);
}

//Create damage to the base sprite for enemy and base collisions
void enemy_base_damage(struct enemy_t *enemy, struct base_t *base, int index) {
       
        int x,y;
        SDL_Rect dest;

        //the x hot spot is taken from the top left of the sprite with the speed in pixels
        //added ahead in case the enemy skips the last few pixels of the sprite and
        //the collision is no longer detected. Speed in pixels is subtracted if traveling left
       
        if (invaders.direction == right) {
       
                x = (enemy->hitbox.x + invaders.speed) - base->hitbox.x;
                y = enemy->hitbox.y - base->hitbox.y;
               
                if (x > 0) {
                       
                        dest.x = 0;
                        dest.y = y;
                        dest.w = x;
                        dest.h = enemy->hitbox.h;
               
                        SDL_FillRect(base_img[index], &dest, 227);
                }
       
        } else if (invaders.direction == left){
               
                x = (enemy->hitbox.x + (enemy->hitbox.w - 1)) - invaders.speed;
                x = x - base->hitbox.x;
                y = enemy->hitbox.y - base->hitbox.y;

                if (x < base->hitbox.w) {
               
                        dest.x = x;
                        dest.y = y;
                        dest.w = base->hitbox.w - 1;
                        dest.h = enemy->hitbox.h;
               
                        SDL_FillRect(base_img[index], &dest, 227);
                }
        }               
}

//Look for collisions based on enemy and base rectangles
void enemy_base_collision() {

        int i,j,k,c;

        for (i = 0; i < 5; i++) {

                for (j = 0;  j < 10; j++) {
               
                        for (k = 0;  k < BASE; k++) {
                       
                                if (invaders.enemy[i][j].alive == 1) {
                               
                                        c = collision(invaders.enemy[i][j].hitbox,base[k].hitbox);               
                                       
                                        if (c == 1) {
                                               
                                                enemy_base_damage(&invaders.enemy[i][j], &base[k], k);
                                        }
                                }
                        }
                }
        }
}

//Look for collisions based on player bullet and invader rectangles
void enemy_hit_collision() {

        int i,j,k,c;
       
        for (i = 0; i < 5; i++) {
               
                for (j = 0; j < 10; j++) {
                       
                        if (invaders.enemy[i][j].alive == 1) {
                       
                                for (k = 0; k < P_BULLETS; k++) {
                       
                                        if (bullets[k].alive == 1) {
                                               
                                                c = collision(bullets[k].hitbox, invaders.enemy[i][j].hitbox);
                               
                                                if (c == 1) {
                               
                                                        invaders.enemy[i][j].alive = 0;
                                                        bullets[k].alive = 0;
                                                        bullets[k].hitbox.x = 0;
                                                        bullets[k].hitbox.y = 0;
                                                        invaders.killed++;
                                                        score.points += invaders.enemy[i][j].points;
                                                }
                                        }
                                }
                        }
                }
        }
}

//Look for collisions based on enemy bullet and player rectangles
void player_hit_collision() {

        int i,c;

        for(i = 0; i < E_BULLETS; i++) {
       
                if (e_bullets[i].alive == 1) {

                        c = collision(e_bullets[i].hitbox, player.hitbox);

                        if (c == 1) {
                               
                                if (player.lives >= 0) {
                               
                                        player.lives--;
                                        pause_for(500);
                                }
                        }
                }
        }
}

//Look for collisions based on player bullet and saucer rectangles
void saucer_hit_collision() {

        int i,c;

        if (saucer.alive == 1) {
       
                for(i = 0; i < P_BULLETS; i++) {
       
                        if (bullets[i].alive == 1) {
                       
                                c = collision(bullets[i].hitbox, saucer.hitbox);
       
                                if (c == 1) {
                               
                                        int r = rand() % 3;
                                       
                                        switch (r) {
                       
                                                case 0:
                                                        score.points += 50;
                                                        break;
       
                                                case 1:
                                                        score.points += 150;
                                                        break;
       
                                                case 2:
                                                        score.points += 300;
                                                        break;
       
                                                default:
                                                        break;
                                        }
                                       
                                        //sucer was hit reset for next time
                                        saucer.alive = 0;
                                       
                                        if (saucer.direction == left) {
                                               
                                                saucer.hitbox.x = 0;
                                                saucer.direction = right;
       
                                        } else if (saucer.direction == right) {
                                       
                                                saucer.hitbox.x = WIDTH - saucer.hitbox.w;
                                                saucer.direction = left;
                                        }
                                }
                        }
                }
        }
}

//Look for collisions based on invader and player rectangles
int enemy_player_collision() {

        int i,j,c;

        for(i = 0; i < 5; i++) {

                for(j = 0; j < 10; j++) {
               
                        if (invaders.enemy[i][j].alive == 1) {
                                       
                                c = collision(player.hitbox, invaders.enemy[i][j].hitbox);

                                if (c == 1) {
                               
                                        player.lives--;
                                        pause_for(500);
                                        init_invaders();
                                        init_bases();
                                        return 1;
                                }
                        }
                }
        }

        return 0;
}

//Look for collisions based on bullet and base rectangles
void bullet_base_collision(struct bullet_t b[], int max, int l) {

        int i,j,c;

        for (i = 0; i < max; i++) {
               
                for (j = 0; j < BASE; j++) {
       
                        if (b[i].alive == 1) {
                       
                                c = collision(b[i].hitbox, base[j].hitbox);

                                if (c == 1) {
                                       
                                        bullet_base_damage(&base[j], j, &b[i],l);
                                }
                        }
                }
        }
}

//Determine for game over event
void game_over_ai() {
       
        if (player.lives < 0) {
               
                state = game_over;
        }
}

//Shoot bullet/s from player
void player_shoot() {

        int i;
       
        for (i = 0; i < P_BULLETS; i++) {
                               
                if (bullets[i].alive == 0) {
                       
                        //count number of shots fired
                        score.shots++;

                        bullets[i].hitbox.x = player.hitbox.x + (P_WIDTH / 2);
                        //-5 at the end so the bullets ends closer to the top of the screen due to 30px speed
                        bullets[i].hitbox.y = player.hitbox.y - (bullets[i].hitbox.h + 10);
                        bullets[i].alive = 1;
                        break;
                }
        }
}

//Determine game level
void calculate_level() {

        if (invaders.killed != 0 && invaders.killed % 50 == 0) {
               
                score.level++;
                init_invaders();
                init_bases();
                init_saucer();
                pause_for(500);
        }
}

//Determine when saucer should appear
void saucer_ai() {

        //every 20 shots
        if (score.shots != 0 && score.shots % 20 == 0) {
       
                saucer.alive = 1;
        }
}

//Determine when invaders should shoot
void enemy_ai() {

        int i, j, k;

        for (i = 0; i < 10; i++) {
               
                for (j = 4; j >= 0; j--) {
                       
                        if (invaders.enemy[j][i].alive == 1) {
                               
                                //player
                                int mid_point = player.hitbox.x + (player.hitbox.w / 2);
                               
                                //enemy
                                int start = invaders.enemy[j][i].hitbox.x;
                                int end = invaders.enemy[j][i].hitbox.x + invaders.enemy[j][i].hitbox.w;

                                if (mid_point > start && mid_point < end) {

                                        //fire bullet if available
                                        for (k = 0; k < E_BULLETS; k++) {
                       
                                                if (e_bullets[k].alive == 0) {
                               
                                                        int r = rand() % 30;

                                                        if (r == 1) {
                                                                e_bullets[k].hitbox.x = start + (E_WIDTH / 2) ;
                                                                e_bullets[k].hitbox.y = invaders.enemy[j][i].hitbox.y;
                                                                e_bullets[k].alive = 1;
                                                        }

                                                        break;
                                                }
                                        }
                                }
                               
                                //alive enemy found reversing up the enemy grid dont check the rest of the colum
                                break;
                        }
                }
        }
}

//Determin when to pause game and how long for
void pause_game() {

        if (SDL_GetTicks() > pause_time + pause_len) {
       
                state = game;
        }
}

//Set amount of time to pause game for
void pause_for(unsigned int len) {

        state = pause;
        pause_time = SDL_GetTicks();
        pause_len = len;
}

//Load image files
int load_image(char filename[], SDL_Surface **surface, enum ck_t colour_key) {
       
        SDL_Surface *temp;
       
        //load image
        temp = SDL_LoadBMP(filename);
       
        if (temp == NULL) {
       
                printf("Unable to load %s.\n", filename);
                return 1;
        }

        Uint32 colourkey;

        /* Set the image colorkey. */
        if (colour_key == magenta) {
               
                colourkey = SDL_MapRGB(temp->format, 255, 0, 255);
       
        } else if (colour_key == lime) {
       
                colourkey = SDL_MapRGB(temp->format, 0, 255, 0);
        }

        SDL_SetColorKey(temp, SDL_SRCCOLORKEY, colourkey);

        //convert the image surface to the same type as the screen
        (*surface) = SDL_DisplayFormat(temp);
       
        if ((*surface) == NULL) {
       
                printf("Unable to convert bitmap.\n");
                return 1;
        }
       
        SDL_FreeSurface(temp);

        return 0;
}

//Main program
int main() {
       
        /* Initialize SDL’s video system and check for errors */
        if (SDL_Init(SDL_INIT_VIDEO) != 0) {

                printf("Unable to initialize SDL: %s\n", SDL_GetError());
                return 1;
        }
       
        /* Make sure SDL_Quit gets called when the program exits! */
        atexit(SDL_Quit);
       
        /*set window title*/
        SDL_WM_SetCaption("Space Invaders", "P");
       
        /* Attempt to set a 800x600 8 bit color video mode */
        screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 8, SDL_DOUBLEBUF );
       
        if (screen == NULL) {
               
                printf("Unable to set video mode: %s\n", SDL_GetError());
                return 1;
        }

        //load images
        load_image("titlescreen.bmp", &title_screen, magenta);
        load_image("cmap.bmp", &cmap, magenta);
        load_image("invaders.bmp", &invadersmap, magenta);
        load_image("player.bmp", &player_img, magenta);
        load_image("saucer.bmp", &saucer_img, magenta);
        load_image("gameover.bmp", &game_over_img, magenta);
        load_image("damage.bmp", &damage_img, lime);
        load_image("damagetop.bmp", &damage_top_img, lime);

        Uint32 next_game_tick = SDL_GetTicks();
        int sleep = 0;
        Uint8 *keystate = 0;
        int quit = 0;
        SDL_Event event;

        init_score();
        init_invaders();
        init_bases();
        init_player();
        init_saucer();
        init_bullets(bullets, P_BULLETS);
        init_bullets(e_bullets, E_BULLETS);
        state = menu;
        title_time = SDL_GetTicks();
               
        /* Animate */
        while (quit == 0) {
               
                /* Grab a snapshot of the keyboard. */
                keystate = SDL_GetKeyState(NULL);
               
                while (SDL_PollEvent(&event)) {

                        switch(event.type) {
                               
                                case SDL_KEYDOWN:
                                       
                                        switch( event.key.keysym.sym ) {
                                       
                                                //exit out of game loop if escape is pressed
                                                case SDLK_ESCAPE:
                                                       
                                                        quit = 1;
                                                break;
                                               
                                                case SDLK_SPACE:       
                                               
                                                        if (state == menu) {

                                                                state = game;

                                                        } else if (state == game){
                                                               
                                                                player_shoot();
                                                                saucer_ai();
                                                       
                                                        } else if (state == game_over) {
                                                       
                                                                init_invaders();
                                                                init_bases();
                                                                init_score();
                                                                init_player();
                                                                state = game;
                                                        }
                                                break;
                                               
                                                default:
                                                break;
                                        }
                                break;
                        }
                }
       
                draw_background();

                if (state == menu) {
                       
                        char s[] = "Press SPACEBAR to start";
                        SDL_Rect src[60];
                       
                        int i;

                        if (title_time + 2000 < SDL_GetTicks())  {
                       
                                src[0].x = 180;
                                src[0].y = 40;
                                src[0].w = 440;
                                src[0].h = 230;
                       
                                SDL_FillRect(screen, &src[0], 248);
                       
                        } else {
                       
                                int y = 0;

                                for (i = 0; i < 60; i++) {
                               
                                        src[i].x = 0;
                                        src[i].y = y;
                                        src[i].w = SCREEN_WIDTH;
                                        src[i].h = 10;

                                        SDL_FillRect(screen, &src[i], 227);
                               
                                        y += 10;                                                       
                                }
                       
                                for (i = 0; i < 60; i++) {

                                        SDL_FillRect(screen, &src[i], rand() % 255);

                                }
                        }
                       
                        draw_title_screen();       
                        draw_string(s, (SCREEN_WIDTH / 2) - (strlen(s) * 10), 500);

                } else if (state == game) {

                        //move player
                        if (keystate[SDLK_LEFT]) {
                               
                                move_player(left);
                        }

                        if (keystate[SDLK_RIGHT]) {
                               
                                move_player(right);
                        }

                        draw_hud();
                        draw_player();
                        draw_bases();
                        draw_invaders();
                        draw_saucer();
                        draw_bullets(bullets, P_BULLETS);
                        draw_bullets(e_bullets, E_BULLETS);
                        enemy_hit_collision();
                        player_hit_collision();
                        enemy_base_collision();
                        saucer_hit_collision();
                        bullet_base_collision(e_bullets, E_BULLETS, 1);
                        bullet_base_collision(bullets, P_BULLETS, 0);
                        enemy_player_collision();
                        move_invaders(invaders.speed);
                        move_saucer();
                        move_bullets(bullets, P_BULLETS, -30);
                        move_bullets(e_bullets, E_BULLETS, 15);
                        calculate_level();
                        enemy_ai();
                        game_over_ai();
                        pause_game();
               
                } else if (state == game_over) {
                       
                        draw_hud();
                        draw_player();
                        draw_bases();
                        draw_invaders();
                        draw_saucer();
                        draw_bullets(bullets, P_BULLETS);
                        draw_bullets(e_bullets, E_BULLETS);
                        draw_game_over();
               
                } else if (state == pause) {
                       
                        draw_hud();
                        draw_player();
                        draw_bases();
                        draw_invaders();
                        draw_saucer();
                        draw_bullets(bullets, P_BULLETS);
                        draw_bullets(e_bullets, E_BULLETS);
                        pause_game();
                }

                /* Ask SDL to update the entire screen. */
                SDL_Flip(screen);

                next_game_tick += 1000 / 30;
                sleep = next_game_tick - SDL_GetTicks();
       
                if( sleep >= 0 ) {

                            SDL_Delay(sleep);
                }
        }
       
        return 0;
}

Codigo en C++

Código:

#include <windows.h>
#include <iostream>
#include <conio.h>

using namespace std;

HANDLE hOut;
COORD KeyWhere;

int Key;

int SX = 20;
int SY = 15;

int OX;
int OY;

int Fire = 0;
int FX;
int FY;
int OFX;
int OFY;

int AX;
int AY;
int Alien = 0;
int AC = 0;
int ALR;
int OAX;
int OAY;

int Points = 0;
int Lives = 3;

int Crash;
int Boom = 0;

int main()
{
    New:
    system("cls");
    Points = 0;
    Lives = 3;
    SX = 20;
    SY = 15;
    AC = 0;
    Alien = 0;
    Boom = 0;
    Fire = 0;
    hOut = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(hOut, FOREGROUND_GREEN);
    cout<<"\n                      --------------*-------------";
    cout<<"\n                    <<<<<  Space invaders v.0  >>>>>";
    cout<<"\n                      --------------*-------------";
    cout<<"\n\n\n                      a = left  b = right  w = up";
    cout<<"\n                      s = down  q = shoot  x = exit";
    cout<<"\n\n\n                        Game starts in 5 secs...";
    Sleep(5000);
    system("cls");

    while(true)
    {
    KeyWhere.X = OX;
    KeyWhere.Y = OY;
    if((OX == SX)&&(OY == SY));
    else
    {
    SetConsoleCursorPosition(hOut, KeyWhere);
    cout<<"    ";
    }
    Sleep(10);
    KeyWhere.X = SX;
    KeyWhere.Y = SY;
    SetConsoleCursorPosition(hOut, KeyWhere);
    SetConsoleTextAttribute(hOut, FOREGROUND_BLUE | FOREGROUND_INTENSITY);
    cout<<"^_!_^";

    KeyWhere.X = 0;
    KeyWhere.Y = 0;
    SetConsoleCursorPosition(hOut, KeyWhere);
    SetConsoleTextAttribute(hOut, FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
    cout<<"Points: "<<Points<<"\nLives: "<<Lives;

    if(Fire == 1)
    {
    OFX = FX;
    OFY = FY;
    KeyWhere.X = OFX;
    KeyWhere.Y = OFY;
    SetConsoleCursorPosition(hOut, KeyWhere);
    cout<<" ";
    FY--;
    KeyWhere.X = FX;
    KeyWhere.Y = FY;
    SetConsoleCursorPosition(hOut, KeyWhere);
    SetConsoleTextAttribute(hOut, FOREGROUND_RED | FOREGROUND_INTENSITY);
    cout<<"|";
    if(FY < 0)
    {
    Fire = 0;
    FY = 0;
    KeyWhere.X = FX;
    KeyWhere.Y = FY;
    SetConsoleCursorPosition(hOut, KeyWhere);
    cout<<"  ";
    }
    if((FY == AY)&&((FX == AX)||(FX == AX+1)||(FX == AX+2)))
    {
    Beep(300, 200);
    Alien = 0;
    KeyWhere.X = FX;
    KeyWhere.Y = FY;
    SetConsoleCursorPosition(hOut, KeyWhere);
    cout<<" ";
    AY = 0;
    Fire = 0;
    Points = Points+10;
    if(Points == 200)
    {
    system("cls");
    SetConsoleTextAttribute(hOut, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
    cout<<"\n\n\n\n                    You made it!!!!";
    cout<<"\n\n                    Wana play again? F1 = yes  Esc = no";
    Beep(300, 100);
    Beep(400, 100);
    Beep(500, 100);
    Beep(600, 100);
    Beep(700, 100);
    Beep(800, 100);
    Beep(900, 100);
    Beep(1000, 100);
    while(true)
    {
    if(GetAsyncKeyState(VK_F1)) goto New;
    if(GetAsyncKeyState(VK_ESCAPE)) return 0;
    }
    }
    system("cls");
    }
    }

    if(Alien == 0)
    {
    srand(GetTickCount());
    AX = rand() % 60;
    AX = AX+10;
    Alien = 1;
    }
    if(Alien == 1)
    {
    AC++;
    if(AC > 30)
    {
    AC = 0;
    AY++;
    if(ALR == 0) AX--;
    else if(ALR == 1);
    else if(ALR == 2) AX++;
    if(AX > 70) AX--;
    if(AX < 10) AX++;
    }
    OAY = AY-1;
    OAX = AX-4;
    KeyWhere.X = OAX;
    KeyWhere.Y = OAY;
    SetConsoleCursorPosition(hOut, KeyWhere);
    cout<<"        ";
    srand(GetTickCount());
    ALR = rand() % 3;
    KeyWhere.X = AX;
    KeyWhere.Y = AY;
    SetConsoleCursorPosition(hOut, KeyWhere);
    SetConsoleTextAttribute(hOut, FOREGROUND_GREEN | FOREGROUND_INTENSITY);
    cout<<"/W\\";
    if(AY > 48)
    {
    Beep(100, 500);
    Alien = 0;
    Points = Points-50;
    AY = 1;
    system("cls");
    }
    }

    OX = SX;
    OY = SY;

    if(kbhit())
    {
    Key = getch();
    if(Key == 'a')
    {
    SX--;
    if(SX < 10) SX++;
    }
    if(Key == 'd')
    {
    SX++;
    if(SX > 70) SX--;
    }
    if(Key == 'w')
    {
    SY--;
    if(SY < 1) SY++;
    }
    if(Key == 's')
    {
    SY++;
    if(SY > 48) SY--;
    }
    if(Key == 'q')
    {
    if(Fire == 1);
    else
    {
    Beep(100, 15);
    Fire = 1;
    FX = SX+2;
    FY = SY-1;

    }
    }
    if(Key == 'x') return 0;
    }

    for(Crash = 0; Crash < 5; Crash++)
    {
    if(SY != AY);
    else
    {
    if(SX+Crash == AX+0) Boom = 1;
    else if(SX+Crash == AX+1) Boom = 1;
    else if(SX+Crash == AX+2) Boom = 1;
    }
    }
    if(Boom == 1)
    {
    Beep(100, 500);
    system("cls");
    Boom = 0;
    Alien == 0;
    Lives--;
    AY = 1;
    SX = 50;
    SY = 30;
    Points = Points - 20;
    if(Lives == 0)
    {
    system("cls");
    SetConsoleTextAttribute(hOut, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
    cout<<"\n\n\n\n                    You loose...";
    cout<<"\n\n                    Wana play again? F1 = yes  Esc = no";
    Beep(500, 300);
    Beep(400, 300);
    Beep(300, 300);
    Beep(200, 300);
    while(true)
    {
    if(GetAsyncKeyState(VK_F1)) goto New;
    if(GetAsyncKeyState(VK_ESCAPE)) return 0;
    }
    }
    }
    }
}

Codigo en C++ (2)

Código:


/*
 ==========================================================================

    Nombre de archivo: proyecto.cpp
    (c) 2006 Autor: Jose Carlos Aragon Suarez
    Descripcion:    Proyecto Final Space Invaders

 ==========================================================================
*/

/* Declaracion de bibliotecas */
#include <iostream.h> //para poder utilizar cin y cout
#include <conio.h>  //para poder utilizar getch()
#include <dos.h>
#include <stdlib.h>
#include<string.h>
#include<fstream.h>



typedef unsigned short int byte;

struct alumno
{
  char nombre[10];
  int punt;
};

byte nvbuena[44][43]=//[22] y.. dupli [44], [42] x
  {
       
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17,17, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17,17,17, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 120, 17,120, 17, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 120, 17, 23,17, 120, 17, 17, 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, 0, 0, 0, 0, 0, 0, 0, 17, 0, 17, 17, 23, 23,23, 17, 120, 17, 17, 17, 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, 0, 0, 0, 17, 17, 2, 17, 17, 23, 23, 23,23, 23, 17, 120, 17, 2, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 2, 2, 17, 120, 17, 23, 23, 23,23, 23, 23, 17, 120, 17, 2, 2, 2, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0},
        {0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 2, 2, 2, 2, 17, 120, 17, 17, 17, 17, 17,17, 17, 17, 17, 17, 17, 2, 2, 2, 2, 2, 17, 17, 17, 0, 0, 0, 0, 0, 0,0,0},
        {0, 0, 0, 0, 0, 0, 17, 17, 2, 2, 2, 2, 2, 17, 120, 120, 120, 120, 120, 120, 17,120, 120, 120, 120, 120, 120, 17, 2, 2, 2, 2, 2, 2, 2, 17, 17, 0, 0, 0, 0,0, 0},
        {0, 0, 0, 0, 17, 17, 2, 2, 2, 2, 2, 2, 2, 17, 120, 120, 120, 17, 17, 17, 17,17, 17, 17, 120, 120, 120, 120, 17, 2, 2, 2, 2, 2, 2, 2, 2, 17, 17, 17, 0,0,0},
        {0, 0, 17, 17, 2, 2, 2, 2, 2, 2, 2, 2, 2, 17, 17, 17, 17, 120, 120, 120, 17,120, 120, 120, 17, 17, 17, 120, 17, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 17,0,0},
        {0, 0, 17, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 17, 120, 120, 120, 120, 17, 17, 17,17, 17, 17, 120, 120, 120, 17, 17, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 17,0,0},
        {0, 17, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 17, 120, 17, 17, 17, 120, 120, 120,120, 120, 120, 17, 17, 17, 120, 17, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,17,0},
        {0, 17, 2, 2, 2, 2, 17, 17, 17, 17, 17, 17, 2, 17, 17, 120, 17, 120, 120, 120, 120,120, 120, 120, 17, 120, 120, 17, 17, 2, 17, 17, 17, 17, 17, 17, 2, 2, 2, 2, 2,17,0},
        {0, 17, 2, 2, 2, 2, 17, 23, 23, 23, 23, 17, 2, 17, 120, 120, 120, 17, 120, 120, 120,120, 120, 120, 17, 120, 120, 17, 2, 2, 17, 23, 23, 23, 23, 17, 2, 2, 2, 2, 2,2,17},
        {17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 120, 120, 17, 17, 17, 17,17, 17, 17, 120, 120, 120, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,17,17},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 120, 120, 17, 120, 120, 120,120, 120, 17, 120, 120, 17, 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, 0, 0, 0, 0, 0, 17, 120, 17, 120, 120, 120,120, 120, 120, 17, 120, 17, 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, 0, 0, 0, 0, 0, 17, 17, 120, 120, 120, 120,120, 120, 120, 17, 17, 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, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17,17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0}
  };
 
byte nvexpo1[44][43]=//[22] y.. dupli [44], [42] x
      {
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 44, 44, 44, 44, 44, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 44, 43, 43, 43, 44, 44, 0, 0, 0, 0, 44, 44, 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, 44, 44, 0, 0, 44, 44, 43, 43, 43, 44, 44, 44, 0, 0, 44, 44, 44, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 44, 44, 0, 44, 44, 44, 44, 44, 44, 44, 43, 43, 43, 43, 43, 44, 44, 43, 43, 40, 40, 44, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 43, 43, 43, 42, 42, 43, 43, 44, 43, 43, 43, 44, 40, 44, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 44, 44, 44, 44, 44, 43, 43, 44, 44, 43, 43, 43, 43, 43, 43, 42, 41, 42, 42, 43, 43, 43, 43, 42, 42, 40, 40, 44, 44, 44, 44, 44, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 44, 44, 44, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 42, 42, 41, 41, 42, 42, 43, 43, 42, 42, 42, 43, 43, 43, 44, 43, 40, 44, 44, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 44, 44, 44, 43, 43, 43, 43, 42, 42, 43, 42, 42, 42, 42, 42, 41, 41, 41, 42, 42, 42, 42, 42, 41, 41, 42, 43, 43, 43, 43, 43, 44, 44, 44, 0, 0, 0, 0, 0, 0},
        {0, 44, 44, 44, 44, 43, 43, 43, 43, 42, 42, 42, 42, 42, 40, 41, 41, 41, 41, 41, 40, 40, 40, 41, 40, 41, 41, 41, 42, 42, 43, 43, 43, 43, 43, 44, 44, 44, 0, 0, 0, 0, 0},
        {0, 44, 44, 44, 43, 43, 43, 43, 42, 42, 42, 41, 40, 40, 40, 40, 41, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 41, 41, 42, 42, 43, 43, 43, 43, 43, 44, 44, 44, 44, 44, 0, 0},
        {0, 44, 44, 43, 43, 43, 43, 42, 42, 41, 41, 41, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 41, 41, 42, 42, 42, 42, 43, 43, 43, 44, 44, 44, 44, 44, 0},
        {0, 0, 44, 43, 43, 43, 42, 42, 41, 41, 41, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 41, 41, 41, 42, 42, 43, 43, 43, 43, 44, 44, 44, 44},
        {0, 44, 43, 43, 43, 42, 42, 42, 41, 41, 41, 40, 40, 40, 40, 40, 41, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 41, 41, 41, 42, 42, 43, 43, 43, 43, 44, 44, 44},
        {44, 44, 43, 43, 42, 42, 42, 42, 41, 41, 42, 41, 41, 41, 41, 41, 42, 41, 41, 40, 41, 40, 40, 40, 41, 41, 40, 40, 40, 40, 41, 41, 41, 41, 41, 42, 42, 43, 43, 43, 43, 44, 44},
        {44, 44, 44, 43, 42, 42, 42, 43, 43, 42, 42, 42, 41, 41, 41, 42, 42, 42, 41, 41, 41, 41, 40, 41, 41, 41, 41, 41, 40, 40, 41, 41, 41, 41, 41, 42, 42, 42, 43, 43, 43, 43, 44},
        {44, 44, 44, 43, 43, 43, 43, 43, 43, 43, 43, 43, 41, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 43, 43, 42, 41, 41, 41, 42, 42, 43, 43, 43, 43, 43, 44},
        {44, 44, 44, 44, 43, 43, 43, 43, 44, 44, 44, 43, 43, 43, 42, 42, 43, 42, 42, 43, 42, 42, 42, 43, 43, 42, 42, 42, 43, 43, 43, 43, 42, 42, 42, 42, 43, 43, 43, 43, 43, 44, 44},
        {44, 44, 0, 44, 44, 44, 44, 44, 44, 44, 44, 44, 43, 43, 43, 43, 43, 43, 43, 42, 42, 42, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 44, 42, 42, 44, 43, 43, 43, 43, 44, 44, 44},
        {0, 0, 0, 0, 44, 44, 0, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 43, 43, 42, 43, 43, 43, 43, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 44, 44, 0, 0, 44, 44, 44, 43, 43, 43, 43, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 44, 43, 43, 43, 43, 44, 44, 44, 44, 44, 44, 44, 0, 0, 44, 44, 0, 44, 44, 0, 44, 44, 44, 0, 0, 0, 0}
    };

byte nvexpo2[44][43]=//[22] y.. dupli [44], [42] x
  {
        {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, 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, 0, 0, 0, 0, 0, 0, 0, 44, 0, 0, 43, 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, 0, 0, 0, 0, 0, 0, 0, 0, 44, 44, 0, 0, 44, 44, 43, 43, 43, 44, 44, 44, 0, 0, 0, 44, 44, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 44, 44, 0, 44, 44, 44, 44, 44, 44, 44, 43, 43, 43, 43, 43, 44, 44, 43, 43, 40, 40, 44, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 44, 44, 44, 44, 44, 44, 0, 0, 44, 44, 44, 43, 43, 43, 42, 42, 43, 43, 44, 43, 43, 43, 44, 40, 0, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 44, 44, 44, 44, 43, 43, 44, 0, 43, 43, 43, 43, 43, 43, 42, 41, 42, 42, 43, 43, 43, 43, 42, 42, 0, 0, 44, 44, 44, 44, 44, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 44, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 42, 42, 41, 41, 42, 42, 43, 43, 42, 42, 42, 43, 0, 0, 44, 43, 40, 44, 44, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 43, 43, 43, 42, 42, 43, 42, 42, 42, 42, 42, 41, 41, 41, 42, 42, 42, 42, 42, 41, 41, 42, 43, 43, 43, 43, 43, 44, 44, 44, 0, 0, 0, 0, 0, 0},
        {0, 0, 44, 44, 44, 43, 43, 43, 43, 42, 42, 42, 42, 42, 40, 41, 41, 41, 41, 41, 40, 40, 40, 41, 40, 41, 41, 41, 42, 42, 43, 43, 43, 43, 43, 44, 44, 44, 0, 0, 0, 0, 0},
        {0, 44, 44, 44, 43, 43, 43, 43, 42, 42, 42, 41, 40, 40, 40, 40, 41, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 41, 41, 42, 42, 43, 43, 43, 43, 43, 44, 44, 44, 0, 0, 0, 0},
        {0, 44, 44, 43, 43, 43, 43, 42, 42, 41, 41, 41, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 41, 41, 42, 42, 42, 42, 43, 43, 43, 44, 44, 44, 0, 0, 0},
        {0, 0, 44, 43, 43, 43, 42, 42, 41, 41, 41, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 41, 41, 41, 42, 42, 43, 43, 43, 43, 44, 44, 0, 0},
        {0, 44, 43, 43, 43, 42, 42, 42, 41, 41, 41, 40, 40, 40, 40, 40, 41, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 41, 41, 41, 42, 42, 43, 43, 43, 43, 44, 0, 0},
        {0, 0, 43, 43, 42, 42, 42, 42, 41, 41, 42, 41, 41, 41, 41, 41, 42, 41, 41, 40, 41, 40, 40, 40, 41, 41, 40, 40, 40, 40, 41, 41, 41, 41, 41, 42, 42, 43, 43, 43, 43, 44, 0},
        {0, 0, 44, 43, 42, 42, 42, 43, 43, 42, 42, 42, 41, 41, 41, 42, 42, 42, 41, 41, 41, 41, 40, 41, 41, 41, 41, 41, 40, 40, 41, 41, 41, 41, 41, 42, 0, 0, 43, 43, 43, 0, 0},
        {0, 0, 44, 0, 0, 43, 43, 43, 43, 43, 43, 43, 41, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 43, 43, 42, 41, 41, 41, 0, 0, 43, 43, 43, 43, 0, 0},
        {0, 44, 44, 0, 0, 43, 43, 43, 44, 44, 44, 43, 43, 43, 42, 42, 43, 42, 42, 43, 42, 42, 42, 43, 43, 42, 42, 42, 43, 43, 43, 43, 42, 42, 42, 42, 0, 43, 43, 43, 43, 0, 0},
        {0, 0, 0, 0, 44, 44, 44, 44, 44, 44, 44, 0, 0, 43, 43, 43, 43, 43, 43, 42, 42, 42, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 0, 0, 42, 44, 43, 43, 43, 43, 44, 0, 0},
        {0, 0, 0, 0, 44, 44, 0, 44, 44, 44, 44, 0, 0, 0, 44, 44, 44, 43, 43, 42, 43, 0, 0, 0, 44, 44, 44, 44, 44, 44, 44, 0, 0, 0, 0, 44, 0, 0, 44, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 44, 44, 43, 43, 43, 0, 0, 44, 0, 0, 0, 44, 0, 0, 0, 0, 0, 44, 44, 0, 0, 0, 0, 0, 44, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  };

byte nvexpo3[44][43]=//[22] y.. dupli [44], [42] x
  {
        {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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 0, 0, 0, 0, 44, 0, 0, 0, 44, 44, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 44, 44, 0, 0, 0, 0, 0, 0, 0, 44, 43, 0, 0, 0, 43, 44, 44, 43, 0, 0, 40, 44, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 42, 43, 43, 44, 43, 43, 0, 0, 0, 0, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 44, 0, 0, 43, 43, 43, 43, 43, 0, 43, 0, 0, 42, 41, 41, 42, 0, 0, 43, 42, 42, 42, 43, 0, 0, 44, 43, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 43, 43, 42, 42, 43, 42, 0, 42, 0, 0, 41, 41, 41, 42, 0, 0, 42, 42, 41, 41, 42, 43, 43, 43, 43, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 44, 0, 0, 0, 0, 43, 43, 42, 42, 42, 42, 42, 40, 41, 41, 0, 41, 41, 40, 40, 40, 41, 40, 41, 41, 41, 42, 42, 0, 0, 43, 43, 43, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 44, 0, 0, 43, 0, 0, 43, 42, 0, 42, 41, 40, 40, 40, 40, 41, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 41, 41, 42, 0, 0, 43, 43, 43, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 43, 0, 0, 42, 0, 0, 41, 41, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 41, 41, 0, 42, 42, 42, 0, 0, 43, 44, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 42, 42, 41, 0, 0, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 0, 41, 41, 0, 0, 0, 43, 43, 43, 0, 0, 0, 0},
        {0, 0, 43, 0, 0, 42, 42, 42, 41, 41, 41, 40, 40, 40, 40, 40, 41, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 41, 41, 41, 42, 0, 0, 43, 43, 43, 0, 0, 0},
        {0, 0, 43, 43, 0, 0, 42, 42, 41, 41, 42, 41, 41, 41, 41, 41, 42, 41, 41, 40, 41, 40, 40, 40, 41, 41, 40, 40, 40, 40, 41, 41, 41, 41, 0, 0, 0, 43, 43, 43, 0, 0, 0},
        {0, 0, 0, 43, 42, 0, 0, 43, 43, 0, 0, 42, 41, 41, 41, 42, 42, 42, 41, 41, 41, 41, 40, 41, 41, 41, 41, 41, 40, 40, 41, 41, 41, 0, 0, 42, 0, 0, 43, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 43, 0, 0, 43, 43, 0, 0, 41, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 43, 43, 42, 0, 0, 41, 0, 0, 43, 0, 0, 43, 0, 0},
        {0, 44, 0, 0, 0, 43, 43, 0, 0, 44, 44, 43, 43, 43, 42, 42, 43, 42, 42, 43, 42, 42, 42, 43, 43, 42, 42, 42, 43, 43, 43, 0, 0, 42, 42, 42, 0, 0, 0, 43, 43, 0, 0},
        {0, 0, 0, 0, 0, 0, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 43, 43, 43, 0, 0, 43, 0, 0, 0, 0, 0, 42, 44, 43, 43, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 44, 43, 43, 0, 0, 0, 0, 0, 44, 44, 0, 0, 44, 44, 44, 0, 0, 0, 0, 44, 0, 0, 44, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 43, 43, 0, 0, 44, 0, 0, 0, 44, 0, 0, 0, 0, 0, 44, 44, 0, 0, 0, 0, 0, 44, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  };

byte nvexpo4[44][43]=//[22] y.. dupli [44], [42] x
  {
        {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, 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, 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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 44, 0, 0, 0, 0, 43, 44, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 42, 43, 43, 44, 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, 0, 0, 0, 44, 0, 0, 43, 43, 0, 0, 43, 42, 41, 42, 42, 0, 43, 43, 43, 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, 43, 0, 0, 43, 43, 0, 43, 0, 0, 42, 41, 41, 42, 0, 0, 43, 42, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 43, 0, 0, 42, 43, 42, 0, 42, 0, 0, 41, 41, 41, 42, 0, 0, 42, 42, 41, 41, 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, 42, 42, 42, 42, 40, 41, 41, 0, 41, 41, 40, 40, 40, 41, 40, 41, 41, 41, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 41, 40, 40, 40, 40, 41, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 41, 41, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 41, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 41, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 40, 40, 40, 40, 40, 41, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 41, 41, 41, 41, 41, 42, 41, 41, 40, 41, 40, 40, 40, 41, 41, 40, 40, 40, 40, 41, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 43, 0, 0, 0, 41, 41, 41, 0, 0, 42, 41, 41, 41, 0, 0, 41, 41, 41, 41, 41, 40, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 43, 43, 0, 0, 0, 0, 0, 0, 0, 0, 42, 42, 0, 0, 0, 0, 42, 42, 42, 42, 42, 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, 0, 43, 0, 0, 43, 0, 0, 0, 0, 42, 42, 0, 0, 42, 42, 0, 0, 43, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 43, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 44, 0, 0, 0, 0, 44, 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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  };

byte nvexpo5[44][43]=//[22] y.. dupli [44], [42] x
  {
        {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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 42, 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, 0, 0, 0, 0, 0, 0, 0, 43, 0, 0, 42, 0, 0, 41, 41, 41, 42, 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, 0, 0, 0, 0, 0, 0, 0, 42, 42, 40, 0, 0, 0, 41, 41, 40, 40, 40, 41, 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, 0, 0, 0, 0, 0, 40, 40, 40, 0, 0, 0, 40, 40, 0, 0, 0, 0, 0, 0, 41, 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, 0, 0, 0, 0, 40, 40, 40, 0, 0, 40, 40, 0, 0, 40, 40, 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, 0, 0, 0, 40, 0, 0, 40, 0, 0, 0, 0, 40, 40, 40, 0, 0, 40, 40, 0, 40, 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, 40, 0, 0, 40, 0, 0, 40, 40, 40, 40, 0, 0, 0, 40, 0, 0, 40, 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, 0, 0, 0, 0, 0, 0, 41, 41, 40, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 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, 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, 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, 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, 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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  };


byte nvmala[32][23]=//[16] "y" duplui[32].. [23] "X"
  {   
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0,0, 0},
        {0, 0, 0, 0, 0, 17, 17, 17, 17, 6, 6, 6, 6, 6, 6, 17, 17, 17, 0, 0, 0,0, 0},
        {0, 0, 0, 17, 17, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 17, 17, 0,0, 0},
        {0, 0, 17, 6, 6, 6, 6, 6, 6, 17, 17, 17, 17, 17, 6, 6, 6, 6, 6, 6, 17,0, 0},
        {0, 17, 6, 6, 6, 6, 6, 6, 17, 119, 119, 119, 119, 119, 17, 6, 6, 6, 6, 6, 6,17, 0},
        {17, 6, 17, 17, 17, 6, 6, 17, 119, 17, 17, 17, 17, 119, 119, 17, 6, 6, 17, 17, 17,6, 17},
        {17, 17, 118, 17, 118, 17, 6, 17, 119, 17, 40, 40, 40, 17, 119, 17, 6, 17, 118, 17, 118,17, 17},
        {17, 6, 17, 20, 17, 17, 6, 17, 119, 119, 17, 17, 17, 119, 119, 17, 6, 17, 17, 20, 17,6, 17},
        {17, 6, 17, 20, 17, 6, 6, 6, 17, 119, 119, 119, 119, 119, 17, 6, 6, 6, 17, 20, 17,6, 17},
        {17, 6, 17, 20, 17, 6, 6, 6, 6, 17, 17, 17, 17, 17, 6, 6, 6, 6, 17, 20, 17,6, 17},
        {17, 17, 17, 17, 17, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 17, 17, 17,17, 17},
        {0, 17, 17, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 17,17, 0},
        {0, 0, 17, 17, 17, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 17, 17, 17,0, 0},
        {0, 0, 0, 17, 118, 17, 17, 17, 17, 6, 6, 6, 6, 6, 17, 17, 17, 17, 118, 17, 0,0, 0},
        {0, 0, 0, 0, 17, 17, 17, 118, 118, 17, 17, 17, 17, 17, 118, 118, 17, 17, 17, 0, 0,0, 0},
        {0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0,0, 0}
  };
byte puntuacion[18][86]=//[9] "y" dupli 18.. [86]"x"
    { 
        {43, 43, 43, 43, 43, 43, 43, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 43, 43, 43, 43, 43, 43, 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, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0},
        {0, 43, 43, 43, 0, 43, 43, 43, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 43, 43, 43, 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, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0},
        {0, 43, 43, 0, 0, 43, 43, 43, 43, 43, 0, 43, 43, 43, 43, 0, 43, 43, 43, 43, 43,0, 43, 43, 43, 0, 0, 0, 0, 43, 43, 43, 0, 0, 0, 43, 43, 43, 43, 0, 43,43, 43, 43, 0, 0, 43, 43, 43, 0, 43, 43, 0, 0, 0, 0, 43, 43, 43, 0, 0,43, 43, 43, 43, 43, 0, 0, 0, 43, 43, 43, 0, 0, 0, 43, 43, 0, 43, 43, 43,0, 0, 0, 0, 0},
        {0, 43, 43, 0, 43, 43, 43, 43, 43, 43, 0, 0, 43, 43, 0, 0, 43, 43, 0, 43, 43,43, 43, 43, 43, 43, 0, 0, 43, 43, 43, 0, 0, 43, 0, 0, 43, 43, 0, 0, 43,43, 0, 0, 0, 0, 43, 43, 43, 43, 43, 43, 0, 0, 43, 43, 43, 43, 43, 0, 0,0, 43, 43, 43, 0, 0, 0, 43, 0, 43, 43, 43, 0, 0, 43, 43, 43, 43, 43, 43,43, 0, 0, 0, 0},
        {0, 43, 43, 43, 43, 43, 43, 43, 43, 43, 0, 43, 43, 43, 0, 0, 43, 43, 43, 43, 43,43, 43, 43, 43, 43, 0, 43, 43, 43, 43, 43, 43, 43, 0, 43, 43, 43, 0, 0, 43,43, 43, 43, 0, 43, 43, 43, 0, 43, 43, 43, 0, 43, 43, 43, 43, 0, 43, 0, 0,0, 43, 43, 43, 0, 0, 43, 0, 0, 43, 43, 43, 43, 0, 43, 43, 43, 43, 43, 43,43, 0, 0, 43, 43},
        {0, 43, 43, 43, 43, 43, 43, 43, 43, 0, 0, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,43, 43, 43, 43, 43, 0, 0, 43, 43, 43, 0, 0, 0, 0, 43, 43, 43, 43, 43, 43,43, 43, 43, 0, 43, 43, 43, 0, 0, 43, 43, 0, 43, 43, 43, 43, 0, 0, 0, 0,0, 43, 43, 43, 0, 0, 43, 43, 43, 43, 43, 43, 43, 0, 43, 43, 43, 43, 43, 43,43, 0, 0, 43, 43},
        {0, 43, 43, 0, 43, 43, 43, 43, 0, 0, 0, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,0, 0, 43, 43, 43, 0, 0, 43, 43, 43, 0, 0, 43, 0, 43, 43, 43, 43, 43, 43,43, 43, 43, 0, 43, 43, 43, 43, 43, 43, 43, 0, 43, 43, 43, 43, 0, 0, 43, 0,0, 43, 43, 43, 0, 0, 43, 43, 43, 43, 43, 43, 43, 0, 43, 43, 0, 0, 43, 43,43, 0, 0, 0, 0},
        {0, 43, 43, 43, 0, 0, 0, 0, 0, 0, 0, 43, 43, 43, 43, 43, 43, 43, 0, 43, 43,0, 0, 43, 43, 0, 0, 0, 43, 43, 43, 43, 43, 43, 0, 43, 43, 43, 43, 43, 43,43, 43, 0, 0, 43, 43, 43, 43, 43, 43, 43, 0, 43, 43, 43, 43, 43, 43, 43, 0,0, 43, 43, 43, 43, 0, 0, 43, 43, 43, 43, 43, 0, 0, 43, 43, 0, 0, 43, 43,0, 0, 0, 43, 43},
        {43, 43, 43, 43, 43, 43, 0, 0, 0, 0, 0, 0, 0, 43, 43, 43, 43, 0, 0, 43, 43,0, 0, 43, 43, 0, 0, 0, 0, 43, 43, 43, 43, 43, 0, 0, 0, 43, 43, 43, 43,43, 0, 0, 0, 0, 43, 43, 43, 0, 43, 43, 0, 0, 43, 43, 43, 43, 0, 43, 0,43, 43, 43, 43, 43, 0, 0, 0, 43, 43, 43, 0, 0, 0, 43, 43, 0, 0, 43, 43,0, 0, 0, 43, 43}
    };
byte salud[18][43]=//[9]"y" dupli 18..[43]"x"
  {
        {0, 43, 43, 43, 43, 43, 0, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 43,43, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 43, 43, 0, 0,0, 0},
        {43, 43, 43, 43, 43, 43, 43, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43,43, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 43, 0, 0,0, 0},
        {43, 43, 43, 43, 43, 43, 0, 0, 43, 0, 0, 0, 43, 43, 43, 0, 43, 43, 0, 0, 43,43, 0, 0, 43, 43, 43, 43, 0, 43, 43, 43, 0, 43, 43, 43, 43, 43, 43, 0, 0,0, 0},
        {43, 43, 43, 43, 43, 43, 43, 0, 0, 0, 0, 0, 43, 43, 43, 43, 43, 43, 0, 0, 43,43, 0, 0, 0, 43, 43, 0, 0, 43, 43, 0, 43, 43, 43, 0, 43, 43, 43, 0, 0,0, 0},
        {0, 43, 43, 43, 43, 43, 43, 43, 43, 0, 0, 43, 43, 43, 0, 43, 43, 43, 0, 0, 43,43, 0, 0, 43, 43, 43, 0, 0, 43, 43, 43, 43, 43, 43, 0, 0, 43, 43, 0, 0,43, 43},
        {0, 0, 0, 43, 43, 43, 43, 43, 43, 43, 0, 43, 43, 43, 0, 0, 43, 43, 0, 0, 43,43, 0, 0, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 0, 0,43, 43},
        {43, 0, 0, 0, 43, 43, 43, 43, 43, 43, 0, 43, 43, 43, 43, 43, 43, 43, 0, 0, 43,43, 0, 0, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 0, 0,0, 0},
        {0, 43, 43, 43, 43, 43, 43, 43, 43, 0, 0, 43, 43, 43, 43, 43, 43, 43, 0, 0, 43,43, 0, 0, 43, 43, 43, 43, 43, 43, 43, 0, 0, 43, 43, 43, 43, 43, 43, 0, 0,43, 43},
        {0, 43, 0, 43, 43, 43, 43, 43, 0, 0, 0, 0, 43, 43, 43, 0, 43, 43, 0, 43, 43,43, 43, 0, 0, 0, 43, 43, 43, 43, 0, 0, 0, 0, 43, 43, 43, 43, 43, 0, 0, 43, 43}
  };
byte vidas[18][45]=//[9]"y" dupli 18.. [45]"x"
  {
        {43, 43, 43, 43, 43, 0, 43, 43, 43, 43, 43, 0, 0, 43, 43, 43, 0, 0, 0, 0, 0,0, 43, 43, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0},
        {0, 43, 43, 43, 43, 0, 0, 43, 43, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 43, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0},
        {0, 43, 43, 43, 43, 0, 43, 43, 43, 43, 0, 0, 43, 43, 43, 43, 43, 0, 0, 43, 43,43, 43, 43, 43, 0, 0, 43, 43, 43, 0, 43, 43, 0, 0, 43, 43, 43, 43, 43, 0,0, 0, 0, 0},
        {0, 43, 43, 43, 43, 0, 43, 43, 43, 0, 0, 0, 0, 43, 43, 0, 0, 0, 43, 43, 43,0, 43, 43, 43, 0, 0, 43, 43, 43, 43, 43, 43, 0, 43, 43, 43, 0, 0, 43, 0,0, 0, 0, 0},
        {0, 0, 43, 43, 43, 0, 43, 43, 43, 0, 0, 0, 0, 43, 43, 0, 0, 0, 43, 43, 43,0, 0, 43, 43, 0, 43, 43, 43, 0, 43, 43, 43, 0, 43, 43, 43, 0, 0, 0, 0,0, 0, 43, 43},
        {0, 0, 43, 43, 43, 0, 43, 43, 43, 0, 0, 0, 0, 43, 43, 0, 0, 0, 43, 43, 43,43, 43, 43, 43, 0, 43, 43, 43, 0, 0, 43, 43, 0, 0, 43, 43, 43, 43, 43, 43,0, 0, 43, 43},
        {0, 0, 43, 43, 43, 43, 43, 43, 0, 0, 0, 0, 0, 43, 43, 0, 0, 0, 43, 43, 43,43, 43, 43, 43, 0, 43, 43, 43, 43, 43, 43, 43, 0, 0, 0, 0, 43, 43, 43, 43,0, 0, 0, 0},
        {0, 0, 0, 43, 43, 43, 43, 43, 0, 0, 0, 0, 0, 43, 43, 43, 43, 0, 0, 43, 43,43, 43, 43, 43, 0, 43, 43, 43, 43, 43, 43, 43, 0, 43, 0, 0, 43, 43, 43, 43,0, 0, 43, 43},
        {0, 0, 43, 43, 43, 43, 43, 43, 43, 0, 0, 0, 43, 43, 43, 43, 43, 0, 0, 0, 43,43, 43, 43, 43, 0, 0, 43, 43, 43, 0, 43, 43, 0, 43, 43, 43, 43, 43, 43, 0,0, 0, 43, 43}
  };
byte nv_vidas[20][21]=//[10]"y" dupli [20]..[21]"x"
  {
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 17, 17, 119, 27, 119, 17, 17, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 17, 17, 17, 119, 27, 27, 27, 17, 119, 17, 17, 17, 0, 0, 0, 0},
        {0, 0, 0, 17, 17, 2, 2, 17, 119, 119, 17, 119, 119, 17, 2, 2, 2, 17, 17, 0, 0},
        {0, 17, 17, 2, 2, 2, 17, 119, 119, 119, 17, 119, 119, 17, 2, 2, 2, 2, 2, 17, 0},
        {0, 17, 2, 27, 27, 27, 17, 17, 17, 17, 119, 17, 17, 17, 2, 27, 27, 27, 2, 2, 17},
        {17, 17, 17, 17, 17, 17, 17, 17, 17, 119, 119, 119, 17, 17, 17, 17, 17, 17, 17, 17, 17},
        {0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 119, 17, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0}
  };
byte bala[6][1]=
{
        {40},
        {40},
        {40},
        {40},
        {40},
        {40}
};
byte explo1[32][23]=//[16] "y dupli" 32..[23]"x"
    {
        {0, 0, 0, 41, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 0, 0, 0, 0},
        {0, 0, 41, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 0, 0, 0},
        {0, 41, 40, 40, 40, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 40, 40, 40, 41,0, 0},
        {41, 40, 40, 40, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 41, 40, 40, 40, 41, 0},
        {40, 40, 40, 41, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 41, 40, 40, 40, 41},
        {40, 40, 41, 41, 42, 42, 42, 43, 43, 43, 43, 43, 43, 43, 43, 43, 42, 42, 42, 41, 40, 40, 40},
        {40, 40, 41, 42, 42, 42, 43, 43, 44, 44, 44, 44, 44, 44, 44, 43, 43, 42, 42, 42, 41, 40, 40},
        {40, 40, 41, 42, 42, 43, 43, 44, 40, 40, 40, 40, 40, 40, 40, 44, 43, 43, 42, 42, 41, 40, 40},
        {40, 40, 41, 42, 42, 43, 43, 44, 40, 40, 40, 40, 40, 40, 40, 44, 43, 43, 42, 42, 41, 40, 40},
        {40, 40, 41, 42, 42, 42, 43, 43, 44, 44, 44, 44, 44, 44, 44, 43, 43, 42, 42, 42, 41, 40, 40},
        {40, 40, 40, 41, 42, 42, 42, 43, 43, 43, 43, 43, 43, 43, 43, 43, 42, 42, 42, 41, 40, 40, 40},
        {41, 40, 40, 40, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 41, 40, 40, 40, 41},
        {0, 41, 40, 40, 40, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 41, 40, 40, 40, 41, 0},
        {0, 0, 41, 40, 40, 40, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 40, 40, 40, 41, 0, 0},
        {0, 0, 0, 41, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 0, 0, 0},
        {0, 0, 0, 0, 41, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 0, 0, 0, 0}
      };
byte explo2[32][23]=//[16] "y dupli" 32..[23]"x"
    {
        {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, 0, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 0, 0, 0, 0, 0},
        {0, 0, 0, 40, 40, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 40, 40, 0, 0, 0, 0},
        {0, 0, 40, 40, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 41, 40, 40, 0, 0, 0},
        {0, 40, 40, 41, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 41, 40, 40, 0, 0},
        {0, 40, 41, 41, 42, 42, 42, 43, 43, 43, 43, 43, 43, 43, 43, 43, 42, 42, 42, 41, 40, 40, 0},
        {0, 40, 41, 42, 42, 42, 43, 43, 44, 44, 44, 44, 44, 44, 44, 43, 43, 42, 42, 42, 41, 40, 0},
        {0, 40, 41, 42, 42, 43, 43, 44, 40, 40, 40, 40, 40, 40, 40, 44, 43, 43, 42, 42, 41, 40, 0},
        {0, 40, 41, 42, 42, 43, 43, 44, 40, 40, 40, 40, 40, 40, 40, 44, 43, 43, 42, 42, 41, 40, 0},
        {0, 40, 41, 42, 42, 42, 43, 43, 44, 44, 44, 44, 44, 44, 44, 43, 43, 42, 42, 42, 41, 40, 0},
        {0, 40, 40, 41, 42, 42, 42, 43, 43, 43, 43, 43, 43, 43, 43, 43, 42, 42, 42, 41, 40, 40, 0},
        {0, 0, 40, 40, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 41, 40, 40, 0, 0},
        {0, 0, 0, 40, 40, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 41, 40, 40, 0, 0, 0},
        {0, 0, 0, 0, 40, 40, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 40, 40, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 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}   
    };
byte explo3[32][23]=//[16] "y dupli" 32..[23]"x"
      {
        {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, 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, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 41, 0, 0, 0, 0, 0},
        {0, 0, 0, 41, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 41, 0, 0, 0, 0},
        {0, 0, 41, 41, 42, 42, 42, 43, 43, 43, 43, 43, 43, 43, 43, 43, 42, 42, 42, 41, 0, 0, 0},
        {0, 0, 41, 42, 42, 42, 43, 43, 44, 44, 44, 44, 44, 44, 44, 43, 43, 42, 42, 42, 41, 0, 0},
        {0, 0, 41, 42, 42, 43, 43, 44, 40, 40, 40, 40, 40, 40, 40, 44, 43, 43, 42, 42, 41, 0, 0},
        {0, 0, 41, 42, 42, 43, 43, 44, 40, 40, 40, 40, 40, 40, 40, 44, 43, 43, 42, 42, 41, 0, 0},
        {0, 0, 41, 42, 42, 42, 43, 43, 44, 44, 44, 44, 44, 44, 44, 43, 43, 42, 42, 42, 41, 0, 0},
        {0, 0, 0, 41, 42, 42, 42, 43, 43, 43, 43, 43, 43, 43, 43, 43, 42, 42, 42, 41, 0, 0, 0},
        {0, 0, 0, 0, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 41, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 41, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 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, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
      }; 
byte explo4[32][23]=//[16] "y dupli" 32..[23]"x"
  {
        {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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 42, 42, 43, 43, 43, 43, 43, 43, 43, 43, 43, 42, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 42, 42, 43, 43, 44, 44, 44, 44, 44, 44, 44, 43, 43, 42, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 42, 43, 43, 44, 40, 40, 40, 40, 40, 40, 40, 44, 43, 43, 42, 0, 0, 0, 0},
        {0, 0, 0, 0, 42, 43, 43, 44, 40, 40, 40, 40, 40, 40, 40, 44, 43, 43, 42, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 42, 43, 43, 44, 44, 44, 44, 44, 44, 44, 43, 43, 42, 42, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 42, 43, 43, 43, 43, 43, 43, 43, 43, 43, 42, 42, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 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, 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},
        {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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  };
 
byte cero[20][12]=//[10] "y dupli" 20..[12]"x"
  {
        {0, 0, 0, 16, 16, 16, 16, 16, 16, 0, 0, 0},
        {0, 0, 16, 2, 2, 2, 16, 2, 2, 16, 0, 0},
        {0, 16, 2, 2, 2, 16, 0, 16, 16, 2, 16, 0},
        {0, 16, 2, 2, 2, 16, 16, 0, 16, 2, 16, 0},
        {16, 2, 2, 2, 2, 2, 16, 16, 16, 2, 2, 16},
        {16, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 16},
        {0, 16, 2, 2, 2, 2, 2, 2, 2, 2, 16, 0},
        {0, 16, 2, 2, 2, 2, 2, 2, 2, 2, 16, 0},
        {0, 0, 16, 2, 2, 2, 2, 2, 2, 16, 0, 0},
        {0, 0, 0, 16, 16, 16, 16, 16, 16, 0, 0, 0}
  };
 
byte uno[20][12]=//[10] "y dupli" 20..[12]"x"
  {
        {0, 0, 0, 0, 16, 16, 16, 0, 0, 0, 0, 0},
        {0, 0, 16, 16, 2, 2, 16, 0, 0, 0, 0, 0},
        {16, 16, 16, 2, 2, 2, 16, 0, 0, 0, 0, 0},
        {0, 0, 16, 2, 2, 2, 16, 0, 0, 0, 0, 0},
        {0, 0, 16, 2, 2, 2, 16, 0, 0, 0, 0, 0},
        {0, 0, 16, 2, 2, 2, 16, 0, 0, 0, 0, 0},
        {0, 0, 16, 2, 2, 16, 0, 0, 0, 0, 0, 0},
        {0, 0, 16, 2, 2, 16, 0, 0, 0, 0, 0, 0},
        {0, 0, 16, 2, 2, 16, 0, 0, 0, 0, 0, 0},
        {0, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0, 0}
  };

byte dos[20][12]=//[10] "y dupli" 20..[12]"x"
  {
        {0, 0, 0, 16, 16, 16, 16, 16, 16, 0, 0, 0},
        {0, 16, 16, 2, 16, 16, 2, 2, 2, 16, 0, 0},
        {0, 16, 2, 16, 0, 16, 2, 2, 2, 16, 0, 0},
        {0, 16, 16, 0, 0, 16, 2, 2, 2, 16, 0, 0},
        {0, 0, 16, 0, 16, 2, 2, 2, 2, 16, 16, 0},
        {0, 0, 0, 0, 16, 2, 2, 2, 16, 2, 16, 0},
        {0, 0, 0, 16, 2, 2, 16, 16, 2, 16, 16, 0},
        {0, 0, 16, 2, 16, 16, 16, 16, 16, 2, 16, 0},
        {0, 16, 2, 2, 16, 2, 2, 2, 2, 2, 16, 0},
        {16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0}
  };

byte tres[20][12]=//[10] "y dupli" 20..[12]"x"
  {
        {0, 0, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0},
        {0, 16, 16, 2, 16, 16, 2, 2, 2, 16, 0, 0},
        {0, 16, 2, 16, 0, 0, 16, 2, 2, 16, 0, 0},
        {0, 16, 16, 0, 0, 16, 16, 2, 16, 16, 0, 0},
        {0, 16, 0, 0, 16, 16, 2, 16, 16, 16, 0, 0},
        {0, 0, 0, 16, 16, 16, 16, 2, 2, 2, 16, 0},
        {16, 0, 0, 16, 16, 0, 16, 2, 2, 2, 16, 0},
        {16, 16, 16, 0, 0, 0, 16, 2, 2, 2, 16, 0},
        {0, 16, 2, 16, 16, 16, 2, 2, 2, 16, 0, 0},
        {0, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0}
  };

byte cuatro[20][12]=//[10] "y dupli" 20..[12]"x"
  {
        {0, 0, 0, 0, 0, 16, 16, 16, 16, 16, 16, 0},
        {0, 0, 0, 0, 16, 2, 2, 2, 2, 16, 0, 0},
        {0, 0, 0, 16, 2, 2, 16, 2, 2, 16, 0, 16},
        {0, 0, 16, 2, 2, 16, 16, 2, 2, 16, 16, 16},
        {0, 0, 16, 2, 16, 16, 16, 2, 2, 16, 2, 16},
        {0, 16, 2, 16, 16, 2, 2, 2, 2, 2, 2, 16},
        {0, 16, 16, 16, 16, 16, 16, 2, 16, 16, 16, 16},
        {0, 0, 0, 0, 0, 0, 16, 2, 2, 16, 0, 16},
        {0, 0, 0, 0, 0, 16, 2, 2, 2, 16, 0, 0},
        {0, 0, 0, 0, 16, 16, 16, 16, 16, 16, 16, 0}
  };

byte cinco[20][12]=//[10] "y dupli" 20..[12]"x"
  {
        {0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0},
        {0, 16, 2, 16, 2, 2, 2, 2, 2, 16, 0, 0},
        {0, 16, 2, 16, 16, 16, 16, 16, 16, 16, 0, 0},
        {0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0},
        {16, 2, 2, 16, 16, 2, 2, 2, 2, 16, 0, 0},
        {16, 16, 16, 0, 0, 16, 2, 2, 2, 2, 16, 0},
        {0, 16, 16, 0, 0, 0, 16, 2, 2, 2, 16, 0},
        {0, 16, 2, 16, 16, 16, 2, 2, 2, 2, 16, 0},
        {16, 16, 16, 2, 2, 2, 2, 2, 2, 16, 0, 0},
        {16, 0, 0, 16, 16, 16, 16, 16, 16, 0, 0, 0}
  };

byte seis[20][12]=//[10] "y dupli" 20..[12]"x"
  {
        {0, 0, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0},
        {0, 16, 16, 2, 16, 16, 16, 2, 16, 0, 0, 0},
        {16, 2, 2, 16, 0, 0, 0, 16, 0, 0, 0, 0},
        {16, 2, 2, 16, 16, 16, 16, 16, 16, 0, 0, 0},
        {16, 2, 2, 16, 16, 16, 16, 2, 2, 16, 0, 0},
        {16, 2, 2, 2, 16, 2, 16, 2, 2, 2, 16, 0},
        {16, 2, 2, 16, 16, 16, 2, 2, 2, 2, 16, 0},
        {16, 2, 2, 2, 2, 2, 2, 2, 2, 16, 16, 0},
        {0, 16, 2, 2, 2, 2, 2, 2, 16, 16, 0, 0},
        {0, 0, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0},
    };

byte siete[20][12]=//[10] "y dupli" 20..[12]"x"
  {
        {16, 0, 0, 16, 16, 16, 16, 16, 16, 16, 16, 0},
        {16, 16, 16, 2, 2, 2, 2, 2, 2, 16, 0, 0},
        {16, 2, 2, 2, 2, 16, 16, 16, 2, 16, 0, 0},
        {0, 16, 16, 16, 16, 0, 16, 2, 2, 16, 0, 0},
        {0, 16, 16, 0, 0, 16, 2, 2, 16, 0, 0, 0},
        {0, 16, 0, 0, 0, 16, 2, 2, 16, 0, 0, 0},
        {0, 16, 0, 0, 16, 2, 2, 2, 16, 0, 0, 0},
        {0, 0, 0, 16, 2, 2, 2, 16, 0, 0, 0, 0},
        {0, 0, 16, 16, 2, 2, 2, 16, 0, 0, 0, 0},
        {0, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0}
    };

byte ocho[20][12]=//[10] "y dupli" 20..[12]"x"
  {
        {0, 0, 16, 16, 16, 16, 16, 16, 0, 0, 0, 0},
        {0, 0, 16, 0, 16, 16, 2, 2, 16, 0, 0, 0},
        {0, 0, 16, 16, 16, 2, 2, 2, 16, 0, 0, 0},
        {0, 0, 16, 16, 2, 2, 2, 16, 16, 0, 0, 0},
        {0, 16, 2, 2, 2, 2, 16, 16, 2, 16, 0, 0},
        {16, 2, 2, 2, 2, 2, 16, 0, 16, 2, 16, 0},
        {16, 2, 2, 2, 2, 2, 2, 16, 16, 16, 16, 0},
        {16, 2, 2, 2, 2, 2, 2, 2, 2, 2, 16, 0},
        {16, 16, 2, 2, 2, 2, 2, 2, 2, 16, 0, 0},
        {0, 0, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0}
    };

byte nueve[20][12]=//[10] "y dupli" 20..[12]"x"
  {
        {0, 0, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0},
        {0, 16, 2, 2, 2, 2, 2, 2, 2, 16, 0, 0},
        {16, 16, 2, 2, 2, 2, 2, 2, 2, 2, 16, 0},
        {16, 2, 2, 2, 2, 16, 16, 16, 2, 2, 16, 0},
        {16, 2, 2, 2, 2, 16, 16, 16, 2, 2, 16, 0},
        {0, 16, 2, 2, 2, 2, 2, 16, 16, 2, 16, 0},
        {0, 16, 16, 16, 16, 16, 16, 16, 2, 2, 16, 0},
        {0, 16, 16, 16, 0, 0, 16, 16, 2, 2, 16, 0},
        {0, 0, 16, 2, 16, 16, 2, 2, 16, 16, 0, 0},
        {0, 0, 16, 16, 16, 16, 16, 16, 0, 0, 0, 0}
  };

 
/*********************************************************/**************************************************************************
 *  Video MCGA  200*320                                                  *           
 *                                                                        *
 **************************************************************************/
void video(int tipo)
{
  REGS entrada,salida;
  entrada.h.ah = 0;
  entrada.h.al = tipo;
  int86(0x10,&entrada,&salida);
}
/*********************************************************/**************************************************************************
 *  Checa si escribiste una tecla y cual es                              *
 *    Si no continua con el proceso                                      *
 **************************************************************************/
int checa_tecla(char &c, byte &sc)
{ struct REGS en,sal;

  en.h.ah = 1;
  int86(22,&en,&sal);
  if (!(sal.x.flags&64))
  {
  en.h.ah = 0;
  int86(0x16,&en,&sal);
  c = sal.h.al;
  sc= sal.h.ah;
  }
  return !(sal.x.flags&64);
}
/*********************************************************/**************************************************************************
 *  Escribe el fondo                                                      *
 *    Hace que gire                                                      *
 **************************************************************************/
void fondo(int color,int cont2)
{
  for(int i=0; i<200; i++)
  {
    for(int c=0;c<320;c++)
    {
      char far *ptr=(char far*)0x0A0000000;
      ptr+=i*320+c;
      *ptr=color;
    }
    if(color==17)
      {cont2=0;}
    if(color==30)
      {cont2=1;}
    if(cont2==0)
      {color=color+1;}
    if(cont2==1)
      {color=color-1;}
  }
}
/*********************************************************/**************************************************************************
 *  Respaldo Puntuacion                                                  *
 *                                                                        *
 **************************************************************************/
void respunt(byte oso[18][86], int renglon, int columna)//oso[44]"Y" [43]"X"
{
  char far *ptr = (char far *)0xA0000000;  //ptr apunta a inicio de MCGA

  ptr += 320*renglon + columna;

  for (int i=0;i<9;i++)//"Y" mitad
  {
      for (int j=0;j<86;j++)//"X"
      {
          oso[9+i][j] = *ptr;
          ptr++;
      }
      ptr += 320 - 86;//"X"
    }
}
/*********************************************************/**************************************************************************
 *  Escribe Puntuacion                                                    *
 *                                                                        *
 **************************************************************************/
void MCGApunt(byte nave[9][86], int r, int c)//nave[44]"y" [43]"x"
{
    char far *ptr = (char far *)0x0A0000000;
  ptr+=320*r+c;
    for (unsigned int i=0;i<9;i++)//"y"
    {
      for (unsigned int j=0;j<86;j++)//"X"
      {
        if (nave[i][j]==0)
          {
            *ptr=nave[i+9][j];//"Y"
          }
        else
          *ptr = nave[i][j];
            ptr++;
      }
    ptr+=320-86;//"X"
    }
}
/*********************************************************/**************************************************************************
 *  Respaldo Salud                                                        *
 *                                                                        *
 **************************************************************************/
void respsalud(byte oso[18][43], int renglon, int columna)//oso[18]"Y" [43]"X"
{
  char far *ptr = (char far *)0xA0000000;  //ptr apunta a inicio de MCGA

  ptr += 320*renglon + columna;

  for (int i=0;i<9;i++)//"Y" mitad
  {
      for (int j=0;j<43;j++)//"X"
      {
          oso[9+i][j] = *ptr;
          ptr++;
      }
      ptr += 320 - 43;//"X"
    }
}
/*********************************************************/**************************************************************************
 *  Escribe Salud                                                        *
 *                                                                        *
 **************************************************************************/
void MCGAsalud(byte nave[9][43], int r, int c)//nave[9]"y" [43]"x"
{
    char far *ptr = (char far *)0x0A0000000;
  ptr+=320*r+c;
    for (unsigned int i=0;i<9;i++)//"y"
    {
      for (unsigned int j=0;j<43;j++)//"X"
      {
        if (nave[i][j]==0)
          {
            *ptr=nave[i+9][j];//"Y"
          }
        else
          *ptr = nave[i][j];
            ptr++;
      }
    ptr+=320-43;//"X"
    }
}
/*********************************************************/**************************************************************************
 *  Respaldo Vidas                                                        *
 *                                                                        *
 **************************************************************************/
void respvidas(byte oso[18][45], int renglon, int columna)//oso[18]"Y" [45]"X"
{
  char far *ptr = (char far *)0xA0000000;  //ptr apunta a inicio de MCGA

  ptr += 320*renglon + columna;

  for (int i=0;i<9;i++)//"Y" mitad
  {
      for (int j=0;j<45;j++)//"X"
      {
          oso[9+i][j] = *ptr;
          ptr++;
      }
      ptr += 320 - 45;//"X"
    }
}
/*********************************************************/**************************************************************************
 *  Escribe Vidas                                                        *
 *                                                                        *
 **************************************************************************/
void MCGAvidas(byte nave[9][45], int r, int c)//nave[9]"y" [45]"x"
{
    char far *ptr = (char far *)0x0A0000000;
  ptr+=320*r+c;
    for (unsigned int i=0;i<9;i++)//"y"
    {
      for (unsigned int j=0;j<45;j++)//"X"
      {
        if (nave[i][j]==0)
          {
            *ptr=nave[i+9][j];//"Y"
          }
        else
          *ptr = nave[i][j];
            ptr++;
      }
    ptr+=320-45;//"X"
    }
}
/*********************************************************/**************************************************************************
 *  Respaldo Nave chica VIDAS                                            *
 *                                                                        *
 **************************************************************************/
void respnv_vidas(byte oso[20][21], int renglon, int columna)//oso[20]"Y" [21]"X"
{
  char far *ptr = (char far *)0xA0000000;  //ptr apunta a inicio de MCGA

  ptr += 320*renglon + columna;

  for (int i=0;i<10;i++)//"Y" mitad
  {
      for (int j=0;j<21;j++)//"X"
      {
          oso[10+i][j] = *ptr;
          ptr++;
      }
      ptr += 320 - 21;//"X"
    }
}
/*********************************************************/**************************************************************************
 *  Escribe Nave chica VIDAS                                              *
 *                                                                        *
 **************************************************************************/
void MCGAnv_vidas(byte nave[10][21], int r, int c)//nave[10]"y" [21]"x"
{
    char far *ptr = (char far *)0x0A0000000;
  ptr+=320*r+c;
    for (unsigned int i=0;i<10;i++)//"y"
    {
      for (unsigned int j=0;j<21;j++)//"X"
      {
        if (nave[i][j]==0)
          {
            *ptr=nave[i+10][j];//"Y"
          }
        else
          *ptr = nave[i][j];
            ptr++;
      }
    ptr+=320-21;//"X"
    }
}
/*********************************************************/**************************************************************************
 *  Escribe Linea Nave Buenas chicas Vidas                                *
 *                                                                        *
 **************************************************************************/
void filanvvidas(int x, int vidas)
{
  for (int w=0; w<vidas; w++)
  {
    MCGAnv_vidas(nv_vidas,0,x);//nave mala,y,x
    x+=23;
  }
}
/*********************************************************/**************************************************************************
 *  Respaldo Nave buena                                                  *
 *                                                                        *
 **************************************************************************/
void respnvbuena(byte oso[44][43], int renglon, int columna)//oso[44]"Y" [43]"X"
{
  char far *ptr = (char far *)0xA0000000;  //ptr apunta a inicio de MCGA

  ptr += 320*renglon + columna;

  for (int i=0;i<21;i++)//"Y" mitad
  {
      for (int j=0;j<43;j++)//"X"
      {
          oso[22+i][j] = *ptr;
          ptr++;
      }
      ptr += 320 - 43;//"X"
    }
}
/*********************************************************/**************************************************************************
 *  Escribe Nave Buena                                                    *
 *                                                                        *
 **************************************************************************/
void MCGAnvbuena(byte nave[22][43], int r, int c)//nave[44]"y" [43]"x"
{
    char far *ptr = (char far *)0x0A0000000;
  ptr+=320*r+c;
    for (unsigned int i=0;i<21;i++)//"y"
    {
      for (unsigned int j=0;j<43;j++)//"X"
      {
        if (nave[i][j]==0)
          {
            *ptr=nave[i+22][j];//"Y"
          }
        else
          *ptr = nave[i][j];
            ptr++;
      }
    ptr+=320-43;//"X"
    }
}
/*********************************************************/**************************************************************************
 *  Respaldo Nave Mala                                                    *
 *                                                                        *
 **************************************************************************/
void respnvmala(byte oso[32][23], int renglon, int columna)//oso[32]"Y" [23]"X"
{
  char far *ptr = (char far *)0xA0000000;  //ptr apunta a inicio de MCGA

  ptr += 320*renglon + columna;

  for (int i=0;i<16;i++)//"Y" mitad
  {
      for (int j=0;j<23;j++)//"X"
      {
          oso[16+i][j] = *ptr;
          ptr++;
      }
      ptr += 320 - 23;//"X"
    }
}
/*********************************************************/**************************************************************************
 *  Escribe Nave Mala                                                    *
 *                                                                        *
 **************************************************************************/
void MCGAnvmala(byte nave[16][23], int r, int c)//nave[16]"y" [23]"x"
{
    char far *ptr = (char far *)0x0A0000000;
  ptr+=320*r+c;
    for (unsigned int i=0;i<16;i++)//"y"
    {
      for (unsigned int j=0;j<23;j++)//"X"
      {
        if (nave[i][j]==0)
          {
            *ptr=nave[i+16][j];//"Y"
          }
        else
          *ptr = nave[i][j];
            ptr++;
      }
    ptr+=320-23;//"X"
    }
}
/*********************************************************/**************************************************************************
 *  Respaldo Explocion Nave Mala                                          *
 *                                                                        *
 **************************************************************************/
void respexplo(byte oso[32][23], int renglon, int columna)//oso[32]"Y" [23]"X"
{
  char far *ptr = (char far *)0xA0000000;  //ptr apunta a inicio de MCGA

  ptr += 320*renglon + columna;

  for (int i=0;i<16;i++)//"Y" mitad
  {
      for (int j=0;j<23;j++)//"X"
      {
          oso[16+i][j] = *ptr;
          ptr++;
      }
      ptr += 320 - 23;//"X"
    }
}
/*********************************************************/**************************************************************************
 *  Escribe explocion                                                    *
 *                                                                        *
 **************************************************************************/
void MCGAexplo(byte nave[16][23], int r, int c)//nave[16]"y" [23]"x"
{
    char far *ptr = (char far *)0x0A0000000;
  ptr+=320*r+c;
    for (unsigned int i=0;i<16;i++)//"y"
    {
      for (unsigned int j=0;j<23;j++)//"X"
      {
        if (nave[i][j]==0)
          {
            *ptr=nave[i+16][j];//"Y"
          }
        else
          *ptr = nave[i][j];
            ptr++;
      }
    ptr+=320-23;//"X"
    }
}
/*********************************************************/**************************************************************************
 *  Mueve Naves Malas                                                    *
 *                                                                        *
 **************************************************************************/
void muevenvmalas(int &p,int &cont2,int vel,int &y3,int &y2,int &y1,int izq,int dere)//0-147
{
   
    if(p==izq)
      {cont2=0;y3=y3+5;y2=y2+5;y1=y1+5;}
    if(p>=dere)
      {cont2=1;y3=y3+5;y2=y2+5;y1=y1+5;}
    if(cont2==0)
      {p=p+vel;}
    if(cont2==1)
      {p=p-vel;}
}
/*********************************************************/**************************************************************************
 *  Escribe Balas Nave Buena                                              *
 *                                                                        *
 **************************************************************************/
void balamover(byte nbbala[6][1],int r,int c)// bala
  {
    char far *ptr = (char far *)0x0A0000000;
  ptr+=320*r+c;
    for (unsigned int i=0;i<6;i++)//"y"
    {
      for (unsigned int j=0;j<1;j++)//"X"
      {
        *ptr = nbbala[i][j];
              ptr++;
      }
    ptr+=320-1;//"X"
    }
  }
/*********************************************************/**************************************************************************
 *  Elimina la fila de las naves malas y Escribe Explosion 3              *
 *                                                                        *
 **************************************************************************/
void eliminanv3(byte nvmala[16][23],int &p,int &h,int &a3,int &b3,int &c3,int &d3,int &e3,int &f3,int &by,int &bx,int &sum,int &exp,int &col,int &cont,int y3, float &punt)// 1 renglon de naves
{
respnvmala(nvmala,y3,p);//nave mala,y,x
       
        //***************************************** nave 2,1
        if(a3==1 && ((by<y3+16 && by>y3) && (bx>p && bx<p+23)))
            {a3=0;by=0;sum=sum+1;exp=1;punt=punt+1.8;}

        //***************************************** nave 2,2
        if(b3==1 && ((by<y3+16 && by>y3) && (bx>p+30 && bx<p+53)))
            {b3=0;by=0;sum=sum+1;exp=1;punt=punt+1.8;}
        //***************************************** nave 2,3
        if(c3==1 && ((by<y3+16 && by>y3) && (bx>p+60 && bx<p+83)))
            {c3=0;by=0;sum=sum+1;exp=1;punt=punt+1.8;}

        //***************************************** nave 2,4
        if(d3==1 && ((by<y3+16 && by>y3) && (bx>p+90 && bx<p+113)))
            {d3=0;by=0;sum=sum+1;exp=1;punt=punt+1.8;}

        //***************************************** nave 2,5
        if(e3==1 && ((by<y3+16 && by>y3) && (bx>p+120 && bx<p+143)))
            {e3=0;by=0;sum=sum+1;exp=1;punt=punt+1.8;}

        //***************************************** nave 2,6
        if(f3==1 && ((by<y3+16 && by>y3) && (bx>p+150 && bx<p+173)))
            {f3=0;by=0;sum=sum+1;exp=1;punt=punt+1.8;}
   
        //***************************************** eliminando naves
        if(a3==1)
            MCGAnvmala(nvmala,y3,p);// 1 nave mala,y,x
        if(b3==1)   
            MCGAnvmala(nvmala,y3,p+30);// 2 nave mala,y,x
        if(c3==1)
            MCGAnvmala(nvmala,y3,p+60);// 3 nave mala,y,x
        if(d3==1)   
            MCGAnvmala(nvmala,y3,p+90);// 4 nave mala,y,x
        if(e3==1)   
            MCGAnvmala(nvmala,y3,p+120);// 5 nave mala,y,x
        if(f3==1)   
            MCGAnvmala(nvmala,y3,p+150);// 6 nave mala,y,x
     
        if(exp==4)
            {respexplo(explo4,y3,col);
            MCGAexplo(explo4,y3,col);
            exp=0;}
          if(exp==3)
            {respexplo(explo3,y3,col);
            MCGAexplo(explo3,y3,col);
            exp=4;}
          if(exp==2)
            {respexplo(explo2,y3,col);
            MCGAexplo(explo2,y3,col);
            exp=3;} 
          if(exp==1)
          {
            respexplo(explo1,y3,p);//nave mala,y,x
            if(a3==0)
              {MCGAexplo(explo1,y3,p);
              cont++;
              if(cont==4)
              {a3=2;exp=2;col=p;cont=0;}}
            if(b3==0)   
              {MCGAexplo(explo1,y3,p+30);
              cont++;
              if(cont==4)
              {b3=2;exp=2;col=p+y3;cont=0;}}
            if(c3==0)
              {MCGAexplo(explo1,y3,p+60);
              cont++;
              if(cont==4)
              {c3=2;exp=2;col=p+60;cont=0;}}
            if(d3==0)   
              {MCGAexplo(explo1,y3,p+90);
              cont++;
              if(cont==4)
              {d3=2;exp=2;col=p+90;cont=0;}}
            if(e3==0)   
              {MCGAexplo(explo1,y3,p+120);
              cont++;
              if(cont==4)
              {e3=2;exp=2;col=p+120;cont=0;}}
            if(f3==0)   
              {MCGAexplo(explo1,y3,p+150);
              cont++;
              if(cont==4)
              {f3=2;exp=2;col=p+150;cont=0;}}
            }
         
}
/*********************************************************/**************************************************************************
 *  Elimina la fila de las naves malas y Escribe Explosion 2              *
 *                                                                        *
 **************************************************************************/
void eliminanv2(byte nvmala[16][23],int &p,int &h,int &a2,int &b2,int &c2,int &d2,int &e2,int &f2,int &by,int &bx,int &sum,int &exp,int &col,int &cont, int y2, float &punt)// 2 renglon de naves
{
respnvmala(nvmala,y2,p);//nave mala,y,x
     
       
        //***************************************** nave 2,1
        if(a2==1 && ((by<y2+16 && by>y2) && (bx>p && bx<p+23)))
            {a2=0;by=0;sum=sum+1;exp=1;punt=punt+1.8;}

        //***************************************** nave 2,2
        if(b2==1 && ((by<y2+16 && by>y2) && (bx>p+30 && bx<p+53)))
            {b2=0;by=0;sum=sum+1;exp=1;punt=punt+1.8;}
        //***************************************** nave 2,3
        if(c2==1 && ((by<y2+16 && by>y2) && (bx>p+60 && bx<p+83)))
            {c2=0;by=0;sum=sum+1;exp=1;punt=punt+1.8;}

        //***************************************** nave 2,4
        if(d2==1 && ((by<y2+16 && by>y2) && (bx>p+90 && bx<p+113)))
            {d2=0;by=0;sum=sum+1;exp=1;punt=punt+1.8;}

        //***************************************** nave 2,5
        if(e2==1 && ((by<y2+16 && by>y2) && (bx>p+120 && bx<p+143)))
            {e2=0;by=0;sum=sum+1;exp=1;punt=punt+1.8;}

        //***************************************** nave 2,6
        if(f2==1 && ((by<y2+16 && by>y2) && (bx>p+150 && bx<p+173)))
            {f2=0;by=0;sum=sum+1;exp=1;punt=punt+1.8;}
   
        //***************************************** eliminando naves
        if(a2==1)
            MCGAnvmala(nvmala,y2,p);// 1 nave mala,y,x
        if(b2==1)   
            MCGAnvmala(nvmala,y2,p+30);// 2 nave mala,y,x
        if(c2==1)
            MCGAnvmala(nvmala,y2,p+60);// 3 nave mala,y,x
        if(d2==1)   
            MCGAnvmala(nvmala,y2,p+90);// 4 nave mala,y,x
        if(e2==1)   
            MCGAnvmala(nvmala,y2,p+120);// 5 nave mala,y,x
        if(f2==1)   
            MCGAnvmala(nvmala,y2,p+150);// 6 nave mala,y,x
       
           
          if(exp==4)
            {respexplo(explo4,y2,col);
            MCGAexplo(explo4,y2,col);
            exp=0;}
          if(exp==3)
            {respexplo(explo3,y2,col);
            MCGAexplo(explo3,y2,col);
            exp=4;}
          if(exp==2)
            {respexplo(explo2,y2,col);
            MCGAexplo(explo2,y2,col);
            exp=3;} 
         
          if(exp==1)
          {
            respexplo(explo1,y2,p);//nave mala,y,x
            if(a2==0)
              {MCGAexplo(explo1,y2,p);
              cont++;
              if(cont==4)
              {a2=2;exp=2;col=p;cont=0;}}
            if(b2==0)   
              {MCGAexplo(explo1,y2,p+30);
              cont++;
              if(cont==4)
              {b2=2;exp=2;col=p+30;cont=0;}}
            if(c2==0)
              {MCGAexplo(explo1,y2,p+60);
              cont++;
              if(cont==4)
              {c2=2;exp=2;col=p+60;cont=0;}}
            if(d2==0)   
              {MCGAexplo(explo1,y2,p+90);
              cont++;
              if(cont==4)
              {d2=2;exp=2;col=p+90;cont=0;}}
            if(e2==0)   
              {MCGAexplo(explo1,y2,p+120);
              cont++;
              if(cont==4)
              {e2=2;exp=2;col=p+120;cont=0;}}
            if(f2==0)   
              {MCGAexplo(explo1,y2,p+150);
              cont++;
              if(cont==4)
              {f2=2;exp=2;col=p+150;cont=0;}}
            }
}
/*********************************************************/**************************************************************************
 *  Elimina la fila de las naves malas y Escribe Explocion 1              *
 *                                                                        *
 **************************************************************************/
void eliminanv1(byte nvmala[16][23],int &p,int &h,int &a1,int &b1,int &c1,int &d1,int &e1,int &f1,int &by,int &bx,int &sum,int &exp,int &col,int &cont,int y1,float &punt)// 3 renglon de naves
{
respnvmala(nvmala,y1,p);//nave mala,y,x
   
     
        //***************************************** nave 1,1
        if(a1==1 && ((by<y1+16 && by>y1)  && (bx>p && bx<p+23)))
            {a1=0;by=0;sum=sum+1;exp=1;punt=punt+1.8;}

        //***************************************** nave 1,2
        if(b1==1 && ((by<y1+16 && by>y1) && (bx>p+30 && bx<p+53)))
            {b1=0;by=0;sum=sum+1;exp=1;punt=punt+1.8;}

        //***************************************** nave 1,3
        if(c1==1 && ((by<y1+16 && by>y1) && (bx>p+60 && bx<p+83)))
            {c1=0;by=0;sum=sum+1;exp=1;punt=punt+1.8;}

        //***************************************** nave 1,4
        if(d1==1 && ((by<y1+16 && by>y1) && (bx>p+90 && bx<p+113)))
            {d1=0;by=0;sum=sum+1;exp=1;punt=punt+1.8;}

        //***************************************** nave 1,5
        if(e1==1 && ((by<y1+16 && by>y1) && (bx>p+120 && bx<p+143)))
            {e1=0;by=0;sum=sum+1;exp=1;punt=punt+1.8;}

        //***************************************** nave 1,6
        if(f1==1 && ((by<y1+16 && by>y1) && (bx>p+150 && bx<p+173)))
            {f1=0;by=0;sum=sum+1;exp=1;punt=punt+1.8;}
   
        //***************************************** eliminando naves
        if(a1==1)
            MCGAnvmala(nvmala,y1,p);// 1 nave mala,y,x
        if(b1==1)   
            MCGAnvmala(nvmala,y1,p+30);// 2 nave mala,y,x
        if(c1==1)
            MCGAnvmala(nvmala,y1,p+60);// 3 nave mala,y,x
        if(d1==1)   
            MCGAnvmala(nvmala,y1,p+90);// 4 nave mala,y,x
        if(e1==1)   
            MCGAnvmala(nvmala,y1,p+120);// 5 nave mala,y,x
        if(f1==1)   
            MCGAnvmala(nvmala,y1,p+150);// 6 nave mala,y,x
       
   
          if(exp==4)
            {respexplo(explo4,y1,col);
            MCGAexplo(explo4,y1,col);
            exp=0;}
          if(exp==3)
            {respexplo(explo3,y1,col);
            MCGAexplo(explo3,y1,col);
            exp=4;}
          if(exp==2)
            {respexplo(explo2,y1,col);
            MCGAexplo(explo2,y1,col);
            exp=3;} 
         
          if(exp==1)
          {
            respexplo(explo1,y1,p);//nave mala,y,x
            if(a1==0)
              {MCGAexplo(explo1,y1,p);
              cont++;
              if(cont==4)
              {a1=2;exp=2;col=p;cont=0;}}
            if(b1==0)   
              {MCGAexplo(explo1,y1,p+30);
              cont++;
              if(cont==4)
              {b1=2;exp=2;col=p+30;cont=0;}}
            if(c1==0)
              {MCGAexplo(explo1,y1,p+60);
              cont++;
              if(cont==4)
              {c1=2;exp=2;col=p+60;cont=0;}}
            if(d1==0)   
              {MCGAexplo(explo1,y1,p+90);
              cont++;
              if(cont==4)
              {d1=2;exp=2;col=p+90;cont=0;}}
            if(e1==0)   
              {MCGAexplo(explo1,y1,p+120);
              cont++;
              if(cont==4)
              {e1=2;exp=2;col=p+120;cont=0;}}
            if(f1==0)   
              {MCGAexplo(explo1,y1,p+150);
              cont++;
              if(cont==4)
              {f1=2;exp=2;col=p+150;cont=0;}}
            }
         
}
/*********************************************************/**************************************************************************
 *  Escribe Balas Nave Mala                                              *
 *                                                                        *
 **************************************************************************/
void balamala(byte nbbala[6][1],int r,int c)// bala
  {
    char far *ptr = (char far *)0x0A0000000;
  ptr+=320*r+c;
    for (unsigned int i=0;i<6;i++)//"y"
    {
      for (unsigned int j=0;j<1;j++)//"X"
      {
        *ptr = nbbala[i][j];
              ptr++;
      }
    ptr+=320-1;//"X"
    }
  }
/*********************************************************/**************************************************************************
 *  Escribe Balas Naves Malas 3                                            *
 *                                                                        *
 **************************************************************************/
void balasmalas3(int &rev, int &n, int &n1,int &n2,int &bm,int &a1,int &b1,int &c1,int &d1,int &e1,int &f1, int &h, int &p, int vel,int y3)
{
      if(rev==1)
        {do{n=random(7);}while(n==0);}
     
      if(h==34)
      {
        if(bm==y3)
        {
        if(n==1 && a1==1)
        {n1=p+3;n2=p+19;}
        if(n==2 && b1==1)
        {n1=p+33;n2=p+49;}
        if(n==3 && c1==1)
        {n1=p+63;n2=p+79;}
        if(n==4 && d1==1)
        {n1=p+93;n2=p+109;}
        if(n==5 && e1==1)
        {n1=p+123;n2=p+139;}
        if(n==6 && f1==1)
        {n1=p+153;n2=p+169;}
        }
       
        if(n==1 && a1==1)
        {balamala(bala,bm,n1);
        balamala(bala,bm,n2);rev=0;}
        if(n==2 && b1==1)
        {balamala(bala,bm,n1);
        balamala(bala,bm,n2);rev=0;}
        if(n==3 && c1==1)
        {balamala(bala,bm,n1);
        balamala(bala,bm,n2);rev=0;}
        if(n==4 && d1==1)
        {balamala(bala,bm,n1);
        balamala(bala,bm,n2);rev=0;}
        if(n==5 && e1==1)
        {balamala(bala,bm,n1);
        balamala(bala,bm,n2);rev=0;}
        if(n==6 && f1==1)
        {balamala(bala,bm,n1);
        balamala(bala,bm,n2);rev=0;}
      }
      bm=bm+vel;
      if(bm>190)
        {bm=y3;rev=1;n1=0;n2=0;}
}
/*********************************************************/**************************************************************************
 *  Escribe Balas Naves Malas 2                                            *
 *                                                                        *
 **************************************************************************/
void balasmalas2(int &rev, int &n, int &n1,int &n2,int &bm,int &a1,int &b1,int &c1,int &d1,int &e1,int &f1, int &h, int &p, int vel,int y2)
{
      if(rev==1)
        {do{n=random(7);}while(n==0);}
     
      if(h==60)
      {
        if(bm==y2)
        {
        if(n==1 && a1==1)
        {n1=p+3;n2=p+19;}
        if(n==2 && b1==1)
        {n1=p+33;n2=p+49;}
        if(n==3 && c1==1)
        {n1=p+63;n2=p+79;}
        if(n==4 && d1==1)
        {n1=p+93;n2=p+109;}
        if(n==5 && e1==1)
        {n1=p+123;n2=p+139;}
        if(n==6 && f1==1)
        {n1=p+153;n2=p+169;}
        }
       
        if(n==1 && a1==1)
        {balamala(bala,bm,n1);
        balamala(bala,bm,n2);rev=0;}
        if(n==2 && b1==1)
        {balamala(bala,bm,n1);
        balamala(bala,bm,n2);rev=0;}
        if(n==3 && c1==1)
        {balamala(bala,bm,n1);
        balamala(bala,bm,n2);rev=0;}
        if(n==4 && d1==1)
        {balamala(bala,bm,n1);
        balamala(bala,bm,n2);rev=0;}
        if(n==5 && e1==1)
        {balamala(bala,bm,n1);
        balamala(bala,bm,n2);rev=0;}
        if(n==6 && f1==1)
        {balamala(bala,bm,n1);
        balamala(bala,bm,n2);rev=0;}
      }
      bm=bm+vel;
      if(bm>190)
        {bm=y2;rev=1;n1=0;n2=0;}
}
/*********************************************************/**************************************************************************
 *  Escribe Balas Naves Malas 1                                            *
 *                                                                        *
 **************************************************************************/
void balasmalas1(int &rev, int &n, int &n1,int &n2,int &bm,int &a1,int &b1,int &c1,int &d1,int &e1,int &f1, int &h, int &p,int vel,int y1)
{
      if(rev==1)
        {do{n=random(7);}while(n==0);}
     
      if(h==80)
      {
        if(bm==y1)
        {
        if(n==1 && a1==1)
        {n1=p+3;n2=p+19;}
        if(n==2 && b1==1)
        {n1=p+33;n2=p+49;}
        if(n==3 && c1==1)
        {n1=p+63;n2=p+79;}
        if(n==4 && d1==1)
        {n1=p+93;n2=p+109;}
        if(n==5 && e1==1)
        {n1=p+123;n2=p+139;}
        if(n==6 && f1==1)
        {n1=p+153;n2=p+169;}
        }
       
        if(n==1 && a1==1)
        {balamala(bala,bm,n1);
        balamala(bala,bm,n2);rev=0;}
        if(n==2 && b1==1)
        {balamala(bala,bm,n1);
        balamala(bala,bm,n2);rev=0;}
        if(n==3 && c1==1)
        {balamala(bala,bm,n1);
        balamala(bala,bm,n2);rev=0;}
        if(n==4 && d1==1)
        {balamala(bala,bm,n1);
        balamala(bala,bm,n2);rev=0;}
        if(n==5 && e1==1)
        {balamala(bala,bm,n1);
        balamala(bala,bm,n2);rev=0;}
        if(n==6 && f1==1)
        {balamala(bala,bm,n1);
        balamala(bala,bm,n2);rev=0;}
      }
      bm=bm+vel;
      if(bm>190)
        {bm=y1;rev=1;n1=0;n2=0;}
}
/*********************************************************/**************************************************************************
 *  Respaldo Puntuacion                                                  *
 *                                                                        *
 **************************************************************************/
void respunt(byte oso[20][12], int renglon, int columna)//oso[20]"Y" [12]"X"
{
  char far *ptr = (char far *)0xA0000000;  //ptr apunta a inicio de MCGA

  ptr += 320*renglon + columna;

  for (int i=0;i<10;i++)//"Y" mitad
  {
      for (int j=0;j<12;j++)//"X"
      {
          oso[10+i][j] = *ptr;
          ptr++;
      }
      ptr += 320 - 12;//"X"
    }
}
/*********************************************************/**************************************************************************
 *  Escribe Puntuacion                                                    *
 *                                                                        *
 **************************************************************************/
void MCGApunt(byte nave[10][12], int r, int c)//nave[16]"y" [23]"x"
{
    char far *ptr = (char far *)0x0A0000000;
  ptr+=320*r+c;
    for (unsigned int i=0;i<10;i++)//"y"
    {
      for (unsigned int j=0;j<12;j++)//"X"
      {
        if (nave[i][j]==0)
          {
            *ptr=nave[i+10][j];//"Y"
          }
        else
          *ptr = nave[i][j];
            ptr++;
      }
    ptr+=320-12;//"X"
    }
}
/*********************************************************/**************************************************************************
 *  Escribe la Puntuacion  obtenida                                      *
 *                                                                        *
 **************************************************************************/
void puntua( int suma)
  {
    if(suma<=1)
      {respunt(cero,1,90);
      MCGApunt(cero,1,90);}
    if(suma>1 && suma<=2)
      {respunt(uno,1,90);
      MCGApunt(uno,1,90);}
    if(suma>2 && suma<=4)
      {respunt(dos,1,90);
      MCGApunt(dos,1,90);}
    if(suma>4 && suma<=6)
      {respunt(tres,1,90);
      MCGApunt(tres,1,90);}
    if(suma>6 && suma<=8)
      {respunt(cuatro,1,90);
      MCGApunt(cuatro,1,90);}
    if(suma>8 && suma<=10)
      {respunt(cinco,1,90);
      MCGApunt(cinco,1,90);}
    if(suma>10 && suma<=12)
      {respunt(seis,1,90);
      MCGApunt(seis,1,90);}
    if(suma>12 && suma<=14)
      {respunt(siete,1,90);
      MCGApunt(siete,1,90);}
    if(suma>14 && suma<=16)
      {respunt(ocho,1,90);
      MCGApunt(ocho,1,90);}
    if(suma>16 && suma<=17)
      {respunt(nueve,1,90);
      MCGApunt(nueve,1,90);}
    if(suma>17 && suma<=18)
      {respunt(uno,1,90);
      MCGApunt(uno,1,90);
      respunt(cero,1,100);
      MCGApunt(cero,1,100);}
  }
/*********************************************************/**************************************************************************
 *  Escribe Salud descontando                                            *
 *                                                                        *
 **************************************************************************/ 
void life(int &desc, int &vidas)
  {
      if(desc==10)
      {
      respunt(uno,1,168);
      MCGApunt(uno,1,168);
      respunt(cero,1,178);
      MCGApunt(cero,1,178);
      }
      if(desc==5)
      {
      respunt(cinco,1,168);
      MCGApunt(cinco,1,168);
      }
      if(desc==0)
      {desc=10;vidas=vidas-1;}
  }

void danonvbuena( int &n1, int &n2, int &bm, int &y, int &x, int &desc,float &punt)
{
  if((bm>y+6 && bm<y+22) && ((n1>x && n1<x+42) || (n2>x && n2<x+42)))
      {desc=desc-5;bm=200;punt=punt-0.5;}
}

void explcionbuena(int &exp, int &y, int &x, int &cont)
    {
          if(exp==0)
            {exp=7;}
          if(exp==5)
            {exp=0;respnvbuena(nvexpo5,y,x);
            MCGAnvbuena(nvexpo5,y,x);
            }
          if(exp==4)
            {exp=5;respnvbuena(nvexpo4,y,x);
            MCGAnvbuena(nvexpo4,y,x);
            }
          if(exp==3)
            {exp=4;respnvbuena(nvexpo3,y,x);
            MCGAnvbuena(nvexpo3,y,x);
            }
          if(exp==2)
            {exp=3;respnvbuena(nvexpo2,y,x);
            MCGAnvbuena(nvexpo2,y,x);
            }
          if(exp==1)
            {respnvbuena(nvexpo1,y,x);
            MCGAnvbuena(nvexpo1,y,x);
            cont--;
            if(cont==0)
              {exp=2;}
            }
    }

/*********************************************************/**************************************************************************
 *  Mueve el Fondo, Mueve la nave y llama todas las funciones            *
 *                                                                        *
 **************************************************************************/
void moverfondo(int i, int y, int x, int velnv, int velnvm, int velbalb, int velbalm, int vel, int &total, byte &sc,int &salte)
{
  char car;
  int cont=0,cont2=0,p=0,cont3,by,bx,activar=0,quita,b=1,sum=0,h=80;
  int a1=1,b1=1,c1=1,d1=1,e1=1,f1=1,a2=1,b2=1,c2=1,d2=1,e2=1,f2=1,a3=1,b3=1,c3=1,d3=1,e3=1,f3=1,exp1=0,exp2=0,exp3=0, col=0,con=0;
  int n,bm=81,rev=1,n1=0,n2=0,blsm=1,desc=10,q=3,off=6,dis=5,y3=30,y2=50,y1=70,dw=1;
  float puntu=0.0;
  int izquierda=0,derecha=147,q1=1;
  do
  {
    cont2=cont2+1;
      if(i==17)
          {cont=1;}
      if(i==30)
          {cont=0;}
      if(cont==1)
          {i=i+1;}
      if(cont==0)
          {i=i-1;}
    fondo(i,cont);// escribe el fondo y lo hace rotar
    respvidas(vidas,1,200);//vidas,y,x
    MCGAvidas(vidas,1,200);//vidas,y,x
    respnv_vidas(nv_vidas,0,246);//nave vidas,y,x
    filanvvidas(246,q);//nave vidas,y,x
    respsalud(salud,1,120);//salud,y,x
    MCGAsalud(salud,1,120);//salud,y,x
    respunt(puntuacion,1,1);//puntuacion,y,x
    MCGApunt(puntuacion,1,1);//puntuacion,y,x
    if(off==6)
    {respnvbuena(nvbuena,y,x);//nave buena,y,x
    MCGAnvbuena(nvbuena,y,x);}//nave buena,y,x
    if(cont2==1)
      {
      muevenvmalas(p,cont3,velnvm,y3,y2,y1,izquierda,derecha);// mueve naves malas 1
      cont2=0;
      }
     
      puntua(sum);// sumatoria de puntuacion
      life(desc,q);//resta la vida
     
      if(q==0 && off==6)
        {off=1;}
     
      if(((y1+15>=y && dw==1) && blsm==1)||((y2+15>=y && dw==1) && blsm==2))
      {off=1;dw=2;}
      if(((y3+15>=y && dw==1) && blsm==3))
      {off=1;dw=2;}
       
      explcionbuena(off,y,x,dis);
     
      if(off==7)
      {sc=45;}
     
     
      eliminanv1(nvmala,p,h,a1,b1,c1,d1,e1,f1,by,bx,sum,exp1,col,con,y1,puntu);//colisiones
      eliminanv2(nvmala,p,h,a2,b2,c2,d2,e2,f2,by,bx,sum,exp2,col,con,y2,puntu);
      eliminanv3(nvmala,p,h,a3,b3,c3,d3,e3,f3,by,bx,sum,exp3,col,con,y3,puntu);
     
      if((f1==2 && f2==2)&& f3==2)
      {derecha=176;
        if((e1==2 && e2==2)&& e3==2)
        {derecha=206;
          if((d1==2 && d2==2)&& d3==2)
          {derecha=236;
            if((c1==2 && c2==2)&& c3==2)
              {derecha=266;
              if((b1==2 && b2==2)&& b3==2)
              {derecha=296;
              }
            }
          }
        }
      }
     
      if((a1==2 && a2==2)&& a3==2)
      {  izquierda=-30;
          if((b1==2 && b2==2)&& b3==2)
          {  izquierda=-60;
            if((c1==2 && c2==2)&& c3==2)
            {  izquierda=-90;
                if((d1==2 && d2==2)&& d3==2)
                {  izquierda=-120;
                    if((e1==2 && e2==2)&& e3==2)
                      {izquierda=-150;}
                }
            }
          }
      }
     
         
        if(activar==1)//*************************************** bala  1
      {
        balamover(bala,by,bx);
          by=by-velbalb;
          if(by<40)
          {activar=0;by=0;}
          b=0;
      }
      else
        b=1;
   
     
      if(blsm==1)
      balasmalas1(rev,n,n1,n2,bm,a1,b1,c1,d1,e1,f1,h,p,velbalm,y1);// aki para bajar balas
      if(blsm==2)
      balasmalas2(rev,n,n1,n2,bm,a2,b2,c2,d2,e2,f2,h,p,velbalm,y2);
      if(blsm==3)
      balasmalas3(rev,n,n1,n2,bm,a3,b3,c3,d3,e3,f3,h,p,velbalm,y3);
     
      danonvbuena(n1,n2,bm,y,x,desc,puntu);
   
           
      if(sum==6)
        {h=60;blsm=2;} 
      if(sum==12)
        {h=34;blsm=3;}
      if(sum==18)
        {sc=45;}
    checa_tecla(car,sc);
   
    total=puntu*100;
     
    delay(vel);// velocidad
    switch(sc)
    {
      case 72 : if(y>160)
                  y=y-2;
                  if(off==6)
                  {respnvbuena(nvbuena,y,x);
                  MCGAnvbuena(nvbuena,y,x);}
                  if(vel>15)
                  vel=vel-1;
                  sc=0;
                break;
      case 80 : if(y<179)
                  y=y+2;
                  if(off==6)
                  {respnvbuena(nvbuena,y,x);
                  MCGAnvbuena(nvbuena,y,x);}
                  if(vel<35)
                  vel=vel+1;
                  sc=0;
                break;
      case 75 : if(x>0)
                  x=x-velnv;//5
                  if(off==6)
                  {respnvbuena(nvbuena,y,x);
                  MCGAnvbuena(nvbuena,y,x);}
                  sc=0;
                break;
      case 77 : if(x<277)
                  x=x+velnv;//5
                  if(off==6)
                  {respnvbuena(nvbuena,y,x);
                  MCGAnvbuena(nvbuena,y,x);}
                  sc=0;
                break;
      case 57 : if(b==1)
                {
                activar=1;
                by=y-6;
                bx=x+20;
                sc=0;}
                break;
      case 25 :
      getch();
                sc=0;
                break;
      case 45 :
                salte=1;
                sc=1;
                break;
    }
     
     
  }while(sc!=1);
}
void read_hist (alumno lista[], int cuantos)
{
  int i=0;
 
  ifstream file ("hi_sco.txt");
  if (!file.fail())
    {
      while(i<cuantos)
        {
          file >> lista[i].nombre >> lista[i].punt;
          i++;
        }
    }
  else
    {
      cout << "\tERROR!!! \n\n No se encontro el archivo 'hi_sco.txt'\n";
      getch();
      return;
    }
  file.close();
}


void escribe_hist (alumno lista[], int cuantos)
{
  int i=0;
 
  ofstream outfile ("hi_sco.txt");
  if (!outfile.fail())
  {
    while (i<cuantos)
      {
        outfile << lista[i].nombre <<" " << lista[i].punt << endl;
        i++;
      }
  }
  outfile.close();
}


void cambiar_hist (int score, alumno lista[], int cuantos)
{
  int a=-99;
  int clr=1;
  char nombre[10];
 
  for (int i=cuantos-1 ; i>=0 ; i--)
    if (score>lista[i].punt)
      {
        a = i;
      }
 
  if (a!=-99)
    {
      clrscr();
      cout << "\n\tFelizidades!!!\n\n\tRealizaste una puntuacion entre los primeros 10!\n\n\n"
          << "\tEntra tu Nombre (maximo 10 letras):\t";
      cin.getline (nombre,10);
      for (i=0;i<10;i++)
        if (nombre[i]=='\0')
        {
          clr=0;
          break;
        }
      if (clr)
      {
        cin.clear();
        cin.ignore(256,'\n');
      }
     
      for (i=cuantos-1 ; i>a ; i--)
        {
          strcpy(lista[i].nombre, lista[i-1].nombre);
          lista[i].punt = lista[i-1].punt;
        }
      strcpy(lista[a].nombre, nombre);
      lista[a].punt = score;
      escribe_hist(lista, cuantos);
    }
}
     

void historial (alumno lista[], int cuantos)
{
  int i=0;
 
  clrscr();
  cout << "\t\t*High Scores*\n"
      << "\t\t=============\n\n"
      << "\tNombre\t\t\tScore\n\n";
  for (i=0 ; i<cuantos ; i++)
    cout << "\t" << lista[i].nombre << "\t \t \t " << lista[i].punt<<endl;
  cout << "\n\n\n\n\tTecla cualquier tecla para regresar";
  getch();
}

//jueves 3  3:30

void main()
{
byte scan;
int nivel, puntuacion;
alumno lista[10];
  int cuantos=10,end;
 
  video(19);
  moverfondo(18,170,130,9,3,4,5,25,puntuacion,scan,end);//5=movieminto nave buena, 1= moviemiento nave mala, 2=velocidad balas buenas, 3=velocidad nbalas malas
video(2);
  read_hist(lista, cuantos);
  if(end==1)
  {cambiar_hist(puntuacion, lista, cuantos);}
  escribe_hist(lista, cuantos);
  read_hist(lista,cuantos);
  if(end==1)
  {historial(lista,cuantos);}
}

Codigo en MFC

Código:

// GameCode.cpp                Version 7                        8/12/03       
// These three functions form the basis of a game loop in the window created in the
// wincode.cpp file



#include "gamecode.h"
#include <math.h>                                // Math stuff
#include <stdlib.h>                                // Standard stuff
#include <dsound.h>                                // Direct sound
#include "mydrawengine.h"
#include "mypicture.h"
#include "mysoundengine.h"
#include "mysound.h"
#include "myinputs.h"
#include <time.h>

#include "Collision.h"
#include "ExplosionCollection.h"
#include "InvaderCollection.h"
#include "WeaponCollection.h"
#include "Player.h"


MyDrawEngine* pTheDrawEngine;        // A pointer to the drawing engine
MySoundEngine* pTheSoundEngine;        // A pointer to the sound engine

extern HWND gHwnd;                                // A handle to the main window application (created and declared in wincode.cpp).
extern HINSTANCE g_hinstance;        // A handle to the program instance

// The game !!! *********************************************************************************

        MyInputs* pTheInputs;
       
        CInvaderCollection*    pInvaders;
        CExplosionCollection*  pExplosions;
        CWeaponCollection*    pWeapons;
        CPlayer*              pPlayer;
       
        RECT rgrClipperRects[1];
       
        bool SpaceDown = false;
        int DeBugg = 0;

int GameInit()
// Called once before entering game loop.
// Use this function to set up the program
// gHwnd is the handle to the window and is required by the constructors for the engines
{
        // Create the engines
        pTheDrawEngine = new MyDrawEngine(SCREENWIDTH, SCREENHEIGHT, COLOURDEPTH, gHwnd);
        pTheSoundEngine = new MySoundEngine(gHwnd);
        pTheInputs=new MyInputs(g_hinstance, gHwnd);
       
        // Set up the Clipper...
        rgrClipperRects[0].top    = 0;
        rgrClipperRects[0].bottom = 600;
        rgrClipperRects[0].left  = 0;
        rgrClipperRects[0].right  = 800;
       
        pTheDrawEngine->SetClipper(1,rgrClipperRects);
       
        // Make the Invaders Collection...
        pInvaders = new CInvaderCollection;
        pInvaders->InitFormation();
       
        // Make the Explosions Collection...
        pExplosions = new CExplosionCollection;
       
        // make the Weapon Collection...
        pWeapons = new CWeaponCollection;
       
        // Make the Player Object...
        pPlayer = new CPlayer;
       
        InitRandom();
       
        return (SUCCESS);
}

// ******************************************************************

int GameMain()
// Called repeatedly - the game loop
{
int i = 0;
int j = 0;
RECT tmpOver;
       
        if (KEYPRESSED('Q'))
        {
                pInvaders->Kill(GetRandNum(0, 39));
        }
       
        if (KEYPRESSED('W'))
        {
                pInvaders->Invader[GetRandNum(0, 39)]->Active = true;
        }
       
        if (pPlayer->Damage[0] < 100)
        {
                pPlayer->Damage[0] += 0.1;
        }
       
        if (pPlayer->Damage[1] < 100)
        {
                pPlayer->Damage[1] += 0.1;
        }
       
        if (pPlayer->Damage[2] < 100)
        {
                pPlayer->Damage[2] += 0.1;
        }
       
       
       
//        ##----MOVEMENT----##  \\
       
        pInvaders->MoveFormation();
        pWeapons->Move();
        pExplosions->Animate();
        pPlayer->Move();
       
       
       
//        ##----COLISIONS----##  \\
       
        for (j = 0; j < MAX_WEAPON_COUNT; j++)
        {
                if (pWeapons->Weapon[j]->Active)
                {
                        if (pWeapons->Weapon[j]->FiredBy != 2)
                        {
                                for (i = 0; i < MAX_INVADER_COUNT; i++)
                                {
                                        if (pInvaders->Invader[i]->Active)
                                        {
                                                if (CheckRECTColl(pInvaders->Invader[i]->DestRect, pWeapons->Weapon[j]->DestRect, tmpOver))
                                                {
                                                        pInvaders->Kill(i);
                                                        pWeapons->Weapon[j]->Active = false;
                                                }
                                        }
                                }
                        }
                       
                        if (pWeapons->Weapon[j]->FiredBy != 1)
                        {
                                if (CheckRECTColl(pPlayer->DestRECT[0], pWeapons->Weapon[j]->DestRect, tmpOver))
                                {
                                        pExplosions->CreateExplosion((pPlayer->DestRECT[0].left + pPlayer->DestRECT[0].right) / 2,
                                                                                                (pPlayer->DestRECT[0].top + pPlayer->DestRECT[0].bottom) / 2, 3);
                                       
                                        pWeapons->Weapon[j]->Active = false;
                                        pPlayer->Damage[0] -= 80;
                                        if (pPlayer->Damage[0] < 0)
                                        {
                                                pPlayer->Damage[0] = 0;
                                        }
                                }
                               
                                if (CheckRECTColl(pPlayer->DestRECT[1], pWeapons->Weapon[j]->DestRect, tmpOver))
                                {
                                        pExplosions->CreateExplosion((pPlayer->DestRECT[1].left + pPlayer->DestRECT[1].right) / 2,
                                                                                                (pPlayer->DestRECT[1].top + pPlayer->DestRECT[1].bottom) / 2, 2);
                                       
                                        pWeapons->Weapon[j]->Active = false;
                                        pPlayer->Damage[1] -= 80;
                                        if (pPlayer->Damage[1] < 0)
                                        {
                                                pPlayer->Damage[1] = 0;
                                        }
                                }
                               
                                if (CheckRECTColl(pPlayer->DestRECT[2], pWeapons->Weapon[j]->DestRect, tmpOver))
                                {
                                        pExplosions->CreateExplosion((pPlayer->DestRECT[2].left + pPlayer->DestRECT[2].right) / 2,
                                                                                                (pPlayer->DestRECT[2].top + pPlayer->DestRECT[2].bottom) / 2, 3);
                                       
                                       
                                        pWeapons->Weapon[j]->Active = false;
                                        pPlayer->Damage[2] -= 80;
                                        if (pPlayer->Damage[2] < 0)
                                        {
                                                pPlayer->Damage[2] = 0;
                                        }
                                }
                        }
                }
        }
       
       
       
//        ##----DRAWING----##  \\
       
        pInvaders->Draw();
        pWeapons->Draw();
        pPlayer->Draw();
        pExplosions->Draw();
       
        pTheDrawEngine->Flip();
        pTheDrawEngine->ClearBackBuffer();
       
        return SUCCESS;
}

// ***********************************************************

void GameShutdown()
// called after the game loop is finished
{
        // Release all memory and directX interfaces
       
        delete pInvaders;
        delete pExplosions;
        delete pWeapons;
        delete pPlayer;
       
        // (engines must be released last)
        pTheDrawEngine->Release();
        pTheSoundEngine->Release();
        pTheInputs->Release();
}

void InitRandom ()
{
        srand(time(NULL));
}

int GetRandNum (int LLimit, int ULimit)
{
        int rValue = 0;  // Used to store the return value
       
        if (LLimit == ULimit)
        {
                rValue = LLimit;
        }
        else if (ULimit < LLimit) // Incase the caller has them the wrong way round.
        {
                rValue = (rand() % (LLimit - ULimit + 1)) + ULimit;
        }
        else
        {
                rValue = (rand() % (ULimit - LLimit + 1)) + LLimit;
        }
        return rValue;
}

Video Tutorial





Uploadable.net - #1 [C] Space Invaders
Uploadable.net - #2 [C-SDL] Space Invaders
Uploadable.net - #3 [C++] Space Invaders (1)
Uploadable.net - #4 [C++] Space Invaders (2)
Uploadable.net - #5 [MFC] Space Invaders

Viewing all articles
Browse latest Browse all 11602

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>