}
},
});
+//\82±\82Ì\83N\83\89\83X\82Ì\83C\83\93\83X\83^\83\93\83X\82Ìtick\82ð\8cÄ\82Ñ\8fo\82³\82È\82¢\82æ\82¤\82É\90Ý\92è\81i\8d\82\91¬\89»\81j
BlockClass.tick = function(){return false;};
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){
+ //\83N\83\89\83Xsp\82Ìtick\82Ì\96ß\82è\92l\82Í\81A\82±\82Ì\83N\83\89\83X\82Ì\83I\83u\83W\83F\83N\83g\82Ì\83C\83\93\83X\83^\83\93\83X\82Ìtick\82ð\8eÀ\8ds\82·\82é\95K\97v\82ª\82 \82é\82©\82Ç\82¤\82©
tickAllObjects = sp.tick(this.stageObjectList[sp]);
}
}
return true;
},
- collideJudge: function(obj, x, y, items){
- //\82·\82×\82Ä\82Ì\83I\83u\83W\83F\83N\83g\82É\91Î\82µ\82Äobj\82Ì\8fÕ\93Ë\8fó\91Ô\82ð\92²\82×\82é\81B
- //\83A\83C\83e\83\80\82ð\8eæ\93¾\82·\82é\82©\94Û\82©
- var gainItem = items instanceof Array;
- var retv = false;
- 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);
- }
- } else{
- //\8fÕ\93Ë\82µ\82½
- retv = true;
- }
- }
- }
- }
- }
-
- return retv;
- },
- moveTo : function(obj, x, y){
- //(x,y)\82Éobj\82ð\88Ú\93®\82µ\82æ\82¤\82Æ\8e\8e\82Ý\82é
- //\93\96\82½\82è\94»\92è\8f\88\97\9d
- var sx = obj.origin.x, sy = obj.origin.y;
- var lx = x - sx, ly = y - sy;
- //if(lx == 0 && ly == 0){
- // //\88Ú\93®\8b\97\97£\82ª0\82Å\82 \82ê\82Î\82Ç\82±\82É\82à\8fÕ\93Ë\82µ\82È\82¢\82Ì\82Å\81A\88Ú\93®\82¹\82¸\82É\95Ô\82é
- // return 0;
- //}
- var collideDirection = 0;//\89º\88Ê4bit : \8fã \89º \8d¶ \89E
- //\88Ú\93®\8b\97\97£\82ð\82Ç\82¿\82ç\82©\88ê\8e²\82Å\82Í\82©\82é
- var ct = Math.max(Math.abs(lx), Math.abs(ly));
- //\82»\82ê\82ð\8aî\8f\80\82É\82µ\82½\88ê\92P\88Ê\93\96\82½\82è\82Ì\88Ú\93®\97Ê
- var dx = lx / ct;
- var dy = ly / ct;
- //\88Ú\93®\82µ\82È\82¢\8e²\82ª\82 \82é\82©\82Ç\82¤\82©\81i\8d\82\91¬\89»\81H\81j
- var fx = (dx == 0);
- var fy = (dy == 0);
- //\8eÀ\8dÛ\82É\88Ú\93®\82·\82é\90æ\82Ì\8dÀ\95W
- var ex = sx;
- var ey = sy;
- //\8eæ\93¾\82µ\82½\83A\83C\83e\83\80\82Ì\83\8a\83X\83g
- var gotItems = [];
- var caterpillar = Math.abs(obj.caterpillar * dx);
- if(!(fx && fy)){
- 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(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);
- } else{
- //\8d\82\82³\82ð\95Ï\82¦\82ê\82Î\88Ú\93®\82Å\82«\82é\82Ì\82Å\8d\82\82³\82ð\95Ï\82¦\82Ä\8cp\91±\82·\82é
- ey -= caterpillar;
- }
- }
- if(!fy && this.collideJudge(obj, ex, ey + dy, gotItems)){
- //y\8e²\82ª\8fÕ\93Ë\82µ\82½\82Ì\82Å\88Ú\93®\82ð\92â\8e~\82µ\83t\83\89\83O\82ð\83Z\83b\83g\82·\82é
- fy = true;
- collideDirection |= (dy > 0 ? 4 : 8);
- }
- if(!fx){
- ex += dx;
- }
- 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;
- }
- }
- }
- //\88Ú\93®
- obj.origin.x = ex;
- obj.origin.y = ey;
-
- //\88Ú\93®\82µ\82½\95û\8cü\82Æ\82Í\8bt\95û\8cü\82É\90Ú\90G\82µ\82Ä\82¢\82é\82©\92²\82×\82é
- dx = (dx > 0 ? -1 : 1);
- if(!fx && this.collideJudge(obj, ex + dx, ey, gotItems)){
- collideDirection |= (dx > 0 ? 1 : 2);
- }
- if(fx){
- dx = -1;
- if(!fx && this.collideJudge(obj, ex + dx, ey, gotItems)){
- collideDirection |= (dx > 0 ? 1 : 2);
- }
- }
-
- dy = (dy > 0 ? -1 : 1);
- if(!fy && this.collideJudge(obj, ex, ey + dy, gotItems)){
- collideDirection |= (dy > 0 ? 4 : 8);
- }
- if(fy){
- dy = -1;
- if(!fy && this.collideJudge(obj, ex, ey + dy, gotItems)){
- collideDirection |= (dy > 0 ? 4 : 8);
- }
- }
-
- for(var i in gotItems){
- var item = gotItems[i];
- if(item.itemAttacked){
- //\83A\83C\83e\83\80\82É\91Î\82µ\82Ä\8eæ\93¾\82³\82ê\82½\82±\82Æ\82ð\92Ê\92m\82·\82é\81B(\8eæ\93¾\82µ\82½\83I\83u\83W\83F\83N\83g\82Ì\83C\83\93\83X\83^\83\93\83X\82¨\82æ\82Ñ\8dÀ\95W\81j
- item.itemAttacked(obj, ex, ey);
- }
- }
-
- return collideDirection;
- },
eachOwnStageObject: function(f){
//\8e©\95ª\8e©\90g\82ª\8f\8a\97L\82·\82é\83I\83u\83W\83F\83N\83g\82·\82×\82Ä\82É\91Î\82µ\82Ä\8aÖ\90\94f\82ð\93K\97p\82·\82é
for(var sp in this.stageObjectList){
this.hysteresis = this.movingFriction/ 60;
// \8c»\8dÝ\82±\82Ì\83I\83u\83W\83F\83N\83g\82ª\90Ý\92u\82µ\82Ä\82¢\82é\82©\82ð\8am\94F\82·\82é\82É\82Í ( (instance) .collideFlag & 4) != 0 \82Æ\82·\82é
// \8fd\97Í\82ª\82È\82\82È\82Á\82½\82ç\82±\82Ì\95û\96@\82Å\82Í\90Ú\92n\82ð\8c\9f\8fo\82Å\82«\82È\82\82È\82é\82ª\82»\82ê\82Í
- this.collideFlag = 0;
+ //this.collideFlag = 0;
// \82±\82Ì\95¨\91Ì\82É\93\82\8fd\97Í(\95¨\91Ì\95Ê\82É\82»\82ê\82¼\82ê\8ew\92è\89Â\81A\83}\83C\83i\83X\92l\8ew\92è\89Â)
this.gravity = 800;
//\93\96\82½\82è\94»\92è\82Ì\83}\81[\83W\83\93\82Ì\8ew\92è
- this.collisionMarginTop = 2;
- this.collisionMarginLeft = 6;
- this.collisionMarginRight = 6;
- this.collisionMarginBottom = 2;
+ //this.collisionMarginTop = 2;
+ //this.collisionMarginLeft = 6;
+ //this.collisionMarginRight = 6;
+ //this.collisionMarginBottom = 2;
//\92i\8d·\82â\8dâ\82ð\8fæ\82è\89z\82¦\82ç\82ê\82é\83\8c\83x\83\8b 0\82¾\82Æ\8dâ\82ð\91S\82\8fã\82ê\82È\82¢
this.caterpillar = 2.5;
+ this.isItemCollector = false;
}.extend(StageObject, {
className: "MovableStageObjectClass",
this.movingSpeed.y += this.gravity / this.ownerStage.manager.tickPerSecond;
//\89^\93®\8f\88\97\9d (collideFlag\82Í\8fÕ\93Ë\82µ\82½\8dÛ\81A\82»\82Ì\95û\8cü(\95¡\90\94\89Â)\82ð\8e¦\82·\83t\83\89\83O\82Å\82 \82é\81BOperatedCharacterClass\82Å\83W\83\83\83\93\83v\94\93®\8e\9e\82Ì\90Ú\92n\8am\94F\82È\82Ç\82É\8eg\82í\82ê\82é)
- this.collideFlag = this.moveTo(
+ this.moveTo(
this.origin.x + (this.movingSpeed.x / this.ownerStage.manager.tickPerSecond),
this.origin.y + (this.movingSpeed.y / this.ownerStage.manager.tickPerSecond)
);
//\8fÕ\93Ë\8e\9e\82Ì\89^\93®\83G\83l\83\8b\83M\81[\8fÁ\96Å\90Ý\92è
- if((this.collideFlag & 1) != 0 && this.movingSpeed.x > 0) this.movingSpeed.x = 0; //\89E\95û\8cü\82É\8fÕ\93Ë
- if((this.collideFlag & 2) != 0 && this.movingSpeed.x < 0) this.movingSpeed.x = 0; //\8d¶\95û\8cü\82É\8fÕ\93Ë
- if((this.collideFlag & 4) != 0 && this.movingSpeed.y > 0) this.movingSpeed.y = 0; //\89º\95û\8cü\82É\8fÕ\93Ë
- if((this.collideFlag & 8) != 0 && this.movingSpeed.y < 0) this.movingSpeed.y = 0; //\8fã\95û\8cü\82É\8fÕ\93Ë
+ //if((this.collidingDirection & CollideRight) != 0 && this.movingSpeed.x > 0) this.movingSpeed.x = 0; //\89E\95û\8cü\82É\8fÕ\93Ë
+ //if((this.collidingDirection & CollideLeft) != 0 && this.movingSpeed.x < 0) this.movingSpeed.x = 0; //\8d¶\95û\8cü\82É\8fÕ\93Ë
+ if((this.collidingDirection & CollideBottom) != 0 && this.movingSpeed.y > 0) this.movingSpeed.y = 0; //\89º\95û\8cü\82É\8fÕ\93Ë
+ if((this.collidingDirection & CollideTop) != 0 && this.movingSpeed.y < 0) this.movingSpeed.y = 0; //\8fã\95û\8cü\82É\8fÕ\93Ë
},
- moveTo : function(x, y) {
- //\93\96\82½\82è\94»\92è\82Ì\8eÀ\91\95
- return this.ownerStage.moveTo(this, x, y);
+ canMoveTo: function(x, y){
+ //\82·\82×\82Ä\82Ì\83I\83u\83W\83F\83N\83g\82É\91Î\82µ\82Ä(x, y)\82É\82 \82é\82Æ\82«\82Ì\8e©\95ª\82Ì\8fÕ\93Ë\8fó\91Ô\82ð\92²\82×\82é\81B
+ var retv = false;
+ for(var sp in this.ownerStage.stageObjectList){
+ for(var i = 0; i < this.ownerStage.stageObjectList[sp].length; i++){
+ var f = this.ownerStage.stageObjectList[sp][i];
+ if(f !== this){
+ //\8e©\95ª\82Å\82È\82¢
+ if(f.isOverlappedWithLocatedObject(this, 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(this.isItemCollector){
+ //\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);
+ }
+ */
+
+ } else{
+ //\8fÕ\93Ë\82µ\82½
+ retv = true;
+ break;
+ }
+ }
+ }
+ }
+ if(retv){
+ break;
+ }
+ }
+
+ return retv;
},
- isCollided : function(obj, x, y)
- {
- //MovableStageObject\82ª(x, y)\82Ì\82Æ\82«\91\8a\8eè\82Ìobj\82Æ\8fÕ\93Ë\82·\82é\82©\94»\92è
- if(obj.judgeCollideRange){
- return obj.judgeCollideRange(x + this.collisionMarginLeft, y + this.collisionMarginTop, x + this.size.x - this.collisionMarginRight, y + this.size.y - this.collisionMarginBottom, this);
+ moveTo : function(x, y) {
+ //\8c»\8dÝ\82Ì\8dÀ\95W\82©\82ç(x,y)\82É\8cü\82¯\82Ä\81A\88Ú\93®\82Å\82«\82é\82¾\82¯\88Ú\93®\82·\82é\81B
+ //\8fÕ\93Ë\95û\8cü\83t\83\89\83O\82à\90Ý\92è\82·\82é\81B
+ var sx = this.origin.x, sy = this.origin.y;
+ var lx = x - sx
+ var ly = y - sy;
+ //\88Ú\93®\8b\97\97£\82ð\82Ç\82¿\82ç\82©\88ê\8e²\82Å\82Í\82©\82é
+ var ct = Math.max(Math.abs(lx), Math.abs(ly));
+ //\82»\82ê\82ð\8aî\8f\80\82É\82µ\82½\88ê\92P\88Ê\93\96\82½\82è\82Ì\88Ú\93®\97Ê
+ var dx = lx / ct;
+ var dy = ly / ct;
+ //\88Ú\93®\82µ\82È\82¢\8e²\82ª\82 \82é\82©\82Ç\82¤\82©\81i\8d\82\91¬\89»\81H\81j
+ var fx = (dx == 0);
+ var fy = (dy == 0);
+ //\8eÀ\8dÛ\82É\88Ú\93®\82·\82é\90æ\82Ì\8dÀ\95W
+ var ex = sx;
+ var ey = sy;
+ //\8eæ\93¾\82µ\82½\83A\83C\83e\83\80\82Ì\83\8a\83X\83g
+ //var gotItems = [];
+ var c = Math.abs(this.caterpillar * dx);
+ if(!(fx && fy)){
+ for(var i = 0; i < ct; i++){
+ if(!fx && this.canMoveTo(ex + dx, ey)){
+ //caterpillar\82Ì\8d\82\82³\82ð\91«\82µ\82Ä\88Ú\93®\82Å\82«\82é\82©\8e\8e\82µ\82Ä\82Ý\82é
+ if(c != 0 && this.canMoveTo(ex + dx, ey - c)){
+ //\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);
+ } else{
+ //\8d\82\82³\82ð\95Ï\82¦\82ê\82Î\88Ú\93®\82Å\82«\82é\82Ì\82Å\8d\82\82³\82ð\95Ï\82¦\82Ä\8cp\91±\82·\82é
+ ey -= c;
+ }
+ }
+ if(!fy && this.canMoveTo(ex, ey + dy)){
+ //y\8e²\82ª\8fÕ\93Ë\82µ\82½\82Ì\82Å\88Ú\93®\82ð\92â\8e~\82µ\83t\83\89\83O\82ð\83Z\83b\83g\82·\82é
+ fy = true;
+ //collideDirection |= (dy > 0 ? 4 : 8);
+ }
+ if(!fx){
+ ex += dx;
+ }
+ 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;
+ }
+ }
}
- return false;
- }
+ //\88Ú\93®
+ this.origin.x = ex;
+ this.origin.y = ey;
+
+ //\8fÕ\93Ë\95û\8cü\94»\92è
+ this.checkCollidingDirection();
+
+ /*
+ for(var i in gotItems){
+ var item = gotItems[i];
+ if(item.itemAttacked){
+ //\83A\83C\83e\83\80\82É\91Î\82µ\82Ä\8eæ\93¾\82³\82ê\82½\82±\82Æ\82ð\92Ê\92m\82·\82é\81B(\8eæ\93¾\82µ\82½\83I\83u\83W\83F\83N\83g\82Ì\83C\83\93\83X\83^\83\93\83X\82¨\82æ\82Ñ\8dÀ\95W\81j
+ item.itemAttacked(obj, ex, ey);
+ }
+ }
+ */
+ return;
+ },
});
//\92Ê\8fí\83W\83\83\83\93\83v\82·\82é\82Æ\82«\82É\8cÄ\82Î\82ê\82é\81B\83W\83\83\83\93\83v\83L\81[\82ð\89\9f\82µ\82Ä\82¢\82é\8aÔ\82Í\82¸\82Á\82Æ\8cÄ\82Î\82ê\82é
//\83W\83\83\83\93\83v\83L\81[\82ð\89\9f\82µ\82Ä\82¢\82é\8e\9e\8aÔ\82Ì\92·\82³\82É\89\9e\82¶\82Ä\83W\83\83\83\93\83v\82Ì\8d\82\82³\82ª\95Ï\89»\82·\82é\81B
jump : function(){
- if(this.collideFlag & CollideBottom){
+ if(this.collidingDirection & CollideBottom){
//\83W\83\83\83\93\83v\82Ì\8f\89\8aú\89»
this.jumpEnd = OperatedCharacterClass.prototype.jumpEnd;
this.jumpPower_tickCount = this.jumpPower_tickCountBase;
var colLH = args[1], colRH = args[2];
- this.collisionLeftHeight = colLH; //\8d¶\8fã\82©\82ç\95Ó\82è\94»\92è\97Ì\88æ\82Ü\82Å\82Ì\8d\82 \82³
+ this.collisionLeftHeight = colLH; //\8d¶\8fã\82©\82ç\95Ó\82è\94»\92è\97Ì\88æ\82Ü\82Å\82Ì\8d\82\82³
this.collisionRightHeight = colRH; //\89E\8fã\82©\82ç\95Ó\82è\94»\92è\97Ì\88æ\82Ü\82Å\82Ì\8d\82\82³
//\83f\83o\83b\83O\8fî\95ñ\82ð\89æ\96Ê\82É\95\\8e¦
this.y2 = 0;
}.extend(BlockClass, {
- judgeCollideRange: function(x1, y1, x2, y2){
- //isPhantom\82É\8aÖ\8cW\82È\82\81A\8fÕ\93Ë\94Í\88Í\82ª\8fd\82È\82é\82©\82Ç\82¤\82©\82ð\92²\82×\82é\81B
+ isOverlappedWith: function(x1, y1, x2, y2){
// 1 - - +
// | |
// | |
// + - - 2
+ //\83I\83u\83W\83F\83N\83g\96{\91Ì\95\94\95ª\82É\8fd\82È\82é\82©\82Ç\82¤\82©\82ð\92²\82×\82é
+ //\82±\82Ì\8aÖ\90\94\82ªfalse\82ð\95Ô\82µ\82½\8e\9e\82Ì\88ø\90\94\82Ì\94Í\88Í\82Ö\82Í\83I\83u\83W\83F\83N\83g\82ª\88Ú\93®\82Å\82«\82é\81B
+ //true\82©\82ÂisPhantom==false\82Ì\8e\9e\82Í\8fÕ\93Ë\82·\82é\81B
+
//\83f\83o\83b\83O\8fî\95ñ
this.x1 = x1;
this.y2 = y2;
this.x2 = x2;
- if(this.collisionLeftHeight != this.collisionRightHeight)
- {
+ if(this.collisionLeftHeight != this.collisionRightHeight){
return this.crossLineJudge(x1, y2 - 1, x2, y2 - 1,
this.origin.x, this.origin.y + this.collisionLeftHeight,
this.origin.x + this.size.x - 1, this.origin.y + this.collisionRightHeight);
- } else{
- //\83`\83F\83b\83N\82·\82é\93ñ\82Â\82Ì\90ü\95ª\82ª\95½\8ds\82¾\82Æ\93\96\82½\82è\94»\92è\82É\98R\82ê\82é\82Ì\82Å\81A\93\96\82½\82è\94»\92è\82ª\90\85\95½\82È\8fê\8d\87\82Í\95Ê\82Ì\8e®\82ð\97\98\97p\82·\82é\81B
- return x2 >= this.origin.x &&
- x1 < this.origin.x + this.size.x - 1 &&
- y2 >= this.origin.y + this.collisionLeftHeight &&
- y1 < this.origin.y + this.size.y - 1;
}
+ //\83`\83F\83b\83N\82·\82é\93ñ\82Â\82Ì\90ü\95ª\82ª\95½\8ds\82¾\82Æ\93\96\82½\82è\94»\92è\82É\98R\82ê\82é\82Ì\82Å\81A\93\96\82½\82è\94»\92è\82ª\90\85\95½\82È\8fê\8d\87\82Í\91¼\82Ì\8e®\82ð\97\98\97p\82·\82é\81B
+ if(this.collisionLeftHeight >= this.size.y){
+ return false;
+ }
+ return (x2 > (this.origin.x + this.collisionMargin.left)) &&
+ (x1 <= (this.origin.x + this.size.x - this.collisionMargin.right)) &&
+ (y2 > (this.origin.y + this.collisionMargin.top + this.collisionLeftHeight)) &&
+ (y1 <= (this.origin.y + this.size.y - this.collisionMargin.bottom));
},
-
//\8dÀ\95W p1,p2 \82ð\8c\8b\82Ô\90ü\95ª\82Æ\8dÀ\95W q1,q2 \82ð\8c\8b\82Ô\90ü\95ª\82ª\8cð\8d·\82µ\82Ä\82¢\82é\82©\82ð\92²\82×\82é
//\82½\82¾\82µ\81A\90ü\95ª\82ª\8fd\82È\82Á\82Ä\82¢\82é\8fê\8d\87(3\93_,4\93_\82ª\88ê\92¼\90ü\8fã\82É\82 \82é)\81A\81u\8cð\8d·\82µ\82Ä\82¢\82é\81v\81A\82Æ\94»\92è\82µ\82Ü\82·\81B
crossLineJudge: function(p1x, p1y, p2x, p2y, q1x, q1y, q2x, q2y){
}
},
});
+//\82±\82Ì\83N\83\89\83X\82Ì\83C\83\93\83X\83^\83\93\83X\82Ìtick\82ð\8cÄ\82Ñ\8fo\82³\82È\82¢\82æ\82¤\82É\90Ý\92è\81i\8d\82\91¬\89»\81j
SlopeBlockClass.tick = function(){return false;};
this.opacity = 1.0; // \93§\96¾\93x\81@(\93§\96¾) 0.0 \81` 1.0 (\95s\93§\96¾)
this.ownerUID = 0;
this.objectID = 0;
- //\8eÀ\91Ì\82ð\8e\9d\82½\82È\82¢\81A\82Â\82Ü\82è\8fÕ\93Ë\94»\92è\82ª\95K\97v\82È\82¢\8fê\8d\87\82Ítrue.
- this.isPhantom = false;
-
- //0\88È\8aO\82Ì\8fê\8d\87\81A\83l\83b\83g\83\8f\81[\83N\93¯\8aú\8e\9e\82É\83A\83C\83e\83\80\82Í\91S\91Ì\82Å\82½\82¾\88ê\82Â\82¾\82¯!!(\83l\83b\83g\83\8f\81[\83N\93¯\8aú\96³\8cø\82È\82ç\96³\8e\8b\82³\82ê\82é)
- this.extObjectId = 0;
-
// PCDSL\82È\82Ç\82©\82ç\97\98\97p\82Å\82«\82éID
this.id = "";
+ //0\88È\8aO\82Ì\8fê\8d\87\81A\83l\83b\83g\83\8f\81[\83N\93¯\8aú\8e\9e\82É\83A\83C\83e\83\80\82Í\91S\91Ì\82Å\82½\82¾\88ê\82Â\82¾\82¯!!(\83l\83b\83g\83\8f\81[\83N\93¯\8aú\96³\8cø\82È\82ç\96³\8e\8b\82³\82ê\82é)
+ this.extObjectId = 0;
+ this.isPhantom = false;
+ this.collidingDirectionCheckEnabled = false;
//\93\96\82½\82è\94»\92è\82Ì\83}\81[\83W\83\93\82Ì\8ew\92è
- this.collisionMarginTop = 0;
- this.collisionMarginLeft = 0;
- this.collisionMarginRight = 0;
- this.collisionMarginBottom = 0;
+ this.collisionMargin = new OffsetBox(0, 0, 0, 0);
+ this.collidingRange = 4;
+ //\8fÕ\93Ë\95û\8cü\83t\83\89\83O\82Í\81A\88Ú\93®\82·\82é\83I\83u\83W\83F\83N\83g\82È\82ç\88Ú\93®\8e\9e\82É\81A\82»\82ê\88È\8aO\82Ì\83I\83u\83W\83F\83N\83g\82ÅcollidingDirectionCheckEnabled==true\82Ì\82à\82Ì\82Í\81A\83X\83e\81[\83W\91¤\82Å\92è\8aú\93I\82É\83`\83F\83b\83N\82ð\82©\82¯\82Ä\90Ý\92è\82µ\82Ü\82·\81B
+ this.collidingDirection = 0;
}
StageObject.prototype = {
className:"StageObject",
//\8fÕ\93Ë\83}\83b\83v\82É\95`\89æ
this.ownerStage.collisionMapContext.save();
this.ownerStage.collisionMapContext.beginPath();
- this.ownerStage.collisionMapContext.moveTo(x + this.collisionMarginLeft, y + this.collisionMarginTop);
- this.ownerStage.collisionMapContext.lineTo(x + this.collisionMarginLeft, y + this.size.y - this.collisionMarginBottom);
- this.ownerStage.collisionMapContext.lineTo(x + this.size.x - this.collisionMarginRight, y + this.size.y - this.collisionMarginBottom);
- this.ownerStage.collisionMapContext.lineTo(x + this.size.x - this.collisionMarginRight, y + this.collisionMarginTop);
+ this.ownerStage.collisionMapContext.moveTo(x + this.collisionMargin.left, y + this.collisionMargin.top);
+ this.ownerStage.collisionMapContext.lineTo(x + this.collisionMargin.left, y + this.size.y - this.collisionMargin.bottom);
+ this.ownerStage.collisionMapContext.lineTo(x + this.size.x - this.collisionMargin.right, y + this.size.y - this.collisionMargin.bottom);
+ this.ownerStage.collisionMapContext.lineTo(x + this.size.x - this.collisionMargin.right, y + this.collisionMargin.top);
this.ownerStage.collisionMapContext.closePath();
this.ownerStage.collisionMapContext.stroke();
this.ownerStage.collisionMapContext.restore();
},
- isCollided : function(obj, x, y)
- {
- //\8e©\95ª\82ª(x, y)\82Ì\82Æ\82«\81A\91\8a\8eèobj\82Æ\8fÕ\93Ë\82·\82é\82©\94»\92è
- if(!this.isPhantom && obj.judgeCollideRange){
- return obj.judgeCollideRange(x + this.collisionMarginLeft,
- y + this.collisionMarginTop,
- x + this.size.x - 1 - this.collisionMarginRight,
- y + this.size.y - 1 - this.collisionMarginBottom, this);
- }
- return false;
- },
- //\83u\83\8d\83b\83N\82Ì\93\96\82½\82è\94»\92è\97Ì\88æ\82ð\95Ï\8dX\82·\82é\82½\82ß\82É\82Í\82±\82Ì\8aÖ\90\94\82ð\83I\81[\83o\81[\83\89\83C\83h\82·\82é
- //\88ø\90\94\82É\82Í\81A\93\96\82½\82è\82ð\8am\82©\82ß\82é\97v\91f\82Ì\93\96\82½\82è\94»\92è\97Ì\88æ\82Ì 1:\8d¶\8fã\8b÷ 2: \89E\89º\8b÷\82Ì\8dÀ\95W\82ð\8ew\92è
- //isCollided\82©\82ç\8cÄ\82Î\82ê\82é
- // 1 - - +
- // | |
- // | |
- // + - - 2
- judgeCollideRange: function(x1, y1, x2, y2, obj){
- //isPhantom\82É\8aÖ\8cW\82È\82\81A\8fÕ\93Ë\94Í\88Í\82ª\8fd\82È\82é\82©\82Ç\82¤\82©\82ð\92²\82×\82é\81B\97×\90Ú\82µ\82Ä\82¢\82é\8fê\8d\87\82à\90Ú\90G\82µ\82Ä\82¢\82é\82Æ\94»\92è\82·\82é\81B
- return x2 + 1 >= this.origin.x + this.collisionMarginLeft &&
- x1 - 1 <= this.origin.x + this.size.x - this.collisionMarginRight &&
- y2 + 1 >= this.origin.y + this.collisionMarginTop &&
- y1 - 1 <= this.origin.y + this.size.y - this.collisionMarginBottom;
- },
- judgeCollideRange_getDirection: function(x1, y1, x2, y2){
- //\8fÕ\93Ë\82·\82é\82±\82Æ\82ª\94»\96¾\82µ\82Ä\82¢\82é\8fó\8bµ\89º\82Å\82Ì\8fÕ\93Ë\83t\83\89\83O\82ð\8eæ\93¾\82·\82é
- var retv = 0;
- if(x1 <= this.origin.x){
- retv |= CollideLeft;
- }
- if(y2 >= this.origin.y + this.size.y - 1){
- retv |= CollideBottom;
- }
- if(y1 <= this.origin.y){
- retv |= CollideTop;
- }
- if(x2 >= this.origin.x + this.size.x - 1){
- retv |= CollideRight;
- }
- return retv;
- },
bindAttribute: function(attr)
{
//\8dX\90V\83f\81[\83^\82ð\8f\80\94õ\82·\82é\82Æ\82«\82É\8cÄ\82Î\82ê\82é
this.size.y = this.attribute.sY;
}
},
+ // 1 - - +
+ // | |
+ // | |
+ // + - - 2
+ isOverlappedWith: function(x1, y1, x2, y2){
+ //\83I\83u\83W\83F\83N\83g\96{\91Ì\95\94\95ª\82É\8fd\82È\82é\82©\82Ç\82¤\82©\82ð\92²\82×\82é
+ //\82±\82Ì\8aÖ\90\94\82ªfalse\82ð\95Ô\82µ\82½\8e\9e\82Ì\88ø\90\94\82Ì\94Í\88Í\82Ö\82Í\83I\83u\83W\83F\83N\83g\82ª\88Ú\93®\82Å\82«\82é\81B
+ //true\82©\82ÂisPhantom==false\82Ì\8e\9e\82Í\8fÕ\93Ë\82·\82é\81B
+ return (x2 > (this.origin.x + this.collisionMargin.left)) &&
+ (x1 <= (this.origin.x + this.size.x - this.collisionMargin.right)) &&
+ (y2 > (this.origin.y + this.collisionMargin.top)) &&
+ (y1 <= (this.origin.y + this.size.y - this.collisionMargin.bottom));
+ },
+ isOverlappedWithLocatedObject: function(obj, x, y){
+ //(x, y)\82Éobj\82ª\82 \82é\82Æ\82«\82Ì\83I\83u\83W\83F\83N\83g\96{\91Ì\94Í\88Í\82É\81A\8e©\95ª\82Ì\83I\83u\83W\83F\83N\83g\96{\91Ì\95\94\95ª\82É\8fd\82È\82é\82©\82Ç\82¤\82©\82ð\92²\82×\82é
+ //\82±\82Ì\8aÖ\90\94\82ªfalse\82ð\95Ô\82µ\82½\8e\9e\82Ì\88ø\90\94\82Ì\94Í\88Í\82Ö\82Í\83I\83u\83W\83F\83N\83g\82ª\88Ú\93®\82Å\82«\82é\81B
+ return this.isOverlappedWith(x, y, x + obj.size.x - 1, y + obj.size.y - 1);
+ },
+ // + - - +
+ // | |
+ // + - 0 - - + - +
+ // | | | |
+ // | | | |
+ // + - + - - 1 - +
+ // | |
+ // + - - +
+ checkCollidingDirection: function(){
+ //\8fÕ\93Ë\95û\8cü\82ð\92²\82×\82é\81B
+ this.collidingDirection = 0;
+ for(var sp in this.ownerStage.stageObjectList){
+ for(var i = 0; i < this.ownerStage.stageObjectList[sp].length; i++){
+ var obj = this.ownerStage.stageObjectList[sp][i];
+ // CollisonBody
+ var cbx0 = this.origin.x + this.collisionMargin.left;
+ var cby0 = this.origin.y + this.collisionMargin.top;
+ var cbx1 = this.origin.x + this.size.x - 1 - this.collisionMargin.right;
+ var cby1 = this.origin.y + this.size.y - 1 - this.collisionMargin.bottom;
+ // CollisionFrame\94Í\88Í\93à\82©\8am\94F
+ if(obj !== this && !obj.isPhantom && obj.isOverlappedWith(
+ cbx0 - this.collidingRange,
+ cby0 - this.collidingRange,
+ cbx1 + this.collidingRange,
+ cby1 + this.collidingRange)){
+ //\8fÕ\93Ë\82Ì\89Â\94\\90«\82ª\82 \82é\82Ì\82Å\8am\94F
+ if(obj.isOverlappedWith(cbx0, cby0, cbx1, cby1)){
+ //body
+ this.collidingDirection |= CollideBody;
+ }
+ if(obj.isOverlappedWith(cbx0, cby0 - this.collidingRange, cbx1, cby0 - 1)){
+ //top
+ this.collidingDirection |= CollideTop;
+ }
+ if(obj.isOverlappedWith(cbx0, cby1 + 1, cbx1, cby1 + this.collidingRange)){
+ //bottom
+ this.collidingDirection |= CollideBottom;
+ }
+ if(obj.isOverlappedWith(cbx0 - this.collidingRange, cby0, cbx0 - 1, cby1)){
+ //left
+ this.collidingDirection |= CollideLeft;
+ }
+ if(obj.isOverlappedWith(cbx1 + 1, cby0, cbx1 + this.collidingRange, cby1)){
+ //right
+ this.collidingDirection |= CollideRight;
+ }
+ }
+ }
+ }
+ return;
+ },
};
// stageName == nullだとステージを開始しない。指定する時は.jsおよびパスを省く
//
+var CollideBody = 16;
var CollideTop = 8;
var CollideBottom = 4;
var CollideLeft = 2;
}
-function OffsetBox(top, down, left, right){
+function OffsetBox(top, bottom, left, right){
this.top = top;
- this.down = down;
+ this.bottom = bottom;
this.left = left;
this.right = right;
}