Пример #1
0
void show_stats()
{
  if (current_level)
  {
    fade_out(8);
    wm->SetMousePos(ivec2(0, 0));
    main_screen->clear();
    image *im=cache.img(cache.reg("art/frame.spe","end_level_screen",SPEC_IMAGE,1));
    main_screen->PutImage(im, ivec2(0, 0));


    int x1=im->Size().x+1,y1=0,x2=xres,y2=main_screen->Size().y;
    fade_in(NULL,16);

    char name[50];
    strcpy(name,current_level->original_name());
    char dig1=name[strlen(name)-strlen(".spe")-2];
    char dig2=name[strlen(name)-strlen(".spe")-1];


    char msg[50];

    if (isdigit(dig1) && isdigit(dig2))
    {
      if (dig1!='0')
        sprintf(msg,"%s : %c%c",symbol_str("lev_complete"),dig1,dig2);
      else
        sprintf(msg,"%s : %c",symbol_str("lev_complete"),dig2);
    } else sprintf(msg,"%s : %s",symbol_str("lev_complete"),current_level->original_name());

    int w = wm->font()->Size().x * strlen(msg),
        h = wm->font()->Size().y;
    int x=(x1+x2)/2-w/2,y=(y1+y2)/2-h/2;
    main_screen->Bar(ivec2(x - 10, y - 10), ivec2(x + w + 10, y + h + 10),
                     wm->bright_color());
    main_screen->Bar(ivec2(x - 9, y - 9), ivec2(x + w + 9, y + h + 9),
                     wm->medium_color());

    wm->font()->PutString(main_screen, ivec2(x + 1, y + 1), msg, wm->dark_color());
    wm->font()->PutString(main_screen, ivec2(x, y), msg, wm->bright_color());
    wm->flush_screen();
    Timer now; now.WaitMs(500);
  }
}
Пример #2
0
void title_page(BITMAP *scrbuffer, DATAFILE *main_data)
{
// function sets up the title screen and allows access to the actual game

    DATAFILE *plane_data, *explosion_data, *shot_data, *object_data;
    struct menuinfo title_menu, options_menu, stats_menu;
    struct optionsinfo options;
    FILE *cfgfile;

// load game specific datafiles into memory
    plane_data      = (DATAFILE *)main_data[PLANE].dat;
    explosion_data  = (DATAFILE *)main_data[EXPLOSION].dat;
    object_data     = (DATAFILE *)main_data[OBJECT].dat;

    title_menu.highlight = 0;

    strcpy(title_menu.option[0], "2 Player Game");
    strcpy(title_menu.option[1], "3 Player Game");
    strcpy(title_menu.option[2], "4 Player Game");
    strcpy(title_menu.option[3], "Options");
    strcpy(title_menu.option[4], "Credits");
    strcpy(title_menu.option[5], "Exit");
    title_menu.num_of_options = 6;
    title_menu.row = 25*8;
    title_menu.col = SCREEN_W/2-78;
    title_menu.fontsize = 2;

    strcpy(options_menu.option[0], "Player Statistics");
    strcpy(options_menu.option[1], "Player Controls");
    strcpy(options_menu.option[2], "Level Options");
    strcpy(options_menu.option[3], "Other Options");
    strcpy(options_menu.option[4], "Back");
    options_menu.num_of_options = 5;
    options_menu.row = 25*8;
    options_menu.col = SCREEN_W/2-92;
    options_menu.fontsize = 2;

    strcpy(stats_menu.option[0],  "Vehicle         :");
    strcpy(stats_menu.option[1],  "Turning Speed   :");
    strcpy(stats_menu.option[2],  "Acceleration    :");
    strcpy(stats_menu.option[3],  "Minimum Speed   :");
    strcpy(stats_menu.option[4],  "Maximum Speed   :");
    strcpy(stats_menu.option[5],  "Number of Shots :");
    strcpy(stats_menu.option[6],  "Shot Life       :");
    strcpy(stats_menu.option[7],  "Shot Lag        :");
    strcpy(stats_menu.option[8],  "Shot Base Speed :");
    strcpy(stats_menu.option[9],  "Laser Length    :");
    strcpy(stats_menu.option[10], "Reset to Vehicle Type");
    strcpy(stats_menu.option[11], "Save Vehicle to Configuration File");
    strcpy(stats_menu.option[12], "Return to Options Menu Without Saving");
    stats_menu.num_of_options = 13;
    stats_menu.row = 22*8;
    stats_menu.col = SCREEN_W/3;
    stats_menu.fontsize = 1;

// load the game's various options from the config file
    cfgfile = fopen("dogfight.cfg", "r");

    options.vehicle      = stats_menu.optionval[0] = read_value(cfgfile, '@',
                           "user vehicle",
                           "vehicle");
    options.turn_speed   = stats_menu.optionval[1] = read_value(cfgfile, '@',
                           "user vehicle",
                           "turn_speed");
    options.acceleration = stats_menu.optionval[2] = read_value(cfgfile, '@',
                           "user vehicle",
                           "acceleration");
    options.min_speed    = stats_menu.optionval[3] = read_value(cfgfile, '@',
                           "user vehicle",
                           "min_speed");
    options.max_speed    = stats_menu.optionval[4] = read_value(cfgfile, '@',
                           "user vehicle",
                           "max_speed");
    options.num_of_shots = stats_menu.optionval[5] = read_value(cfgfile, '@',
                           "user vehicle",
                           "num_of_shots");
    options.shot_life    = stats_menu.optionval[6] = read_value(cfgfile, '@',
                           "user vehicle",
                           "shot_life");
    options.shot_lag     = stats_menu.optionval[7] = read_value(cfgfile, '@',
                           "user vehicle",
                           "shot_lag");
    options.shot_base_speed = stats_menu.optionval[8] = read_value(cfgfile, '@',
                              "user vehicle",
                              "shot_base_speed");
    options.laser_length    = stats_menu.optionval[9] = read_value(cfgfile, '@',
                              "user vehicle",
                              "laser_length");

    options.gravity            = read_value(cfgfile, '@', "user level", "gravity");
    options.backdrop           = read_value(cfgfile, '@', "user level", "backdrop");
    options.cloud_type         = read_value(cfgfile, '@', "user level", "cloud_type");
    options.invincibility_life = read_value(cfgfile, '@', "options",    "invincibility_life");
    options.explosion_speed    = read_value(cfgfile, '@', "options",    "explosion_speed");
    options.coralie            = read_value(cfgfile, '@', "options",    "coralie_mode");

    fclose(cfgfile);

// draw the title page and fade in to it
    base_title_page(scrbuffer, main_data, plane_data, title_menu);
    fade_in(pal, 5);

    do {
        // reset the selection in case a game has just been exited
        title_menu.selection = -1;

        // draw the title page
        base_title_page(scrbuffer, main_data, plane_data, title_menu);

        // move the cursor
        title_menu = move_menu_cursor(title_menu);

        // start a game with the appropriate number of players
        if (title_menu.selection >= 0 && title_menu.selection <= 2) {
            fade_out(10);
            game(scrbuffer, main_data, plane_data, explosion_data, object_data, options,
                 title_menu.selection+2);

            // fix up the title screen before fading in to it
            title_menu.highlight = 0;
            base_title_page(scrbuffer, main_data, plane_data, title_menu);
            fade_in(pal, 5);
        }
        else if (title_menu.selection == 3) {
            // go to the options sub menu
            options = goto_options_menu(scrbuffer, main_data, plane_data, options, options_menu,
                                        stats_menu);
            title_menu.highlight = 0;
        }

    } while (title_menu.selection != title_menu.num_of_options-1);
}
Пример #3
0
void EL_EscudoClass::fade_in(char channel)
{
    fade_in(channel, 10);
}
Пример #4
0
void play_intro(void)
{
#define COL(index,red,green,blue) \
  if ((index>=min) && (index<=max)) { \
    pal[index].r = (red);             \
    pal[index].g = (green);           \
    pal[index].b = (blue);            \
  }

#define FADE(speed) \
  fade_from(source, pal, speed); \
  get_palette(source)

#define NORMAL() \
  min = 0;         \
  max = PAL_SIZE-1

  BITMAP *bg = (BITMAP *)datafile[MYLOGO_BMP].dat;
  PALETTE source, pal;
  int n, n2;
  int min, max;

  /* play the introduction theme */
  qtetris_music(MUSIC_INTRO, FALSE);

  n = 0;
  NORMAL();

  set_palette(black_palette);
  get_palette(source);
  get_palette(pal);

  /* DAC *********************************/
  clear(virtual);
  blit(bg, virtual, 0, 0,
    QTETRIS_SCREEN_W/2 - bg->w/2,
    QTETRIS_SCREEN_H/2 - bg->h/2, bg->w, bg->h);
  qtetris_blit(virtual);
  FADE(1);

  /* David A. Capello */
  /* fg */
  min = 1;
  max = 28;
  for (n2=0, n=min; n<=max+2; n2=n, n+=2) {
    COL(n2,  0,  0,  0);
    COL(n,   32, 32, 63);
    COL(n+1, 63, 63, 63);
    FADE(32);
  }

  /* bg */
  min = 32;
  max = 45;
  for (n=max; n>=min-4; n--) {
    NORMAL();
    for (n2=1; n2<=28; n2+=2) {
      COL(n2+1, 63-(-63*(n-45)/(45-32+4)),
                63-(-63*(n-45)/(45-32+4)),
                63-(-63*(n-45)/(45-32+4)));
      COL(n2, -63*(n-45)/(45-32+4), 0, 0);
    }

    min = 32;
    max = 45;
    COL(n+4, 63, 63, 63);
    COL(n+2, 63,  0,  0);
    COL(n,   63, 63,  0);

    FADE(64);
  }

  /* Present */
  NORMAL();
  COL(253, 63, 63, 63);
  COL(254, 32, 32, 32);
  COL(255, 16, 16, 16);
  FADE(4);

  /* fin de la primer etapa **************/
  fade_out(2);

  /* QUEEN LOGO **************************/
  fade_out(2);

  clear(virtual);
  blit(datafile[QUEENLOG_BMP].dat, virtual, 0, 0,
    QTETRIS_SCREEN_W/2-((BITMAP *)datafile[QUEENLOG_BMP].dat)->w/2,
    QTETRIS_SCREEN_H/2-((BITMAP *)datafile[QUEENLOG_BMP].dat)->h/2,
    ((BITMAP *)datafile[QUEENLOG_BMP].dat)->w,
    ((BITMAP *)datafile[QUEENLOG_BMP].dat)->h);
  qtetris_blit(virtual);

  fade_in(datafile[PALETTE_BMP].dat, 1);
  get_palette(pal);
  get_palette(source);
  FADE(2);
  fade_out(2);

  /* TETRIS ******************************/
  set_palette(black_palette);

  get_palette(source);
  get_palette(pal);

  NORMAL();
  for (n=0; n<PAL_SIZE; n++) {
    COL(n, 63, 63, 63);
  }
  FADE(2);

  /* mainscreen */
  clear(virtual);
  drawing_mode(DRAW_MODE_COPY_PATTERN, datafile[TETRISBG_BMP].dat, 0, 0);
  rectfill(virtual, 0, 0, QTETRIS_SCREEN_W, QTETRIS_SCREEN_H, -1);

  color_map = shadow_map;
  drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
  draw_trans_sprite(virtual, datafile[TETRIS_BMP].dat,
    QTETRIS_SCREEN_W/2 - ((BITMAP *)datafile[TETRIS_BMP].dat)->w/2 + 6,
    QTETRIS_SCREEN_H/2 - ((BITMAP *)datafile[TETRIS_BMP].dat)->h/2 + 12);
  solid_mode();

  draw_sprite(virtual, datafile[TETRIS_BMP].dat,
    QTETRIS_SCREEN_W/2 - ((BITMAP *)datafile[TETRIS_BMP].dat)->w/2,
    QTETRIS_SCREEN_H/2 - ((BITMAP *)datafile[TETRIS_BMP].dat)->h/2);
  qtetris_blit(virtual);

  for (n=15; n<112; n++) {
    COL(n, 0, 0, 0);
  }
  FADE(2);
  FADE(2);

  fade_from(pal, datafile[PALETTE_BMP].dat, 2);
}
Пример #5
0
void show_stats()
{
  if (current_level)
  {
    int xp,yp;

    if (!player_list->next)
    {
      fade_out(8);
      eh->set_mouse_position(0,0);
      screen->clear();

      switch_mode(VMODE_640x480);

      load_image_into_screen("art/frame.spe","end_level_screen",xp,yp);
      fade_in(NULL,16);
    } else
    {
      xp=screen->width()/2-640/2;
      yp=screen->height()/2-480/2;
    }



    char name[50];
    strcpy(name,current_level->original_name());
    char dig1=name[strlen(name)-strlen(".spe")-2];
    char dig2=name[strlen(name)-strlen(".spe")-1];

   
    char msg[50];
    int lev_num;


    if (isdigit(dig1) && isdigit(dig2))
      lev_num=(dig1-'0')*10+dig2-'0';
    else
      lev_num=dig2-'0';

    sprintf(msg,symbol_str("lev_complete"),lev_num);   

    int w=eh->font()->width()*strlen(msg),h=eh->font()->height();    
    int x1=0,y1=0,x2=xres,y2=yres;
    //    int x=(x1+x2)/2-w/2,y=(y1+y2)/2-h/2;
    int x=444+xp,y=293+yp;   
   
    eh->font()->put_string(screen,x+1,y+1,msg,eh->dark_color());    
    eh->font()->put_string(screen,x,y,msg,eh->bright_color());
    
    y+=eh->font()->height();
    sprintf(msg,"Time taken.. %0.1f minutes",current_level->time_taken()/60.0);
    eh->font()->put_string(screen,x+1,y+1,msg,eh->dark_color());    
    eh->font()->put_string(screen,x,y,msg,eh->bright_color());

    y+=eh->font()->height();
    sprintf(msg,"Kills....... %d",player_list->kills);
    eh->font()->put_string(screen,x+1,y+1,msg,eh->dark_color());    
    eh->font()->put_string(screen,x,y,msg,eh->bright_color());



    eh->flush_screen();
    stat_show_start.get_time();

    old_stat=stat_man;
    stat_man=new next_level_status_manager(xp+443,yp+424,xp+589,yp+443,93);  
  }
}
Пример #6
0
void menu_handler(event &ev, input_manager *inm)
{
  switch (ev.type)
  {
    case EV_MESSAGE :
    {
      switch (ev.message.id)
      {
				case ID_LIGHT_OFF :
				if (!volume_window)
				{
                                  screen->clear();
				  eh->flush_screen(); 
				  gamma_correct(pal,1);
				  fade_in(cash.img(title_screen),8);
                                  inm->redraw();
				  eh->flush_screen(); 
				} break;
				case ID_RETURN :
				if (!volume_window)
				{
				  the_game->set_state(RUN_STATE);
				} break;
				case ID_START_GAME :
				if (!volume_window)
				{        
				  the_game->load_level(level_file);
				  the_game->set_state(RUN_STATE);
				  view *v;
				  for (v=player_list;v;v=v->next)
				    if (v->focus)
				      v->reset_player();
				   
				} break;

   
        case ID_LOAD_PLAYER_GAME :
				if (!volume_window)
				{
				  int got_level=load_game(0,symbol_str("LOAD"));
				  the_game->reset_keymap();
				  if (got_level)
				  {
				    char name[50];
				    sprintf(name,"save%04d.spe",got_level);
				    the_game->load_level(name);
				    the_game->set_state(RUN_STATE);	    
				  }
				} break;
			
			
				case ID_VOLUME : 
				if (!volume_window)
				{ create_volume_window(); } break;
			
				case ID_MEDIUM :
				{
				  set_symbol_value(l_difficulty,l_medium);
				  save_difficulty();
				} break;
				case ID_HARD :
				{
				  set_symbol_value(l_difficulty,l_hard);
				  save_difficulty();
				} break;
				case ID_EXTREME :
				{
				  set_symbol_value(l_difficulty,l_extreme);
				  save_difficulty();
				} break;
				case ID_EASY :
				{
				  set_symbol_value(l_difficulty,l_easy);
				  save_difficulty();
				} break;
			
				case ID_NETWORKING :
				{
				  if (!volume_window)
				  {
				    net_configuration *cfg=new net_configuration;
				    if (cfg->input())
				    {
				      if (main_net_cfg) delete main_net_cfg;
				      main_net_cfg=cfg;
				    } else delete cfg;
				    the_game->draw(0);
				    inm->redraw();
				  }
				} break;
					      
				case ID_SHOW_SELL :
				if (!volume_window)
				{ 
				  show_sell(1); 
				  screen->clear();
				  if (title_screen>=0)
				  {
				    image *tit=cash.img(title_screen);
				      tit->put_image(screen,screen->width()/2-tit->width()/2,
								      screen->height()/2-tit->height()/2);
				  }
				  inm->redraw();
				  fade_in(NULL,8);
				  eh->flush_screen(); 
			
				} break;
					      
				case ID_MACKEYS :
                                  do_key_config(eh);

                                  /*
					fade_out(8);
					RestoreMac();
					MacKeyConfigMenu();

					UnRestoreMac(); */

                                    fade_in(cash.img(title_screen),8);
                                    inm->redraw();
                                    eh->flush_screen(); 
					break;

				case ID_MACCONF :
                                  do_monitor_config(eh);

				  fade_in(cash.img(title_screen),8);
                                  inm->redraw();
                                  eh->flush_screen(); 
                                  break;
      } break;
    } break;
    case EV_CLOSE_WINDOW :
    {
      if (ev.window==volume_window)
      { eh->close_window(volume_window); volume_window=NULL; }
    } break;
  }
}
Пример #7
0
void show_sell(int abortable)
{
#if 0
  void *ss=make_find_symbol("sell_screens");
  if (!DEFINEDP(symbol_value(ss)))
  {
    int sp=current_space;
    current_space=PERM_SPACE;
//    char *prog="((\"art/help.spe\" . \"sell2\")(\"art/help.spe\" . \"sell4\")(\"art/help.spe\" . \"sell3\")(\"art/endgame.spe\" . \"credit\"))";
    char *prog="((\"art/endgame.spe\" . \"credit\") (\"art/help.spe\" . \"sell6\"))";
    set_symbol_value(ss,compile(prog));
    current_space=sp;
  }

  if (DEFINEDP(symbol_value(ss)))
  {
    image blank(2,2); blank.clear();
    eh->set_mouse_shape(blank.copy(),0,0);      // don't show mouse

    ss=symbol_value(ss);
    int quit=0;
    while (ss && !quit)
    {
      int im=cash.reg_object("art/help.spe",CAR(ss),SPEC_IMAGE,1);
      fade_in(cash.img(im),16);

      event ev;
      do
      { 
      	eh->flush_screen();
				eh->get_event(ev);
      } while (ev.type!=EV_KEY);
      if (ev.key==JK_ESC && abortable)
        quit=1;
      fade_out(16);
      ss=CDR(ss);
    }
    eh->set_mouse_shape(cash.img(c_normal)->copy(),1,1);
  }
#else
 	image blank(2,2); blank.clear();
  eh->set_mouse_shape(blank.copy(),0,0);      // don't show mouse
	screen->clear();

  image *im;
  event ev;
	int i;
  
  im=cash.img(cash.reg("art/endgame.spe","credit",SPEC_IMAGE,1));
  char *str=lstring_value(eval(make_find_symbol("thanks_text")));

	int dx=(xres+1)/2-im->width()/2,dy=(yres+1)/2-im->height()/2;
	im->put_image(screen,dx,dy);

  fade_in(0,16);	

  uchar cmap[32];
  for (i=0;i<32;i++)
    cmap[i]=pal->find_closest(i*256/32,i*256/32,i*256/32);

	i = 0;

	int tx = 300, ty = 350, twx = 319, twy = 119;	
	
  while (eh->event_waiting()) eh->get_event(ev);
	ev.type = EV_SPURIOUS;

	time_marker start;
	int txti = 0;
  do
  { 
  	im->put_part(screen,dx+tx,dy+ty,tx,ty,tx+twx,ty+twy);
		txti++;
    text_draw(twy+5-txti,dx+tx+15,dy+ty,dx+tx+twx-15,dy+ty+twy,str,eh->font(),cmap,eh->bright_color()); 		
  	eh->flush_screen();
		
		time_marker now;
    while (now.diff_time(&start)<0.10) 
      now.get_time();
    start.get_time();

    while (eh->event_waiting() && ev.type!=EV_KEY) eh->get_event(ev);
  } while (txti<600 && ev.type!=EV_KEY && ev.type!=EV_MOUSE_BUTTON);
  fade_out(16);

	if (!abortable || !(ev.type==EV_KEY && ev.key==JK_ESC))
	{ 
	  im=cash.img(cash.reg("art/help.spe","sell6",SPEC_IMAGE,1));
	  fade_in(im,16);	
	
	  do
	  { 
	  	eh->flush_screen();
			eh->get_event(ev);
	  } while (ev.type!=EV_KEY && ev.type!=EV_MOUSE_BUTTON);
	  fade_out(16);
	}
  eh->set_mouse_shape(cash.img(c_normal)->copy(),1,1);
#endif
}
Пример #8
0
int menu_play()
{
 	 DATAFILE *menu = load_datafile("data\\menu.dat");
 	 BITMAP *buffer = create_bitmap(640,480);
 	 BITMAP *mbuffer = create_bitmap(640,480);
 	 MIDI *inicio = load_midi("musics\\inicio.midi");
 	 font = (FONT *)menu[9].dat;
 	 
 	 int ret;
 	 
 	 CBotao Jogar;
 	 Jogar.Start();
 	 Jogar.img[NORMAL] = (BITMAP *)menu[2].dat;
	 Jogar.img[CIMA] = (BITMAP *)menu[3].dat;
	 Jogar.tx = 134;
  	 Jogar.ty = 30;

	 CBotao Opcoes;
	 Opcoes.Start();
	 Opcoes.img[NORMAL] = (BITMAP *)menu[4].dat;
	 Opcoes.img[CIMA] = (BITMAP *)menu[5].dat;
	 Opcoes.tx = 134;
	 Opcoes.ty = 30;
	
	 CBotao Sair;
	 Sair.Start();
	 Sair.img[NORMAL] = (BITMAP *)menu[6].dat;
	 Sair.img[CIMA] = (BITMAP *)menu[7].dat;
	 Sair.tx = 134;
	 Sair.ty = 30;

 	 
     blit((BITMAP *)menu[1].dat, buffer, 0, 0, 0, 0, 640, 480);
 	 draw_sprite(buffer, Jogar.img[NORMAL], 253, 274);
 	 draw_sprite(buffer, Opcoes.img[NORMAL], 253, 315);
 	 draw_sprite(buffer, Sair.img[NORMAL], 253, 356);
 	 
 	 
 	 play_fli("movie\\filme.flc", screen, 0 , check_escape_key);
 	 fade_in((BITMAP *)menu[10].dat, 10);
 	 play_fli("movie\\filme2.flc", screen, 0 , check_escape_key);
 	 fade_out(10);

 	 
 	 set_trans_blender(255, 255, 255, 75);
     draw_trans_sprite(buffer, (BITMAP*)menu[8].dat, 30, 480-323);

 	 fade_in(buffer, 10);
 	 play_midi(inicio, 100);
 	 
 	 while(!key[KEY_ESC])
 	 {
        rest(3);
        clear_bitmap(buffer);
        clear_to_color(mbuffer, makecol(255,0,255));

	    blit((BITMAP *)menu[1].dat, buffer, 0, 0, 0, 0, 640, 480);
	    
        if (!Jogar.Manage(buffer, 253, 274, mbuffer, "Clique aqui para Jogar"))
        {   
           ret = JOGAR;
		   break;
        }
		if (!Opcoes.Manage(buffer, 253, 315, mbuffer, "Opcoes de Jogo"))
		{
           ret = OPCOES;
		   break;
        }
		if (!Sair.Manage(buffer, 253, 356, mbuffer, "Sair do Jogo"))
		{
           ret = SAIR;
		   break;
        }
	    set_trans_blender(255, 255, 255, 70);
	    draw_trans_sprite(buffer, (BITMAP*)menu[8].dat, 30, 480-323);
	    
	    
	    draw_sprite(mbuffer, (BITMAP *)menu[0].dat, mouse_x, mouse_y);
	    
	    //textprintf_ex(buffer, font, 10, 10, makecol(0,0,0),-1, "FPS: %d", fps); 	 	 	   
	    set_trans_blender(255, 255, 255, 150);
	    draw_trans_sprite(buffer, mbuffer, 0, 0);
	    blit(buffer, screen, 0, 0, 0, 0, 640, 480);
	 }
	 fade_out(10);
	 //destroy_bitmap(mbuffer);
	 Jogar.Destroy();
	 Opcoes.Destroy();
	 Sair.Destroy();
	 destroy_bitmap(buffer);
	 
	 return ret;
}
Пример #9
0
int opMenu()
{
     DATAFILE *menu = load_datafile("data\\menu.dat");
 	 BITMAP *buffer = create_bitmap(640,480);
 	 
 	 blit((BITMAP *)menu[1].dat, buffer, 0, 0, 0, 0, MAX_W, MAX_H);
 	 textprintf_centre_ex(buffer, font, 320, 305, makecol(0,30,50),-1, "Para trocar entre o modo fullscreen e janela, aperte ENTER.");
 	 
 	 font = (FONT *)menu[9].dat;
 	 
 	 fade_in(buffer, 10);
 	 
 	 FILE *conf = fopen("config.cdb", "wb");
 	 
 	 if (conf == NULL)
 	 {
        allegro_message("Problema com o arquivo de configuração: config.cdb");
        return 5;
     }
 	 
 	 while (!key[KEY_ESC])
 	 {
        clear(buffer);
        
        blit((BITMAP *)menu[1].dat, buffer, 0, 0, 0, 0, MAX_W, MAX_H);
 	    textprintf_centre_ex(buffer, font, 320, 305, makecol(0,30,50),-1, "Para trocar entre o modo fullscreen e janela, aperte ENTER.");
        
        if (key[KEY_ENTER])
        {
        
           if (is_windowed_mode())
           {
	          if (set_gfx_mode(GFX_AUTODETECT, MAX_W, MAX_H, 0, 0) != 0) {
		         allegro_message(allegro_error);
		         exit(-1);
	          }
	          fade_out(10);
	          unload_datafile(menu);
              destroy_bitmap(buffer);
              
              fprintf(conf, "%d", 2);
              fclose(conf);
     
              return 0;
           }
           else
           {
	          if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, MAX_W, MAX_H, 0, 0) != 0) {
		         allegro_message(allegro_error);
		         exit(-1);
	          }
	          fade_out(10);
	          unload_datafile(menu);
              destroy_bitmap(buffer);
              
              fprintf(conf, "%d", 1);
              fclose(conf);
     
              return 0;
           }
        }
        
        draw_sprite(buffer, (BITMAP *)menu[0].dat, mouse_x, mouse_y);
        
        blit(buffer, screen, 0, 0, 0, 0, MAX_W, MAX_H);
     }
     fade_out(10);
     
     unload_datafile(menu);
     destroy_bitmap(buffer);
     
     return 0;
}
Пример #10
0
void Main(u16 PLAYERS)
{
	int incl, incl_x, incl_y, i, delay;
	u16 boton, PLAYER=1;
	u16 bx, by, incl_c;
	u16 rx = 16,
	      ry = 144,
	      saltoX = 1,
	      saltoY = 1,
		incRaqueta;
	u16 LifeCount = 3;
	u32 ScoreCount = 0;
	boolean jugando, rastro;
	u16 direccion, tipoBola, long_r, mesias;
	u16 nivel = 1;
	u8 *nivelMap;

	GANA_NIVEL:

	if(nivel>1) fade_out(30, 1, 0);
	RefrescaBG(nivel,mesias);
	limpia_oam();
	Wait(100);	//Espera 3 segundos
	fade_in(30, 1, 0);

	IniciaPropiedadesBloques(nivel);
	RefrescaNivel(nivel);

	if(nivel==1) { nivelMap = blockMap_1; }//N1 = N2 = 12; }
	if(nivel==2) { nivelMap = blockMap_2; }//N1 = N2 = 13; }
	if(nivel==3) { nivelMap = blockMap_3; }//N1 = N2 = 14; }
	if(nivel==4) { nivelMap = blockMap_4; }//N1 = N2 = 15; }
	if(nivel==5) { nivelMap = blockMap_5; }//N1 = N2 = 16; }

	REINICIA:

	RefrescaLife(LifeCount);
	limpia_activoBonXY();

	jugando=TRUE;
	mesias=FALSE;
	RefrescaBG(nivel,mesias);

	tipoBola=BOLA1;
	ANCHO_BOLA=6;
	ALTO_BOLA=6;
	long_r=FALSE;
	ANCHO_RAQUETA=32;

	if(PLAYERS==2) {
		if(PLAYER==2) { PLAYER=1; goto DO_PLAYER; }
		if(PLAYER==1) { PLAYER=2; goto DO_PLAYER; }
	}
	DO_PLAYER:
	if(LifeCount==0 || nivel==6) jugando=FALSE;

	if(jugando==TRUE) IniciaMovimientoRaqueta(rx,ry,long_r,PLAYER,ScoreCount);

	rastro=FALSE;
	MAX_Y=160;

	delay=0;

	bx = Inicio_Bx;
	by = ry - ALTO_BOLA;
	rx = Inicio_Rx;

	while (LifeCount > 0 && nivel<=5)

		{

		/*<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><*/

		if(bx>( MAX_X - ANCHO_BOLA ) ) incl_x=-1;
		if(bx< MIN_X ) incl_x=1;
		if(by>( MAX_Y - ALTO_BOLA) )
		{
			incl_y=-1;
			if(mesias==FALSE) { LifeCount--; goto REINICIA; }
			if(mesias==TRUE) { mesias=FALSE; MAX_Y=160; }
		}
		if(by<= MIN_Y ) incl_y=1;

	if(long_r==FALSE)
	{
		if (by == (ry-ALTO_BOLA) && bx >= (rx-ANCHO_BOLA) && bx <= (rx-ANCHO_BOLA)+8 ) {incl_x=-1; incl_y=-1; incl=supizq;}
		if (by == (ry-ALTO_BOLA) && bx >= (rx-ANCHO_BOLA)+9 && bx <= (rx-ANCHO_BOLA)+16 ) {incl_x=-1; incl_y=-1; incl=supsupizq;}
		if (by == (ry-ALTO_BOLA) && bx >= (rx-ANCHO_BOLA)+17 && bx <= (rx-ANCHO_BOLA)+24 ) {incl_x=1; incl_y=-1; incl=supsupder;}
		if (by == (ry-ALTO_BOLA) && bx >= (rx-ANCHO_BOLA)+25 && bx <= (rx-ANCHO_BOLA)+32 ) {incl_x=1; incl_y=-1; incl=supder;}
			if (bx == (rx-ANCHO_BOLA) && ( by>=ry-ALTO_BOLA && by<=ry+8) ) {incl_x=-1; incl_y=-1; incl=izqizqsup;}
			if (bx == (rx+ANCHO_RAQUETA) && ( by>=ry-ALTO_BOLA && by<=ry+8) ) {incl_x=1; incl_y=-1; incl=derdersup;}
	}
	if(long_r==TRUE)
	{
		if (by == (ry-ALTO_BOLA) && bx >= (rx-ANCHO_BOLA) && bx <= (rx-ANCHO_BOLA)+8 ) {incl_x=-1; incl_y=-1; incl=supizq;}
		if (by == (ry-ALTO_BOLA) && bx >= (rx-ANCHO_BOLA)+9 && bx <= (rx-ANCHO_BOLA)+16 ) {incl_x=-1; incl_y=-1; incl=supizq;}
		if (by == (ry-ALTO_BOLA) && bx >= (rx-ANCHO_BOLA)+17 && bx <= (rx-ANCHO_BOLA)+24 ) {incl_x=-1; incl_y=-1; incl=supsupizq;}
		if (by == (ry-ALTO_BOLA) && bx >= (rx-ANCHO_BOLA)+25 && bx <= (rx-ANCHO_BOLA)+32 ) {incl_x=1; incl_y=-1; incl=supsupder;}
		if (by == (ry-ALTO_BOLA) && bx >= (rx-ANCHO_BOLA)+33 && bx <= (rx-ANCHO_BOLA)+40 ) {incl_x=1; incl_y=-1; incl=supder;}
		if (by == (ry-ALTO_BOLA) && bx >= (rx-ANCHO_BOLA)+41 && bx <= (rx-ANCHO_BOLA)+48 ) {incl_x=1; incl_y=-1; incl=supder;}
			if (bx == (rx-ANCHO_BOLA) && ( by>=ry-ALTO_BOLA && by<=ry+8) ) {incl_x=-1; incl_y=-1; incl=izqizqsup;}
			if (bx == (rx+ANCHO_RAQUETA) && ( by>=ry-ALTO_BOLA && by<=ry+8) ) {incl_x=1; incl_y=-1; incl=derdersup;}
	}

for (i=0 ; i <= 162 ; i++)
		{
		if ( by == L[i].y-ALTO_BOLA && (bx >= L[i].x-ANCHO_BOLA && bx <= L[i].xM) )
			{ incl_y=-1;
			if(L[i].BONUS!=NO_BONUS && L[i].golpes <= 1) { L[i].activoBonus=TRUE; }
			if(rastro==TRUE && L[i].destruye==TRUE)
			{
				L[i].golpes = 0;
				incl_y=1;
			}
			if (L[i].golpes > 0)
				{
				L[i].golpes--;
				ScoreCount+=25;
				}
			if (L[i].destruye == TRUE && L[i].golpes == 0)
				{ 
				L[i].x = L[i].y = L[i].xM = L[i].yM = 0;
				nivelMap[L[i].tile1] = O1; nivelMap[L[i].tile2] = O2;
				ScoreCount+=100;
				}
			}

		if ( by == L[i].yM && (bx >= L[i].x-ANCHO_BOLA && bx <= L[i].xM) )
			{ incl_y=1;
			if(L[i].BONUS!=NO_BONUS && L[i].golpes <= 1) { L[i].activoBonus=TRUE; }
			if(rastro==TRUE && L[i].destruye==TRUE)
			{
				L[i].golpes = 0;
				incl_y=-1;
			}
			if (L[i].golpes > 0)
				{
				L[i].golpes--;
				ScoreCount+=25;
				}
			if (L[i].destruye == TRUE && L[i].golpes == 0)
				{ 
				L[i].x = L[i].y = L[i].xM = L[i].yM = 0;
				nivelMap[L[i].tile1] = O1; nivelMap[L[i].tile2] = O2;
				ScoreCount+=100;
				}
			}

		if ( bx == L[i].x-ANCHO_BOLA && (by >= L[i].y-ALTO_BOLA && by <= L[i].yM) )
			{ incl_x=-1;
			if(L[i].BONUS!=NO_BONUS && L[i].golpes <= 1) { L[i].activoBonus=TRUE; }
			if(rastro==TRUE && L[i].destruye==TRUE)
			{
				L[i].golpes = 0;
				incl_x=1;
			}
			if (L[i].golpes > 0)
				{
				L[i].golpes--;
				ScoreCount+=25;
				}
			if (L[i].destruye == TRUE)
				{ 
				L[i].x = L[i].y = L[i].xM = L[i].yM = 0;
				nivelMap[L[i].tile1] = O1; nivelMap[L[i].tile2] = O2;
				ScoreCount+=100;
				}
			}

		if ( bx == L[i].xM && (by >= L[i].y-ALTO_BOLA && by <= L[i].yM) )
			{ incl_x=1;
			if(L[i].BONUS!=NO_BONUS && L[i].golpes <= 1) { L[i].activoBonus=TRUE; }
			if(rastro==TRUE && L[i].destruye==TRUE)
			{
				L[i].golpes = 0;
				incl_x=-1;
			}
			if (L[i].golpes > 0)
				{
				L[i].golpes--;
				ScoreCount+=25;
				}
			if (L[i].destruye == TRUE && L[i].golpes == 0)
				{ 
				L[i].x = L[i].y = L[i].xM = L[i].yM = 0;
				nivelMap[L[i].tile1] = O1; nivelMap[L[i].tile2] = O2;
				ScoreCount+=100;
				}
			}
		}

	for (i=0 ; i <= 108 ; i++)
		if(L[i].activoBonus == TRUE)	
		{
			if(L[i].BONUS!=NO_BONUS)
				{
					RefrescaBonus(L[i].bonX,L[i].bonY,L[i].BONUS,L[i].bonN);
					L[i].bonY++;
					if(L[i].bonX+16>=rx && L[i].bonX<=rx+ANCHO_RAQUETA && L[i].bonY>=ry && L[i].bonY<=ry+ALTO_RAQUETA)
					{
						if(L[i].BONUS==COMET_BONUS)
							{
							rastro=TRUE;
							L[i].BONUS=NO_BONUS;
							L[i].activoBonus=FALSE;
							RefrescaBonus(240+8,160+8,L[i].BONUS,L[i].bonN);
							}
						if(L[i].BONUS==LONG_R_BONUS)
							{
							ANCHO_RAQUETA=48;
							long_r=TRUE;
							L[i].BONUS=NO_BONUS;
							L[i].activoBonus=FALSE;
							RefrescaBonus(240+8,160+8,L[i].BONUS,L[i].bonN);
							}
						if(L[i].BONUS==LIFE_BONUS)
							{
							LifeCount++;
							L[i].BONUS=NO_BONUS;
							L[i].activoBonus=FALSE;
							RefrescaBonus(240+8,160+8,L[i].BONUS,L[i].bonN);
							}
						if(L[i].BONUS==BIGBALL_BONUS)
							{
							rastro=FALSE;
							tipoBola = BOLA2;
							ANCHO_BOLA=8;
							ALTO_BOLA=8;
							L[i].BONUS=NO_BONUS;
							L[i].activoBonus=FALSE;
							RefrescaBonus(240+8,160+8,L[i].BONUS,L[i].bonN);
							}
						if(L[i].BONUS==MESIAS_BONUS)
							{
							mesias=TRUE;
							MAX_Y=160-12;
							L[i].BONUS=NO_BONUS;
							L[i].activoBonus=FALSE;
							RefrescaBonus(240+8,160+8,L[i].BONUS,L[i].bonN);
							}
					}
					if(L[i].bonY>=MAX_Y+16)
					{
						L[i].BONUS=NO_BONUS;
						L[i].activoBonus=FALSE;
						RefrescaBonus(240+8,160+8,L[i].BONUS,L[i].bonN);
					}
				}
		}

		boton = joypad();
		if ( (boton & J_B)) incRaqueta=3;
		if (!(boton & J_B)) incRaqueta=4;

		if (!(boton & J_RIGHT) && rx < (MAX_X - ANCHO_RAQUETA) ) rx+=incRaqueta;
		if (!(boton & J_LEFT) && rx > MIN_X ) rx-=incRaqueta;
		if (rx > MAX_X - ANCHO_RAQUETA) rx=MAX_X - ANCHO_RAQUETA;

		if (!(boton & J_SELECT)) goto REINICIA;

		//bx += col;
		//by += fil;

		if(incl_x==1) {	if(incl==0) incl=1;	if(incl==2) incl=3;	if(incl==4) incl=5;
					if(incl==6) incl=7;	if(incl==8) incl=9;	if(incl==10) incl=11; }
		if(incl_x==-1) {	if(incl==1) incl=0;	if(incl==3) incl=2;	if(incl==5) incl=4;
					if(incl==7) incl=6;	if(incl==9) incl=8;	if(incl==11) incl=10; }
		if(incl_y==1) {	if(incl==4) incl=6;	if(incl==2) incl=8;	if(incl==0) incl=10;
					if(incl==1) incl=11;	if(incl==3) incl=9;	if(incl==5) incl=7; }
		if(incl_y==-1) {	if(incl==6) incl=4;	if(incl==8) incl=2;	if(incl==10) incl=0;
					if(incl==11) incl=1;	if(incl==9) incl=3;	if(incl==7) incl=5; }

		if(incl==0) {
			if(incl_c<2) { by--; }
			if(incl_c>=2) { by--; bx--; incl_c=0; }
		}
		if(incl==1) {
			if(incl_c<2) { by--; }
			if(incl_c>=2) { by--; bx++; incl_c=0; }
		}
		if(incl==2) if(incl_c>=1) {bx--; by--; incl_c=0;}
		if(incl==3) if(incl_c>=1) {by--; bx++; incl_c=0;}
		if(incl==4) {
			if(incl_c<2) { bx--; }
			if(incl_c>=2) { bx--; by--; incl_c=0; }
		}
		if(incl==5) {
			if(incl_c<2) { bx++; }
			if(incl_c>=2) { bx++; by--; incl_c=0; }
		}
		if(incl==6) {
			if(incl_c<2) { bx--; }
			if(incl_c>=2) { bx--; by++; incl_c=0; }
		}
		if(incl==7) {
			if(incl_c<2) { bx++; }
			if(incl_c>=2) { bx++; by++; incl_c=0; }
		}
		if(incl==8) if(incl_c>=1) {bx--; by++; incl_c=0;}
		if(incl==9) if(incl_c>=1) {bx++; by++; incl_c=0;}
		if(incl==10) {
			if(incl_c<2) { by++; }
			if(incl_c>=2) { by++; bx--; incl_c=0; }
		}
		if(incl==11) {
			if(incl_c<2) { by++; }
			if(incl_c>=2) { by++; bx++; incl_c=0; }
		}

		wait_vbl_done();
		//Wait(2);

		EstableceRaqueta(rx, ry, long_r, PLAYER);
		if(incl_x<0 && incl_y<0) direccion=0;
		if(incl_x>0 && incl_y<0) direccion=1;
		if(incl_x<0 && incl_y>0) direccion=2;
		if(incl_x>0 && incl_y>0) direccion=3;
		EstableceBola(bx, by, rastro, direccion, tipoBola);
		RefrescaScore(ScoreCount);

		if(LifeCount>99) LifeCount=99;
		RefrescaLife(LifeCount);

		if(ChecaTerminadoNivel()==TRUE) {nivel++; goto GANA_NIVEL;}
		RefrescaBG(nivel,mesias);

		incl_c++;
		}

}