Skip to content

Commit

Permalink
Final Updates (Polish, Instanced Mesh, -comments)
Browse files Browse the repository at this point in the history
  • Loading branch information
AksharNana committed Oct 27, 2023
1 parent 0a08d97 commit c586297
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 48 deletions.
2 changes: 1 addition & 1 deletion levels/First-Year/First-Year.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class FirstLevel extends Game {
numTokensText.textContent = `${0}/${1}`;

// Add Post-Processing Effects
// this._PostProcessing();
this._PostProcessing();
}

_PostProcessing() {
Expand Down
10 changes: 1 addition & 9 deletions levels/Second-Year/Second-Year.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ class SecondYear extends Game {
this._AddSecondTokens();
}
_AddSecondTokens() {
console.log("Adding Second Token!");

/*source: https://sketchfab.com/3d-models/batman-arkham-asylum-harley-quinn-46b5868a4a8d4a2b9389221a039b24b2
author: EWTube0 (https://sketchfab.com/EWTube0) */
let loaderObj = new GLTFLoader();
loaderObj.load(
"../../../assets/models/tokens/batman/scene.gltf",
"../../assets/models/tokens/batman/scene.gltf",
(gltf) => {
let token = new Token();
token.object = gltf.scene;
Expand All @@ -43,12 +41,6 @@ class SecondYear extends Game {
this.setKeyPos(token);
this.totalKeys += 1;
numTokensText.textContent=`${0}/${2}`;
console.log(
"This is the second token position " +
token.object.position.x +
" " +
token.object.position.z
);
//token.object.position.set(this.player.position.x + 2, this.player.position.y, this.player.position.z );
token.sound = new THREE.PositionalAudio(this.AudioListener);
token.object.add(token.sound);
Expand Down
8 changes: 3 additions & 5 deletions levels/Third-Year/Third-Year.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,17 @@ class ThirdYear extends Game {
);

this._AddSecondTokens();
this._PostProcessing();
// this._PostProcessing();
this.nextLevel = "/~sjmsp/";
this.restartLevel = "/~sjmsp/levels/Third-Year/Third-Year.html";
}

_AddSecondTokens() {
console.log("Adding Second Token!");

/*source: https://sketchfab.com/3d-models/scary-acoustic-guitar-c7022e2914a34189ab11ce5c1240249e
author: yotam92 (https://sketchfab.com/yotam92) */
let loaderObj = new GLTFLoader();
loaderObj.load(
"../../../assets/models/tokens/guitar/scene.gltf",
"../../assets/models/tokens/guitar/scene.gltf",
(gltf) => {
let token = new Token();
token.object = gltf.scene;
Expand Down Expand Up @@ -68,7 +66,7 @@ author: yotam92 (https://sketchfab.com/yotam92) */
);
/*source: https://sketchfab.com/3d-models/graduation-86895e10baf54c46896823394766fb86
author: Cyberluna (https://sketchfab.com/cyberluna) */
loaderObj.load("../../../assets/models/tokens/grad/scene.gltf", (gltf) => {
loaderObj.load("../../assets/models/tokens/grad/scene.gltf", (gltf) => {
let token2 = new Token();
token2.object = gltf.scene;
token2.object.scale.set(0.1, 0.1, 0.1);
Expand Down
11 changes: 1 addition & 10 deletions utilities/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -1092,12 +1092,6 @@ class Game {
token.loaded = true;
this.onTokenLoaded(token);
this.setKeyPos(token);
console.log(
"This is the first token position " +
token.object.position.x +
" " +
token.object.position.z
);
token.sound = new THREE.PositionalAudio(this.AudioListener);
token.object.add(token.sound);

Expand Down Expand Up @@ -1127,7 +1121,6 @@ class Game {
author: EWTube0 (https://sketchfab.com/EWTube0)*/
let loaderObj = new GLTFLoader();
loaderObj.load("../../assets/models/characters/npc/scene.gltf", (gltf) => {
console.log("Spawning npc: " + this.npcId);
let t_npc = new NPC();
let result = t_npc.getNPC(this.npcId);
t_npc.mesh = gltf.scene;
Expand Down Expand Up @@ -1194,7 +1187,6 @@ author: EWTube0 (https://sketchfab.com/EWTube0)*/

hurt() {
this.currentHealth -= 1;
console.log(this.currentHealth);
if (this.currentHealth < 0 && this.playerLives != 0) {
if (this.playerLives == 3) {
Heart1.style.display = "none";
Expand Down Expand Up @@ -1352,7 +1344,6 @@ author: EWTube0 (https://sketchfab.com/EWTube0)*/
if (!this.npcDeathNoise.isPlaying) {
this.npcDeathNoise.play();
}
console.log(this.npcDeathFrames[i]);
this.enemy[i].translateY(0.5 * this.npcDeathFrames[i]);
this.npcDeathFrames[i]++;
} else {
Expand Down Expand Up @@ -1791,7 +1782,7 @@ author: EWTube0 (https://sketchfab.com/EWTube0)*/
this.visualise(this.maze); // Visualises the maze
this.exit(); // Adds the exit door
this.enter(); // Adds the entry door
// this.bounds(); // Adds invisible boundaries to the starting area
this.bounds(); // Adds invisible boundaries to the starting area
}

/**
Expand Down
26 changes: 4 additions & 22 deletions utilities/NPC.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,12 @@ class NPC {
enemyX = Math.round(enemyX/5) * 5;
enemyZ = Math.round(enemyZ/5) * 5;
mazeCopy[Math.floor(enemyZ / 5 + 10)][Math.floor(enemyX / 5 + 10)] = 2;
//console.log("Enemy z " + enemyZ);
//mazeCopy[10][10] = 3;


const playerPos = player.position.clone();
let playerX = 0;
let playerZ = 0;

// console.log(`z pos = ${playerPos.z}\nFloor = ${Math.floor(playerPos.z)}`);

if (
Math.abs(Math.floor(playerPos.x) - playerPos.x) <=
Math.abs(Math.ceil(playerPos.x) - playerPos.x)
Expand Down Expand Up @@ -130,16 +128,6 @@ class NPC {
let path = aStar.findPathAStar();

if (path.length > 1) {
//path.shift();
// console.log(
// "Enemy Z: " + (enemyZ / 5 + 10) + " Enemy X: " + (enemyX / 5 + 10)
// );
// console.log(
// "Player Z: " + (playerZ / 5 + 10) + " Player Z: " + (playerX / 5 + 10)
// );
// console.log("Current path place: " + path[0]);
// console.log("Next path place: " + path[1]);
console.log(path.length);
if(!this.dead){
if(path.length < 50 && path.length > 25){
this.humm.stop();
Expand All @@ -153,9 +141,6 @@ class NPC {
}
}
}
// if ((path[0][0] != (enemyZ / 5 + 10)) && ((path[0][1] != (enemyZ / 5 + 10)))){
// path.shift();
// }

enemyPath.clear();

Expand All @@ -164,22 +149,19 @@ class NPC {
new YUKA.Vector3(5 * (path[i][1] - 10), 1, 5 * (path[i][0] - 10))
);
}
// vehicle.position.copy(enemy.position);


vehicle.maxSpeed = 5;

mazeCopy[Math.floor(enemyZ / 5 + 10)][Math.floor(enemyX / 5 + 10)] = 0;
//enemy.position.copy(enemyPath.current());


const followPathBehavior = new YUKA.FollowPathBehavior(enemyPath, 0.1);
vehicle.steering.clear();
vehicle.steering.add(followPathBehavior);

const onPathBehavior = new YUKA.OnPathBehavior(enemyPath);
vehicle.steering.add(onPathBehavior);

// entityManager.clear();
// entityManager.add(vehicle);
}
}
}
Expand Down
1 change: 0 additions & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export default defineConfig({
rollupOptions: {
input: {
main: path.resolve(__dirname, 'index.html'),
intro: path.resolve(__dirname, 'intro.html'),
FirstYear: path.resolve(__dirname, 'levels/First-Year/First-Year.html'),
SecondYear: path.resolve(__dirname, 'levels/Second-Year/Second-Year.html'),
ThirdYear: path.resolve(__dirname, 'levels/Third-Year/Third-Year.html'),
Expand Down

0 comments on commit c586297

Please sign in to comment.