rnd-20021006-1-src
[rocksndiamonds.git] / src / init.c
index d800de9f61c72d4a5cd0cf676fc1eda09692d1dd..32b2cb8e3d6504c2f426e26ba65b554695b3c855 100644 (file)
@@ -923,24 +923,31 @@ void InitElementInfo()
   };
 #endif
 
-  int i, j, k;
+  int i, act, dir;
 
-  /* always start with reliable default values */
+  /* set values to -1 to identify later as "uninitialized" values */
   for(i=0; i<MAX_ELEMENTS; i++)
   {
-    for(j=0; j<NUM_GFX_ACTIONS_MAPPED; j++)
+    for(act=0; act<NUM_GFX_ACTIONS_MAPPED; act++)
     {
-      element_info[i].graphic[j] = -1;                 /* use default */
+      element_info[i].graphic[act] = -1;
 
-      for(k=0; k<NUM_MV_DIRECTIONS; k++)
-       element_info[i].direction_graphic[j][k] = -1;   /* use default */
+      for(dir=0; dir<NUM_MV_DIRECTIONS; dir++)
+       element_info[i].direction_graphic[act][dir] = -1;
     }
   }
 
+#if 0
   for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
     element_info[i].graphic[GFX_ACTION_DEFAULT] =
       GFX_CHAR_START + (i - EL_CHAR_START);
+#else
+  for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
+    element_info[i].graphic[GFX_ACTION_DEFAULT] =
+      IMG_CHAR_START + (i - EL_CHAR_START);
+#endif
 
+#if 0
   for (i=EL_SP_START; i<=EL_SP_END; i++)
   {
     int nr_element = i - EL_SP_START;
@@ -952,6 +959,7 @@ void InitElementInfo()
     element_info[i].graphic[GFX_ACTION_DEFAULT] =
       GFX_START_ROCKSSP + nr_graphic;
   }
+#endif
 
 #if 0
   /* this overrides some of the above default settings (GFX_SP_ZONK etc.) */
@@ -1010,36 +1018,42 @@ void InitElementInfo()
     i++;
   }
 
-  /* now set all '-1' values with element specific default values */
+  /* now set all '-1' values to element specific default values */
   for(i=0; i<MAX_ELEMENTS; i++)
   {
     int default_action_graphic = element_info[i].graphic[GFX_ACTION_DEFAULT];
     int default_action_direction_graphic[NUM_MV_DIRECTIONS];
 
     if (default_action_graphic == -1)
-      default_action_graphic = EL_CHAR_QUESTION;
-
-    for(k=0; k<NUM_MV_DIRECTIONS; k++)
-      default_action_direction_graphic[k] =
-       element_info[i].direction_graphic[GFX_ACTION_DEFAULT][k];
+      default_action_graphic = IMG_CHAR_QUESTION;
 
-    for(j=0; j<NUM_GFX_ACTIONS_MAPPED; j++)
+    for(dir=0; dir<NUM_MV_DIRECTIONS; dir++)
     {
-      /* no graphic for this specific action -- use default action graphic */
-      if (element_info[i].graphic[j] == -1)
-       element_info[i].graphic[j] = default_action_graphic;
+      default_action_direction_graphic[dir] =
+       element_info[i].direction_graphic[GFX_ACTION_DEFAULT][dir];
+
+      if (default_action_direction_graphic[dir] == -1)
+       default_action_direction_graphic[dir] = default_action_graphic;
+    }
 
-      for(k=0; k<NUM_MV_DIRECTIONS; k++)
+    for(act=0; act<NUM_GFX_ACTIONS_MAPPED; act++)
+    {
+      for(dir=0; dir<NUM_MV_DIRECTIONS; dir++)
       {
-       int default_direction_graphic = default_action_direction_graphic[k];
+       int default_direction_graphic = element_info[i].graphic[act];
 
-       /* no default direction graphic -- use graphic for current action */
+       /* no graphic for current action -- use default direction graphic */
        if (default_direction_graphic == -1)
-         default_direction_graphic = element_info[i].graphic[j];
+         default_direction_graphic = default_action_direction_graphic[dir];
 
-       if (element_info[i].direction_graphic[j][k] == -1)
-         element_info[i].direction_graphic[j][k] = default_direction_graphic;
+       if (element_info[i].direction_graphic[act][dir] == -1)
+         element_info[i].direction_graphic[act][dir] =
+           default_direction_graphic;
       }
+
+      /* no graphic for this specific action -- use default action graphic */
+      if (element_info[i].graphic[act] == -1)
+       element_info[i].graphic[act] = default_action_graphic;
     }
   }
 
@@ -1067,10 +1081,19 @@ static void InitGraphicInfo()
   {
     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].offset_x = parameter[GFX_ARG_OFFSET];
+    new_graphic_info[i].offset_y = 0;
+
+    /* animation frames are ordered vertically instead of horizontally */
+    if (parameter[GFX_ARG_VERTICAL])
+    {
+      new_graphic_info[i].offset_x = 0;
+      new_graphic_info[i].offset_y = parameter[GFX_ARG_OFFSET];
+    }
 
     new_graphic_info[i].anim_frames = parameter[GFX_ARG_FRAMES];
 
@@ -1078,22 +1101,26 @@ static void InitGraphicInfo()
     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;
+    /* set mode for animation frame order */
+    if (parameter[GFX_ARG_MODE_LOOP])
+      new_graphic_info[i].anim_mode = ANIM_LOOP;
+    else if (parameter[GFX_ARG_MODE_LINEAR])
+      new_graphic_info[i].anim_mode = ANIM_LINEAR;
+    else if (parameter[GFX_ARG_MODE_PINGPONG])
+      new_graphic_info[i].anim_mode = ANIM_PINGPONG;
+    else if (parameter[GFX_ARG_MODE_PINGPONG2])
+      new_graphic_info[i].anim_mode = ANIM_PINGPONG2;
+    else if (parameter[GFX_ARG_FRAMES] > 1)
+      new_graphic_info[i].anim_mode = ANIM_LOOP;
     else
-      new_graphic_info[i].anim_mode = ANIM_NORMAL;
+      new_graphic_info[i].anim_mode = ANIM_NONE;
 
-    /* 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;
+    /* set additional flag to play animation frames in reverse order */
+    if (parameter[GFX_ARG_MODE_REVERSE])
+      new_graphic_info[i].anim_mode |= ANIM_REVERSE;
 
     /* 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