Mercurial > hg > Game > Cerium
comparison TaskManager/Test/test_render/universe.cpp @ 157:7bc603ec6111 draft
fix
author | gongo@henri.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Thu, 04 Dec 2008 15:51:47 +0900 |
parents | |
children | 4d792df6ebf2 |
comparison
equal
deleted
inserted
replaced
156:16c3cbbbfc50 | 157:7bc603ec6111 |
---|---|
1 #include <stdlib.h> | |
2 #include "SceneGraph.h" | |
3 #include "xml_file/universe.h" | |
4 | |
5 static void | |
6 cube_collision(SceneGraphPtr node, int screen_w, int screen_h, | |
7 SceneGraphPtr tree) | |
8 { | |
9 } | |
10 | |
11 static void | |
12 cube_move2(SceneGraphPtr node, int screen_w, int screen_h) | |
13 { | |
14 node->angle[1] += 1.0f; | |
15 if (node->angle[1] > 360.0f) { | |
16 node->angle[1] = 0.0f; | |
17 } | |
18 | |
19 node->xyz[0] += node->stack_xyz[0]; | |
20 if ((int)node->xyz[0] > screen_w || (int)node->xyz[0] < 0) { | |
21 node->stack_xyz[0] = -node->stack_xyz[0]; | |
22 } | |
23 | |
24 node->xyz[1] += node->stack_xyz[1]; | |
25 if ((int)node->xyz[1] > screen_h || (int)node->xyz[1] < 0) { | |
26 node->stack_xyz[1] = -node->stack_xyz[1]; | |
27 } | |
28 } | |
29 | |
30 static void | |
31 cube_move(SceneGraphPtr node, int screen_w, int screen_h) | |
32 { | |
33 node->angle[1] += 1.0f; | |
34 if (node->angle[1] > 360.0f) { | |
35 node->angle[1] = 0.0f; | |
36 } | |
37 | |
38 node->xyz[0] += node->stack_xyz[0]; | |
39 if ((int)node->xyz[0] > screen_w || (int)node->xyz[0] < 0) { | |
40 node->stack_xyz[0] = -node->stack_xyz[0]; | |
41 } | |
42 | |
43 node->xyz[1] += node->stack_xyz[1]; | |
44 if ((int)node->xyz[1] > screen_h || (int)node->xyz[1] < 0) { | |
45 node->stack_xyz[1] = -node->stack_xyz[1]; | |
46 } | |
47 } | |
48 | |
49 static void | |
50 moon_move(SceneGraphPtr node, int screen_w, int screen_h) | |
51 { | |
52 node->angle[0] += 1.0f; | |
53 if (node->angle[0] > 360.0f) { | |
54 node->angle[0] = 0.0f; | |
55 } | |
56 } | |
57 | |
58 void | |
59 universe_init(void) | |
60 { | |
61 SceneGraph::createFromXMLfile("xml_file/universe.xml"); | |
62 Earth->set_move_collision(cube_move, cube_collision); | |
63 Earth->stack_xyz[0] = 3.0f; | |
64 Earth->stack_xyz[1] = 3.0f; | |
65 Moon->set_move_collision(moon_move, cube_collision); | |
66 } |