home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 February / maximum-cd-2009-02.iso / DiscContents / SMC_1.6_win32.exe / src / objects / objectsprite.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2008-06-21  |  1.9 KB  |  70 lines

  1. /***************************************************************************
  2.  * objectsprite.cpp  - multi image object sprite class
  3.  *
  4.  * Copyright (C) 2005 - 2008 Florian Richter
  5.  ***************************************************************************/
  6. /*
  7.    This program is free software; you can redistribute it and/or modify
  8.    it under the terms of the GNU General Public License as published by
  9.    the Free Software Foundation; either version 3 of the License, or
  10.    (at your option) any later version.
  11.    
  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  14. */
  15.  
  16. #include "../objects/objectsprite.h"
  17. #include "../core/game_core.h"
  18.  
  19. /* *** *** *** *** *** *** *** cImageObjectSprite *** *** *** *** *** *** *** *** *** *** */
  20.  
  21. cImageObjectSprite :: cImageObjectSprite( float x /* = 0 */, float y /* = 0 */ )
  22. : cMovingSprite( NULL, x, y )
  23. {
  24.     curr_img = -1;
  25. }
  26.  
  27. cImageObjectSprite :: ~cImageObjectSprite( void )
  28. {
  29.     images.clear();
  30. }
  31.  
  32. void cImageObjectSprite :: Set_Image( int num, bool new_startimage /* = 0 */, bool del_img /* = 0 */ )
  33. {
  34.     if( curr_img == num )
  35.     {
  36.         return;
  37.     }
  38.  
  39.     curr_img = num;
  40.  
  41.     if( curr_img < 0 )
  42.     {
  43.         cMovingSprite::Set_Image( NULL, new_startimage, del_img );
  44.     }
  45.     else if( curr_img < static_cast<int>(images.size()) )
  46.     {
  47.         cMovingSprite::Set_Image( images[curr_img], new_startimage, del_img );
  48.     }
  49.     else
  50.     {
  51.         printf( "Warning : Object image number %d bigger as the array size %u, sprite type %d, name %s\n", curr_img, static_cast<unsigned int>(images.size()), type, name.c_str() );
  52.     }
  53. }
  54.  
  55. GL_Surface *cImageObjectSprite :: Get_Image( unsigned int num ) 
  56. {
  57.     if( num >= images.size() )
  58.     {
  59.         return NULL;
  60.     }
  61.  
  62.     return images[num];
  63. }
  64.  
  65. void cImageObjectSprite :: Clear_Images( void )
  66. {
  67.     curr_img = -1;
  68.     images.clear();
  69. }
  70.