| 1 | |
| 2 | /** |
| 3 | * |
| 4 | * @file jj1bullet.h |
| 5 | * |
| 6 | * Part of the OpenJazz project |
| 7 | * |
| 8 | * @par History: |
| 9 | * - 23rd August 2005: Created OpenJazz.h |
| 10 | * - 31st January 2006: Created level.h from parts of OpenJazz.h |
| 11 | * - 4th February 2009: Created events.h from parts of level.h |
| 12 | * - 11th February 2009: Created bullet.h from parts of events.h |
| 13 | * - 1st August 2012: Renamed bullet.h to jj1bullet.h |
| 14 | * |
| 15 | * @par Licence: |
| 16 | * Copyright (c) 2005-2012 AJ Thomson |
| 17 | * |
| 18 | * OpenJazz is distributed under the terms of |
| 19 | * the GNU General Public License, version 2.0 |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | |
| 24 | #ifndef _BULLET_H |
| 25 | #define _BULLET_H |
| 26 | |
| 27 | |
| 28 | #include "level/movable.h" |
| 29 | |
| 30 | #include "OpenJazz.h" |
| 31 | |
| 32 | |
| 33 | // Constants |
| 34 | |
| 35 | // Indexes for elements of the bullet set |
| 36 | #define B_SPRITE 0 |
| 37 | #define B_XSPEED 4 |
| 38 | #define B_YSPEED 8 |
| 39 | #define B_GRAVITY 12 |
| 40 | #define B_FINISHANIM 16 |
| 41 | #define B_FINISHSOUND 17 |
| 42 | #define B_BEHAVIOUR 18 |
| 43 | #define B_BEHAVIOR 18 |
| 44 | #define B_STARTSOUND 19 |
| 45 | |
| 46 | // Survival time |
| 47 | #define T_BULLET 1000 |
| 48 | #define T_TNT 300 |
| 49 | |
| 50 | |
| 51 | // Classes |
| 52 | |
| 53 | class JJ1Bird; |
| 54 | class JJ1Event; |
| 55 | class JJ1LevelPlayer; |
| 56 | class Sprite; |
| 57 | |
| 58 | /// JJ1Bullet |
| 59 | class JJ1Bullet : public Movable { |
| 60 | |
| 61 | private: |
| 62 | JJ1Bullet* next; ///< The next bullet |
| 63 | JJ1LevelPlayer* source; ///< Source player. If NULL, was fired by an event |
| 64 | Sprite* sprite; ///< Sprite |
| 65 | signed char* set; ///< Bullet type properties |
| 66 | int direction; ///< 0: Left, 1: Right, 2: L (lower), 3: R (lower) |
| 67 | unsigned int time; ///< Time at which the bullet will self-destruct |
| 68 | |
| 69 | JJ1Bullet* remove (); |
| 70 | |
| 71 | public: |
| 72 | JJ1Bullet (JJ1Bullet* nextBullet, JJ1LevelPlayer* sourcePlayer, fixed startX, fixed startY, signed char *bullet, int newDirection, unsigned int ticks); |
| 73 | ~JJ1Bullet (); |
| 74 | |
| 75 | JJ1LevelPlayer* getSource (); |
| 76 | JJ1Bullet* step (unsigned int ticks); |
| 77 | void draw (int change); |
| 78 | |
| 79 | }; |
| 80 | |
| 81 | #endif |
| 82 |