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