comparison Renderer/Test/bullet_action.cc @ 508:f6daf964f483

reorganization
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 12 Oct 2009 09:43:07 +0900
parents Renderer/Application/bullet_action.cc@735f76483bb2
children
comparison
equal deleted inserted replaced
507:735f76483bb2 508:f6daf964f483
1 #include <math.h>
2 #include "SceneGraphRoot.h"
3 #include "SGList.h"
4 #include "hit_judge.h"
5 #define PI M_PI
6
7 int i = 0;
8
9 void
10 bullet_init(SceneGraphPtr bullet, SceneGraphPtr player)
11 {
12 bullet->xyz[0] = player->xyz[0];
13 bullet->xyz[1] = player->xyz[1];
14 bullet->xyz[2] = player->xyz[2];
15
16 bullet->angle[0] = player->angle[0];
17 bullet->angle[1] = player->angle[1];
18 bullet->angle[2] = player->angle[2];
19 }
20
21 void
22 bluebullet_move(SceneGraphPtr node, int screen_w, int screen_h)
23 {
24 double a = (node->angle[2]+90)*PI/180;
25 double b = (node->angle[0]+90)*PI/180;
26
27 double y = sin(a);
28 double x = cos(a);
29 double z = -cos(b);
30
31 node->xyz[0] += x * 5;//x軸方向
32 node->xyz[1] += y * 5;//y軸方向
33 node->xyz[2] += z * 5;//z軸方向
34 }
35
36 void
37 bullet_collision(SceneGraphPtr node, int screen_w, int screen_h, SceneGraphPtr tree)
38 {
39 SceneGraphIteratorPtr it = sgroot->getIterator(tree);
40 //static int damage = 0;
41
42 for (; it->hasNext(E_PLANE);) {
43 it->next(E_PLANE);
44 SceneGraphPtr enemy = it->get();
45
46 int judge = square_judge(node, enemy);
47 if(judge == HIT)
48 {
49 //node->set_move_collision(null_move, bullet_collision);
50 //E_PLANE->set_move_collision(null_move, enemy_collision);
51 enemy->remove();
52 node->remove();
53 //printf("hit!!!\n");
54 //bullet_delete(node, scene_graph);
55 }
56 }
57
58 if(node->xyz[1] > 100)
59 {
60 node->remove();
61 //scene_graph->delete_object(node, node->next,node->prev);
62 //i -= 1;
63 //printf("bullet_delete:残り弾数=%d\n",i);
64 }
65 }