Mercurial > hg > Game > Cerium
annotate Renderer/Test/gaplant_action.cc @ 1245:a97b4dd4574c draft
Added tag real_matrix for changeset cd50c48f45e7
author | Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 11 Nov 2011 17:04:13 +0900 |
parents | 7a311860a76e |
children |
rev | line source |
---|---|
539 | 1 #include <iostream> |
2 #include <cmath> | |
3 #include "SceneGraphRoot.h" | |
4 #include "gaplant.h" | |
5 using namespace std; | |
6 | |
7 void | |
8 move_right(SceneGraphPtr node) | |
9 { | |
628 | 10 /*cout << "右を押したんだ " << node->angle[2] << "\n";*/ |
11 node->angle[1] -= 10; | |
12 /* if (node->angle[2] < -30) { | |
539 | 13 node->angle[2] = -30; |
628 | 14 } |
15 node->xyz[0] += 5;*/ | |
539 | 16 } |
17 | |
18 void | |
19 move_left(SceneGraphPtr node) | |
20 { | |
628 | 21 /*cout << "左を押したんだ " << node->angle[2] << "\n";*/ |
22 node->angle[1] += 10; | |
23 /* if (node->angle[2] > 30) { | |
539 | 24 node->angle[2] = 30; |
628 | 25 } |
26 node->xyz[0] -= 5;*/ | |
539 | 27 } |
28 | |
29 void | |
30 move_down(SceneGraphPtr node) | |
31 { | |
628 | 32 /*cout << "下だって押したくなる時はある "<< node->angle[0] << "\n";*/ |
33 node->angle[0] += 10; | |
34 /*if (node->angle[0] > -60) { | |
539 | 35 node->angle[0] = -60; |
628 | 36 } |
37 node->xyz[1] += 5;*/ | |
539 | 38 } |
39 | |
40 void | |
41 move_up(SceneGraphPtr node) | |
42 { | |
628 | 43 /*cout << "上を押したんだ "<< node->angle[0] << "\n";*/ |
44 node->angle[0] -= 10; | |
45 /*if (node->angle[0] < -120) { | |
539 | 46 node->angle[0] = -120; |
628 | 47 } |
48 node->xyz[1] -= 5;*/ | |
539 | 49 } |
50 | |
51 void | |
653
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
628
diff
changeset
|
52 gaplant_move(SceneGraphPtr node, void *sgroot_, int w, int h) |
539 | 53 { |
653
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
628
diff
changeset
|
54 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; |
539 | 55 Pad *pad = sgroot->getController(); |
56 | |
57 if (pad->right.isHold() || pad->left.isHold() || pad->down.isHold() || pad->up.isHold()) { | |
58 if (pad->right.isHold()) { | |
59 move_right(node); | |
60 } else if (pad->left.isHold()) { | |
61 move_left(node); | |
62 } else if (pad->down.isHold()) { | |
63 move_down(node); | |
64 } else if (pad->up.isHold()) { | |
65 move_up(node); | |
66 } | |
67 } | |
68 | |
69 if (pad->cross.isHold() || pad->circle.isHold()) { | |
70 if (pad->cross.isHold()) { | |
71 node->xyz[2] += 5; | |
72 } else if (pad->circle.isHold()) { | |
73 node->xyz[2] -= 5; | |
74 } | |
75 } | |
76 } | |
77 | |
78 void | |
653
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
628
diff
changeset
|
79 gaplant_coll(SceneGraphPtr node, void *sgroot_, int w, int h, SceneGraphPtr tree) |
539 | 80 { |
653
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
628
diff
changeset
|
81 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; |
539 | 82 SceneGraphIteratorPtr it = sgroot->getIterator(tree); |
83 //static int damage = 0; | |
84 | |
578 | 85 for (; it->hasNext(sgroot->getSgid("Ball"));) { |
86 it->next(sgroot->getSgid("Ball")); | |
539 | 87 SceneGraphPtr ball = it->get(); |
88 | |
89 double dis_x = node->xyz[0] - ball->xyz[0]; | |
90 double dis_y = node->xyz[1] - ball->xyz[1]; | |
91 double dis_z = node->xyz[2] - ball->xyz[2]; | |
92 double distance = sqrt(dis_x*dis_x + dis_y*dis_y + dis_z*dis_z); | |
93 | |
94 if (distance < CHECK_HIT_RAD + BALL_RAD) { | |
95 cout << "今からもっと細かく判定するよ ^q^\n"; | |
96 ball->remove(); | |
97 } | |
98 } | |
99 } |