### view Renderer/Test/gaplant_action.cc @ 1029:22d7263cec2d

author tkaito Mon, 15 Nov 2010 22:39:25 +0900 d0b8860c17f8
line wrap: on
line source
```
#include <iostream>
#include <cmath>
#include "SceneGraphRoot.h"
#include "gaplant.h"
using namespace std;

void
move_right(SceneGraphPtr node)
{
/*cout << "右を押したんだ " << node->angle[2] << "\n";*/
node->angle[1] -= 10;
/* if (node->angle[2] < -30) {
node->angle[2] = -30;
}
node->xyz[0] += 5;*/
}

void
move_left(SceneGraphPtr node)
{
/*cout << "左を押したんだ " << node->angle[2] << "\n";*/
node->angle[1] += 10;
/* if (node->angle[2] > 30) {
node->angle[2] = 30;
}
node->xyz[0] -= 5;*/
}

void
move_down(SceneGraphPtr node)
{
/*cout << "下だって押したくなる時はある "<< node->angle[0] << "\n";*/
node->angle[0] += 10;
/*if (node->angle[0] > -60) {
node->angle[0] = -60;
}
node->xyz[1] += 5;*/
}

void
move_up(SceneGraphPtr node)
{
/*cout << "上を押したんだ "<< node->angle[0] << "\n";*/
node->angle[0] -= 10;
/*if (node->angle[0] < -120) {
node->angle[0] = -120;
}
node->xyz[1] -= 5;*/
}

void
gaplant_move(SceneGraphPtr node, void *sgroot_, int w, int h)
{
SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;

move_right(node);
move_left(node);
move_down(node);
move_up(node);
}
}

node->xyz[2] += 5;
node->xyz[2] -= 5;
}
}
}

void
gaplant_coll(SceneGraphPtr node, void *sgroot_, int w, int h, SceneGraphPtr tree)
{
SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
SceneGraphIteratorPtr it = sgroot->getIterator(tree);
//static int damage = 0;

for (; it->hasNext(sgroot->getSgid("Ball"));) {
it->next(sgroot->getSgid("Ball"));
SceneGraphPtr ball = it->get();

double dis_x = node->xyz[0] - ball->xyz[0];
double dis_y = node->xyz[1] - ball->xyz[1];
double dis_z = node->xyz[2] - ball->xyz[2];
double distance = sqrt(dis_x*dis_x + dis_y*dis_y + dis_z*dis_z);

cout << "今からもっと細かく判定するよ ^q^\n";
ball->remove();
}
}
}
```