breakout/upgrade_drop.js

31 lines
508 B
JavaScript
Raw Normal View History

2023-09-07 16:46:56 -05:00
Object.assign(self, {
fallspeed: 150,
tag: "ball",
upgrade: function() {},
size: 12,
phys:1,
collider: circle2d.clone(),
color: Color.Rainbow.blue,
start() {
this.collider.radius = this.size;
this.collider.sensor = true;
},
draw() {
Shape.circle(this.pos,this.size,this.color);
},
collide(hit) {
if (!(hit.obj.from === 'paddle'))
return;
this.upgrade();
this.kill();
},
update(dt) {
this.pos = this.pos.add([0,-this.fallspeed*dt]);
},
});