1
/*
2
 *  The Mana World
3
 *  Copyright (C) 2004  The Mana World Development Team
4
 *
5
 *  This file is part of The Mana World.
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 2 of the License, or
10
 *  any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License
18
 *  along with this program; if not, write to the Free Software
19
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
 */
21
22
#ifndef SPRITE_H
23
#define SPRITE_H
24
25
class Graphics;
26
27
/**
28
 * A sprite is some visible object on a map. This abstract class defines the
29
 * interface used by the map to sort and display the sprite.
30
 */
31
class Sprite
32
{
33
    public:
34
        /**
35
         * Destructor.
36
         */
37
        virtual
38
        ~Sprite() {}
39
40
        /**
41
         * Draws the sprite to the given graphics context.
42
         *
43
         * Note: this function could be simplified if the graphics context
44
         * would support setting a translation offset. It already does this
45
         * partly with the clipping rectangle support.
46
         */
47
        virtual void draw(Graphics *graphics, int offsetX, int offsetY) const = 0;
48
49
        /**
50
         * Returns the horizontal size of the sprites graphical representation
51
         * in pixels or 0 when it is undefined.
52
         */
53
        virtual int getWidth() const
54
        { return 0; }
55
56
        /**
57
         * Returns the vertical size of the sprites graphical representation
58
         * in pixels or 0 when it is undefined.
59
         */
60
        virtual int getHeight() const
61
        { return 0; }
62
63
        /**
64
         * Returns the pixel Y coordinate of the sprite.
65
         */
66
        virtual int getPixelY() const = 0;
67
68
        /**
69
         * Returns the number of Image layers used to draw the sprite.
70
         */
71
        virtual int getNumberOfLayers() const
72
        { return 0; }
73
74
        /**
75
         * Returns the current alpha value used to draw the sprite.
76
         */
77
        virtual float getAlpha() const = 0;
78
79
        /**
80
         * Sets the alpha value used to draw the sprite.
81
         */
82
        virtual void setAlpha(float alpha) = 0;
83
};
84
85
#endif