ScummVM API documentation
sprites.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
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 3 of the License, or
10 * (at your option) 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, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef ULTIMA_SPRITES_H
23#define ULTIMA_SPRITES_H
24
25#include "common/array.h"
26#include "common/path.h"
27#include "graphics/managed_surface.h"
28#include "ultima/shared/core/rect.h"
29
30namespace Ultima {
31namespace Shared {
32namespace Gfx {
33
34class Sprite {
35private:
37 Graphics::ManagedSurface _transSurface;
38public:
43
47 Sprite(const Sprite &src);
48
56 Sprite(const byte *src, uint bpp, uint16 w = 16, uint16 h = 16);
57
61 Sprite &operator=(const Sprite &src);
62
67
71 uint16 w() const { return _surface.w; }
72
76 uint16 h() const { return _surface.h; }
77
81 byte *getPixels() { return (byte *)_surface.getPixels(); }
82
86 byte *getBasePtr(int16 x, int16 y) { return (byte *)_surface.getBasePtr(x, y); }
87
91 const byte *getBasePtr(int16 x, int16 y) const { return (const byte *)_surface.getBasePtr(x, y); }
92};
93
94class Sprites {
95protected:
97 Point _spriteSize; // Size of individual sprites
98protected:
106 void load(const Common::Path &name, uint bpp, uint16 w = 16, uint16 h = 16);
107public:
111 virtual ~Sprites() {}
112
116 Point getSpriteSize() const { return _spriteSize; }
117
121 size_t size() const { return _data.size(); }
122
126 bool empty() const { return size() == 0; }
127
131 virtual Sprite &operator[](uint idx) { return _data[idx]; }
132};
133
134} // End of namespace Gfx
135} // End of namespace Shared
136} // End of namespace Ultima
137
138#endif
size_type size() const
Definition: array.h:316
Definition: path.h:52
Definition: managed_surface.h:51
const void * getBasePtr(int x, int y) const
Definition: managed_surface.h:252
int16 & w
Definition: managed_surface.h:134
int16 & h
Definition: managed_surface.h:135
void * getPixels()
Definition: managed_surface.h:271
Definition: sprites.h:34
uint16 w() const
Definition: sprites.h:71
byte * getPixels()
Definition: sprites.h:81
Sprite(const byte *src, uint bpp, uint16 w=16, uint16 h=16)
Sprite & operator=(const Sprite &src)
byte * getBasePtr(int16 x, int16 y)
Definition: sprites.h:86
Sprite(const Sprite &src)
const byte * getBasePtr(int16 x, int16 y) const
Definition: sprites.h:91
void draw(Graphics::ManagedSurface &dest, const Common::Point &pt)
uint16 h() const
Definition: sprites.h:76
Definition: sprites.h:94
virtual Sprite & operator[](uint idx)
Definition: sprites.h:131
void load(const Common::Path &name, uint bpp, uint16 w=16, uint16 h=16)
virtual ~Sprites()
Definition: sprites.h:111
size_t size() const
Definition: sprites.h:121
Point getSpriteSize() const
Definition: sprites.h:116
bool empty() const
Definition: sprites.h:126
Definition: rect.h:144