diff Renderer/Test/boss1_action.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 4dc02d3e98bb
line wrap: on
line diff
--- a/Renderer/Test/boss1_action.cc	Sat Nov 21 11:20:29 2009 +0900
+++ b/Renderer/Test/boss1_action.cc	Wed Nov 25 21:56:14 2009 +0900
@@ -10,14 +10,14 @@
 */
 
 static void
-null_collision(SceneGraphPtr node, int screen_w, int screen_h,
+null_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
 	       SceneGraphPtr tree)
 {
 }
 
 
 static void
-boss1_move_right(SceneGraphPtr node, int screen_w, int screen_h) {
+boss1_move_right(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) {
   node->xyz[0] += node->stack_xyz[0];
   if(node->xyz[0] > (screen_w - boss_radius_x)) {
     node->set_move_collision(boss1_move_left, null_collision);
@@ -26,7 +26,7 @@
 
 //ボスが左に移動する動作
 static void
-boss1_move_left(SceneGraphPtr node, int screen_w, int screen_h) {
+boss1_move_left(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) {
   node->xyz[0] -= node->stack_xyz[0];
   if(node->xyz[0] < boss_radius_x) {
     node->set_move_collision(boss1_move_right, null_collision);
@@ -64,8 +64,9 @@
 */
 
 static void
-player_move(SceneGraphPtr node, int screen_w, int screen_h)
+player_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
   Pad *pad = sgroot->getController();
   
   if (pad->left.isPush()
@@ -126,9 +127,11 @@
 static int boss1sgid;
 
 static void
-player_collision(SceneGraphPtr node, int screen_w, int screen_h,
+player_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
 		 SceneGraphPtr tree)
 {
+    
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
   //自機とボスのx,y座標での距離と2点間の距離
   static float x_distant, y_distant, distance;
   //ボスの四角形の四隅の座標
@@ -160,7 +163,7 @@
 }
 
 static void
-shot_move(SceneGraphPtr node, int screen_w, int screen_h)
+shot_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
   node->xyz[1] -= shot_speed;
   
@@ -171,9 +174,10 @@
 }
 
 static void
-shot_collision(SceneGraphPtr node, int screen_2, int screen_h,
+shot_collision(SceneGraphPtr node, void *sgroot_, int screen_2, int screen_h,
 	       SceneGraphPtr tree)
 {
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
   //自機とボスのx,y座標での距離と2点間の距離
   static float x_distant, y_distant, distance;
   //ボスの四角形の四隅の座標
@@ -205,6 +209,12 @@
   }
 }
 
+MainLoopPtr 
+boss1_action::init_only_sg(SgChange *sgroot, int screen_w, int screen_h)
+{
+    return sgroot;
+}
+
 extern Application *
 application() {
     return new boss1_action();
@@ -215,8 +225,10 @@
 static int blast8;
 
 static void
-blast_move(SceneGraphPtr node, int screen_w, int screen_h)
+blast_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
+
   if(node->sgid > blast8) {
     SceneGraphPtr blast = sgroot->createSceneGraph(node->sgid - 1);
     blast->set_move_collision(blast_move, null_collision);