Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
reset() {
const { notes, totalQuantizedSteps } = this.renderer.melodies[0];
const unit = this.renderer.width * 4 / totalQuantizedSteps;
const add = (this.id === 0) ? 1 : 1;
const yPos = (this.id === 0) ? this.renderer.height * 0.25 : this.renderer.height * 0.5;
Body.setPosition(this.body, { x: (notes[0].quantizedStartStep + add) * unit, y: yPos });
Body.setVelocity(this.body, { x: 0, y: 0 });
}
update(dt: number){
if (this.owner != null && this.action != "throw" && this.action != "break") {
if (this.owner.action == "hide") {
Body.setPosition(this.body, this.owner.body.position);
this.action = "idle";
}else{
Body.setPosition(this.body, Vector.add(this.owner.body.position, this.offset));
this.action = "hold";
}
}
if(this.action == "break"){
if(this.delayOnRemove <= 0){
this.destroy();
}else{
this.delayOnRemove -= dt;
}
}
if(this.action == "throw"){
update(dt: number){
if (this.owner != null && this.action != "throw" && this.action != "break") {
if (this.owner.action == "hide") {
Body.setPosition(this.body, this.owner.body.position);
this.action = "idle";
}else{
Body.setPosition(this.body, Vector.add(this.owner.body.position, this.offset));
this.action = "hold";
}
}
if(this.action == "break"){
if(this.delayOnRemove <= 0){
this.destroy();
}else{
this.delayOnRemove -= dt;
}
}
if(this.action == "throw"){
if (this.throwRecoverTime < this.delayOnThrowRecover){
this.throwRecoverTime += dt;
}else{