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 #ifndef SLUDGE_SPRITES_H
22 #define SLUDGE_SPRITES_H
23 
24 #include "graphics/managed_surface.h"
25 
26 namespace Sludge {
27 
28 struct Sprite {
29  int xhot, yhot;
30  Graphics::Surface surface;
31  Graphics::Surface burnSurface;
32 };
33 
35 public:
36  uint16 *pal;
37  byte *r;
38  byte *g;
39  byte *b;
40  byte originalRed, originalGreen, originalBlue, total;
41 
42  SpritePalette() { init(); }
43  ~SpritePalette() { kill(); }
44 
45  void init() {
46  pal = nullptr;
47  r = g = b = nullptr;
48  total = 0;
49  originalRed = originalGreen = originalBlue = 255;
50  }
51 
52  void kill() {
53  if (pal) {
54  delete[] pal;
55  pal = nullptr;
56  }
57  if (r) {
58  delete[] r;
59  r = nullptr;
60  }
61  if (g) {
62  delete[] g;
63  g = nullptr;
64  }
65  if (b) {
66  delete[] b;
67  b = nullptr;
68  }
69  }
70 
71  void setColor(byte red, byte green, byte blue) {
72  originalRed = red;
73  originalGreen = green;
74  originalBlue = blue;
75  }
76 };
77 
78 struct SpriteBank {
79  int total;
80  int type;
81  Sprite *sprites;
82  SpritePalette myPalette;
83  bool isFont;
84 };
85 
86 // Sprite display informations
87 struct SpriteDisplay {
88  int x, y;
89  int width, height;
90  bool freeAfterUse;
91  Graphics::FLIP_FLAGS flip;
92  Graphics::Surface *surface;
93  byte transparency;
94 
95  SpriteDisplay(int xpos, int ypos, Graphics::FLIP_FLAGS f, Graphics::Surface *ptr, int w = -1, int h = 1, bool free = false, byte trans = 255) :
96  x(xpos), y(ypos), flip(f), surface(ptr), width(w), height(h), freeAfterUse(free), transparency(trans) {
97  }
98 };
99 
100 } // End of namespace Sludge
101 
102 #endif
Definition: surface.h:67
Definition: sprites.h:28
Definition: sprites.h:78
Definition: sprites.h:34
Definition: builtin.h:27
Definition: sprites.h:87