diff options
Diffstat (limited to 'src/sprite.h')
-rw-r--r-- | src/sprite.h | 89 |
1 files changed, 57 insertions, 32 deletions
diff --git a/src/sprite.h b/src/sprite.h index 847c01a6..38db8b41 100644 --- a/src/sprite.h +++ b/src/sprite.h @@ -1,7 +1,6 @@ /* * The Mana Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2010 The Mana Developers * * This file is part of The Mana Client. * @@ -22,64 +21,90 @@ #ifndef SPRITE_H #define SPRITE_H +#include "resources/spritedef.h" + class Graphics; +class Image; -/** - * A sprite is some visible object on a map. This abstract class defines the - * interface used by the map to sort and display the sprite. - */ class Sprite { public: + virtual ~Sprite() {} + + /** + * Resets the sprite. + * + * @returns true if the sprite changed, false otherwise + */ + virtual bool reset() = 0; + /** - * Destructor. + * Plays an action using the current direction. + * + * @returns true if the sprite changed, false otherwise */ - virtual - ~Sprite() {} + virtual bool play(std::string action) = 0; /** - * Draws the sprite to the given graphics context. + * Inform the animation of the passed time so that it can output the + * correct animation frame. * - * Note: this function could be simplified if the graphics context - * would support setting a translation offset. It already does this - * partly with the clipping rectangle support. + * @returns true if the sprite changed, false otherwise */ - virtual void draw(Graphics *graphics, int offsetX, int offsetY) const = 0; + virtual bool update(int time) = 0; /** - * Returns the horizontal size of the sprites graphical representation - * in pixels or 0 when it is undefined. + * Draw the current animation frame at the coordinates given in screen + * pixels. */ - virtual int getWidth() const - { return 0; } + virtual bool draw(Graphics* graphics, int posX, int posY) const = 0; /** - * Returns the vertical size of the sprites graphical representation - * in pixels or 0 when it is undefined. + * Gets the width in pixels of the image of the current frame */ - virtual int getHeight() const - { return 0; } + virtual int getWidth() const = 0; /** - * Returns the pixel Y coordinate of the sprite. + * Gets the height in pixels of the image of the current frame */ - virtual int getPixelY() const = 0; + virtual int getHeight() const = 0; /** - * Returns the number of Image layers used to draw the sprite. + * Returns a reference to the current image being drawn. */ - virtual int getNumberOfLayers() const - { return 0; } + virtual const Image* getImage() const = 0; /** - * Returns the current alpha value used to draw the sprite. + * Sets the direction. + * + * @returns true if the sprite changed, false otherwise */ - virtual float getAlpha() const = 0; + virtual bool setDirection(SpriteDirection direction) = 0; /** - * Sets the alpha value used to draw the sprite. + * Sets the alpha value of the animated sprite */ - virtual void setAlpha(float alpha) = 0; + virtual void setAlpha(float alpha) + { mAlpha = alpha; } + + /** + * Returns the current alpha opacity of the animated sprite. + */ + virtual float getAlpha() const + { return mAlpha; } + + /** + * Returns the current frame number for the sprite. + */ + virtual size_t getCurrentFrame() const = 0; + + /** + * Returns the frame count for the sprite. + */ + virtual size_t getFrameCount() const = 0; + + protected: + float mAlpha; /**< The alpha opacity used to draw */ }; -#endif +#endif // SPRITE_H |