Mercurial > hg > Members > tkaito > dandy
view mydandy.cc @ 2:69b4108bf4e8
refact few
author | tkaito |
---|---|
date | Sun, 06 Jun 2010 03:22:11 +0900 |
parents | |
children | dca6d5d2ef46 |
line wrap: on
line source
#include "SceneGraphRoot.h" #include "dandy.h" SceneGraphPtr *dandys; void def_angle(SceneGraphPtr node, void *sgroot_, int w, int h); void left_angle(SceneGraphPtr node, void *sgroot_, int w, int h); void right_angle(SceneGraphPtr node, void *sgroot_, int w, int h); void dandy_move(SceneGraphPtr node, void *sgroot_, int w, int h) { SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; Pad *pad = sgroot->getController(); /* 左右の移動 */ if (pad->right.isPush() && w > node->xyz[0]) { right_angle(node, sgroot, w, h); } else if (pad->left.isPush() && 0 < node->xyz[0]) { left_angle(node, sgroot, w, h); } else { //def_angle(node, sgroot, w, h); } if (pad->right.isHold() && w > node->xyz[0]) { node->xyz[0] += 10.0f; } else if (pad->left.isHold() && 0 < node->xyz[0]) { node->xyz[0] -= 10.0f; } if (pad->right.isRelease()) { } else if(pad->left.isRelease()) { } /* 上下の移動 */ if (pad->up.isHold() && 0 < node->xyz[1]) { node->xyz[1] -= 10.0f; //def_angle(node, sgroot, w, h); } else if (pad->down.isHold() && h > node->xyz[1]) { node->xyz[1] += 10.0f; } } void dandy_collision(SceneGraphPtr node, void *sgroot_, int w, int h,SceneGraphPtr tree) { } /* 時機や敵機のオブジェクトや何やらを作成してsetSceneDataまで */ void create_object(void *sgroot_, int w, int h) { SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; SceneGraphPtr dandy, rdandy, rtdandy, ldandy, ltdandy; //SceneGraphPtr tmp[5] = {ldandy, ltdandy, dandy, rtdandy, rtdandy}; //dandys = tmp; SceneGraphPtr back = sgroot->createSceneGraph(); dandy = sgroot->createSceneGraph("mydandy"); ldandy = sgroot->createSceneGraph("l-dandy"); ltdandy = sgroot->createSceneGraph("lt-dandy"); rdandy = sgroot->createSceneGraph("r-dandy"); rtdandy = sgroot->createSceneGraph("rt-dandy"); dandy->xyz[0] = w/2; dandy->xyz[1] = h*0.9; dandy->set_move_collision(dandy_move, dandy_collision); //ldandy->set_move_collision(dandy_move, dandy_collision); ltdandy->set_move_collision(dandy_move, dandy_collision); rdandy->set_move_collision(dandy_move, dandy_collision); rtdandy->set_move_collision(dandy_move, dandy_collision); back->addChild(dandy); sgroot->setSceneData(back); } void def_angle(SceneGraphPtr node, void *sgroot_, int w, int h) { SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; SceneGraphPtr dandy = sgroot->createSceneGraph("mydandy"); SceneGraphPtr back = sgroot->createSceneGraph(); dandy->xyz[0] = node->xyz[0]; dandy->xyz[1] = node->xyz[1]; dandy->set_move_collision(dandy_move, dandy_collision); back->addChild(dandy); sgroot->setSceneData(back); } void right_angle(SceneGraphPtr node, void *sgroot_, int w, int h) { SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; SceneGraphPtr rtdandy; SceneGraphPtr back = sgroot->createSceneGraph(); rtdandy = sgroot->createSceneGraph("rt-dandy"); rtdandy->xyz[0] = node->xyz[0]; rtdandy->xyz[1] = node->xyz[1]; rtdandy->set_move_collision(dandy_move, dandy_collision); back->addChild(rtdandy); sgroot->setSceneData(back); rtdandy->xyz[0] += 1.0f; } void left_angle(SceneGraphPtr node, void *sgroot_, int w, int h) { SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; SceneGraphPtr ltdandy; SceneGraphPtr back = sgroot->createSceneGraph(); ltdandy = sgroot->createSceneGraph("lt-dandy"); ltdandy->xyz[0] = node->xyz[0]; ltdandy->xyz[1] = node->xyz[1]; ltdandy->set_move_collision(dandy_move, dandy_collision); back->addChild(ltdandy); sgroot->setSceneData(back); ltdandy->xyz[0] -= 1.0f; }