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
|
19
|
103 void
|
0
|
104 Putenemy(int charano, float x, float y, float vx, float vy,
|
|
105 CHARACTER * (*action)(CHARACTER *chara))
|
|
106 {
|
|
107 CHARACTER *q;
|
|
108
|
|
109 for(q = active_chara_list->next; q != NULL ;q = q->next)
|
|
110 {
|
|
111 if(q->f == FALSE)
|
|
112 {
|
|
113 break;
|
|
114 }
|
|
115 }
|
|
116
|
|
117 q->state = action;
|
|
118 q->collision = atari;
|
|
119 q->x = x;
|
|
120 q->y = y;
|
|
121 q->vx = vx;
|
|
122 q->vy = vy;
|
|
123 q->tama = tf;
|
|
124 q->vit = enemystate[charano].p;
|
|
125 q->score = enemystate[charano].sc;
|
|
126 q->charano = enemystate[charano].charano;
|
|
127 q->s = 0;
|
|
128 q->f = TRUE;
|
|
129 //q->state = ALIVE;
|
|
130 //q->group = ENEMY
|
|
131
|
|
132 }
|
|
133
|
|
134 void state_update()
|
|
135 {
|
|
136 CHARACTER *p;
|
|
137 for(p = active_chara_list->next; p!= NULL ;p = p->next)
|
|
138 {
|
|
139 p=(*p->state)(p);
|
|
140 }
|
|
141 }
|
|
142
|
|
143 void collision_detect()
|
|
144 {
|
|
145 CHARACTER *p;
|
|
146 for(p = active_chara_list->next; p!=NULL;p = p->next)
|
|
147 {
|
34
|
148 if((p->state != chara_state8) && (p->state != chara_state9)) {
|
0
|
149 p=(*p->collision)(p);
|
34
|
150 }
|
0
|
151 }
|
|
152 }
|
|
153
|
|
154 void obj_draw()
|
|
155 {
|
|
156 CHARACTER *p;
|
|
157 for(p = active_chara_list->next; p!=NULL;p = p->next)
|
|
158 {
|
|
159 if(p->f == TRUE)
|
|
160 {
|
|
161 PutSprite(1, p->x, p->y, p->charano);
|
|
162 }
|
|
163 }
|
|
164 }
|
|
165
|
|
166 void outofwindow()
|
|
167 {
|
|
168 CHARACTER *p;
|
|
169 for(p = active_chara_list->next; p!=NULL; p = p->next)
|
|
170 {
|
34
|
171 if((p->state != chara_state8) && (p->state != chara_state9))
|
|
172 {
|
0
|
173 if ((p->y > 964 + 32)
|
|
174 || (p->x > 1688 + 50)
|
|
175 || (p->y < 0 - 128)
|
|
176 || (p->x < 0 - 200))
|
|
177 {
|
|
178 p->f = FALSE;
|
|
179 p->state = delete_chara;
|
|
180 p->collision = noaction;
|
|
181 }
|
34
|
182 }
|
0
|
183 }
|
|
184 }
|