Adonthell
0.4
Main Page
Related Pages
Classes
Files
File List
File Members
mapobject.h
Go to the documentation of this file.
1
/*
2
$Id: mapobject.h,v 1.13 2001/07/28 20:34:49 gnurou Exp $
3
4
Copyright (C) 1999/2000/2001 Alexandre Courbot
5
Part of the Adonthell Project http://adonthell.linuxgames.com
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.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY.
11
12
See the COPYING file for more details.
13
*/
14
15
16
/**
17
* @file mapobject.h
18
*
19
* @author Alexandre Courbot <alexandrecourbot@linuxgames.com>
20
* @brief Declares the mapobject class.
21
*/
22
23
24
#ifndef _MAPOBJECT_H
25
#define _MAPOBJECT_H
26
27
#include "
animation.h
"
28
#include "
mapsquare_walkable.h
"
29
30
31
/// Where the mapobjects resides in the data tree.
32
#define MAPOBJECTS_DIR "gfx/mapobjects/"
33
34
35
36
/**
37
* Objects that can be placed on a landmap.
38
*
39
* A mapobject is basically a set of animations. Each animation can be freely
40
* placed on a resizeable grid which represents the actual land where the
41
* object will be placed. This grid also has information about the walkability
42
* of it's squares, which will be repercuted on the landmap as soon as the
43
* object is placed.
44
*
45
*/
46
class
mapobject
:
public
mapsquare_walkable_area
47
{
48
public
:
49
50
/**
51
* Default constructor.
52
*
53
*/
54
mapobject
();
55
56
/**
57
* Destructor.
58
*
59
*/
60
~mapobject
();
61
62
/**
63
* Resets the mapobject to its post-constructor state.
64
*
65
*/
66
void
clear
();
67
68
/**
69
* @name State updating.
70
*
71
*/
72
//@{
73
74
/**
75
* Updates the mapobject's state.
76
*
77
*/
78
bool
update
();
79
80
//@}
81
82
83
/**
84
* @name Drawing methods.
85
*
86
*/
87
//@{
88
89
void
draw
(
s_int16
x,
s_int16
y,
const
drawing_area
* da_opt = NULL,
surface
* target = NULL)
const
;
90
91
/**
92
* Similar to draw (), but assume the x and y parameters are where the base
93
* square should appear.
94
*
95
* @param x X position where to draw.
96
* @param y Y position where to draw.
97
* @param da_opt optional drawing_area to use during the drawing operation.
98
* @param target pointer to the surface where to draw the drawable. If NULL, draw on the screen.
99
*/
100
void
draw_from_base
(
s_int16
x,
s_int16
y,
const
drawing_area
* da_opt = NULL,
101
surface
* target = NULL)
const
;
102
103
104
//@}
105
106
107
108
/**
109
* @name Loading/saving methods.
110
*
111
* @note You can't save a mapobject with this class.
112
*
113
*/
114
//@{
115
116
/**
117
* Loads a mapobject from an opened file.
118
* @param file the opened file from which to load.
119
* @return 0 in case of success, error code otherwise.
120
*
121
*/
122
s_int8
get
(
igzstream
& file);
123
124
/**
125
* Loads a mapobject from it's filename.
126
*
127
* @param fname the name of the file to load.
128
*
129
* @return 0 in case of success, error code otherwise.
130
*/
131
s_int8
load
(
string
fname);
132
133
/** Saves an mapobject into an opened file, in %game format, with
134
* alpha and mask values.
135
* @warning as the mapobject which is saved comes from a %screen's depth
136
* surface, it will be slightly altered during the save.
137
* If you want a class capable of saving mapobjects with full
138
* truecolor quality, use mapobject_edit instead.
139
* @param file opened file where to save into.
140
* @return
141
* @li 0 in case of success.
142
* @li -1 in case of error.
143
* @sa save ()
144
*/
145
s_int8
put
(
ogzstream
& file)
const
;
146
147
/** Saves an mapobject into an file, in %game format, with
148
* alpha and mask values.
149
* @warning as the mapobject which is saved comes from a %screen's depth
150
* surface, it will be slightly altered during the save.
151
* If you want a class capable of saving mapobjects with full
152
* truecolor quality, use mapobject_edit instead.
153
* @param fname file name where to save into.
154
* @return
155
* @li 0 in case of success.
156
* @li -1 in case of error.
157
* @sa put ()
158
*/
159
s_int8
save
(
string
fname)
const
;
160
161
//@}
162
163
164
165
/**
166
* @name Individual animations manipulation.
167
*
168
*/
169
//@{
170
171
/**
172
* Returns the number of animations of this mapobject.
173
*
174
*
175
* @return the number of animations of this mapobject.
176
*/
177
u_int16
nbr_of_animations
()
const
178
{
179
return
anim.size ();
180
}
181
182
/**
183
* Returns a pointer to one of the mapobject's animations.
184
*
185
* @param nbr index of the animation to get.
186
*
187
* @return pointer to the nbr animation.
188
*/
189
animation
*
get_animation
(
u_int16
nbr)
190
{
191
return
anim[nbr];
192
}
193
194
/**
195
* Inserts an animation at a given position of the animations array.
196
*
197
* The mapobject will be responsible for freeing the inserted animation.
198
*
199
* @param an pointer to the animation to add.
200
* @param pos index where to add the animation.
201
*
202
* @return 0 in case of success, error code otherwise.
203
*/
204
s_int8
insert_animation
(
animation
* an,
u_int16
pos);
205
206
207
/**
208
* Removes an animation at a given position.
209
* The animation itself will also be deleted ().
210
*
211
* @param pos The index of the animation to remove.
212
*
213
* @return 0 in case of success, error code otherwise.
214
*/
215
s_int8
delete_animation
(
u_int16
pos);
216
217
//@}
218
219
220
#ifndef SWIG
221
/**
222
* Mapobject copy (similar to copy ()).
223
*
224
* @attention Not available from Python. Use copy () from Python instead.
225
* @sa copy ()
226
*/
227
mapobject
&
operator =
(
const
mapobject
& mo);
228
#endif
229
230
/**
231
* Synonym of operator = to guarantee its access from Python.
232
*
233
* @sa operator =
234
*/
235
void
copy
(
const
mapobject
& src)
236
{
237
*
this
= src;
238
}
239
240
private
:
241
242
/**
243
* Forbid value passing.
244
*
245
*/
246
mapobject
(
mapobject
&src);
247
248
mutable
vector <animation *> anim;
249
};
250
251
#endif
src
mapobject.h
Generated by
1.8.1.1