Mercurial > hg > Game > Cerium
changeset 144:594093237a15 draft
fix
author | gongo@localhost.localdomain |
---|---|
date | Sat, 29 Nov 2008 11:43:13 +0900 |
parents | 9588726193e1 |
children | a5138d6e8996 |
files | TaskManager/Test/test_render/cube_action.cpp TaskManager/Test/test_render/main.cpp TaskManager/Test/test_render/viewer.cpp TaskManager/Test/test_render/viewer.h |
diffstat | 4 files changed, 69 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Test/test_render/cube_action.cpp Sat Nov 29 03:36:11 2008 +0900 +++ b/TaskManager/Test/test_render/cube_action.cpp Sat Nov 29 11:43:13 2008 +0900 @@ -1,5 +1,5 @@ #include "SceneGraph.h" -//#include "xml_file/cube_split.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); @@ -17,6 +17,14 @@ 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]; @@ -33,6 +41,14 @@ 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]; @@ -91,11 +107,14 @@ } void -create_cube_split(void) +create_cube_split(int number) { - //SceneGraph::createFromXMLfile("xml_file/cube_split.xml"); - //Plane->set_move_collision(plane_idle, cube_collision); - //CUBE->set_move_collision(cube_move_idle, cube_collision); - SceneGraph::createFromXMLfile("xml_file/cube.xml"); - Cube->set_move_collision(cube_move_idle, cube_collision); + 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); + } }
--- a/TaskManager/Test/test_render/main.cpp Sat Nov 29 03:36:11 2008 +0900 +++ b/TaskManager/Test/test_render/main.cpp Sat Nov 29 11:43:13 2008 +0900 @@ -5,13 +5,24 @@ #include "Func.h" /* prototype */ -void init(int argc, char *argc[]); +int init(int argc, char *argc[]); extern void task_initialize(); Viewer *screen; -void +static int sg_number = 0; + +static char *help_str = "Usage: ./test_nogl [OPTION]\n\ + -cpu Number of SPE (default 1)\n\ + -width, -height window size (default 640x480)\n\ + -sg Draw SceneGraph\n\ + 0: 丸ボタン(Keyboard だとz) を押すと、キューブが二つに分かれる\n\ + 1: 0 のキューブが大きい版\n\ + 2: スネークさんが写るだけ\n\ + 3: キューブが跳ね返りながら、勝手にキューブが増えて行く"; + +int init(int argc, char *argv[]) { int bpp = 0; @@ -35,9 +46,16 @@ if (strcmp(argv[i], "-xml") == 0) { xml = argv[++i]; } + if (strcmp(argv[i], "-sg") == 0) { + sg_number = (atoi)(argv[++i]); + } if (strcmp(argv[i], "-cpu") == 0) { spenum = atoi(argv[++i]); } + if (strcmp(argv[i], "-help") == 0) { + printf("%s\n", help_str); + return -1; + } if (strcmp(argv[i], "-video") == 0) { if (strcmp(argv[i+1], "sdl") == 0) { vtype = VTYPE_SDL; @@ -55,7 +73,9 @@ } screen->video_init(); - screen->run_init(xml); + screen->run_init(xml, sg_number); + + return 0; } int @@ -63,7 +83,7 @@ { task_initialize(); - init(argc, argv); + return init(argc, argv); - return 0; + //return 0; }
--- a/TaskManager/Test/test_render/viewer.cpp Sat Nov 29 03:36:11 2008 +0900 +++ b/TaskManager/Test/test_render/viewer.cpp Sat Nov 29 11:43:13 2008 +0900 @@ -104,11 +104,11 @@ } extern void node_init(void); -extern void create_cube_split(void); +extern void create_cube_split(int); extern void create_snake_bg(void); void -Viewer::run_init(char *xml) +Viewer::run_init(char *xml, int sg_number) { HTaskPtr task_next; HTaskPtr task_init_tex; @@ -126,9 +126,21 @@ //SceneGraph::createFromXMLfile(xml); //polygon->viewer = this; - //create_cube_split(); - create_snake_bg(); - //node_init(); + switch (sg_number) { + case 0: + case 1: + create_cube_split(sg_number); + break; + case 2: + create_snake_bg(); + break; + case 3: + node_init(); + break; + default: + node_init(); + break; + } scene_graph->controller = create_controller();
--- a/TaskManager/Test/test_render/viewer.h Sat Nov 29 03:36:11 2008 +0900 +++ b/TaskManager/Test/test_render/viewer.h Sat Nov 29 11:43:13 2008 +0900 @@ -34,7 +34,7 @@ virtual void swap_buffers(); virtual void clean_pixels() {} - virtual void run_init(char *xml); + virtual void run_init(char *xml, int sg_number); virtual void run_loop(void); virtual void run_draw(void); virtual void run_finish(void);