//\96{\97\88\82Í\82±\82±\82É\93\96\82½\82è\94»\92è\8f\88\97\9d\82ð\93ü\82ê\82é
var sx = obj.origin.x, sy = obj.origin.y;
var lx = x - sx, ly = y - sy;
+ var rx = x, ry = y;
if(lx == 0 && ly == 0) return;
var dx, dy, ct;
+ var collideDirection = 0; //\89º\88Ê4bit : \8fã \89º \8d¶ \89E
ct = Math.max(Math.abs(lx), Math.abs(ly));
dx = lx / ct; dy = ly / ct;
- for(var i = 1; i <= ct; i++)
+ var fx = dx == 0, fy = dy == 0;
+ for(var i = 0; i < ct && !(fx && fy); i++)
{
//\89¼\82É\82¨\82¢\82Ä\82Ý\82é\8dÀ\95W
- var ex = sx + dx * i, ey = sy + dy * i;
+ var ex = fx ? rx : sx + dx * i, ey = fy ? ry : sy + dy * i;
- if(this.eachStageObject(function(f){
- if(!f.isPhantom && f != obj)
+ this.eachStageObject(function(f){
+ if(!f.isPhantom && f !== obj)
{
- if(obj.isCollided(f, ex, ey))
+ if(!fx && obj.isCollided(f, ex + dx, ey))
{
- /*if(obj.isCollided(f, ex, ey - dy))
- {
- obj.movingSpeedX = 0;
- }
- if(obj.isCollided(f, ex - dx, ey))
- {
- obj.movingSpeedY = 0;
- }*/
- obj.origin.x = ex - dx;
- obj.origin.y = ey - dy;
- return false;
+ rx = ex;
+ fx = true;
+ collideDirection |= (dx > 0 ? 1 : 2);
+ console.log(0);
}
+
+ if(!fy && obj.isCollided(f, ex, ey + dy))
+ {
+ ry = ey;
+ fy = true;
+ collideDirection |= (dy > 0 ? 4 : 8);
+ }
+ if(fx && fy) return false;
}
return true;
- }) == false) return;
+ });
}
- obj.origin.x = x;
- obj.origin.y = y;
+ obj.origin.x = rx;
+ obj.origin.y = ry;
}
};
}
//\8fd\97Í
- this.movingSpeed.y += 160 / this.stage.manager.tickPerSecond;
+ this.movingSpeed.y += 300 / this.stage.manager.tickPerSecond;
//\89^\93®\8f\88\97\9d
- this.moveTo(
+ var col = this.moveTo(
this.origin.x + (this.movingSpeed.x / this.stage.manager.tickPerSecond),
this.origin.y + (this.movingSpeed.y / this.stage.manager.tickPerSecond)
);
+ //\8fÕ\93Ë\8e\9e\82Ì\89^\93®\83G\83l\83\8b\83M\81[\8fÁ\96Å\90Ý\92è
+ if(col & 1 != 0 && this.movingSpeed.x > 0) this.movingSpeed.x = 0;
+ if(col & 2 != 0 && this.movingSpeed.x < 0) this.movingSpeed.x = 0;
+ if(col & 4 != 0 && this.movingSpeed.y > 0) this.movingSpeed.y = 0;
+ if(col & 8 != 0 && this.movingSpeed.y < 0) this.movingSpeed.y = 0;
},
moveTo : function(x, y) {
//\93\96\82½\82è\94»\92è\82Ì\8eÀ\91\95
//MovableStageObject\82ª(x, y)\82Ì\82Æ\82«\91\8a\8eè\82Ìobj\82Æ\8fÕ\93Ë\82·\82é\82©\94»\92è
if(obj instanceof BlockClass)
{
- return x < obj.origin.x + 32 && x + 32>= obj.origin.x && y < obj.origin.y + 32 && y + 32 >= obj.origin.y;
+ var ox = obj.origin.x, oy = obj.origin.y;
+ return x + 32 >= ox && x <= ox + 32 && y + 32 >= oy && y <= oy + 32;
}
return false;
}
var OperatedCharacterClass = function(stage, images){
OperatedCharacterClass.base.apply(this, arguments);
-
+
+ this.moveSpeed = 400;
+ this.jumpSpeed = 500;
+
}.extend(CharacterClass, {
goLeft : function(){
- this.movingSpeed.x -= 200;
+ this.movingSpeed.x = -this.moveSpeed;
},
goRight : function(){
- this.movingSpeed.x += 200;
+ this.movingSpeed.x = this.moveSpeed;
},
jump : function(){
- this.movingSpeed.y -= 400;
+ this.movingSpeed.y = -this.jumpSpeed;
},
tick : function(){
OperatedCharacterClass.base.prototype.tick.apply(this);
this.runningStage.keyUp(event);
}
},
+ calculateFps: function(){
+ if(this.oldTickCount)
+ {
+ drawText(this.debugContext, "FPS " + (this.tickCount - this.oldTickCount), 0, 120);
+ }
+ this.oldTickCount = this.tickCount;
+ setTimeout(this.calculateFps, 1000);
+ },
timerTick: function(){
//****timerTick****
this.tickCount++;
stage.runStage();
//runningStageに登録することで、イベントの通知が開始され、GameStageは実行状態に入る。
this.runningStage = stage;
+ this.calculateFps();
},
stopStage: function(){
//****現在実行中のステージを終了する****
},
};
-
+var oldTickCount = 0;
+(calculateFps = function(){
+
+
+ setTimeout(calculateFps, 1000);
+})();
//
with(stgObjects) {
var tbl = [
- [_,_,_,_],
- [a,_,_,a],
- [a,a,a,a]
+ [],
+ [],
+ [],
+ [],
+ [],
+ [],
+ [],
+ [],
+ [],
+ [],
+ [],
+ [],
+ [],
+ [],
+ [a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a],
];
}
var main = new MainCharacterClass(stage, ["kuma1.png","kuma2.png","kuma3.png"]);
main.origin.x = 50;
-main.origin.y = 50;
+main.origin.y = 250;
stage.operatingCharacter = main;
stage.addStageObject(main);
stage;