Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/467.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 点数不正确_Javascript_Html_Css_Game Physics - Fatal编程技术网

Javascript 点数不正确

Javascript 点数不正确,javascript,html,css,game-physics,Javascript,Html,Css,Game Physics,我还有一个关于游戏创作的问题,我已经提出了 当我继续开发并尝试实现point counter时,我遇到了另一个问题 似乎有时点数是反的,而不是+1到+2甚至+3。 我怀疑代码部分expo+=1的位置不正确,因为它(可能)会被循环2次(或多次)而不是一次,但坦率地说,我不确定 代码可在以下位置找到: var级别=[ [“x”, “xx x”, “xxx x”, “xx!xx x牛”, “x!!!x x xx”, “xx!xx x x”, “x x x x x”, “x xx x”, “x x x

我还有一个关于游戏创作的问题,我已经提出了

当我继续开发并尝试实现point counter时,我遇到了另一个问题

似乎有时点数是反的,而不是+1到+2甚至+3。 我怀疑代码部分
expo+=1
的位置不正确,因为它(可能)会被循环2次(或多次)而不是一次,但坦率地说,我不确定

代码可在以下位置找到:

var级别=[
[“x”,
“xx x”,
“xxx x”,
“xx!xx x牛”,
“x!!!x x xx”,
“xx!xx x x”,
“x x x x x”,
“x xx x”,
“x x x”,
“x x x”,
“x x xx”,
“x x”,
“x@xxxxx o x”,
“XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX”,
“x x”,
“x!!!!!x”,
“x!!!!!x”,
“xxxxxxx”,
"                                      "],
];
var寿命=3;
var=0;
document.getElementById(“life”).innerHTML=(“Lives left:+life”);
document.getElementById(“expo”).innerHTML=(“点:”+expo);
函数向量(x,y){
这个.x=x;这个.y=y;
}
Vector.prototype.plus=函数(其他){
返回新向量(this.x+other.x,this.y+other.y);
};
Vector.prototype.times=函数(比例){
返回新向量(此.x*比例,此.y*比例);
};
//注意:使用大写词表示构造函数是值
变量actorchars={
“@”:玩家,
“o”:硬币,
“=”:熔岩,
“|”:熔岩,
“v”:熔岩,
熔岩
};
功能播放器(pos){
this.pos=pos.plus(新向量(0,-.5));
this.size=新向量(.5,1);
该速度=新矢量(0,0);
}
Player.prototype.type=“Player”;
功能(位置、通道){
this.pos=pos;
this.size=新向量(1,1);
如果(ch==“=”)
该速度=新矢量(2,0);
else if(ch=='|')
该速度=新矢量(0,2);
else if(ch=='v'){
this.speed=新向量(0,5);//新向量(0,3);
this.repeatPos=pos;
}else if(ch=='#'){
该速度=新矢量(0,10);
}
}
Lava.prototype.type=“Lava”
//Lava.prototype.type=“Lava”;
功能硬币(pos){
this.basePos=this.pos=pos;
this.size=新向量(.6、.6);
//回首
this.wobble=Math.random()*Math.PI*2;
}
Coin.prototype.type=“Coin”;
Level.prototype.isFinished=函数(){
返回this.status!==null&&this.finishDelay<0;
};
职能级别(计划){
this.width=平面[0]。长度;
this.height=plan.length;
this.grid=[];
this.actors=[];
对于(变量y=0;yright-margin)
this.wrap.scrollLeft=中心.x+边距-宽度;
如果(中心y<顶部+边距)
this.wrap.scrollTop=center.y-边距;
else if(中心y>底部-边距)
this.wrap.scrollTop=center.y+
else if (type == "coin") {
  this.actors = this.actors.filter(function(other) {
  return other != actor;
});
if (!this.actors.some(function(actor) {
  console.log("coin picked up")
  expo += 1;
  document.getElementById("expo").innerHTML = ("Points: " + expo);
  return actor.type == "coin";
})) {
  life += 1;
  document.getElementById("life").innerHTML = ("Lives left: " + life);
  this.status = "won";
  this.finishDelay = 1;
}
else if (type == "coin") {
  expo += 1;
  document.getElementById("expo").innerHTML = ("Points: " + expo);
  this.actors = this.actors.filter(function(other) {
  return other != actor;
});
if (!this.actors.some(function(actor) {
  console.log("coin picked up")
  return actor.type == "coin";
})) {
  life += 1;
  document.getElementById("life").innerHTML = ("Lives left: " + life);
  this.status = "won";
  this.finishDelay = 1;
}