Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Main Project/assets/weathervane.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Main Project/boss.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Boss {
this.x = x;
this.y = y;
this.size = 150; // Boss size
this.currencyValue = 50; // Boss currency value
this.currencyValue = 100; // Boss currency value
this.attackCooldown = 0; // Cooldown for attacks
this.lastAttackTime = 0;
this.bossImage;
Expand Down
1 change: 1 addition & 0 deletions Main Project/bossFight.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<script src="projectile.js"></script>
<script src="boss.js"></script>
<script src="bossFight.js"></script>
<script src="windVane.js"></script>
</head>
<body>
<div id="health-bar-container">
Expand Down
27 changes: 16 additions & 11 deletions Main Project/bossFight.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let minions = [];
let inkProjectiles = [];
let tentacles = [];
let boss;

let windVane;
const selectedLevel = parseInt(localStorage.getItem("selectedLevel")) || 1;
const highestLevelBeat = parseInt(localStorage.getItem("highestLevelBeat")) || 0;

Expand All @@ -35,11 +35,11 @@ let projectileOffset = 0;
let enemyImage;
let bossImage;
let minionImage;

let projectileImage;
let windVaneImage;
let inkEffectDuration = 0;



function preload() {
player.playerImage = loadImage('./assets/shiplvl1Base.png');
player.sailImage = loadImage('./assets/shiplvl1FrontSail.png')
Expand All @@ -50,7 +50,8 @@ let projectileOffset = 0;
minionImage = loadImage('./assets/kraken.png');
tentacleImage = loadImage('./assets/tentacle.png');
backgroundMusic = loadSound('./music/PirateLoop.wav');

projectileImage = loadImage('./assets/cannon.png');
windVaneImage = loadImage('./assets/weathervane.png');
}

function loadMusic() {
Expand Down Expand Up @@ -78,7 +79,7 @@ function setup() {
const defeatMessage = document.getElementById('defeat-message');

// Initialize the boss with the new constructor
boss = new Boss(300, 300, 1, healthBarContainer, healthBar, defeatMessage); // Example position and health
boss = new Boss(300, 300, 20, healthBarContainer, healthBar, defeatMessage); // Example position and health
boss.bossImage = bossImage;

setInterval(() => {
Expand All @@ -98,6 +99,9 @@ function setup() {
}
}, 5000); // 5000 milliseconds = 5 seconds

//initialize wind vane
windVane = new WindVane();
windVane.img = windVaneImage;
// Draw and move minions

//camera to follow player
Expand Down Expand Up @@ -169,14 +173,14 @@ function draw() {
// enemyFrameCount = 0;
//}



controllerInput();



player.drawPlayer();
player.movePlayer();
player.movePlayer(windVane.windAngle);
player.checkCollisionEnemies(minions);
player.checkCollisionProjectiles(inkProjectiles);
player.drawRudderAndSails();
Expand Down Expand Up @@ -223,17 +227,17 @@ function draw() {
extraMove = player.getMovementOfPlayer();
extraXMove = extraMove[0];
extraYMove = extraMove[1];
let tmpProjectile1 = new Projectile(player.x, player.y, player.angle, -1, extraXMove, extraYMove);
let tmpProjectile1 = new Projectile(player.x, player.y, player.angle, -1, extraXMove, extraYMove, projectileImage);
projectiles.push(tmpProjectile1);
let tmpProjectile2 = new Projectile(player.x, player.y, player.angle, 1, extraXMove, extraYMove);
let tmpProjectile2 = new Projectile(player.x, player.y, player.angle, 1, extraXMove, extraYMove, projectileImage);
projectiles.push(tmpProjectile2);

projectileFrameCount = 0;
}

if (delozierMode) {
for (let i = 0; i < Math.PI * 2; i += Math.PI / 10) {
let tmpProjectile = new Projectile(player.x, player.y, i + projectileOffset, 1, 0, 0);
let tmpProjectile = new Projectile(player.x, player.y, i + projectileOffset, 1, 0, 0, projectileImage);
projectiles.push(tmpProjectile);
}
projectileOffset += Math.PI / 25;
Expand Down Expand Up @@ -290,7 +294,8 @@ function draw() {

console.log("Player currency: " + player.currency);


windVane.update();
windVane.show();
}
// Function to check collision between ink projectile and player
function checkCollision(ink, player) {
Expand Down
76 changes: 20 additions & 56 deletions Main Project/cortana.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ class Boss {
return tentacle;
} */

harpoonAttack(player, harpoonImage) {
harpoonAttack(player, harpoonImage, harpoonArray) {
if (this.isDead) return;
// Harpoon attack
if (!this.harpoon) {
this.harpoon = {

let harpoon = {
x: this.x,
y: this.y,
length: 300,
Expand All @@ -110,83 +110,47 @@ class Boss {
hasHit: false,
duration: 1000, // Harpoon duration in milliseconds
// Set up a timer to remove the tentacle after the specified duration
expireTimeout(){
setTimeout(() => {
this.expire();
}, this.duration)
},
expire() {
this.hasHit = false; // Reset hasHit flag
// Remove the tentacle from the tentacles array
tentacles = tentacles.filter(tentacle => tentacle !== this);
clearTimeout(this.expireTimeout); // Clear the timeout
},
draw: function() {
push();
translate(this.x, this.y); // Move origin to the harpoon's coordinates
rotate(this.angle); // Rotate by the harpoon's angle
imageMode(CENTER); // Set image mode to CENTER
image(harpoonImage, this.length / 2 + 30, -this.width / 2, this.length, this.width); // Draw the harpoon image
pop();
},
hitPlayer(player) {
if (!this.hasHit) {
// Calculate the end point of the tentacle
let endX = this.x + this.length * cos(this.angle);
let endY = this.y + this.length * sin(this.angle);

// Check if the player is within the tentacle's reach
let distance = dist(player.x, player.y, endX, endY);
if (distance < player.size / 2) {
player.takeDamage(1);
this.hasHit = true;
return true;
}
}
return false;
},
isExpired: function() {
return millis() - this.creationTime >= this.duration;
},
},
dragPlayer: function(player) {
// Apply a force to drag the player closer to the boss
let forceX = (this.x - player.x) * 0.25;
let forceY = (this.y - player.y) * 0.25;
player.x += forceX;
player.y += forceY;
},
resetHit: function() {
setInterval(() => {
this.hasHit = false;
}, 1000);
}

};
}
// Check for collision and drag the player if hit
/*if (this.harpoon.hitPlayer()) {
this.draw();
player.takeDamage(1);
this.harpoon.dragPlayer(player);
}*/
return this.harpoon;

harpoonArray.push(harpoon);
console.log("harpoon array size in function: " + harpoonArray.length);
}

attack(player, minionImage, tentacleImage, projectilesArray, projectileImage) {
attack(player, minionImage, tentacleImage, projectilesArray, projectileImage, harpoonArray) {
const currentTime = millis();
if (currentTime - this.lastAttackTime >= 5000) {
this.lastAttackTime = currentTime;
let attackType = Math.floor(Math.random() * 3);
//let attackType = 2;
switch (attackType) {
case 0:
console.log("Spawning minions");
return this.spawnMinions(minionImage);
case 1:
console.log("Shooting ink");
return this.shootInk(player, projectilesArray);
case 2:
console.log("Tentacle smash");
return this.harpoonAttack(player, tentacleImage);
console.log("minions assemble");
return this.spawnMinions(minionImage);
case 1:
this.shootInk(player, projectilesArray);
console.log("cannon attack");
break;
case 2:
this.harpoonAttack(player, tentacleImage, harpoonArray);
console.log("Harpoon array size in attack: " + harpoonArray.length);
break;

}

}
Expand Down
1 change: 1 addition & 0 deletions Main Project/cortanaFight.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<script src="projectile.js"></script>
<script src="cortana.js"></script>
<script src="cortanaFight.js"></script>
<script src="windVane.js"></script>
</head>
<body>
<div id="health-bar-container">
Expand Down
Loading