changeset 10:ea99603c6099

add_comment
author <e085737>
date Sun, 05 Dec 2010 10:37:49 +0900
parents 182428b3aee8
children 0800fc0944ac
files Vacuum_new/resources/SceneGraph.js Vacuum_new/resources/SceneGraphRoot.js Vacuum_new/resources/cube.js Vacuum_new/resources/title.js Vacuum_new/resources/vacuum.js vacuum_new/resources/SceneGraph.js vacuum_new/resources/vacuum.js
diffstat 7 files changed, 32 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/Vacuum_new/resources/SceneGraph.js	Sat Dec 04 22:08:22 2010 +0900
+++ b/Vacuum_new/resources/SceneGraph.js	Sun Dec 05 10:37:49 2010 +0900
@@ -7,6 +7,7 @@
 }
 
 
+//カメラの位置を調整
 function Camera_zoom(){
     var zoom = 10.0
 
@@ -20,6 +21,7 @@
 }
 
 
+/* 再帰的に呼び出して全てのnodeのcollisionを実行する */
 function collision_object(node,sgroot,w,h){
     for(num in node.child){
 	collision_object(node.child[num],sgroot,w,h)
@@ -31,6 +33,7 @@
 }
 
 
+/* 再帰的に呼び出して全てのnodeのmoveを実行する */
 function move_object(node,sgroot,w,h){
     for(num in node.child){
 	move_object(node.child[num],sgroot,w,h)
@@ -40,11 +43,14 @@
     }
 }
 
+
+/* 再帰的に呼び出して全てのnodeをdrawする */
 function draw_object(ctx,node,sgroot){
     for(num in node.child){
         draw_object(ctx,node.child[num],sgroot)
     }
     if(node.id != null){
+	/* idを引数にイメージを引っ張ってきてimageに格納している */
         var image = sgroot.getSgid(node.id)
         drawBall(ctx, node.angle, node.xyz, node.scale, image) 
     }
@@ -124,6 +130,7 @@
 }
 
 
+/* moveとcollisionをsetする */
 SceneGraph.prototype.set_move_collision = function(new_move, new_collision){
     this.move = new_move
     this.collision = new_collision
@@ -163,6 +170,7 @@
 }
 
 
+/* 子どもの追加 */
 SceneGraph.prototype.addChild = function(node){	
    var num = this.child.length 
    this.child.push(node)
--- a/Vacuum_new/resources/SceneGraphRoot.js	Sat Dec 04 22:08:22 2010 +0900
+++ b/Vacuum_new/resources/SceneGraphRoot.js	Sun Dec 05 10:37:49 2010 +0900
@@ -44,7 +44,6 @@
     }
 
 
-    if(id.name == "GAMEOVER") alert(id.name)
     if(sg_exec_tree != null){
 	sg_exec_tree.addChild(src)
     }
@@ -75,7 +74,7 @@
 
 
 SceneGraphRoot.prototype.createSceneGraph3 = function(){
-   p = new SceneGraph() 
+   var p = new SceneGraph() 
 
    p.sgroot = this
 
@@ -100,10 +99,10 @@
 	    sg.prev = last
     }*/
     //cnt++
-    
 }
 
 
