⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 Game developed with C++ and ALLEGRO
💻 CPP
字号:
#include <cstdlib>
#include <iostream>
#include <algif.h>
#include <stdlib.h>
#include<dos.h>
#include "Score.h"
#include "Tiempo.h"
#include "Escenario.h"
#include "Item.h"
#include "Momia.h"
#include "Personaje.h"
#include "Monito.h"
#include <allegro.h>

using namespace std;

Tiempo t;

void tiempo(){
     t.segundos++;
     if(t.segundos%59==0){
                    t.minutos++;
     }
                    
}END_OF_FUNCTION(tiempo);

int main(int argc, char *argv[])
{
    Monito *mon[5];
    Momia *mm[5];
    BITMAP *mp;
    int aux,aux1;
    PALLETE pal;
    bool pasar=true;
    int i,j;
    int nivel=0;
    bool *ifmove;
    allegro_init();    
    install_timer();
    set_color_depth(desktop_color_depth());
    set_gfx_mode(GFX_AUTODETECT_WINDOWED,600,400,0,0);
    algif_init();
    install_keyboard();
    set_color_conversion(COLORCONV_TOTAL);
    ifmove=new bool[3];
    bool *mmm;
    mmm=new bool[2];
    mmm[0]=false;
    mmm[1]=false;
    bool winm=false;
    ifmove[0]=false;
    ifmove[1]=false;
    ifmove[2]=false;
    Escenario *e;
    Cuadro tabla[6][6];
    //Funcion para tiempo
    LOCK_VARIABLE(t.segundos);
    LOCK_FUNCTION(tiempo);
    install_int(tiempo,1000);
    aux=aux1=t.segundos;
    mon[0]=new Monito(250,100); 
    mm[0]=new Momia(300,300); 
    mon[1]=new Monito(300,100); 
    mm[1]=new Momia(300,250);
    mon[2]=new Monito(350,200); 
    mm[2]=new Momia(400,50);
    mon[3]=new Monito(500,150); 
    mm[3]=new Momia(300,50);
    mon[4]=new Monito(500,250); 
    mm[4]=new Momia(400,300);       
    BITMAP *lado;
    lado=load_gif("imagenes/lateral.gif",pal);
    mp=load_gif("imagenes/menu_princ.gif",pal);
    draw_sprite(screen,mp,0,0);
    while(!key[KEY_ESC]){
                         if(key[KEY_ENTER])
                                           break;
                         else if(key[KEY_S])
                                   exit(0);                     
    }
    while(nivel != 5){
                 e=new Escenario(mon[nivel],600,400,0,tabla, mm[nivel]);
                 e->cargar(nivel);
                 t.segundos=0;
                 while(!key[KEY_ESC]){
                         ifmove=e->mo->mover(e->tabla);
                         if(aux != t.segundos){
                                draw_sprite(screen,lado,0,0);
                                textprintf_ex(screen, font, 10, 350, makecol(0, 0, 0),-1, "Tiempo: %d : ", t.minutos);
                                textprintf_ex(screen, font, 110, 350, makecol(0, 0, 0),-1, "%d", t.segundos);
                                aux=t.segundos;
                                if(t.segundos%59==0)
                                              t.segundos=0;
                         }
                         if(ifmove[0]){
                                mmm=e->mom->mover(e->tabla);
                                for(i=0; i<1000; i++)
                                    for(j=0; j<110000; j++)
                                    {}
                                mmm=e->mom->mover(e->tabla);
                         }            
                         if(ifmove[1])
                                      break;
                         if(ifmove[2]){
                                       winm=true;
                                      break;
                         }          
                         if(mmm[0]){
                                     winm=true;
                                      break;
                         }                  
                         cout<<"while"<<endl;       
                 }
                 if(winm){
                          for(i=0; i<1000; i++)
                                    for(j=0; j<110000; j++)
                                    {}
                         exit(0);
                 }
                 nivel++;
                 clear(screen);
                 delete e;
    }   
    clear_keybuf();
    allegro_exit(); 
    system("pause");
}END_OF_MAIN();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -