Я анализировал этот фрагмент кода (новичок в javascript), который является частью простой игры с нестабильными птицами, но не могу понять, к чему относится эта функция this.x = width
.Что именно означает width
.
Некоторый контекст
function Pipe() {
this.spacing = 175;
this.top = random(height / 6, 3 / 4 * height);
this.bottom = height - (this.top + this.spacing);
this.x = width;
this.w = 80;
this.speed = 4 ;
this.highlight = false;
this.hits = function(bird) {
if (bird.y < this.top || bird.y > height - this.bottom) {
if (bird.x > this.x && bird.x < this.x + this.w) {
this.highlight = true;
return true;
}
}
this.highlight = false;
return false;
}
this.show = function() {
fill(255);
if (this.highlight) {
fill(255, 0, 0);
}
rect(this.x, 0, this.w, this.top);
rect(this.x, height-this.bottom, this.w, this.bottom);
}
this.update = function() {
this.x -= this.speed;
}
this.offscreen = function() {
if (this.x < -this.w) {
return true;
} else {
return false;
}
}
}
Буду очень признателен, если кто-нибудь сможет мне помочь с этим.