Mercurial > hg > Game > Cerium
changeset 1386:20a09f7522a7 draft
change motion_man.cc
author | Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 27 Jan 2012 14:17:06 +0900 |
parents | 207e0ed76cf1 |
children | 83dac8ff2c90 |
files | Renderer/Test/motion_man.cc |
diffstat | 1 files changed, 21 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/Renderer/Test/motion_man.cc Fri Jan 27 02:10:52 2012 +0900 +++ b/Renderer/Test/motion_man.cc Fri Jan 27 14:17:06 2012 +0900 @@ -11,6 +11,8 @@ float tx=0,ty=10; float cx=0,cy=-10; static int cube_subID,cub5ID,cub6ID; +static float cube_radius = 35.0f; +static float cube_sub_radius = 35.0f; static void push_move_false(SceneGraphPtr, void *sgroot_, int w, int h, SceneGraphPtr tree) { @@ -19,12 +21,11 @@ static void walk(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree) { SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; - SceneGraphIteratorPtr it1 = sgroot->getIterator(tree); - SceneGraphIteratorPtr it2 = sgroot->getIterator(tree); + SceneGraphIteratorPtr it = sgroot->getIterator(tree); Pad *pad = sgroot->getController(); - it1->next(cub5ID); - SceneGraphPtr cub5 = it1->get(); + it->next(cub5ID); + SceneGraphPtr cub5 = it->get(); if (pad->left.isHold()) { if (x==80) { @@ -38,8 +39,8 @@ } } - it2->next(cub6ID); - SceneGraphPtr cub6 = it2->get(); + it->next(cub6ID); + SceneGraphPtr cub6 = it->get(); if (pad->left.isHold()) { if (dx==-80) { cub6->angle[0] += 10; @@ -51,6 +52,20 @@ dx=cub6->angle[0]; } } + + float x_distance,y_distance,distance; + it->next(cube_subID); + SceneGraphPtr cube_sub = it->get(); + x_distance = node->xyz[0] - cube_sub->xyz[0]; + y_distance = node->xyz[1] - cube_sub->xyz[1]; + + distance = hypotf(x_distance,y_distance); + + if (distance <= (cube_radius = cube_sub_radius)) { + cube_sub->xyz[0] -= 30; + if (cube_sub->xyz[0]<-40) + cube_sub->xyz[0] = screen_w / 3; + } } static void