1 /**
2  * @file sprite_capsule.h
3  * @brief The capsule sprite which contains a bonus or a penalty
4  * @date 2012-09-02
5  * @copyright 1991-2014 TLK Games
6  * @author Bruno Ethvignot
7  * @version $Revision: 24 $
8  */
9 /*
10  * copyright (c) 1991-2014 TLK Games all rights reserved
11  * $Id: sprite_capsule.h 24 2014-09-28 15:30:04Z bruno.ethvignot@gmail.com $
12  *
13  * TecnoballZ is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * TecnoballZ is distributed in the hope that it will be useful, but
19  * WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
26  * MA  02110-1301, USA.
27  */
28 #ifndef __SPRITE_CAPSULE__
29 #define __SPRITE_CAPSULE__
30 class sprite_capsule;
31 
32 #include "../include/sprite_object.h"
33 #include "../include/sprite_paddle.h"
34 #include "../include/right_panel_score.h"
35 #include "../include/handler_display.h"
36 #include "../include/sprite_projectile.h"
37 
38 /*
39 const Sint32 NUM_OF_IMAGES = 7;
40 const Sint16 NO_IMAGE = -1;
41 const Sint16 IMAGE_EXPAND_PADDLE = 0 * NUM_OF_IMAGES;
42 const Sint16 IMAGE_SHRINK_PADDLE = 1 * NUM_OF_IMAGES;
43 const Sint16 IMAGE_EXTRA_LIFE = 2 * NUM_OF_IMAGES;
44 const Sint16 IMAGE_EXPAND_PADDLE = 3 * NUM_OF_IMAGES;
45 const Sint16 IMAGE_POWER_BALL_1 = 4 * NUM_OF_IMAGES;
46 const Sint16 IMAGE_POWER_BALL_2 = 5 * NUM_OF_IMAGES;
47 const Sint16 IMAGE_EXTRA_BALLS = 6 * NUM_OF_IMAGES;
48 const Sint16 IMAGE_MULTI_BALLS = 7 * NUM_OF_IMAGES;
49 const Sint16 IMAGE_FIRE_POWER_1 = 8 * NUM_OF_IMAGES;
50 const Sint16 IMAGE_GLUE = 9 * NUM_OF_IMAGES;
51 const Sint16 IMAGE_INVERSE_CONTROL = 10 * NUM_OF_IMAGES;
52 const Sint16 IMAGE_FIRE_POWER_2 = 11 * NUM_OF_IMAGES;
53 const Sint16 IMAGE_BALL_SIZE_2 = 12 * NUM_OF_IMAGES;
54 const Sint16 IMAGE_BALL_SIZE_3 = 13 * NUM_OF_IMAGES;
55 const Sint16 IMAGE_CHANCE = 14 * NUM_OF_IMAGES;
56 const Sint16 IMAGE_ENABLE_HUGELY_OPTIONS = 15 * NUM_OF_IMAGES;
57 const Sint16 IMAGE_BOTTOM_WALL = 16 * NUM_OF_IMAGES;
58 const Sint16 IMAGE_ROBOT_PADDLE = 17 * NUM_OF_IMAGES;
59 const Sint16 IMAGE_BALLS_CONTROL = 18 * NUM_OF_IMAGES;
60 const Sint16 IMAGE_PADDLE_INVINCIBILITY = 19 * NUM_OF_IMAGES;
61 */
62 
63 class sprite_capsule:public sprite_object
64 {
65   friend class controller_capsules;
66   friend class supervisor_shop;
67 
68 public:
69   static const Uint32 NUM_OF_IMAGES = 7;
70 
71 typedef enum
72 {
73   GAD_VIDE00 = 0,
74   GLUE = 2,
75   NEXT_LEVEL = 4,
76   /** Paddle invincibility capsule is available only
77    * in the guardians level */
78   PADDLE_INVINCIBILITY = 4,
79   FIRE_POWER_1 = 6,
80   FIRE_POWER_2 = 8,
81   SHRINK_PADDLE = 10,
82   EXPAND_PADDLE = 12,
83   LOSE_A_LIFE = 14,
84   EXTRA_LIFE = 16,
85   EXTRA_BALLS = 18,
86   MULTI_BALLS = 20,
87   POWER_BALL_1 = 22,
88   POWER_BALL_2 = 24,
89   INVERSE_CONTROL = 26,
90   /** The "rebuild wall" option is not associated with a capsule,
91    * but it is available only in the shop */
92   REBUILD_THE_WALL = 28,
93   /** The "maximum speed of balls" option is not associated with
94    * a capsule, but is only available as a part of chance capsule */
95   MAXIMUM_SPEED_OF_BALLS = 30,
96   ENABLE_BOTTOM_PADDLE = 32,
97   ENABLE_RIGHT_PADDLE = 34,
98   ENABLE_TOP_PADDLE = 36,
99   ENABLE_LEFT_PADDLE = 38,
100   BALL_SIZE_2 = 40,
101   BALL_SIZE_3 = 42,
102   CHANCE = 44,
103   ENABLE_HUGELY_OPTIONS = 46,
104   /** The "set to the prices to 1" option is not associated with a
105    * capsule, but is only available as a part of chance capsule */
106   SET_THE_PRICES_TO_1 = 48,
107   BOTTOM_WALL = 50,
108   ROBOT_PADDLE = 52,
109   BALLS_CONTROL = 54,
110   MAGNETIC_EYE = 56,
111   LESS_BRICKS = 58,
112   SOME_INFOS = 60,
113   LEAVE_SHOP = 62
114 }
115 CASPULES_ENUM;
116 
117 
118 
119 
120 private:
121 
122 
123 
124   typedef enum
125     {
126       NO_IMAGE = -1,
127       IMAGE_EXPAND_PADDLE = 0 * NUM_OF_IMAGES,
128       IMAGE_SHRINK_PADDLE = 1 * NUM_OF_IMAGES,
129       IMAGE_EXTRA_LIFE = 2 * NUM_OF_IMAGES,
130       IMAGE_LOSE_A_LIFE = 3 * NUM_OF_IMAGES,
131       IMAGE_POWER_BALL_1 = 4 * NUM_OF_IMAGES,
132       IMAGE_POWER_BALL_2 = 5 * NUM_OF_IMAGES,
133       IMAGE_EXTRA_BALLS = 6 * NUM_OF_IMAGES,
134       IMAGE_MULTI_BALLS = 7 * NUM_OF_IMAGES,
135       IMAGE_FIRE_POWER_1 = 8 * NUM_OF_IMAGES,
136       IMAGE_GLUE = 9 * NUM_OF_IMAGES,
137       IMAGE_INVERSE_CONTROL = 10 * NUM_OF_IMAGES,
138       IMAGE_FIRE_POWER_2 = 11 * NUM_OF_IMAGES,
139       IMAGE_BALL_SIZE_2 = 12 * NUM_OF_IMAGES,
140       IMAGE_BALL_SIZE_3 = 13 * NUM_OF_IMAGES,
141       IMAGE_CHANCE = 14 * NUM_OF_IMAGES,
142       IMAGE_ENABLE_HUGELY_OPTIONS = 15 * NUM_OF_IMAGES,
143       IMAGE_BOTTOM_WALL = 16 * NUM_OF_IMAGES,
144       IMAGE_ROBOT_PADDLE = 17 * NUM_OF_IMAGES,
145       IMAGE_BALLS_CONTROL = 18 * NUM_OF_IMAGES,
146       IMAGE_PADDLE_INVINCIBILITY = 19 * NUM_OF_IMAGES
147     }
148   images_enum;
149 
150 
151 
152 
153   /** Capsule direction: BOTTOM_PADDLE, RIGHT_PADDLE, TOP_PADDLE,
154    * or LEFT_PADDLE */
155   Uint32 towards;
156   Uint32 capsule_identifier;
157   sprite_paddle *paddle;
158   static const Sint16 gagdetBrik[];
159   static const Sint16 gagdetGuar[];
160 
161 public:
162     sprite_capsule ();
163    ~sprite_capsule ();
164   void init_members ();
165   void enable_indicator_capsule (Uint32 id);
166   void enable_capsule (brick_redraw * brick, Uint32 id);
167   void enable_capsule (sprite_ball * ball, Uint32 id);
168   void enable_capsule (sprite_projectile * blast, Uint32 id);
169   void enable_guardian_capsule (sprite_ball * ball, Uint32 id);
170   void set_in_shop (Uint32 id);
171   void clone_from_capsule (sprite_capsule * capsule);
172   Uint32 get_id ();
173   sprite_paddle *move ();
174 private:
175   void set_new_capsule (Uint32 id, const Sint16 *frames, Uint32 xcoord, Uint32 ycoord, sprite_paddle *pad);
176   void enable_capsule (Uint32 index);
177 };
178 #endif
179