rnd-20020919-1-src
[rocksndiamonds.git] / src / init.c
index 2f19f9495b280a3d0f111e8e0caae5ea5563d070..96d96ace7186d6b75c3b39435c3d18d0d8f4e9a4 100644 (file)
@@ -36,9 +36,10 @@ static char *image_filename[NUM_PICTURES] =
   "RocksSP.pcx",
   "RocksDC.pcx",
   "RocksMore.pcx",
-  "RocksFont.pcx",
-  "RocksFont2.pcx",
-  "RocksFont3.pcx"
+  "RocksFontBig.pcx",
+  "RocksFontSmall.pcx",
+  "RocksFontMedium.pcx",
+  "RocksFontEM.pcx"
 }; 
 
 static void InitSetup(void);
@@ -382,9 +383,9 @@ void InitGfx()
   pix[PIX_DB_DOOR] = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH);
   pix[PIX_DB_FIELD] = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH);
 
-  pix[PIX_SMALLFONT] = LoadCustomImage(image_filename[PIX_SMALLFONT]);
+  pix[PIX_FONT_SMALL] = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
 
-  InitFontInfo(NULL, NULL, pix[PIX_SMALLFONT]);
+  InitFontInfo(NULL, NULL, pix[PIX_FONT_SMALL], NULL);
 
   DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW);
   DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED);
@@ -393,7 +394,7 @@ void InitGfx()
 
   for(i=0; i<NUM_PICTURES; i++)
   {
-    if (i != PIX_SMALLFONT)
+    if (i != PIX_FONT_SMALL)
     {
       DrawInitText(image_filename[i], 150, FC_YELLOW);
 
@@ -401,7 +402,8 @@ void InitGfx()
     }
   }
 
-  InitFontInfo(pix[PIX_BIGFONT], pix[PIX_MEDIUMFONT], pix[PIX_SMALLFONT]);
+  InitFontInfo(pix[PIX_FONT_BIG], pix[PIX_FONT_MEDIUM], pix[PIX_FONT_SMALL],
+              pix[PIX_FONT_EM]);
 
   InitTileClipmasks();
 }
@@ -822,9 +824,94 @@ void InitElementInfo()
     { -1,                              -1                      }
   };
 
+  static struct
+  {
+    int element;
+    int graphic_left;
+    int graphic_right;
+    int graphic_up;
+    int graphic_down;
+  }
+  element_to_direction_graphic[] =
+  {
+    {
+      EL_FLIEGER,
+      IMG_SPACESHIP_LEFT,      IMG_SPACESHIP_RIGHT,
+      IMG_SPACESHIP_UP,                IMG_SPACESHIP_DOWN
+    },
+    {
+      EL_KAEFER,
+      IMG_BUG_LEFT,            IMG_BUG_RIGHT,
+      IMG_BUG_UP,              IMG_BUG_DOWN
+    },
+    {
+      EL_PACMAN,
+      IMG_PACMAN_LEFT,         IMG_PACMAN_RIGHT,
+      IMG_PACMAN_UP,           IMG_PACMAN_DOWN
+    },
+    {
+      EL_SPIELER1,
+      IMG_PLAYER1_LEFT,                IMG_PLAYER1_RIGHT,
+      IMG_PLAYER1_UP,          IMG_PLAYER1_DOWN
+    },
+    {
+      EL_SPIELER2,
+      IMG_PLAYER2_LEFT,                IMG_PLAYER2_RIGHT,
+      IMG_PLAYER2_UP,          IMG_PLAYER2_DOWN
+    },
+    {
+      EL_SPIELER3,
+      IMG_PLAYER3_LEFT,                IMG_PLAYER3_RIGHT,
+      IMG_PLAYER3_UP,          IMG_PLAYER3_DOWN
+    },
+    {
+      EL_SPIELER4,
+      IMG_PLAYER4_LEFT,                IMG_PLAYER4_RIGHT,
+      IMG_PLAYER4_UP,          IMG_PLAYER4_DOWN
+    },
+    {
+      EL_SCHWEIN,
+      IMG_PIG_LEFT,            IMG_PIG_RIGHT,
+      IMG_PIG_UP,              IMG_PIG_DOWN
+    },
+    {
+      EL_DRACHE,
+      IMG_DRAGON_LEFT,         IMG_DRAGON_RIGHT,
+      IMG_DRAGON_UP,           IMG_DRAGON_DOWN
+    },
+    {
+      EL_MOLE,
+      IMG_MOLE_LEFT,           IMG_MOLE_RIGHT,
+      IMG_MOLE_UP,             IMG_MOLE_DOWN
+    },
+    {
+      EL_PINGUIN,
+      IMG_PENGUIN_LEFT,                IMG_PENGUIN_RIGHT,
+      IMG_PENGUIN_UP,          IMG_PENGUIN_DOWN
+    },
+    {
+      EL_SP_MURPHY,
+      IMG_SP_MURPHY_LEFT,      IMG_SP_MURPHY_RIGHT,
+      IMG_SP_MURPHY_UP,                IMG_SP_MURPHY_DOWN
+    },
+    {
+      EL_SP_SNIKSNAK,
+      IMG_SP_SNIKSNAK_LEFT,    IMG_SP_SNIKSNAK_RIGHT,
+      IMG_SP_SNIKSNAK_UP,      IMG_SP_SNIKSNAK_DOWN
+    },
+    {
+      -1,
+      -1,                      -1,
+      -1,                      -1
+    }
+  };
+
   /* always start with reliable default values */
   for(i=0; i<MAX_ELEMENTS; i++)
