C:/Documents and Settings/mtauraso/Desktop/proj3/projectX/Sprite.h

Go to the documentation of this file.
00001 #ifndef SPRITE_H
00002 #define SPRITE_H
00003 #include "SDL.h"
00004 #include "SDL_opengl.h"
00005 #include <string>
00006 #include <iostream>
00007 #include <map>
00008 
00009 typedef enum { LEFT = -1, RIGHT = 1 } xDirection;
00010 typedef enum { UP = -1, MIDDLE = 0, DOWN = 1 } yDirection;
00011 
00012 class Sprite
00013 {
00014 public:
00015         Sprite(){;}
00016         /*
00017         filename of a png to be the sprite.
00018         */
00019         Sprite(std::string filename);
00020         Sprite(std::string filename, int width, int height);
00021         Sprite(Sprite *sprite);
00022         /*
00023         level coordinates of the location to draw the sprite 
00024         (hopefully passed to it by the object whose sprite it is)
00025         */
00026         virtual Sprite* instance();
00027         virtual void draw(int x, int y, bool origin = LEVEL);
00028         int width(){return _rect.w;}
00029         int height(){return _rect.h;}
00030         void setHeight( int h ){ _rect.h = h; };
00031         void setWidth( int w ){ _rect.w = w; };
00032         SDL_Rect rect(){return _rect;}
00033         void setRect( SDL_Rect r ){ _rect = r; };
00034         std::string filename() {return _filename;}
00035 
00036         virtual void update(){;}
00037         virtual void reset(){;}
00038 
00039         static Sprite* loadSprite( std::string filename );
00040         static Sprite* loadText( std::string filename );
00041 
00042 
00043         xDirection getDirection() {return _direction;}
00044         void setDirection(xDirection direction) {_direction = direction;}
00045 
00046         //static const bool LEFT = true;
00047         //static const bool RIGHT = false;
00048         static const bool LEVEL = true;
00049         static const bool SCREEN = false;
00050 
00051 protected:
00052 
00053         static std::map<std::string,Sprite *> SPRITES;
00054 
00055 
00056         std::string _filename;
00057         int _hTexture;
00058         GLfloat _coords[4];
00059         SDL_Rect _rect;
00060         xDirection _direction;
00061 };
00062 
00063 #endif

Generated on Sat Apr 22 15:05:20 2006 for ProjectX by  doxygen 1.4.6-NO