annotate TaskManager/Test/test_render/bullet_action.cpp @ 238:443c7ae1c7a7 draft

warning clean
author admin@mcbk.cr.ie.u-ryukyu.ac.jp
date Fri, 29 May 2009 13:43:52 +0900
parents 8ac35507094d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
213
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
1 #include <math.h>
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
2 #include "SceneGraphRoot.h"
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
3 #include "SGList.h"
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
4 #include "hit_judge.h"
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
5 #define PI M_PI
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
6
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
7 int i = 0;
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
8
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
9 void
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
10 bullet_init(SceneGraphPtr bullet, SceneGraphPtr player)
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
11 {
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
12 bullet->xyz[0] = player->xyz[0];
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
13 bullet->xyz[1] = player->xyz[1];
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
14 bullet->xyz[2] = player->xyz[2];
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
15
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
16 bullet->angle[0] = player->angle[0];
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
17 bullet->angle[1] = player->angle[1];
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
18 bullet->angle[2] = player->angle[2];
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
19 }
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
20
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
21 void
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
22 bluebullet_move(SceneGraphPtr node, int screen_w, int screen_h)
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
23 {
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
24 double a = (node->angle[2]+90)*PI/180;
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
25 double b = (node->angle[0]+90)*PI/180;
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
26
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
27 double y = sin(a);
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
28 double x = cos(a);
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
29 double z = -cos(b);
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
30
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
31 node->xyz[0] += x * 5;//x軸方向
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
32 node->xyz[1] += y * 5;//y軸方向
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
33 node->xyz[2] += z * 5;//z軸方向
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
34 }
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
35
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
36 void
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
37 bullet_collision(SceneGraphPtr node, int screen_w, int screen_h, SceneGraphPtr tree)
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
38 {
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
39 SceneGraphIteratorPtr it = sgroot->getIterator(tree);
238
443c7ae1c7a7 warning clean
admin@mcbk.cr.ie.u-ryukyu.ac.jp
parents: 213
diff changeset
40 //static int damage = 0;
213
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
41
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
42 for (; it->hasNext(E_PLANE);) {
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
43 it->next(E_PLANE);
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
44 SceneGraphPtr enemy = it->get();
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
45
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
46 int judge = square_judge(node, enemy);
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
47 if(judge == HIT)
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
48 {
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
49 //node->set_move_collision(null_move, bullet_collision);
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
50 //E_PLANE->set_move_collision(null_move, enemy_collision);
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
51 enemy->remove();
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
52 node->remove();
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
53 //printf("hit!!!\n");
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
54 //bullet_delete(node, scene_graph);
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
55 }
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
56 }
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
57
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
58 if(node->xyz[1] > 100)
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
59 {
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
60 node->remove();
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
61 //scene_graph->delete_object(node, node->next,node->prev);
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
62 //i -= 1;
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
63 //printf("bullet_delete:残り弾数=%d\n",i);
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
64 }
8ac35507094d add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
diff changeset
65 }