+  {
     element_info[i].graphic = GFX_LEERRAUM;
+    element_info[i].has_direction_graphic = FALSE;
+  }
 
   for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
     element_info[i].graphic = GFX_CHAR_START + (i - EL_CHAR_START);
@@ -850,6 +937,25 @@ void InitElementInfo()
     element_info[element].graphic = graphic;
     i++;
   }
+
+  /* this initializes special graphics for left/right/up/down directions */
+  i = 0;
+  while (element_to_direction_graphic[i].element > -1)
+  {
+    int element = element_to_direction_graphic[i].element;
+    int graphic_left  = element_to_direction_graphic[i].graphic_left;
+    int graphic_right = element_to_direction_graphic[i].graphic_right;
+    int graphic_up    = element_to_direction_graphic[i].graphic_up;
+    int graphic_down  = element_to_direction_graphic[i].graphic_down;
+
+    element_info[element].direction_graphic[MV_BIT_LEFT]  = graphic_left;
+    element_info[element].direction_graphic[MV_BIT_RIGHT] = graphic_right;
+    element_info[element].direction_graphic[MV_BIT_UP]    = graphic_up;
+    element_info[element].direction_graphic[MV_BIT_DOWN]  = graphic_down;
+
+    element_info[element].has_direction_graphic = TRUE;
+    i++;
+  }
 }
 
 static void InitGraphicInfo()
@@ -858,24 +964,54 @@ static void InitGraphicInfo()
 
   image_files = getCurrentImageList();
 
-  printf("D> %d\n", image_files[GFX_BD_DIAMOND].parameter[GFXARG_NUM_FRAMES]);
-  printf("W> %d\n", image_files[GFX_ROBOT_WHEEL].parameter[GFXARG_NUM_FRAMES]);
-
   for(i=0; i<MAX_GRAPHICS; i++)
   {
     /* always start with reliable default values */
     graphic_info[i].bitmap = NULL;
     graphic_info[i].src_x = 0;
     graphic_info[i].src_y = 0;
-    graphic_info[i].anim_frames = 1;
-    graphic_info[i].anim_delay = 0;
-    graphic_info[i].anim_mode = ANIM_NORMAL;
 
     getGraphicSource(i, &graphic_info[i].bitmap,
                     &graphic_info[i].src_x, &graphic_info[i].src_y);
   }
 
-#if 1
+  for(i=0; i<NUM_IMAGE_FILES; i++)
+  {
+    int *parameter = image_files[i].parameter;
+
+    /* always start with reliable default values */
+    new_graphic_info[i].bitmap = getBitmapFromImageID(i);
+    new_graphic_info[i].src_x = parameter[GFX_ARG_XPOS] * TILEX;
+    new_graphic_info[i].src_y = parameter[GFX_ARG_YPOS] * TILEY;
+
+    new_graphic_info[i].anim_frames = parameter[GFX_ARG_FRAMES];
+
+    new_graphic_info[i].anim_delay = parameter[GFX_ARG_DELAY];
+    if (new_graphic_info[i].anim_delay == 0)   /* delay must be at least 1 */
+      new_graphic_info[i].anim_delay = 1;
+
+    /* basically, animation can be either normal or reverse direction */
+    if (parameter[GFX_ARG_REVERSE])
+      new_graphic_info[i].anim_mode = ANIM_REVERSE;
+    else
+      new_graphic_info[i].anim_mode = ANIM_NORMAL;
+
+    /* additionally, animation can be either pingpong or pingpong2 layout */
+    if (parameter[GFX_ARG_PINGPONG])
+      new_graphic_info[i].anim_mode |= ANIM_PINGPONG;
+    else if (parameter[GFX_ARG_PINGPONG2])
+      new_graphic_info[i].anim_mode |= ANIM_PINGPONG2;
+
+    /* animation synchronized with global frame counter, not move position */
+    new_graphic_info[i].anim_global_sync = parameter[GFX_ARG_GLOBAL_SYNC];
+
+    new_graphic_info[i].anim_vertical = parameter[GFX_ARG_VERTICAL];
+  }
+
+#if 0
+  printf("D> %d\n", image_files[GFX_BD_DIAMOND].parameter[GFX_ARG_NUM_FRAMES]);
+  printf("W> %d\n", image_files[GFX_ROBOT_WHEEL].parameter[GFX_ARG_NUM_FRAMES]);
+
   graphic_info[GFX_ABLENK].bitmap = getBitmapFromImageID(GFX_ROBOT_WHEEL);
   graphic_info[GFX_ABLENK].src_x = 0;
   graphic_info[GFX_ABLENK].src_y = 0;