Last active
April 18, 2022 04:41
-
-
Save Badestrand/b63474f5d1194c7132a7c264a843cba3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Enemy { | |
tick(deltaTime) { | |
... | |
const thisAabb = new THREE.Box3().setFromObject(this.mesh) | |
for (const projectile of allProjectiles) { | |
const projectileAabb = new THREE.Box3().setFromObject(projectile.mesh) | |
if (thisAabb.intersectsBox(projectileAabb)) { | |
spawnParticles(projectile.mesh.position.clone(), 5, Colors.brownDark, 1) | |
projectile.remove() | |
this.hitpoints -= projectile.damage | |
} | |
} | |
if (this.hitpoints <= 0) { | |
this.explode() | |
} | |
} | |
explode() { | |
spawnParticles(this.mesh.position.clone(), 15, Colors.red, 3) | |
sceneManager.remove(this) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment