initial commit
This commit is contained in:
commit
e8c3f9862a
193 files changed
+29795
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import { Vector2D } from './Vector2D.js';
|
||||
|
||||
export class GameObject {
|
||||
constructor(x = 0, y = 0) {
|
||||
this.pos = new Vector2D(x, y);
|
||||
this.velocity = new Vector2D(0, 0);
|
||||
this.width = 0;
|
||||
this.height = 0;
|
||||
}
|
||||
|
||||
update(dt = 1 / 60) {
|
||||
this.pos = this.velocity.mulS(dt).addV(this.pos);
|
||||
}
|
||||
|
||||
intersect(other) {
|
||||
return (
|
||||
Math.abs(this.pos.x - other.pos.x) * 2 < this.width + other.width &&
|
||||
Math.abs(this.pos.y - other.pos.y) * 2 < this.height + other.height
|
||||
);
|
||||
}
|
||||
|
||||
draw() {}
|
||||
|
||||
remove(container) {
|
||||
if (!container) return;
|
||||
const index = container.indexOf(this);
|
||||
if (index !== -1) container.splice(index, 1);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user