1 /* $Id: plan-17.c,v 1.113 2005/06/26 10:17:35 oohara Exp $ */
2 /* [very easy] Afterdeath */
3 
4 #include <stdio.h>
5 
6 #include "scheduler.h"
7 #include "tenm_table.h"
8 #include "afterdeath.h"
9 #include "stage-title.h"
10 #include "warning.h"
11 #include "normal-enemy.h"
12 #include "const.h"
13 #include "tenm_math.h"
14 
15 #include "plan-17.h"
16 
17 static void plan_17_circle_party(double x, double dx, double dy);
18 
19 int
plan_17(int t)20 plan_17(int t)
21 {
22   int s;
23   int theta;
24   double x;
25   double ddy;
26   int t_shoot;
27 
28   /* sanity check */
29   if (t < 0)
30     return SCHEDULER_ERROR;
31 
32   if (t == 30)
33     tenm_table_add(stage_title_new());
34 
35   if (t == 160)
36     plan_17_circle_party(200.0, 4.0, 3.0);
37 
38   if (t == 350)
39     plan_17_circle_party(440.0, -3.5, 0.5);
40   if (t == 400)
41     plan_17_circle_party(520.0, -3.3, 4.4);
42 
43   if ((t == 590) || (t == 630) || (t == 670))
44   {
45     if (t == 590)
46       x = 200.0;
47     else if (t == 630)
48       x = 100.0;
49     else
50       x = 300.0;
51 
52     tenm_table_add(normal_enemy_new(x, -24.0,
53                                     BRICK, 0,
54                                     0, -1, 0, -1, 0, 1, 2,
55                                     /* move 0 */
56                                     9999, 0.0, 4.0, 0.0, 0.0,
57                                     0.0, 0.0, 0.0, 0.0, 0,
58                                     /* shoot 0 */
59                                     15 + (t - 590), 37, 30, 0, 0, 1,
60                                     /* shoot 1 */
61                                     9999, 37, (45 + (t - 590)) % 37, 0, 1, 1));
62   }
63 
64   if ((t >= 860) && (t < 1294))
65   {
66     s = t - 860;
67     if ((s % 62 == 0) || (s % 62 == 26))
68     {
69       x = 60.0;
70       theta = 25 + s % 26;
71       if (s % 62 != 0)
72       {
73         x = 500.0;
74         theta = 180 - theta;
75       }
76       plan_17_circle_party(x, 2.7 * tenm_cos(theta), 3.6 * tenm_sin(theta));
77     }
78   }
79 
80   if ((t >= 1490) && (t < 1610))
81   {
82     s = t - 1490;
83     if ((s % 8 == 0) && (s % 40 < 32))
84     {
85       if (s < 40)
86       {
87         x = 20.0;
88         ddy = -0.06;
89       }
90       else if (s < 80)
91       {
92         x = 120.0;
93         ddy = -0.08;
94       }
95       else
96       {
97         x = 220.0;
98         ddy = -0.1;
99       }
100 
101       if (s % 40 == 0)
102         t_shoot = 40;
103       else
104         t_shoot = 9999;
105 
106       tenm_table_add(normal_enemy_new(x, -19.0,
107                                       BALL_SOLDIER, 0,
108                                       0, -1, 0, -1, 0, 1, 2,
109                                       /* move 0 */
110                                       9999, 2.0, ddy * (-90.0), 0.0, ddy,
111                                       0.0, 0.0, 0.0, 0.0, 0,
112                                       /* shoot 0 */
113                                       90, t_shoot, 0, 0, 0, 1,
114                                       /* shoot 1 */
115                                       9999, 9999, 0, 0, 1, 1));
116     }
117   }
118   if ((t >= 1800) && (t < 1960))
119   {
120     s = t - 1800;
121     if ((s % 8 == 0) && (s % 40 < 32))
122     {
123       if (s < 40)
124       {
125         x = ((double) WINDOW_WIDTH) - 10.0;
126         ddy = -0.04;
127       }
128       else if (s < 80)
129       {
130         x = ((double) WINDOW_WIDTH) - 100.0;
131         ddy = -0.06;
132       }
133       else if (s < 120)
134       {
135         x = ((double) WINDOW_WIDTH) - 190.0;
136         ddy = -0.08;
137       }
138       else
139       {
140         x = ((double) WINDOW_WIDTH) - 280.0;
141         ddy = -0.1;
142       }
143 
144       if (s % 40 == 0)
145         t_shoot = 25;
146       else
147         t_shoot = 9999;
148 
149       tenm_table_add(normal_enemy_new(x, -19.0,
150                                       BALL_SOLDIER, 0,
151                                       0, -1, 0, -1, 0, 1, 2,
152                                       /* move 0 */
153                                       9999, -1.5, ddy * (-90.0), 0.0, ddy,
154                                       0.0, 0.0, 0.0, 0.0, 0,
155                                       /* shoot 0 */
156                                       90, t_shoot, 0, 0, 0, 1,
157                                       /* shoot 1 */
158                                       9999, 9999, 0, 0, 1, 1));
159     }
160   }
161 
162   if (t == 2200)
163     tenm_table_add(warning_new());
164 
165   if (t == 2330)
166     tenm_table_add(afterdeath_new());
167 
168   return SCHEDULER_SUCCESS;
169 }
170 
171 static void
plan_17_circle_party(double x,double dx,double dy)172 plan_17_circle_party(double x, double dx, double dy)
173 {
174   int i;
175   int t_shoot;
176   double speed_theta;
177   int theta;
178 
179   if (dx > 0.0)
180   {
181     speed_theta = 0.4;
182     theta = -180;
183   }
184   else
185   {
186     speed_theta = -0.4;
187     theta = 180;
188   }
189 
190   for (i = 0; i < 4; i++)
191   {
192     if (i == 0)
193       t_shoot = 9912;
194     else
195       t_shoot = 0;
196 
197     tenm_table_add(normal_enemy_new(x, -19.0 - ((double) i) * 25.0,
198                                     BALL_SOLDIER, 0,
199                                     50, -1, 0, -1, 0, 5, 2,
200                                     /* move 0 */
201                                     50, 0.0, 3.0 + ((double) i) * 0.5,
202                                     0.0, 0.0,
203                                     0.0, 0.0, 0.0, 0.0, 1,
204                                     /* move 1 */
205                                     5, 0.0, 0.0, 0.0, 0.0,
206                                     0.0, 0.0, 0.0, 0.0, 2,
207                                     /* move 2 */
208                                     10,
209                                     3.0 * tenm_cos(i * 25),
210                                     3.0 * tenm_sin(i * 25),
211                                     0.0, 0.0,
212                                     0.0, 0.0, 0.0, 0.0, 3,
213                                     /* move 3 */
214                                     100, dx, dy, 0.0, 0.0,
215                                     x, 150.0 - 19.0, 1.0, speed_theta, 4,
216                                     /* move 4 */
217                                     9999,
218                                     11.0 * tenm_cos(i * 25 + theta),
219                                     11.0 * tenm_sin(i * 25 + theta),
220                                     0.0, 0.0,
221                                     0.0, 0.0, 0.0, 0.0, 4,
222                                     /* shoot 0 */
223                                     97, 9999, t_shoot, 0, 0, 1,
224                                     /* shoot 1 */
225                                     9999, 9999, 0, 0, 1, 1));
226   }
227 }
228