* Make Sprite an IMMObject.
[matthijs/ABM2.git] / ABM2 / Amaltheia / Sprite.h
1 /***************************************************************************
2  *   Copyright (C) 2005 by Dimitris Saougos & Filippos Papadopoulos   *
3  *   <psybases@gmail.com>                                                             *
4  *                                                                                                       *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU Library General Public License as       *
7  *   published by the Free Software Foundation; either version 2 of the    *
8  *   License, or (at your option) any later version.                                    *
9  *                                                                                                           *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU Library General Public     *
16  *   License along with this program; if not, write to the                 *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #ifndef _SPRITE
22 #define _SPRITE
23
24 #include "Graphics.h"
25 #include "Engine/mmanager.h"
26
27
28 /*
29 Class: Sprite
30 Represents a sprite
31 */
32
33 class Sprite : public IMMObject
34 {
35 private:
36         Texture *tex;
37         int tileWidth;
38         int tileHeight;
39         Graphics *g;
40         //SDL_Rect sRect;
41         unsigned long texW;
42         unsigned long texH;
43         float texWFactor;
44         float texHFactor;
45         void glEnter2DMode();
46         void glLeave2DMode();
47
48 public:
49 //group: Constructors
50         
51         /*constructor: Sprite
52
53         parameters:
54
55         filename - the filename of the image which will be our sprite
56         key - the colour key to use for this sprite
57          tw - the tile width
58          th - the tile height. _tw_ and _th are useful when you have the sprite's animation in fixed tiles in an image.
59          In many cases we haven't, so we specify the full size of the image
60          g- a pointer to the Graphics object*/
61         Sprite( char *filename, colour key, int tw, int th, Graphics *g);
62         ~Sprite(void);
63
64 //group: Methods
65                 
66 /*method: blit
67         Blits a sprite on the display at point (x,y). This is the top-left point of the sprite.
68         
69 parameters:
70         x - x coordinate in screen coordinates
71         y - y coordinate in screen coordinates
72         scalex - the factor to scale in the X axis
73         scalex - the factor to scale in the Y axis
74         dx - tile index in X
75         dy - tile index in Y
76         colour - the colour mask to use*/
77         void blit(int x, int y, float scalex, float scaley, int dx, int dy,  colour c);
78         AUTO_SIZE;      
79 };
80
81 #endif