OSDN Git Service

optimize
authorttwilb <ttwilb@users.sourceforge.jp>
Sat, 24 Aug 2013 06:19:03 +0000 (15:19 +0900)
committerttwilb <ttwilb@users.sourceforge.jp>
Sat, 24 Aug 2013 06:19:03 +0000 (15:19 +0900)
www/corelib/classes/BlockClass.js
www/corelib/classes/GameStageClass.js
www/corelib/classes/SlopeBlockClass.js

index 7d43a01..935ebf3 100644 (file)
@@ -14,4 +14,6 @@ var BlockClass = function(ownerStage, args)
                        this.ownerStage.mainContext.restore();
                }
        },
-});
\ No newline at end of file
+});
+BlockClass.tick = function(){return false;};
+
index d06b003..76fe66e 100644 (file)
@@ -42,9 +42,10 @@ GameStage.prototype = {
                {
                        var tickAllObjects = true;
                        //\82Ü\82¸\81A\83N\83\89\83X\92è\8b`.tick() (\97á\82¦\82ÎBlockStageObjectClass.tick = function(){};) \82ª\92è\8b`\82³\82ê\82Ä\82½\82ç\8eÀ\8ds
-                       //if(sp.tick){
-                       //      tickAllObjects = sp.tick(this.stageObjectList[sp]);
-                       //}
+                       if(sp.tick){
+                               tickAllObjects = sp.tick(this.stageObjectList[sp]);
+                       }
+                       
                        //\8e\9f\82É\8ae\8eíStageObject\82Ìtick\82ð\8eÀ\8ds
                        if(tickAllObjects)
                        {
@@ -194,31 +195,33 @@ GameStage.prototype = {
                //\83A\83C\83e\83\80\82ð\8eæ\93¾\82·\82é\82©\94Û\82©
                var gainItem = items instanceof Array;
                var retv = false;
-               this.eachStageObject(function(f){
-                       if(f !== obj){
-                               if(obj.isCollided(f, x, y)){
-                                       //\8fÕ\93Ë\90æf\82Ì\8fÕ\93Ë\94Í\88Í\93à\82É\82¢\82é
-                                       if(f.isPhantom){
-                                               //\8fÕ\93Ë\90æf\82ª\8fÕ\93Ë\94»\92è\96³\8e\8b\82¾\82Á\82½\82ç\81A\8fÕ\93Ë\82Í\82µ\82È\82¢
-                                               if(gainItem){
-                                                       //\8fÕ\93Ë\90æf\82ð\8eæ\93¾\82µ\82½\83A\83C\83e\83\80\82É\89Á\82¦\82é\81B
-                                                       for(var titem in items){
-                                                               //\95¡\90\94\92Ç\89Á\82Ì\96h\8e~
-                                                               if(titem == f){
-                                                                       return true;
+               for(var sp in this.stageObjectList)
+               {
+                       for(var i = 0; i < this.stageObjectList[sp].length; i++){
+                               var f = this.stageObjectList[sp][i];
+                               if(f !== obj){
+                                       if(obj.isCollided(f, x, y)){
+                                               //\8fÕ\93Ë\90æf\82Ì\8fÕ\93Ë\94Í\88Í\93à\82É\82¢\82é
+                                               if(f.isPhantom){
+                                                       //\8fÕ\93Ë\90æf\82ª\8fÕ\93Ë\94»\92è\96³\8e\8b\82¾\82Á\82½\82ç\81A\8fÕ\93Ë\82Í\82µ\82È\82¢
+                                                       if(gainItem){
+                                                               //\8fÕ\93Ë\90æf\82ð\8eæ\93¾\82µ\82½\83A\83C\83e\83\80\82É\89Á\82¦\82é\81B
+                                                               for(var titem in items){
+                                                                       //\95¡\90\94\92Ç\89Á\82Ì\96h\8e~
+                                                                       if(titem == f){
+                                                                               continue;
+                                                                       }
                                                                }
+                                                               items.push(f);
                                                        }
-                                                       items.push(f);
+                                               } else{
+                                                       //\8fÕ\93Ë\82µ\82½
+                                                       retv = true;
                                                }
-                                       } else{
-                                               //\8fÕ\93Ë\82µ\82½
-                                               retv = true;
-                                               return true;
                                        }
                                }
                        }
-                       return true;
-               });
+               }
                
                return retv;
        },
@@ -250,7 +253,7 @@ GameStage.prototype = {
                        for(var i = 0; i < ct; i++){
                                if(!fx && this.collideJudge(obj, ex + dx, ey, gotItems)){
                                        //caterpillar\82Ì\8d\82\82³\82ð\91«\82µ\82Ä\88Ú\93®\82Å\82«\82é\82©\8e\8e\82µ\82Ä\82Ý\82é
-                                       if(this.collideJudge(obj, ex + dx, ey - caterpillar, gotItems)){
+                                       if(caterpillar != 0 && this.collideJudge(obj, ex + dx, ey - caterpillar, gotItems)){
                                                //\82»\82ê\82Å\82àx\8e²\82ª\8fÕ\93Ë\82µ\82½\82Ì\82Å\88Ú\93®\82ð\92â\8e~\82µ\83t\83\89\83O\82ð\83Z\83b\83g\82·\82é
                                                fx = true;
                                                collideDirection |= (dx > 0 ? 1 : 2);
@@ -269,6 +272,10 @@ GameStage.prototype = {
                                }
                                if(!fy){
                                        ey += dy;
+                               }else if(fx)
+                               {
+                                       // fx && fy \82Å\82 \82ê\82Î\82±\82ê\88È\8fã\83\8b\81[\83v\82µ\82Ä\82à\88Ó\96¡\82È\82¢\82Ì\82Å\94²\82¯\82é
+                                       break;
                                }
                        }
                }
index 6715606..e914521 100644 (file)
@@ -106,4 +106,5 @@ var SlopeBlockClass = function(ownerStage, args)
                        this.ownerStage.collisionMapContext.stroke();
                }
        },
-});
\ No newline at end of file
+});
+SlopeBlockClass.tick = function(){return false;};