Exemplo n.º 1
0
Editor::Editor()
{
  layer = 1;

  // Other Sprites
  buffer = create_bitmap( SCREEN_W, SCREEN_H);

  // Create map
  tile_map = new tileMap("data/templates/blank64x48");

  // Create example tile
  exampleTile = new tile(0, tile_map -> getIndex());
  exampleTile -> setX(0);
  exampleTile -> setY(0);

  FONT *f1, *f2, *f3, *f4, *f5;

  //Sets Font
  f1 = load_font("fonts/arial_black.pcx", NULL, NULL);
  f2 = extract_font_range(f1, ' ', 'A'-1);
  f3 = extract_font_range(f1, 'A', 'Z');
  f4 = extract_font_range(f1, 'Z'+1, 'z');

  //Merge fonts
  font = merge_fonts(f4, f5 = merge_fonts(f2, f3));

  //Destroy temporary fonts
  destroy_font(f1);
  destroy_font(f2);
  destroy_font(f3);
  destroy_font(f4);
  destroy_font(f5);

  edittext = ".txt";
  iter = edittext.begin();

  opening = false;
  saving = false;
}
Exemplo n.º 2
0
/* load_txt_font:
 *  Loads a scripted font.
 */
FONT *load_txt_font(AL_CONST char *filename, RGB *pal, void *param)
{
   char buf[1024], *font_str, *start_str = 0, *end_str = 0;
   char font_filename[1024];
   FONT *f, *f2, *f3, *f4;
   PACKFILE *pack;
   int begin, end, glyph_pos=32;

   pack = pack_fopen(filename, F_READ);
   if (!pack) 
      return NULL;

   f = f2 = f3 = f4 = NULL;

   while(pack_fgets(buf, sizeof(buf)-1, pack)) {
      font_str = strtok(buf, " \t");
      if (font_str) 
         start_str = strtok(0, " \t");
      if (start_str) 
         end_str = strtok(0, " \t");

      if (!font_str || !start_str) {
         if (f)
            destroy_font(f);
         if (f2)
            destroy_font(f2);

         pack_fclose(pack);

         return NULL;
      }

      if(font_str[0] == '-')
         font_str[0] = '\0';

      begin = strtol(start_str, 0, 0);

      if (end_str)
         end = strtol(end_str, 0, 0);
      else 
         end = -1;

      if(begin <= 0 || (end > 0 && end < begin)) {
         if (f)
            destroy_font(f);
         if (f2)
            destroy_font(f2);

         pack_fclose(pack);

         return NULL;
      }

      /* Load the font that needs to be merged with the current font */
      if (font_str[0]) {
         if (f2)
            destroy_font(f2);
         if (exists(font_str)) {
            f2 = load_font(font_str, pal, param);
         } else if (is_relative_filename(font_str)) {
            replace_filename(font_filename, filename, font_str,
                             sizeof(font_filename));
            f2 = load_font(font_filename, pal, param);
         }
         else {
            f2 = NULL;
         }
         if (f2)
            glyph_pos=get_font_range_begin(f2, -1);
      }

      if (!f2) {
         if (f)
            destroy_font(f);
         pack_fclose(pack);
         return NULL;
      }

      if (end == -1)
         end = begin + get_font_range_end(f2,-1) - glyph_pos;

      /* transpose the font to the range given in the .txt file */
      f4=extract_font_range(f2,glyph_pos,glyph_pos + (end - begin));

      if (f4 && (begin != glyph_pos)) {
         transpose_font(f4, begin - glyph_pos);
      }
      glyph_pos += (end - begin) + 1;

      /* FIXME: More efficient way than to repeatedely merge into a new font? */
      if (f && f4) {
         f3 = f;
         f = merge_fonts(f4, f3);
         destroy_font(f4);
         destroy_font(f3);
      }
      else {
         f = f4;
      }
      f3=f4=NULL;
   }
   if (f2)
      destroy_font(f2);

   pack_fclose(pack);
   return f;
}
Exemplo n.º 3
0
Menu::Menu(){
  // Init fmod
  FSOUND_Init (44100, 32, 0);

  // Create buffer image
  buffer = create_bitmap( SCREEN_W, SCREEN_H);

  // Load images
  if(!(menu = load_bitmap( ("images/gui/menu.png"), NULL)))
    abort_on_error( "Cannot find image images/gui/menu.png \n Please check your files and try again");
  if(!(menuselect = load_bitmap( ("images/gui/menuSelector.png"), NULL)))
    abort_on_error( "Cannot find image images/gui/menuSelector.png \n Please check your files and try again");
  if(!(help = load_bitmap( ("images/gui/help.png"), NULL)))
    abort_on_error( "Cannot find image images/gui/help.png \n Please check your files and try again");
  if(!(cursor[0] = load_bitmap( ("images/gui/cursor1.png"), NULL)))
    abort_on_error( "Cannot find image images/gui/cursor1.png \n Please check your files and try again");
  if(!(cursor[1] = load_bitmap( ("images/gui/cursor2.png"), NULL)))
    abort_on_error( "Cannot find image images/gui/cursor2.png \n Please check your files and try again");
  if(!(levelSelectLeft = load_bitmap( ("images/gui/levelSelectLeft.png"), NULL)))
    abort_on_error( "Cannot find image images/gui/levelSelectLeft.png \n Please check your files and try again");
  if(!(levelSelectRight = load_bitmap( ("images/gui/levelSelectRight.png"), NULL)))
    abort_on_error( "Cannot find image images/gui/levelSelectRight.png \n Please check your files and try again");
  if(!(levelSelectNumber = load_bitmap( ("images/gui/levelSelectNumber.png"), NULL)))
    abort_on_error( "Cannot find image images/gui/levelSelectNumber.png \n Please check your files and try again");
  if(!(copyright = load_bitmap( ("images/gui/copyright.png"), NULL)))
    abort_on_error( "Cannot find image images/gui/copyright.png \n Please check your files and try again");
  if(!(credits = load_bitmap( ("images/gui/credits.png"), NULL)))
    abort_on_error( "Cannot find image images/gui/credits.png \n Please check your files and try again");

  //Load sound effects
  if(!(click = load_sample(("sounds/click.wav")))){
    abort_on_error( "Cannot find sound sounds/click.png \n Please check your files and try again");
  }

  // Temporary fonts
  FONT *f1, *f2, *f3, *f4, *f5;

  //Sets Font
  if(!(f1 = load_font(("fonts/arial_black.pcx"), NULL, NULL))){
    abort_on_error( "Cannot find font fonts/arial_black.png \n Please check your files and try again");
  }

  f2 = extract_font_range(f1, ' ', 'A'-1);
  f3 = extract_font_range(f1, 'A', 'Z');
  f4 = extract_font_range(f1, 'Z'+1, 'z');

  //Merge fonts
  font = merge_fonts(f4, f5 = merge_fonts(f2, f3));

  //Destroy temporary fonts
  destroy_font(f1);
  destroy_font(f2);
  destroy_font(f3);
  destroy_font(f4);
  destroy_font(f5);

  // Allow transparency
  set_alpha_blender();

  //Variables
  newSelectorY = SCREEN_H - 323;
  selectorY = SCREEN_H - 323;
  selectorX = 60;
  mouse_control = false;
  selectorHovering = 0;

  // Create map for live background
  tile_map = new tileMap("data/levels/level_01");

  // Set background scroll direction
  scrollDirection = "right";
  tile_map -> y = random( 0, (tile_map -> height * 64) - SCREEN_H);
  tile_map -> x = 0;

  levelOn = 0;
}