Mercurial > hg > Game > Cerium
view TaskManager/Test/test_render/cube_action.cpp @ 203:1eba8570808c draft
fix CreateSpan::run
author | gongo@localhost.localdomain |
---|---|
date | Mon, 26 Jan 2009 18:30:35 +0900 |
parents | 4e66b3327c50 |
children | c020ccff4627 |
line wrap: on
line source
#include "SceneGraph.h" #include "xml_file/cube_split.h" #include "xml_file/cube.h" static void cube_move_left(SceneGraphPtr node, int screen_w, int screen_h); static void cube_move_right(SceneGraphPtr node, int screen_w, int screen_h); static void cube_move_idle(SceneGraphPtr node, int screen_w, int screen_h); static void cube_collision(SceneGraphPtr node, int screen_w, int screen_h, SceneGraphPtr tree); static void cube_split(SceneGraphPtr root); static void cube_move_left(SceneGraphPtr node, int screen_w, int screen_h) { node->xyz[0] -= node->stack_xyz[0]; node->xyz[1] -= node->stack_xyz[0] * node->stack_xyz[1]; node->xyz[2] -= node->stack_xyz[0] * node->stack_xyz[2]; if (node->xyz[0] < 0) { node->set_move_collision(cube_move_right, cube_collision); } if (node->xyz[1] < 0 || node->xyz[1] > screen_h) { node->stack_xyz[1] = -node->stack_xyz[1]; } node->angle[0] += 2.0f; node->angle[1] += 2.0f * node->stack_xyz[1]; node->angle[2] += 2.0f * node->stack_xyz[2]; //if (node->frame > 10 && scene_graph->controller->circle.push) { //cube_split(node); //} } static void cube_move_right(SceneGraphPtr node, int screen_w, int screen_h) { node->xyz[0] += node->stack_xyz[0]; node->xyz[1] -= node->stack_xyz[0] * node->stack_xyz[1]; node->xyz[2] -= node->stack_xyz[0] * node->stack_xyz[2]; if (node->xyz[0] > screen_w) { node->set_move_collision(cube_move_left, cube_collision); } if (node->xyz[1] < 0 || node->xyz[1] > screen_h) { node->stack_xyz[1] = -node->stack_xyz[1]; } node->angle[0] += 2.0f; node->angle[1] += 2.0f * node->stack_xyz[1]; node->angle[2] += 2.0f * node->stack_xyz[2]; //if (node->frame > 10 && scene_graph->controller->circle.push) { //cube_split(node); //} } static void cube_split(SceneGraphPtr root) { SceneGraphPtr p = root->clone(); root->addBrother(p); root->set_move_collision(cube_move_left, cube_collision); p->set_move_collision(cube_move_right, cube_collision); p->xyz[0] = root->xyz[0] + 2; p->xyz[1] = root->xyz[1]; p->xyz[2] = root->xyz[2]; p->stack_xyz[0] = 2.0f; p->stack_xyz[1] = random()%3-1; p->stack_xyz[2] = random()%3-1; root->xyz[0] -= 2; root->stack_xyz[0] = 2.0f; root->stack_xyz[1] = random()%3-1; root->stack_xyz[2] = random()%3-1; } static void cube_move_idle(SceneGraphPtr node, int screen_w, int screen_h) { node->xyz[0] = screen_w/2; node->xyz[1] = screen_h/2; node->xyz[2] = -300.0f; //if (scene_graph->controller->circle.push) { //cube_split(node); //} } static void cube_collision(SceneGraphPtr node, int screen_w, int screen_h, SceneGraphPtr tree) { } static void plane_idle(SceneGraphPtr node, int w, int h) { node->xyz[2] = 100.0f; } void create_cube_split(int number) { if (number == 0) { SceneGraph::createFromXMLfile("xml_file/cube_split.xml"); Plane->set_move_collision(plane_idle, cube_collision); CUBE->set_move_collision(cube_move_idle, cube_collision); } else { SceneGraph::createFromXMLfile("xml_file/cube.xml"); Cube->set_move_collision(cube_move_idle, cube_collision); } }