Mercurial > hg > Members > kono > Cerium
comparison Renderer/Test/ball_bound.cc @ 656:d0b8860c17f8
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
author | hiroki@henri.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Wed, 25 Nov 2009 21:56:14 +0900 |
parents | a5fda4e51498 |
children | 4f77768d7a7f |
comparison
equal
deleted
inserted
replaced
646:ffcc25c7c566 | 656:d0b8860c17f8 |
---|---|
4 #include "MainLoop.h" | 4 #include "MainLoop.h" |
5 #include "ball_bound.h" | 5 #include "ball_bound.h" |
6 | 6 |
7 | 7 |
8 // prototype | 8 // prototype |
9 static void ball_move(SceneGraphPtr node, int screen_w, int screen_h); | 9 static void ball_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h); |
10 static void ball_collision(SceneGraphPtr node, int screen_w, int screen_h, SceneGraphPtr tree); | 10 static void ball_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree); |
11 static void ball_collision_idle(SceneGraphPtr, int w, int h, SceneGraphPtr tree); | 11 static void ball_collision_idle(SceneGraphPtr, void *sgroot_, int w, int h, SceneGraphPtr tree); |
12 | 12 |
13 | 13 |
14 static float vy = 0.0f; // y 方向速度 | 14 static float vy = 0.0f; // y 方向速度 |
15 static float dt = 1.0/1.0f; // frame rate | 15 static float dt = 1.0/1.0f; // frame rate |
16 | 16 |
22 static float ball_radius = 100.0f; | 22 static float ball_radius = 100.0f; |
23 | 23 |
24 static float speed = 10.0f; | 24 static float speed = 10.0f; |
25 | 25 |
26 static void | 26 static void |
27 ball_move_idle2(SceneGraphPtr node, int screen_w, int screen_h) | 27 ball_move_idle2(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) |
28 { | 28 { |
29 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; | |
29 Pad *pad = sgroot->getController(); | 30 Pad *pad = sgroot->getController(); |
30 | 31 |
31 if (pad->circle.isHold()) { | 32 if (pad->circle.isHold()) { |
32 if (pad->left.isHold()) { | 33 if (pad->left.isHold()) { |
33 node->xyz[0] -= speed; | 34 node->xyz[0] -= speed; |
52 } | 53 } |
53 | 54 |
54 static int time = 0; | 55 static int time = 0; |
55 | 56 |
56 static void | 57 static void |
57 ball_move_idle(SceneGraphPtr node, int screen_w, int screen_h) | 58 ball_move_idle(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) |
58 { | 59 { |
60 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; | |
59 Pad *pad = sgroot->getController(); | 61 Pad *pad = sgroot->getController(); |
60 | 62 |
61 if (pad->circle.isPush()) { | 63 if (pad->circle.isPush()) { |
62 node->set_move_collision(ball_move_idle2, ball_collision_idle); | 64 node->set_move_collision(ball_move_idle2, ball_collision_idle); |
63 time = 0; | 65 time = 0; |
75 time = 0; | 77 time = 0; |
76 } | 78 } |
77 } | 79 } |
78 | 80 |
79 static void | 81 static void |
80 ball_move(SceneGraphPtr node, int screen_w, int screen_h) | 82 ball_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) |
81 { | 83 { |
82 vy += g * dt; | 84 vy += g * dt; |
83 node->xyz[1] += vy * dt; | 85 node->xyz[1] += vy * dt; |
84 // node->xyz[0] += 10.0f; | 86 // node->xyz[0] += 10.0f; |
85 } | 87 } |
86 | 88 |
87 static void | 89 static void |
88 ball_collision_idle(SceneGraphPtr, int w, int h, SceneGraphPtr tree) | 90 ball_collision_idle(SceneGraphPtr, void *sgroot_, int w, int h, SceneGraphPtr tree) |
89 { | 91 { |
90 } | 92 } |
91 | 93 |
92 static void | 94 static void |
93 ball_collision(SceneGraphPtr node, int screen_w, int screen_h, | 95 ball_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, |
94 SceneGraphPtr tree) | 96 SceneGraphPtr tree) |
95 { | 97 { |
96 if (node->xyz[1] > screen_h - ball_radius) { | 98 if (node->xyz[1] > screen_h - ball_radius) { |
97 node->xyz[1] = screen_h - ball_radius; | 99 node->xyz[1] = screen_h - ball_radius; |
98 | 100 |
129 sgroot->setSceneData(ball); | 131 sgroot->setSceneData(ball); |
130 | 132 |
131 return sgroot; | 133 return sgroot; |
132 } | 134 } |
133 | 135 |
136 MainLoopPtr | |
137 ball_bound::init_only_sg(SgChange *sgroot, int screen_w, int screen_h) | |
138 { | |
139 return sgroot; | |
140 } | |
141 | |
134 extern Application * | 142 extern Application * |
135 application() { | 143 application() { |
136 return new ball_bound(); | 144 return new ball_bound(); |
137 } | 145 } |
138 | 146 |