Particle = class {
constructor(x, y) {
this.a = [posx,posy,prx,pry] = [].concat(x,y,x,y);
}}constructor(x, y) {
this.posx=x;
this.posy=y;
this.prx=x;
this.pry=y;
}
Здравствуйте уважаемые.
Очень нужно чтоб как-можно больше в доме было построено с помощью молотка
Но меня постигло разочарование, возможно, правда, в себе))
видео как человек с горящими глазами пытается закрутить шурупы молотком
Никак не хочет работать в отличии от стандартного
видео как грустный человек закручивает шурупы отвёрткой
this.a = [posx,posy,prx,pry] = [].concat(x,y,x,y);
class Particle {
constructor(x, y) {
return Object.assign(this, {
posx: x,
posy: y,
prx: x,
pry: y
});
}
} const prots = function(){
Particle.prototype.move = function(dir) {
this.c = [].splice(prx, 2, posx, posy);
this.c.posx += Math.random() - 0.5 + dir.x;
this.c.posy += Math.random() - 0.5 + dir.y;
};
Particle.prototype.border = function() {
let b1 = this.posx - 491, b2 = this.posy - 361,
b3 = Math.pow( Math.abs(b1),2),
b4 = Math.pow( Math.abs(b2),2);
b3+b4>5000 || b3+b4<1500 ? (
this.prx = this.posx = this.posx - 2*b1,
this.pry = this.posy = this.posy - 2*b2) : null;
};
class DynamicProperties {
constructor(keys, values) {
keys.forEach((key, i) => {
this[ key ] = values[ i ];
})
}
}
class Particle extends DynamicProperties {
static primary_keys = ['a', 'b', 'c', 'd'];
constructor(x, y) {
super(Particle.primary_keys, [ x, y, x*2, 3 ]);
}
}
const my_test_particle = new Particle(1, 2);
// Particle {a: 1, b: 2, c: 2, d: 3}
class myClass {
constructor() {
this._arr = [];
}
get myArr() {
return this._arr;
}
set myArr(newArr) {
this._arr = newArr;
}
}
const myClasslItem = new myClass();
myClasslItem.myArr = [1,2,3,4]; // сработает сеттер
console.log(myClasslItem.myArr); // сработает геттер, выведется [1,2,3,4]