Skip to content

Commit

Permalink
Fixed some gliches and added more sound effects
Browse files Browse the repository at this point in the history
  • Loading branch information
Datamaverik committed Jun 19, 2024
1 parent ffb0664 commit 0efe3c5
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 23 deletions.
Binary file added sounds/AKMr.mp3
Binary file not shown.
Binary file added sounds/AWMr.mp3
Binary file not shown.
Binary file added sounds/DEagler.mp3
Binary file not shown.
Binary file added sounds/M4A1r.mp3
Binary file not shown.
Binary file added sounds/UZIr.mp3
Binary file not shown.
Binary file added sounds/gunChange.mp3
Binary file not shown.
1 change: 1 addition & 0 deletions src/Gun.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class Gun {
reload() {
if (this.isReloading || this.isFiring) return; // Check if already reloading
this.isReloading = true; // Set reloading flag
playSound(this.name+"r");
ammo.textContent = `Reloading....`;
// setting color of the indicator
if (this.ammo > 0) {
Expand Down
38 changes: 19 additions & 19 deletions src/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ player.switchSprite("IdleR");
// color: "gray",
// });
Hmeter.value = player.health / 100;
const platform = new Platform({
position: { x: canvas.width / 2 - 75, y: 250 },
width: 150,
});
// const platform = new Platform({
// position: { x: canvas.width / 2 - 75, y: 250 },
// width: 150,
// });
// creating guns
const M4A1 = new Gun({
ammo: 60,
Expand Down Expand Up @@ -210,13 +210,13 @@ sorroundings = [
cannonLeft,
cannonRight,
...blocks,
platform,
];

function changeGun(gun) {
if (currentGun.isFiring || currentGun.isReloading) return;

// update the current gun
playSound("gunChange");
currentGun = gun;
gunIcon.innerHTML = gunSvg[currentGun.name];
const factor = currentGun.magLimit / 100;
Expand Down Expand Up @@ -318,7 +318,7 @@ function animate() {
zombies[i].detectPlayerCollision(player);
}
player.zombies = zombies;
platform.draw();
// platform.draw();
theta = calculateAngle(player);
currentGun.draw();
cannonLeft.draw();
Expand Down Expand Up @@ -417,16 +417,16 @@ function animate() {
}

// platform collision left
if (
player.position.y + player.height <= platform.position.y &&
player.position.y + player.height + player.velocity.y >=
platform.position.y &&
player.position.x + player.width >= platform.position.x &&
player.position.x <= platform.position.x + platform.width
) {
player.velocity.y = 0;
player.grounded = true;
}
// if (
// player.position.y + player.height <= platform.position.y &&
// player.position.y + player.height + player.velocity.y >=
// platform.position.y &&
// player.position.x + player.width >= platform.position.x &&
// player.position.x <= platform.position.x + platform.width
// ) {
// player.velocity.y = 0;
// player.grounded = true;
// }

// adding fire effect if jetpack is active
updateParticles();
Expand Down Expand Up @@ -680,16 +680,16 @@ document.querySelectorAll(".powerUp").forEach((btn, i) => {
return;
}
player.score -= 1200;
Pvelocity = 5;
Pvelocity = 4;
speedDur += 15;
if (!speedPUTimeout) {
speedPUTimeout = setTimeout(() => {
Pvelocity = 3;
Pvelocity = 2;
}, speedDur * 1000);
} else {
clearTimeout(speedPUTimeout);
speedPUTimeout = setTimeout(() => {
Pvelocity = 3;
Pvelocity = 2;
}, speedDur * 1000);
}
usePowerUp();
Expand Down
14 changes: 10 additions & 4 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ let collisionDetected,
trapInd = 0,
scrollOffset = 0,
damageDur = 0,
Pvelocity = 3,
Pvelocity = 2,
zombieCount = 0,
totalZombies = 0,
zombies = [],
Expand Down Expand Up @@ -143,7 +143,7 @@ function spawnZombies(interval) {
collisionBlocks: blocks,
zombies,
health: 300,
speed: 0.65,
speed: 0.55,
height: 75,
width: 35,
damage: 15,
Expand Down Expand Up @@ -315,7 +315,7 @@ function spawnZombies(interval) {
collisionBlocks: blocks,
zombies,
health: 210,
speed: 0.42,
speed: 0.38,
damage: 10,
attackFreq: 3000,
color: "red",
Expand Down Expand Up @@ -533,13 +533,19 @@ const gunSvg = {

const sounds = {
AWM: new Audio("./sounds/AWM2.mp3"),
AWMr: new Audio("./sounds/AWMr.mp3"),
AKM: new Audio("./sounds/AKM.mp3"),
AKMr: new Audio("./sounds/AKMr.mp3"),
UZI: new Audio("./sounds/UZI_Single.mp3"),
UZIr: new Audio("./sounds/UZIr.mp3"),
DEagle: new Audio("./sounds/DEagle.mp3"),
DEagler: new Audio("./sounds/DEagler.mp3"),
M4A1: new Audio("./sounds/M4A1.mp3"),
M4A1r: new Audio("./sounds/M4A1r.mp3"),
Run: new Audio("./sounds/Run.mp3"),
Jump: new Audio("./sounds/Jump.mp3"),
Jump2: new Audio("./sounds/Jump2.mp3"),
Jump: new Audio("./sounds/Jump.mp3"),
gunChange: new Audio("./sounds/gunChange.mp3"),
Hurt: new Audio("./sounds/Hurt.mp3"),
Hurt2: new Audio("./sounds/Hurt2.mp3"),
LandMine: new Audio("./sounds/LandMine.mp3"),
Expand Down

0 comments on commit 0efe3c5

Please sign in to comment.