0
|
1 #include <stdio.h>
|
|
2 #include <stdlib.h>
|
|
3 #include "syokika.h"
|
|
4 #include "bool.h"
|
|
5 #include <SDL.h>
|
|
6 #include "SDL_opengl.h"
|
|
7 #include "object.h"
|
|
8 #include "Character.h"
|
|
9 #include "Character_state.h"
|
|
10 #include "count2.h"
|
|
11 #include "tokuten.h"
|
|
12 #include "schedule.h"
|
|
13 #include "sankaku.h"
|
|
14 #include "sgoex.h"
|
|
15 #include "collision.h"
|
|
16 #include "debug.h"
|
|
17
|
|
18 #include "error.h"
|
7
|
19 #include "state_task.h"
|
19
|
20 #include "Func.h"
|
0
|
21
|
|
22 #define CHARACTER_MAX_POOL_SIZE 2048
|
|
23
|
|
24 CHARACTER *active_chara_list;
|
|
25 CHARACTER *free_chara_list;
|
|
26
|
|
27
|
|
28
|
|
29 const table enemystate[] = ENEMY_STATUS_TABLE;
|
|
30 int filpcount = 0;
|
|
31 int stage = 0;
|
|
32 BOOL tf = FALSE;
|
|
33 static int pool_size;
|
|
34
|
|
35 int init_chara_list(int num)
|
|
36 {
|
|
37 if(active_chara_list == NULL)
|
|
38 {
|
|
39 return extend_chara_list_pool(num);
|
|
40 }
|
|
41 return 1;
|
|
42 }
|
|
43
|
|
44 int
|
|
45 extend_chara_list_pool(int num)
|
|
46 {
|
|
47
|
|
48 pool_size = num;
|
|
49 __debug("task init start");
|
|
50
|
|
51 int i;
|
|
52 CHARACTER *q[num];
|
|
53
|
|
54 for(i = 0; i<num ; i++)
|
|
55 {
|
|
56 q[i] = (CHARACTER*)malloc(sizeof(CHARACTER));
|
|
57 q[i]->f = FALSE;
|
|
58 q[i]->state = noaction;
|
33
|
59 q[i]->dt1 = 0;
|
|
60 q[i]->dt2 = 0;
|
19
|
61 q[i]->task = 0;
|
0
|
62 q[i]->collision = noaction;
|
|
63 }
|
|
64
|
|
65 for(i = 0; i<num-1 ; i++)
|
|
66 {
|
|
67 q[i]->next = q[i+1];
|
|
68 //q[i]->next->prev = q[i];
|
|
69 }
|
|
70
|
|
71 q[num-1]->next = NULL;
|
|
72 active_chara_list = (CHARACTER*)malloc(sizeof(CHARACTER));
|
|
73 active_chara_list->f = FALSE;
|
|
74 active_chara_list->state = noaction;
|
|
75 active_chara_list->collision = noaction;
|
|
76 active_chara_list->next = q[0];
|
|
77 //q[0]->prev = active_chara_list;
|
|
78 //active_chara_list->prev = q[num-1];
|
|
79 //q[num-1]->next = active_chara_list;
|
|
80 CHARACTER *p;
|
|
81
|
|
82 for(p = active_chara_list->next; p != NULL ; p = p->next)
|
|
83 {
|
|
84 if(p != NULL)
|
|
85 {
|
|
86 __debug("list_test");
|
|
87 }
|
|
88 }
|
|
89 return 1;
|
|
90 }
|
|
91
|
|
92 void TFon()
|
|
93 {
|
|
94 tf = TRUE;
|
|
95 }
|
|
96
|
|
97 void TFoff()
|
|
98 {
|
|
99 tf = FALSE;
|
|
100 }
|
|
101
|
|
102
|
44
|
103 static int global_id = 0;
|
|
104
|
|
105
|
19
|
106 void
|
0
|
107 Putenemy(int charano, float x, float y, float vx, float vy,
|
|
108 CHARACTER * (*action)(CHARACTER *chara))
|
|
109 {
|
|
110 CHARACTER *q;
|
44
|
111
|
0
|
112 for(q = active_chara_list->next; q != NULL ;q = q->next)
|
|
113 {
|
|
114 if(q->f == FALSE)
|
|
115 {
|
|
116 break;
|
|
117 }
|
|
118 }
|
|
119
|
44
|
120 q->chara_id = global_id;
|
|
121 ++global_id;
|
0
|
122 q->state = action;
|
|
123 q->collision = atari;
|
|
124 q->x = x;
|
|
125 q->y = y;
|
|
126 q->vx = vx;
|
|
127 q->vy = vy;
|
|
128 q->tama = tf;
|
|
129 q->vit = enemystate[charano].p;
|
|
130 q->score = enemystate[charano].sc;
|
|
131 q->charano = enemystate[charano].charano;
|
|
132 q->s = 0;
|
|
133 q->f = TRUE;
|
|
134 //q->state = ALIVE;
|
|
135 //q->group = ENEMY
|
44
|
136 if (q->tama == FALSE) {
|
|
137 printf("F%d: [%d] x=%f y=%f vx=%f vy=%f CREATE\n", filpcount, q->chara_id, q->x, q->y, q->vx, q->vy);
|
|
138 }
|
0
|
139 }
|
|
140
|
|
141 void state_update()
|
|
142 {
|
|
143 CHARACTER *p;
|
|
144 for(p = active_chara_list->next; p!= NULL ;p = p->next)
|
|
145 {
|
|
146 p=(*p->state)(p);
|
|
147 }
|
|
148 }
|
|
149
|
|
150 void collision_detect()
|
|
151 {
|
|
152 CHARACTER *p;
|
|
153 for(p = active_chara_list->next; p!=NULL;p = p->next)
|
|
154 {
|
34
|
155 if((p->state != chara_state8) && (p->state != chara_state9)) {
|
0
|
156 p=(*p->collision)(p);
|
34
|
157 }
|
0
|
158 }
|
|
159 }
|
|
160
|
|
161 void obj_draw()
|
|
162 {
|
|
163 CHARACTER *p;
|
|
164 for(p = active_chara_list->next; p!=NULL;p = p->next)
|
|
165 {
|
|
166 if(p->f == TRUE)
|
|
167 {
|
|
168 PutSprite(1, p->x, p->y, p->charano);
|
|
169 }
|
|
170 }
|
|
171 }
|
|
172
|
|
173 void outofwindow()
|
|
174 {
|
|
175 CHARACTER *p;
|
|
176 for(p = active_chara_list->next; p!=NULL; p = p->next)
|
|
177 {
|
34
|
178 if((p->state != chara_state8) && (p->state != chara_state9))
|
|
179 {
|
0
|
180 if ((p->y > 964 + 32)
|
|
181 || (p->x > 1688 + 50)
|
|
182 || (p->y < 0 - 128)
|
|
183 || (p->x < 0 - 200))
|
|
184 {
|
|
185 p->f = FALSE;
|
44
|
186 p->tama = TRUE;
|
0
|
187 p->state = delete_chara;
|
|
188 p->collision = noaction;
|
|
189 }
|
34
|
190 }
|
0
|
191 }
|
|
192 }
|