f7a0c347a885d6ad9e40c1109d537652d16a70a2
[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
26
27 /*
28 Class: Sprite
29 Represents a sprite
30 */
31
32 class Sprite
33 {
34 private:
35         Texture *tex;
36         int tileWidth;
37         int tileHeight;
38         Graphics *g;
39         //SDL_Rect sRect;
40         unsigned long texW;
41         unsigned long texH;
42         float texWFactor;
43         float texHFactor;
44         void glEnter2DMode();
45         void glLeave2DMode();
46
47 public:
48 //group: Constructors
49         
50         /*constructor: Sprite
51
52         parameters:
53
54         filename - the filename of the image which will be our sprite
55         key - the colour key to use for this sprite
56          tw - the tile width
57          th - the tile height. _tw_ and _th are useful when you have the sprite's animation in fixed tiles in an image.
58          In many cases we haven't, so we specify the full size of the image
59          g- a pointer to the Graphics object*/
60         Sprite( char *filename, colour key, int tw, int th, Graphics *g);
61         ~Sprite(void);
62
63 //group: Methods
64                 
65 /*method: blit
66         Blits a sprite on the display at point (x,y). This is the top-left point of the sprite.
67         
68 parameters:
69         x - x coordinate in screen coordinates
70         y - y coordinate in screen coordinates
71         scalex - the factor to scale in the X axis
72         scalex - the factor to scale in the Y axis
73         dx - tile index in X
74         dy - tile index in Y
75         colour - the colour mask to use*/
76         void blit(int x, int y, float scalex, float scaley, int dx, int dy,  colour c);
77         
78 };
79
80 #endif