Allow dynamic giblet time

This commit is contained in:
Ketchetwahmeegwun T. Southall 2022-01-30 15:20:21 -08:00
parent f9d91adcaf
commit 12d317e4c8

View File

@ -5,13 +5,17 @@ import { WorldContext } from "./World"
export class GibletEntity extends Entity {
lifetime: number = 10000
elapsed: number = 0
constructor(ctor: string, dir: number, force: number) {
constructor(ctor: string, dir: number, force: number, life?: number) {
super(ctor)
let r = dir * (Math.PI/180)
this.velocity[0] = Math.cos(r) * force
this.velocity[1] = Math.sin(r) * force
if (life) {
this.lifetime = life + Math.random()*life
} else {
this.lifetime = 10000 + Math.random()*10000
}
}
update(delta: number, ctx?: WorldContext) {
super.update(delta)
this.elapsed += delta