This file is indexed.

/usr/include/flatzebra/RSprite.h is in libflatzebra-dev 0.1.6-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
/*  $Id: RSprite.h,v 1.4 2010/07/31 05:29:45 sarrazip Exp $
    RSprite.h - Sprite with floating point coordinates in a 2D game.

    flatzebra - Generic 2D Game Engine library
    Copyright (C) 1999-2003 Pierre Sarrazin <http://sarrazip.com/>

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
*/

#ifndef _H_RSprite
#define _H_RSprite

#include <flatzebra/Couple.h>
#include <flatzebra/RCouple.h>
#include <flatzebra/PixmapArray.h>

#include <vector>


namespace flatzebra {


typedef std::vector<class RSprite *> RSpriteList;


class RSprite
/*  RSprite in a 2D game.
*/
{
public:
    RSprite(const PixmapArray &pixmapArray,
            const RCouple &pos = RCouple(),
            const RCouple &speed = RCouple(),
            const RCouple &accel = RCouple(),
            const RCouple &collBoxPos = RCouple(),
            const RCouple &collBoxSize = RCouple());
    /*  Initializes the sprite with the given pixmap array and coordinates.
        Keeps a pointer to 'pixmapArray' but does NOT become the owner
        of the pixmap array.
        Keeps copies of the other parameters.

        The "collision box" is the box that is used in detecting
        collisions between this sprite and other sprites.
        'collBoxPos' must be a position with respect to top left corner
        of sprite's rectangle.
    */

    virtual ~RSprite();
    /*  Does not free the pixmap array given to the constructor.
    */

    size_t getNumPixmaps() const;
    /*  Returns the number of pixmaps in this sprite.
    */

    SDL_Surface *getPixmap(size_t i) const;
    /*  Returns the pixmap at index 'i' is this sprite's pixmap list.
        This index is zero-based.
        No check is made to ensure that i is valid.
    */

    const PixmapArray *getPixmapArray() const;
    /*  Returns the (non null) pointer to this sprite's pixmap array.
    */

    const RCouple &getPos() const;
    const RCouple &getSpeed() const;
    const RCouple &getAccel() const;
    const Couple &getSize() const;
    RCouple &getPos();
    RCouple &getSpeed();
    RCouple &getAccel();
    Couple &getSize();
    /*  Returns a reference to the coordinates of this sprite.
    */

    RCouple getCenterPos() const;
    /*  Returns the position of the center of this sprite.
    */

    void setCenterPos(const RCouple &c);
    /*  Sets the (top-left) position so that 'c' becomes the center position.
    */

    RCouple getLowerLeftPos() const;
    /*  Returns the position of the lower left corner of the rectangle
        that contains the sprite.
    */

    RCouple getLowerRightPos() const;
    /*  Returns the position of the lower right corner of the rectangle
        that contains the sprite.
        This position is the sum of the sprite's position and its size.
    */

    RCouple getCollBoxPos() const;
    RCouple getCollBoxSize() const;
    void setCollBoxPos(const RCouple &c);
    void setCollBoxSize(const RCouple &c);
    /*  Returns or changes the coordinates of this sprite's collision box.
        The position is relative to the top left corner of the sprite.
    */

    void setPos(const RCouple &c);
    void setSpeed(const RCouple &c);
    void setAccel(const RCouple &c);
    void addSpeedToPos();
    void subSpeedFromPos();
    void addAccelToSpeed();
    void subAccelFromSpeed();
    /*  Change the coordinates of the sprite.
    */

    bool collidesWithRSprite(const RSprite &s) const;
    /*  Returns true if the collision box of sprite 's' has an intersection
        with the collision box of this sprite.
    */

    void setTimeToLive(unsigned long t);
    unsigned long getTimeToLive() const;
    unsigned long decTimeToLive();
    void clearTimeToLive();
    /*  Manage the time to live variable.
        decTimeToLive() does not decrement the value if it is already zero;
        it returns the resulting value.
    */


    size_t currentPixmapIndex;  // index into thePixmapArray
    /*  The current pixmap index can be used to have this sprite object
        remember which image is currently used.
        setCurrentPixmapIndex() does not check if 'i' is valid;
        'i' must be lower than the size of this sprite's PixmapArray.

        'currentPixmapIndex' is initially zero.
    */


    long *values;  // array
    size_t numUserValues;

    void boundPosition(Couple settingSizeInPixels);
    /*  If the position of sprite 's' is out of the setting (whose size
        is given by 'settingSizeInPixels'), then this position is adjusted
        to bring the sprite back in.
        It is assumed that the top left corner of the setting is (0, 0).
    */

protected:  // data became protected with version 0.1 @sarrazip 20010203

    /*  All the following RCouple objects are in pixels.
        All pixmaps in the pixmap array must have the same size.
    */

    const PixmapArray *thePixmapArray;  // not owned by this object

    RCouple pos;    // in pixels
    RCouple speed;  // in pixels
    RCouple accel;  // in pixels
    Couple size;    // in (integer) pixels
    unsigned long timeToLive;
            // number of ticks left for this sprite;
            // often used to count other things.

    RCouple collBoxPos;
            // position of collision box w.r.t. to top left corner of sprite
    RCouple collBoxSize;

private:
    /*        Forbidden operations:
    */
    RSprite(const RSprite &x);
    RSprite &operator = (const RSprite &x);
};


/*  INLINE METHODS
*/

inline
const RCouple &
RSprite::getPos() const
{
    return pos;
}

inline
const RCouple &
RSprite::getSpeed() const
{
    return speed;
}

inline
const RCouple &
RSprite::getAccel() const
{
    return accel;
}

inline
const Couple &
RSprite::getSize() const
{
    return size;
}

inline
RCouple &
RSprite::getPos()
{
    return pos;
}

inline
RCouple &
RSprite::getSpeed()
{
    return speed;
}

inline
RCouple &
RSprite::getAccel()
{
    return accel;
}

inline
Couple &
RSprite::getSize()
{
    return size;
}

inline
RCouple
RSprite::getCenterPos() const
{
    return pos + size / 2;
}

inline
void
RSprite::setCenterPos(const RCouple &c)
{
    pos = c - size / 2;
}


inline
RCouple
RSprite::getLowerLeftPos() const
{
    return RCouple(pos.x, pos.y + size.y);
}


inline
RCouple
RSprite::getLowerRightPos() const
{
    return pos + size;
}

inline
RCouple
RSprite::getCollBoxPos() const
{
    return collBoxPos;
}

inline
RCouple
RSprite::getCollBoxSize() const
{
    return collBoxSize;
}

inline
void
RSprite::setCollBoxPos(const RCouple &c)
{
    collBoxPos = c;
}

inline
void
RSprite::setCollBoxSize(const RCouple &c)
{
    collBoxSize = c;
}

inline
void
RSprite::setPos(const RCouple &c)
{
    pos = c;
}

inline
void
RSprite::setSpeed(const RCouple &c)
{
    speed = c;
}

inline
void
RSprite::setAccel(const RCouple &c)
{
    accel = c;
}

inline
void
RSprite::addSpeedToPos()
{
    pos += speed;
}

inline
void
RSprite::subSpeedFromPos()
{
    pos -= speed;
}

inline
void
RSprite::addAccelToSpeed()
{
    speed += accel;
}

inline
void
RSprite::subAccelFromSpeed()
{
    speed -= accel;
}

inline
void
RSprite::setTimeToLive(unsigned long t)
{
    timeToLive = t;
}

inline
unsigned long
RSprite::getTimeToLive() const
{
    return timeToLive;
}

inline
unsigned long
RSprite::decTimeToLive()
{
    if (timeToLive != 0) timeToLive--; return timeToLive;
}

inline
void
RSprite::clearTimeToLive()
{
    timeToLive = 0;
}

inline
size_t
RSprite::getNumPixmaps() const
{
    return thePixmapArray->getNumImages();
}

inline
SDL_Surface *
RSprite::getPixmap(size_t i) const
{
    return thePixmapArray->getImage(i);
}

inline
const PixmapArray *
RSprite::getPixmapArray() const
{
    return thePixmapArray;
}


}  // namespace flatzebra


#endif  /* _H_RSprite */