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 Collectible { | |
constructor(mesh, onApply) { | |
this.mesh = new THREE.Object3D() | |
const bubble = new THREE.Mesh( | |
new THREE.SphereGeometry(10, 100, 100), | |
new THREE.MeshPhongMaterial({ | |
color: COLOR_COLLECTIBLE_BUBBLE, | |
transparent: true, | |
opacity: .4, | |
flatShading: true, |
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 |
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 SimpleGun { | |
downtime() { | |
return 0.1 | |
} | |
damage() { | |
return 1 | |
} | |
shoot(direction) { |
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
const metalMaterial = new THREE.MeshStandardMaterial({ | |
color: 0x222222, | |
flatShading: true, | |
roughness: 0.5, | |
metalness: 1.0 | |
}) | |
class SimpleGun { | |
static createMesh() { | |
const BODY_RADIUS = 3 |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title></title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<style rel="stylesheet" type="text/less"> | |
* { | |
margin: 0; | |
padding: 0; |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title></title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<style rel="stylesheet" type="text/less"> | |
* { | |
margin: 0; | |
padding: 0; |