+/* 渡された引数をもとにイメージを検索する */
 SceneGraphRoot.prototype.getSgid = function(obj_name){
     for(var name in sg_src){
         if(obj_name == sg_src[name].name){
@@ -189,20 +188,11 @@
 	return zoom_out_push
     }
 
-
-    if(zoom_in_push){
-        view_point += 5.0
-    }
-    
-    if(zoom_out_push){
-	view_point -= 5.0
-    }
-
 }
 
 
 
-
+/* rootになるnodeを設定する */
 SceneGraphRoot.prototype.setSceneData = function(sg){
     sg.parents = null
     sg_exec_tree = sg
--- a/Vacuum_new/resources/cube.js	Sat Dec 04 22:08:22 2010 +0900
+++ b/Vacuum_new/resources/cube.js	Sun Dec 05 10:37:49 2010 +0900
@@ -1,3 +1,4 @@
+/* ある程度時間が経つとcube_splitを実行 */
 cube_collision = function(node, sgroot, screen_w, screen_h){ 
     if(node.frame > 400){
 	cube_split(node, sgroot)
--- a/Vacuum_new/resources/title.js	Sat Dec 04 22:08:22 2010 +0900
+++ b/Vacuum_new/resources/title.js	Sun Dec 05 10:37:49 2010 +0900
@@ -1,10 +1,10 @@
 function title_collision(node, sgroot, w, h){
-    pad = new sgroot.getController()
+    var pad = new sgroot.getController()
 
     if(pad.start_isHold()){
-        back = new sgroot.createSceneGraph3()
+        var back = new sgroot.createSceneGraph3()
 
-	vacuum = new sgroot.createSceneGraph1("BIGCUBE")
+	var vacuum = new sgroot.createSceneGraph1("BIGCUBE")
         vacuum.xyz[0] = w/2
 	vacuum.xyz[1] = h/2
 	vacuum.set_move_collision(vacuum_move, vacuum_coll)
@@ -12,6 +12,6 @@
 	back.addChild(vacuum)
 	add_cubecollision_object(redcube.name, vacuum, w, h, sgroot)
 
-	sgroot.setSceneData(vacuum)
+	sgroot.setSceneData(back)
     }
 }
--- a/Vacuum_new/resources/vacuum.js	Sat Dec 04 22:08:22 2010 +0900
+++ b/Vacuum_new/resources/vacuum.js	Sun Dec 05 10:37:49 2010 +0900
@@ -12,7 +12,7 @@
 
 
 vacuum_coll = function(node, sgroot, screen_w, screen_h){
-    const ENCOUNT = 100 
+    const ENCOUNT = 100
     var pad = new sgroot.getController()
     if(node.frame%ENCOUNT == ENCOUNT-1){
         if(Math.random() < 0.5){
@@ -59,6 +59,8 @@
         if(near_enemy != null){
             near_enemy.stack_xyz[2] = 1
             var lockon = sgroot.createSceneGraph2("LOCK")
+	    lockon.xyz[0] = near_enemy.xyz[0]
+	    lockon.xyz[1] = near_enemy.xyz[1]
             lockon.set_move_collision(no_move_idle, lockon_collision)
             near_enemy.addChild(lockon)
 	}
@@ -106,7 +108,6 @@
 
 
 add_cubecollision_object = function(id, root, w, h, sgroot){
-    //var common_move = new sgroot.createSceneGraph3()
     var cube_object = new sgroot.createSceneGraph1(id)
     cube_object.xyz[0] = Math.random()*w
     cube_object.xyz[1] = Math.random()*h
@@ -121,7 +122,7 @@
     sgroot.createFromXMLfile(gl, "./xml/gamecube.xml");
     sgroot.createFromXMLfile(gl, "./xml/title.xml");
 
-    title = new sgroot.createSceneGraph1("TITLE")
+    var title = new sgroot.createSceneGraph1("TITLE")
     title.xyz[0] = w/2
     title.xyz[1] = h/2
     title.set_move_collision(no_move_idle, title_collision) 
--- a/vacuum_new/resources/SceneGraph.js	Sat Dec 04 22:08:22 2010 +0900
+++ b/vacuum_new/resources/SceneGraph.js	Sun Dec 05 10:37:49 2010 +0900
@@ -7,6 +7,7 @@
 }
 
 
+//カメラの位置を調整
 function Camera_zoom(){
     var zoom = 10.0
 
@@ -20,6 +21,7 @@
 }
 
 
+/* 再帰的に呼び出して全てのnodeのcollisionを実行する */
 function collision_object(node,sgroot,w,h){
     for(num in node.child){
 	collision_object(node.child[num],sgroot,w,h)
@@ -31,6 +33,7 @@
 }
 
 
+/* 再帰的に呼び出して全てのnodeのmoveを実行する */
 function move_object(node,sgroot,w,h){
     for(num in node.child){
 	move_object(node.child[num],sgroot,w,h)
@@ -40,11 +43,14 @@
     }
 }
 
+
+/* 再帰的に呼び出して全てのnodeをdrawする */
 function draw_object(ctx,node,sgroot){
     for(num in node.child){
         draw_object(ctx,node.child[num],sgroot)
     }
     if(node.id != null){
+	/* idを引数にイメージを引っ張ってきてimageに格納している */
         var image = sgroot.getSgid(node.id)
         drawBall(ctx, node.angle, node.xyz, node.scale, image) 
     }
@@ -124,6 +130,7 @@
 }
 
 
+/* moveとcollisionをsetする */
 SceneGraph.prototype.set_move_collision = function(new_move, new_collision){
     this.move = new_move
     this.collision = new_collision
@@ -163,6 +170,7 @@
 }
 
 
+/* 子どもの追加 */
 SceneGraph.prototype.addChild = function(node){	
    var num = this.child.length 
    this.child.push(node)
--- a/vacuum_new/resources/vacuum.js	Sat Dec 04 22:08:22 2010 +0900
+++ b/vacuum_new/resources/vacuum.js	Sun Dec 05 10:37:49 2010 +0900
@@ -12,7 +12,7 @@
 
 
 vacuum_coll = function(node, sgroot, screen_w, screen_h){
-    const ENCOUNT = 100 
+    const ENCOUNT = 100
     var pad = new sgroot.getController()
     if(node.frame%ENCOUNT == ENCOUNT-1){
         if(Math.random() < 0.5){
@@ -59,6 +59,8 @@
         if(near_enemy != null){
             near_enemy.stack_xyz[2] = 1
             var lockon = sgroot.createSceneGraph2("LOCK")
+	    lockon.xyz[0] = near_enemy.xyz[0]
+	    lockon.xyz[1] = near_enemy.xyz[1]
             lockon.set_move_collision(no_move_idle, lockon_collision)
             near_enemy.addChild(lockon)
 	}
@@ -106,7 +108,6 @@
 
 
 add_cubecollision_object = function(id, root, w, h, sgroot){
-    //var common_move = new sgroot.createSceneGraph3()
     var cube_object = new sgroot.createSceneGraph1(id)
     cube_object.xyz[0] = Math.random()*w
     cube_object.xyz[1] = Math.random()*h
@@ -121,7 +122,7 @@
     sgroot.createFromXMLfile(gl, "./xml/gamecube.xml");
     sgroot.createFromXMLfile(gl, "./xml/title.xml");
 
-    title = new sgroot.createSceneGraph1("TITLE")
+    var title = new sgroot.createSceneGraph1("TITLE")
     title.xyz[0] = w/2
     title.xyz[1] = h/2
     title.set_move_collision(no_move_idle, title_collision)