comparison TaskManager/Test/test_render/vacuum.cpp @ 378:bdeb7a73285b draft

test_nogl not working
author kazz@kazzone.cr.ie.u-ryukyu.ac.jp
date Fri, 31 Jul 2009 19:10:53 +0900
parents 4fb99cd5d13f
children ce86b0186a4a
comparison
equal deleted inserted replaced
377:82f7205da9ad 378:bdeb7a73285b
3 #include "SceneGraphRoot.h" 3 #include "SceneGraphRoot.h"
4 #include "SGList.h" 4 #include "SGList.h"
5 #define ENCOUNT 55 5 #define ENCOUNT 55
6 using namespace std; 6 using namespace std;
7 7
8 <<<<<<< local
9 static void cube_move_left(SceneGraphPtr node, int screen_w, int screen_h);
10 static void cube_move_right(SceneGraphPtr node, int screen_w, int screen_h);
11 static void cube_move_idle(SceneGraphPtr node, int screen_w, int screen_h);
12 static void cube_collision(SceneGraphPtr node, int screen_w, int screen_h,
13 SceneGraphPtr tree);
14 static void cube_split(SceneGraphPtr root);
15 =======
16 static float vacuum_speed = 10.0f; 8 static float vacuum_speed = 10.0f;
17 >>>>>>> other
18 9
19 10
20 /*オブジェクト毎にファイルを分けてみた 11 /*オブジェクト毎にファイルを分けてみた
21 * 12 *
22 * 13 *
26 17
27 void 18 void
28 no_move_idle(SceneGraphPtr node, int screen_w, int screen_h) 19 no_move_idle(SceneGraphPtr node, int screen_w, int screen_h)
29 { 20 {
30 21
31 <<<<<<< local
32 if (node->xyz[0] < 0) {
33 node->set_move_collision(cube_move_right, cube_collision);
34 }
35
36 if (node->xyz[1] < 0 || node->xyz[1] > screen_h) {
37 node->stack_xyz[1] = -node->stack_xyz[1];
38 }
39
40 //node->angle[0] += 2.0f;
41 //node->angle[1] += 2.0f * node->stack_xyz[1];
42 //node->angle[2] += 2.0f * node->stack_xyz[2];
43
44 if (++node->frame > 60) {
45 cube_split(node);
46 }
47 =======
48 >>>>>>> other
49 } 22 }
50 23
51 void 24 void
52 no_collision_idle(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree) 25 no_collision_idle(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree)
53 { 26 {
54 <<<<<<< local
55 node->xyz[0] += node->stack_xyz[0];
56 #if 0
57 node->xyz[1] -= node->stack_xyz[0] * node->stack_xyz[1];
58 node->xyz[2] -= node->stack_xyz[0] * node->stack_xyz[2];
59 #else
60 node->xyz[1] += node->stack_xyz[1];
61 #endif
62 27
63 if (node->xyz[0] > screen_w) {
64 node->set_move_collision(cube_move_left, cube_collision);
65 }
66 =======
67 >>>>>>> other
68
69 <<<<<<< local
70 if (node->xyz[1] < 0 || node->xyz[1] > screen_h) {
71 node->stack_xyz[1] = -node->stack_xyz[1];
72 }
73
74 //node->angle[0] += 2.0f;
75 //node->angle[1] += 2.0f * node->stack_xyz[1];
76 //node->angle[2] += 2.0f * node->stack_xyz[2];
77
78 if (++node->frame > 60) {
79 cube_split(node);
80 }
81 =======
82 >>>>>>> other
83 } 28 }
84 29
85 void 30 void
86 vacuum_coll(SceneGraphPtr node, int screen_w, int screen_h, 31 vacuum_coll(SceneGraphPtr node, int screen_w, int screen_h,
87 SceneGraphPtr tree) 32 SceneGraphPtr tree)
88 { 33 {
89 Pad *pad = sgroot->getController(); 34 Pad *pad = sgroot->getController();
90 35
91 <<<<<<< local
92 if (pad->circle.isPush()) {
93 cube_split(node);
94 =======
95 if(node->frame%ENCOUNT == ENCOUNT-1) { 36 if(node->frame%ENCOUNT == ENCOUNT-1) {
96 if(random()%2) { 37 if(random()%2) {
97 add_cubecollision_object(REDCUBE,node,screen_w,screen_h); 38 add_cubecollision_object(REDCUBE,node,screen_w,screen_h);
98 } 39 }
99 else { 40 else {
100 add_cubecollision_object(ENEMY,node,screen_w,screen_h); 41 add_cubecollision_object(ENEMY,node,screen_w,screen_h);
101 } 42 }
102 >>>>>>> other
103 } 43 }
104 44
105 if (pad->cross.isHold()) { 45 if (pad->cross.isHold()) {
106 SceneGraphIteratorPtr it = sgroot->getIterator(tree); 46 SceneGraphIteratorPtr it = sgroot->getIterator(tree);
107 collision_red(it,node); 47 collision_red(it,node);
114 lock_attack(node,it); 54 lock_attack(node,it);
115 } 55 }
116 56
117 } 57 }
118 58
119 <<<<<<< local
120 static void
121 cube_collision(SceneGraphPtr node, int screen_w, int screen_h,
122 SceneGraphPtr tree)
123 =======
124 void 59 void
125 lock_attack(SceneGraphPtr node,SceneGraphIteratorPtr it) 60 lock_attack(SceneGraphPtr node,SceneGraphIteratorPtr it)
126 >>>>>>> other
127 { 61 {
128 62
129 SceneGraphPtr enemy; 63 SceneGraphPtr enemy;
130 SceneGraphPtr near_enemy = NULL; 64 SceneGraphPtr near_enemy = NULL;
131 float dx,dy,r,range = 100; 65 float dx,dy,r,range = 100;
157 near_enemy->addChild(lockon); 91 near_enemy->addChild(lockon);
158 } 92 }
159 93
160 } 94 }
161 95
162 <<<<<<< local
163 static void
164 vacuum_coll(SceneGraphPtr node, int screen_w, int screen_h,
165 SceneGraphPtr tree)
166 {
167 SceneGraphIteratorPtr it = sgroot->getIterator();
168 SceneGraphPtr bigm;
169 Pad *pad = sgroot->getController();
170 float dx, dy, r;
171 float q = 0;
172 =======
173 void 96 void
174 lockon_collision(SceneGraphPtr node,int w,int h,SceneGraphPtr tree) { 97 lockon_collision(SceneGraphPtr node,int w,int h,SceneGraphPtr tree) {
175 >>>>>>> other
176 98
177 <<<<<<< local
178 if (pad->cross.isRelease()) {
179 return;
180 }
181 =======
182 Pad *pad = sgroot->getController(); 99 Pad *pad = sgroot->getController();
183 SceneGraphPtr lockon_enemy = node->parent; 100 SceneGraphPtr lockon_enemy = node->parent;
184 >>>>>>> other
185 101
186 /* node->angle[0] = -lockon_enemy->angle[0]; 102 /* node->angle[0] = -lockon_enemy->angle[0];
187 node->angle[1] = -lockon_enemy->angle[1]; 103 node->angle[1] = -lockon_enemy->angle[1];
188 node->angle[2] = -lockon_enemy->angle[2];*/ 104 node->angle[2] = -lockon_enemy->angle[2];*/
189 105
190 <<<<<<< local
191 for (; it->hasNext(MCUBE);) {
192 it->next(MCUBE);
193 SceneGraphPtr mcube = it->get();
194 =======
195 if(pad->circle.isRelease()) { 106 if(pad->circle.isRelease()) {
196 lockon_enemy->remove(); 107 lockon_enemy->remove();
197 } 108 }
198 >>>>>>> other
199 109
200 <<<<<<< local
201 dx = node->xyz[0] - mcube->xyz[0];
202 dy = node->xyz[1] - mcube->xyz[1];
203
204 r = sqrt(dx*dx + dy*dy);
205
206 if (r >= 1) q = 300/r;
207
208 if (r < 50.0f) {
209 mcube->remove();
210 continue;
211 }
212
213 if (dx == 0) {
214 if(mcube->xyz[1] > node->xyz[1]) {
215 mcube->xyz[1] -= q;
216 } else if(mcube->xyz[1] < node->xyz[1]) {
217 mcube->xyz[1] += q;
218 }
219 } else {
220 if(mcube->xyz[0] > node->xyz[0]) {
221 mcube->xyz[0] -= q*cos(atan(dy/dx));
222 mcube->xyz[1] -= q*sin(atan(dy/dx));
223 mcube->stack_xyz[0] = -q*cos(atan(dy/dx));
224 mcube->stack_xyz[1] = -q*sin(atan(dy/dx));
225 } else if(mcube->xyz[0] < mcube->xyz[0]) {
226 mcube->xyz[0] += q*cos(atan(dy/dx));
227 mcube->xyz[1] += q*sin(atan(dy/dx));
228 mcube->stack_xyz[0] = -q*cos(atan(dy/dx));
229 mcube->stack_xyz[1] = -q*sin(atan(dy/dx));
230 }
231 }
232 }
233 =======
234 >>>>>>> other
235 } 110 }
236 111
237 112
238 void 113 void
239 vacuum_move(SceneGraphPtr node , int w, int h) 114 vacuum_move(SceneGraphPtr node , int w, int h)
240 { 115 {
241 Pad *pad = sgroot->getController(); 116 Pad *pad = sgroot->getController();
242 117
243 <<<<<<< local
244 if (pad->right.isHold()) {
245 node->xyz[0] += vacuum_speed;
246 } else if (pad->left.isHold()) {
247 node->xyz[0] -= vacuum_speed;
248 =======
249 if (pad->right.isHold() && w > node->xyz[0]) { 118 if (pad->right.isHold() && w > node->xyz[0]) {
250 node->xyz[0] += vacuum_speed; 119 node->xyz[0] += vacuum_speed;
251 node->angle[0] += 2; 120 node->angle[0] += 2;
252 } else if (pad->left.isHold() && 0 < node->xyz[0]) { 121 } else if (pad->left.isHold() && 0 < node->xyz[0]) {
253 node->xyz[0] -= vacuum_speed; 122 node->xyz[0] -= vacuum_speed;
254 node->angle[0] -= 2; 123 node->angle[0] -= 2;
255 >>>>>>> other
256 } 124 }
257 125
258 <<<<<<< local
259 if (pad->up.isHold()) {
260 node->xyz[1] -= vacuum_speed;
261 } else if (pad->down.isHold()) {
262 node->xyz[1] += vacuum_speed;
263 =======
264 if (pad->up.isHold() && 0 < node->xyz[1]) { 126 if (pad->up.isHold() && 0 < node->xyz[1]) {
265 node->xyz[1] -= vacuum_speed; 127 node->xyz[1] -= vacuum_speed;
266 node->angle[1] -= 2; 128 node->angle[1] -= 2;
267 } else if (pad->down.isHold() && h > node->xyz[1]) { 129 } else if (pad->down.isHold() && h > node->xyz[1]) {
268 node->xyz[1] += vacuum_speed; 130 node->xyz[1] += vacuum_speed;
269 node->angle[1] += 2; 131 node->angle[1] += 2;
270 >>>>>>> other
271 } 132 }
272 133
273 if (pad->start.isPush()) { 134 if (pad->start.isPush()) {
274 <<<<<<< local
275 node->xyz[0] = w/2;
276 node->xyz[1] = h*0.8;
277 =======
278 node->xyz[0] = w/2; 135 node->xyz[0] = w/2;
279 node->xyz[1] = h*0.8; 136 node->xyz[1] = h*0.8;
280 >>>>>>> other
281 } 137 }
282 } 138 }
283 139
284 140
285 141