Virtual U.org
Get Personal Training on VU Today
    
Top shadow
 
 register/help
User Name:

Password:

OSPRTRES.H Source File
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

OSPRTRES.H

Go to the documentation of this file.
00001 //Filename    : OSPRTRES.H
00002 //Description : Header file of Object Sprite resource
00003 //Owner       : Fred
00004 
00005 #ifndef __OSPRTRES_H
00006 #define __OSPRTRES_H
00007 
00008 #include <ORESX.H>
00009 
00010 //-------- Define struct SpriteRec ----------//
00011 
00013 struct SpriteRec {
00014     enum { TYPE_LEN=1, CODE_LEN=8, RECNO_LEN=5, COUNT_LEN=5, SPRITE_PARA_LEN=2, DAMAGE_LEN=3, TURN_RES_LEN=2 };
00015 
00016     char sprite_type;
00017     char sprite_code[CODE_LEN];
00018 
00019     //  char loc_width[SPRITE_PARA_LEN];
00020     //  char loc_height[SPRITE_PARA_LEN];
00021 
00022     //  char speed[SPRITE_PARA_LEN];
00023     //  char frames_per_step[SPRITE_PARA_LEN];
00024 };
00025 
00026 //----- Define struct SpriteActionRec ------//
00027 
00029 struct SpriteActionRec {
00030     enum { NAME_LEN=8, ACTION_LEN=2, DIR_ID_LEN=2, RECNO_LEN=5, COUNT_LEN=2 };
00031 
00032     char sprite_name[NAME_LEN];
00033     char action[ACTION_LEN];
00034     char dir_id[DIR_ID_LEN];
00035     char first_frame_recno[RECNO_LEN];
00036     char frame_count[COUNT_LEN];
00037 };
00038 
00039 //----- Define struct SpriteMove ------//
00040 
00043 struct SpriteMove {
00044     short first_frame_recno;                        // first frame recno to frame_array.
00045     char  frame_count;                              // no. of frames in the movement
00046 };
00047 
00048 //----- Define struct SpriteStop ------//
00049 
00052 struct SpriteStop {
00053     short frame_recno;                              // frame recno to frame_array.
00054     char  frame_count;
00055 };
00056 
00057 //---------- Define struct SpriteInfo -----------//
00058 
00061 class SpriteInfo {
00062 public:
00063     enum { CODE_LEN=8 };
00064 
00065     char       sprite_code[CODE_LEN+1];           // used as filename to get bitmap from res_bitmap
00066     char       sprite_type;
00067 
00068     short      loc_width;                         // no. of locations it takes horizontally and vertically
00069     short      loc_height;
00070 
00071     char*      bitmap_ptr[MAX_ZOOM_LEVEL];        //temp
00072     short      bitmap_width[MAX_ZOOM_LEVEL];      //temp
00073     short      bitmap_height[MAX_ZOOM_LEVEL];     //temp
00074 
00075     int        loaded_count;                      // if it >= 1, it has been loaded into the memory
00076     ResourceIdx  res_bitmap[MAX_ZOOM_LEVEL];      // frame bitmap resource
00077 
00078     // move_array[24] to cater upward and downward directions for projectile
00079     // and also 16-direction movement for weapons
00080     //SpriteMove         move_array[3*GameDef::MAX_SPRITE_DIR_TYPE];
00081     //SpriteStop         stop_array[3*GameDef::MAX_SPRITE_DIR_TYPE];
00082 
00083 public:
00084     ~SpriteInfo();
00085 
00086     void       load_bitmap_res();
00087     void       free_bitmap_res();
00088 
00089     int      is_loaded()    { return loaded_count>0; }
00090     // SpriteInfo *get_sub_sprite(int i);
00091 private:
00092     void      load_bitmap_res(int zoomLevel, char* namePrefix, char* nameSuffix);
00093 };
00094 
00095 //---------- Define class SpriteRes ------------//
00096 
00098 class SpriteRes {
00099 public:
00100     char init_flag;
00101     int  sprite_info_count;
00102 
00103 private:
00104     SpriteInfo* sprite_info_array;
00105 
00106 public:
00107     SpriteRes()   { init_flag=0; }
00108 
00109     void  init();
00110     void  deinit();
00111 
00112     void  update_speed();
00113 
00114 #ifdef DEBUG
00115     SpriteInfo* operator[](int recNo);
00116 #else
00117     SpriteInfo* operator[](int recNo)   { return sprite_info_array+recNo-1; }
00118 #endif
00119 
00120 private:
00121     void  load_sprite_info();
00122 };
00123 
00124 extern SpriteRes sprite_res;
00125 
00126 //----------------------------------------------//
00127 #endif

Generated on Fri Aug 23 01:38:24 2002 for VirtualU by doxygen1.2.17