Mercurial > hg > Game > Cerium
annotate TaskManager/Test/test_render/universe.cpp @ 198:b832e6cff83e draft
rename snake_bg to panel
author | gongo@gendarme.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Mon, 26 Jan 2009 10:38:29 +0900 |
parents | 4e66b3327c50 |
children | 1fd0107ebb25 |
rev | line source |
---|---|
157 | 1 #include <stdlib.h> |
195 | 2 #include "SceneGraphRoot.h" |
3 #include "SGList.h" | |
4 | |
5 int moonrem = 0; | |
157 | 6 |
7 static void | |
8 cube_collision(SceneGraphPtr node, int screen_w, int screen_h, | |
9 SceneGraphPtr tree) | |
10 { | |
11 } | |
12 | |
13 static void | |
195 | 14 moon_collision(SceneGraphPtr node, int screen_w, int screen_h, |
15 SceneGraphPtr tree) | |
16 { | |
17 } | |
18 | |
19 static void | |
20 moon_move(SceneGraphPtr node, int screen_w, int screen_h) | |
21 { | |
22 node->angle[0] += 3.0f; | |
23 printf("%f\n", node->angle[0]); | |
24 if (node->angle[0] > 360.0f) { | |
25 node->remove(); | |
26 //node->angle[0] = 0.0f; | |
27 moonrem = 1; | |
28 } | |
29 } | |
30 | |
31 | |
32 static void | |
33 cube_move(SceneGraphPtr node, int screen_w, int screen_h) | |
157 | 34 { |
35 node->angle[1] += 1.0f; | |
36 if (node->angle[1] > 360.0f) { | |
37 node->angle[1] = 0.0f; | |
195 | 38 if (moonrem) { |
39 SceneGraphPtr moon = sgroot->createSceneGraph(Moon); | |
40 moon->set_move_collision(moon_move, moon_collision); | |
41 node->addChild(moon); | |
42 moonrem = 0; | |
43 } | |
157 | 44 } |
45 | |
46 node->xyz[0] += node->stack_xyz[0]; | |
47 if ((int)node->xyz[0] > screen_w || (int)node->xyz[0] < 0) { | |
48 node->stack_xyz[0] = -node->stack_xyz[0]; | |
49 } | |
50 | |
51 node->xyz[1] += node->stack_xyz[1]; | |
52 if ((int)node->xyz[1] > screen_h || (int)node->xyz[1] < 0) { | |
53 node->stack_xyz[1] = -node->stack_xyz[1]; | |
54 } | |
55 } | |
56 | |
195 | 57 void |
198
b832e6cff83e
rename snake_bg to panel
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
195
diff
changeset
|
58 universe_init(void) |
157 | 59 { |
195 | 60 SceneGraphPtr earth; |
61 SceneGraphPtr moon; | |
157 | 62 |
195 | 63 sgroot->createFromXMLfile("xml_file/universe.xml"); |
157 | 64 |
195 | 65 // SGList.h にある SceneGraph ID から SceneGraph を生成する |
66 earth = sgroot->createSceneGraph(Earth); | |
67 moon = sgroot->createSceneGraph(Moon); | |
157 | 68 |
195 | 69 // SceneGraph の move と collision を設定 |
70 earth->set_move_collision(cube_move, cube_collision); | |
71 earth->stack_xyz[0] = 3.0f; | |
72 earth->stack_xyz[1] = 3.0f; | |
73 moon->set_move_collision(moon_move, moon_collision); | |
157 | 74 |
195 | 75 // SceneGraph 同士の親子関係を設定 (今回は 親 earth、子 moon) |
76 earth->addChild(moon); | |
77 | |
78 // SceneGraphRoot に、使用する SceneGraph を設定する | |
79 // このとき、ユーザーが記述した SceneGraph の root を渡す。 | |
80 sgroot->setSceneData(earth); | |
157 | 81 } |