diff Renderer/Test/boss1_action.cc @ 562:a5fda4e51498

name search
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 22 Oct 2009 22:22:31 +0900
parents b05bae017029
children d0b8860c17f8
line wrap: on
line diff
--- a/Renderer/Test/boss1_action.cc	Thu Oct 22 19:31:09 2009 +0900
+++ b/Renderer/Test/boss1_action.cc	Thu Oct 22 22:22:31 2009 +0900
@@ -1,7 +1,6 @@
 #include "SceneGraphRoot.h"
 #include "MainLoop.h"
 #include "boss1_action.h"
-#include "xml_file/boss1.xml.h"
 
 /*
 static void
@@ -116,7 +115,7 @@
   }
   
   if (pad->circle.isPush()) {
-    SceneGraphPtr shot = sgroot->createSceneGraph(P_SHOT1);
+    SceneGraphPtr shot = sgroot->createSceneGraph("P_SHOT1");
     shot->set_move_collision(shot_move, shot_collision);
     shot->xyz[0] = node->xyz[0];
     shot->xyz[1] = node->xyz[1] - player_radius;
@@ -124,6 +123,8 @@
   }    
 }
 
+static int boss1sgid;
+
 static void
 player_collision(SceneGraphPtr node, int screen_w, int screen_h,
 		 SceneGraphPtr tree)
@@ -136,8 +137,8 @@
   SceneGraphIteratorPtr it = sgroot->getIterator(tree);
   
   
-  for (; it->hasNext(BOSS1);) {
-    it->next(BOSS1);
+  for (; it->hasNext(boss1sgid);) {
+    it->next(boss1sgid);
     SceneGraphPtr enemy = it->get();
     
     //各変数の初期化
@@ -181,8 +182,8 @@
   SceneGraphIteratorPtr it = sgroot->getIterator(tree);
   
   
-  for (; it->hasNext(BOSS1);) {
-    it->next(BOSS1);
+  for (; it->hasNext(boss1sgid);) {
+    it->next(boss1sgid);
     SceneGraphPtr enemy = it->get();
     
     x_distant = node->xyz[0] - enemy->xyz[0];
@@ -193,7 +194,7 @@
     
     //円同士のcollision
     if(distance <  boss_radius_y) {
-      SceneGraphPtr blast = sgroot->createSceneGraph(BLAST1);
+      SceneGraphPtr blast = sgroot->createSceneGraph("BLAST1");
       
       blast->set_move_collision(blast_move, null_collision);
       blast->xyz[0] = node->xyz[0];
@@ -211,11 +212,12 @@
 
 const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n";
 
+static int blast8;
 
 static void
 blast_move(SceneGraphPtr node, int screen_w, int screen_h)
 {
-  if(node->sgid > BLAST8) {
+  if(node->sgid > blast8) {
     SceneGraphPtr blast = sgroot->createSceneGraph(node->sgid - 1);
     blast->set_move_collision(blast_move, null_collision);
     blast->xyz[0] = node->xyz[0];
@@ -223,7 +225,7 @@
     node->addBrother(blast);
   }
   
-  if (node->sgid == BLAST8) {
+  if (node->sgid == blast8) {
     node->flag_drawable = 1;
   }
   
@@ -241,18 +243,22 @@
   sgroot->createFromXMLfile("xml_file/player1.xml");
   sgroot->createFromXMLfile("xml_file/p_shot.xml");
   sgroot->createFromXMLfile("xml_file/blast.xml");
-  
+ 
+  blast8 = sgroot->getSgid("BLAST8");
+ 
   //rootとなるSceneGraphを生成
   SceneGraphPtr root = sgroot->createSceneGraph();
   
   //自機の初期化
-  SceneGraphPtr player = sgroot->createSceneGraph(PLAYER);
+  SceneGraphPtr player = sgroot->createSceneGraph("PLAYER");
   player->xyz[0] = screen_w/2;
   player->xyz[1] = screen_h - player_radius;
   root->addChild(player);
 
   //ボスの初期化
-  SceneGraphPtr boss1 = sgroot->createSceneGraph(BOSS1);
+  SceneGraphPtr boss1 = sgroot->createSceneGraph("BOSS1");
+  boss1sgid = boss1->sgid;
+
   boss1->xyz[0] = screen_w/2;
   boss1->xyz[1] = boss_radius_y;
   //  boss1->xyz[2] = first_boss1_depth;
@@ -260,9 +266,9 @@
   root->addChild(boss1);
 
   //ボスの左右パーツを追加
-  SceneGraphPtr left_parts = sgroot->createSceneGraph(BOSS1_L);
+  SceneGraphPtr left_parts = sgroot->createSceneGraph("BOSS1_L");
   boss1->addChild(left_parts);
-  SceneGraphPtr right_parts = sgroot->createSceneGraph(BOSS1_R);
+  SceneGraphPtr right_parts = sgroot->createSceneGraph("BOSS1_R");
   boss1->addChild(right_parts);
 
   //各機体の動きと当たり判定をセット