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