home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / RAYCAST.ZIP / ANIMTEX.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-10  |  2.0 KB  |  84 lines

  1. #include "ray.h"
  2. #include "globals.h"
  3.  
  4. USHORT anim_tex_count;
  5. wall_entry ** anim_tex_list;
  6.  
  7. /*
  8.    Is_Anim_Texture
  9.    Returns TRUE if texture can be animated
  10. */
  11.  
  12. BOOL Is_Anim_Texture(wall_entry * test_wall)
  13. {
  14. return ( ((test_wall->anim_speed!=0)&&(test_wall->num_image>1))
  15.             ? TRUE : FALSE);
  16. }
  17.  
  18. /*
  19.    Setup_Anim_Tex
  20.    Builds a list of animated textures to speed updates in animation
  21.    Notes: Requires that both floor and wall textures have been loaded.
  22.    Otherwise will crash
  23. */
  24.  
  25. void Setup_Anim_Tex()
  26. {
  27. anim_tex_count=0;
  28. USHORT cur_tex;
  29.  
  30. // First get a count of all anim textures
  31. for (cur_tex=1; cur_tex<Number_Of_Textures; cur_tex++)
  32.   if (Is_Anim_Texture(wall+cur_tex))
  33.      anim_tex_count++;
  34.  
  35. for (cur_tex=0; cur_tex<(Number_Of_FTs-1); cur_tex++)
  36.   if (Is_Anim_Texture(floortex+cur_tex))
  37.      anim_tex_count++;
  38.  
  39. // Are there any animations?
  40.  
  41. if (anim_tex_count==0)
  42.    return;
  43.  
  44. // allocate memory for list
  45.  
  46. anim_tex_list=(wall_entry **)NewPtr(anim_tex_count * sizeof(wall_entry *));
  47.  
  48. // set all members of list to see the anim texs
  49.  
  50. USHORT cur_anim_index=0;
  51.  
  52. for (cur_tex=1; cur_tex<Number_Of_Textures; cur_tex++)
  53.    if (Is_Anim_Texture(wall+cur_tex)) {
  54.       anim_tex_list[cur_anim_index]=wall+cur_tex;
  55.       cur_anim_index++;
  56.       }
  57.  
  58. for (cur_tex=0; cur_tex< (Number_Of_FTs-1); cur_tex++)
  59.     if (Is_Anim_Texture(floortex+cur_tex)) {
  60.        anim_tex_list[cur_anim_index]=floortex+cur_tex;
  61.        cur_anim_index++;
  62.        }
  63. }
  64.  
  65. /*
  66.     Animate_Textures
  67.     Updates all textures based on the update num passed to the function
  68.     Note: Requires Setup_Anim_Tex to be called first!
  69. */
  70.  
  71. void Animate_Textures(long update_num)
  72. {
  73. USHORT cur_anim_index;
  74. wall_entry * cur_texture;
  75. for (cur_anim_index=0; cur_anim_index<anim_tex_count; cur_anim_index++) {
  76.    cur_texture=anim_tex_list[cur_anim_index];
  77.    if (!(update_num & cur_texture->anim_speed)) {
  78.         cur_texture->cur_image++;
  79.         if (cur_texture->cur_image>=cur_texture->num_image)
  80.            cur_texture->cur_image=0;
  81.         }
  82.    }
  83. }
  84.