frameseq.h

Go to the documentation of this file.
00001 /*
00002  *  Copyright (C) 2000-2001  The Exult Team
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00019 #ifndef INCL_FRAMESEQ
00020 #define INCL_FRAMESEQ 1
00021 
00022 /*
00023  *  A sequence of frames.  Frame 0 is the resting state.
00024  */
00025 class Frames_sequence
00026   {
00027   unsigned char *frames;
00028   int num_frames;
00029 public:
00030   Frames_sequence(int cnt, unsigned char *f);
00031   ~Frames_sequence()
00032     { delete [] frames; }
00033           // Get resting frame.
00034   unsigned char get_resting() const
00035     { return frames[0]; }
00036           // Get next frame.  Call
00037           //   with index = 0 for first one.
00038   unsigned char get_next(int& index) const
00039     {
00040     if (++index >= num_frames)
00041       index = 1;
00042     return frames[index];
00043     }
00044   void decrement(int& index) const
00045     { if (--index <= 0) index = num_frames - 1; }
00046           // Find frame, masking off rotation.
00047           // Rets. 0 if not found.
00048   int find_unrotated(unsigned char frame)
00049     {
00050     for (int i = num_frames - 1; i > 0; i--)
00051       if (((frame ^ frames[i])&0xf) == 0)
00052         return i;
00053     return 0;
00054     }
00055   };
00056 #endif

Generated on Mon Jul 9 14:42:45 2007 for ExultEngine by  doxygen 1.5.1