Skip to content

Commit

Permalink
Merge branch 'nighthawkcoders:main' into VeErA
Browse files Browse the repository at this point in the history
  • Loading branch information
VeeraKalakota authored Feb 17, 2025
2 parents 251ee66 + 8a10fb7 commit 2fead5d
Show file tree
Hide file tree
Showing 18 changed files with 111 additions and 119 deletions.
4 changes: 4 additions & 0 deletions assets/js/platformer/BossFight.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export class BossFight extends Character {
isDead: false // New state for checking if Titan is dead
};

this.dead = false;

// Laser-related properties
this.immune = 0;
this.debounce = 0;
Expand All @@ -56,6 +58,8 @@ export class BossFight extends Character {
// Method to handle Titan's death state (makes the Titan disappear)
handleDeath() {
if (this.currentHp <= 0 && !this.state.isDead) {
this.dead = true;
console.log("this.dead set to" + this.dead);
this.state.isDead = true; // Set the Titan as dead
GameEnv.invincible = true; // Make invincible
this.canvas.style.display = "none"; // Hide the Titan's canvas (makes it disappear)
Expand Down
54 changes: 54 additions & 0 deletions assets/js/platformer/Flag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import GameEnv from './GameEnv.js';
import Coin from './Coin.js';

export class Flag extends Coin {
constructor(canvas, image, data, xPercentage, yPercentage) {
super(canvas, image, data, xPercentage, yPercentage);
this.x = xPercentage * GameEnv.innerWidth;
this.y = yPercentage * GameEnv.bottom;
this.size();
this.id = this.initiateId()
this.scaleSize = data?.scaleSize || 80;
}
draw() {
this.ctx.drawImage(this.image, 0, 0, this.canvas.width, this.canvas.height);
}
size() {
if (this.id) {
if (GameEnv.hasFlag.includes(this.id)) {
this.hide()
}
}
const scaledHeight = GameEnv.innerHeight * (this.scaleSize / 832);
const scaledWidth = scaledHeight * this.aspect_ratio;
const coinX = this.coinX;
const coinY = (GameEnv.bottom - scaledHeight) * this.coinY;

// Set variables used in Display and Collision algorithms
this.bottom = coinY;
this.collisionHeight = scaledHeight;
this.collisionWidth = scaledWidth;

this.canvas.width = scaledWidth;
this.canvas.height = scaledHeight;
this.canvas.style.width = `${scaledWidth}px`;
this.canvas.style.height = `${scaledHeight}px`;
this.canvas.style.position = 'absolute';
this.canvas.style.left = `${coinX}px`;
this.canvas.style.top = `${coinY}px`;
}
collisionAction() {
// check player collision
if (this.collisionData.touchPoints.other.id === "player") {
if (this.id) {
GameEnv.hasFlag.push(this.id)
}
this.destroy();

GameEnv.playSound("coin");


}
}
}
export default Flag;
3 changes: 2 additions & 1 deletion assets/js/platformer/GameEnv.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class GameEnv {
* @property {boolean} spellUsed - Checks whether the wand has been used by the player
*/
static userID = "Guest";
static userID = "guest";
static player = null;
static levels = [];
static currentLevel = null;
Expand Down Expand Up @@ -105,6 +105,7 @@ export class GameEnv {

static spellUsed = false

static hasFlag = []

// Make the constructor throws an error, or effectively make it a private constructor.
constructor() {
Expand Down
4 changes: 2 additions & 2 deletions assets/js/platformer/GameSetterBossFight.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Background from './Background.js'
import BackgroundTransitions from './BackgroundTransitions.js';
import Platform from './Platform.js';
import JumpPlatform2 from './PlatformJump2.js';
//import JumpPlatform2 from './PlatformJump2.js';
import BlockPlatform from './BlockPlatform.js';
import Coin from './Coin.js';
import skibidiTitan from './SkibidiTitan.js';
Expand Down Expand Up @@ -502,7 +502,7 @@ const assets = {
{ name: 'shard', id: 'coin', class: Shard, data: assets.obstacles.coin, xPercentage: 0.5, yPercentage: 0.5 },
{ name: 'shard', id: 'coin', class: Shard, data: assets.obstacles.coin, xPercentage: 0.5, yPercentage: 0.5 },
{ name: 'laser', id: 'Laser', class: Laser, data: assets.obstacles.laser, xPercentage: 0.75, yPercentage: 0.5 },
{ name: 'skibidiTitan', id: 'skibidiTitan', class: BossFight, data: assets.enemies.skibidiTitan, xPercentage: 0.35, yPercentage: 0.5, minPosition: 0.5 },
{ name: 'titan', id: 'skibidiTitan', class: BossFight, data: assets.enemies.skibidiTitan, xPercentage: 0.35, yPercentage: 0.5, minPosition: 0.5 },
{ name: 'escaper', id: 'player', class: PlayerBossFight, data: assets.players.escaper },
{ name: 'tolietfinish', id: 'finishline', class: FinishLine, data: assets.obstacles.toiletfinish, xPercentage: 0.85, yPercentage: 0.77 },
{ name: 'complete3', id: 'background', class: BackgroundTransitions, data: assets.backgrounds.complete3 },
Expand Down
27 changes: 13 additions & 14 deletions assets/js/platformer/GameSetterGreece.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Lava from './Lava.js';
import Dragon from './FlyingDragon.js';
import FlyingIsland from './PlatformFlyingIsland.js';
import Coin from './Coin.js';
import Flag from './Flag.js';


// Define the GameSetup object literal
Expand Down Expand Up @@ -58,22 +59,22 @@ const assets = {
},
players: {
knight: {
src: "/images/platformer/sprites/scout_sprite.png",
width: 63.25,
height: 66.66,
scaleSize: 80,
speedRatio: 1,
src: "/images/platformer/sprites/knightGreece.png",
width: 133,
height: 136,
scaleSize: 70,
speedRatio: 0.70,
idle: {
left: { row: 1, frames: 2 },
right: { row: 2, frames: 2 },
left: { row: 1, frames: 0 },
right: { row: 3, frames: 0 },
},
walk: {
left: { row: 1, frames: 2 },
right: { row: 2, frames: 2 },
left: { row: 1, frames: 8 },
right: { row: 3, frames: 8 },
},
run: {
left: { row: 1, frames: 2 },
right: { row: 2, frames: 2},
left: { row: 1, frames: 8 },
right: { row: 3, frames: 8},
},
jump: {
left: { row: 1, frames: 2 },
Expand Down Expand Up @@ -160,7 +161,6 @@ const assets = {
{ name: 'dragon', id: 'dragon', class: Dragon, data: assets.enemies.dragon, xPercentage: 0.5, minPosition: 0.05 },
{ name: 'knight', id: 'player', class: PlayerGreece, data: assets.players.knight },
{ name: 'flyingIsland', id: 'flyingIsland', class: FlyingIsland, data: assets.platforms.island, xPercentage: 0.82, yPercentage: 0.55 },
{ name: 'flag', id: 'finishline', class: FinishLine, data: assets.obstacles.flag, xPercentage: 0.875, yPercentage: 0.275 },
{ name: 'hillsEnd', id: 'background', class: BackgroundTransitions, data: assets.transitions.hillsEnd },
{ name: 'lava', id: 'lava', class: Lava, data: assets.platforms.lava, xPercentage: 0, yPercentage: 1 },
{ name: 'coin', id: 'coin', class: Coin, data: assets.obstacles.coin, xPercentage: 0.1, yPercentage: 0.9 },//0.4, 0.9 might be a lower value for testing
Expand All @@ -169,8 +169,7 @@ const assets = {
{ name: 'sandstone', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.sandstone, xPercentage: 0.25, yPercentage: 0.65 },
{ name: 'sandstone', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.sandstone, xPercentage: 0.15, yPercentage: 0.5 },
{ name: 'sandstone', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.sandstone, xPercentage: 0.09, yPercentage: 0.4 },
{ name: 'flyingIsland', id: 'flyingIsland', class: FlyingIsland, data: assets.platforms.island, xPercentage: 0.001, yPercentage: 0.3 },
{ name: 'flag', id: 'finishline', class: FinishLine, data: assets.obstacles.flag, xPercentage: 0.09, yPercentage: 0.08 },
{ name: 'flag', id: 'flag', class: Flag, data: assets.obstacles.flag, xPercentage: 0.09, yPercentage: 0.23 },



Expand Down
25 changes: 13 additions & 12 deletions assets/js/platformer/GameSetterSkibidi.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Background from './Background.js'
import BackgroundTransitions from './BackgroundTransitions.js';
import Platform from './Platform.js';
import JumpPlatform2 from './PlatformJump2.js';
//import JumpPlatform2 from './PlatformJump2.js';
import BlockPlatform from './BlockPlatform.js';
import Coin from './Coin.js';
import skibidiTitan from './SkibidiTitan.js';
Expand Down Expand Up @@ -105,7 +105,7 @@ const assets = {
island: { src: "/images/platformer/platforms/island.png" },
block: { src: "/images/platformer/platforms/brick_block.png" }, //MAY need 3 new variables: sizeRatio, widthRatio, and heightRatio


/*
itemBlock2: { //power-up
src: "/images/platformer/sprites/jumppowerup.png", //spritesheet
sizeRatio: 0.000000001,
Expand All @@ -118,6 +118,7 @@ const assets = {
hitbox: { widthPercentage: 0, heightPercentage: 0 }
},
*/
},
backgrounds: {
boss: { src: "/images/platformer/backgrounds/BossBackground.png", parallaxSpeed: 0.4, moveOnKeyAction: true },
Expand Down Expand Up @@ -178,18 +179,18 @@ const assets = {
hitbox: { widthPercentage: 0.3, heightPercentage: 0.8 }
},
escaper: {
src: "/images/platformer/sprites/merged_sprite_sheet.png",
width: 81,
height: 83,
scaleSize: 85,
speedRatio: 0.7,
animationSpeed: 6, // How fast it goes through displaying each frame in specified row below:
src: "/images/platformer/sprites/skibidiMan.png",
width: 54,
height: 60,
scaleSize: 110,
speedRatio: 0.9,
animationSpeed: 5.5, // How fast it goes through displaying each frame in specified row below:
idle: {row: 0, frames: 4 }, // idle animation
walk: { row: 1, frames: 6 }, // walking animation
run: { row: 2, frames: 6 }, // running animation
run: { row: 2, frames: 6}, // running animation
jump: {row: 4, frames: 6 }, // jumping animation
attack: {row: 4, frames: 6 },
hitbox: { widthPercentage: 0.3, heightPercentage: 0.8 }
attack: {row: 3, frames: 5 },
hitbox: { widthPercentage: 0.3, heightPercentage: 0.9, offsetx: 0, offsety: 10 }

},
whitemario: {
Expand Down Expand Up @@ -510,7 +511,7 @@ const assets = {
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.sand, xPercentage: 0.7, yPercentage: 0.84 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.sand, xPercentage: 0.3, yPercentage: 0.4 },
///{ name: 'coin', id: 'coin', class: Coin, data: assets.obstacles.vbucks, xPercentage: 0.475, yPercentage: 0.5 },
{ name: 'itemBlock2', id: 'jumpPlatform', class: JumpPlatform2, data: assets.platforms.itemBlock2, xPercentage: 0.56, yPercentage: 0.8 }, //item block is a platform
// { name: 'itemBlock2', id: 'jumpPlatform', class: JumpPlatform2, data: assets.platforms.itemBlock2, xPercentage: 0.56, yPercentage: 0.8 }, //item block is a platform
//{ name: 'itemBlock2', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.itemBlock2, xPercentage: 0.56, yPercentage: 0.8 }, //item block is a platform
{ name: 'coin', id: 'coin', class: Coin, data: assets.obstacles.coin, xPercentage: 0.35, yPercentage: 0.85 },
{ name: 'coin', id: 'coin', class: Coin, data: assets.obstacles.coin, xPercentage: 0.3, yPercentage: 0.34 },
Expand Down
2 changes: 0 additions & 2 deletions assets/js/platformer/GameSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import GameSetterHills from './GameSetterHills.js';
import GameSetterGreece from './GameSetterGreece.js';
import GameSetterQuidditch from './GameSetterQuidditch.js';
import GameSetterWinter from './GameSetterWinter.js';
import GameSetterBoss from './GameSetterBoss.js';
import GameSetterSkibidi from './GameSetterSkibidi.js';
import GameSetterBossFight from './GameSetterBossFight.js'
import GameSetterEnd from './GameSetterEnd.js';
Expand Down Expand Up @@ -231,7 +230,6 @@ const GameSetup = {
GameLevelSetup(GameSetterQuidditch, this.path, this.playerOffScreenCallBack);
GameLevelSetup(GameSetterWinter, this.path, this.playerOffScreenCallBack);
GameLevelSetup(GameSetterSkibidi, this.path, this.playerOffScreenCallBack);
GameLevelSetup(GameSetterBoss, this.path, this.playerOffScreenCallBack);
GameLevelSetup(GameSetterBossFight, this.path, this.playerOffScreenCallBack);
// End Game
GameLevelSetup(GameSetterEnd, this.path, this.gameOverCallBack, true);
Expand Down
73 changes: 0 additions & 73 deletions assets/js/platformer/PlatformJump2.js

This file was deleted.

6 changes: 5 additions & 1 deletion assets/js/platformer/PlayerBossFight.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import GameEnv from './GameEnv.js';
import GameControl from './GameControl.js';
import PlayerBaseOneD from './PlayerBaseOneD.js'; ///With this you can change the direction of the sprite sheet with just the sprite rows.
import BossFight from './BossFight.js';

/**
* @class PlayerBossFight class
Expand Down Expand Up @@ -155,7 +156,8 @@ export class PlayerBossFight extends PlayerBaseOneD { /// Using PlayerBaseOneD a
case "finishline":
// 1. Caught in finishline
if (this.collisionData.touchPoints.this.onTopofOther || this.state.isFinishing ) {
if (GameEnv.titan && GameEnv.titan.state.isDead) {
const titan = GameEnv.gameObjects.find(obj => obj.name === 'titan');
if (titan.currentHp <= 0) {
// Position player in the center of the finishline
this.x = this.collisionData.newX;
this.state.movement = { up: false, down: false, left: false, right: false, falling: false};
Expand All @@ -168,6 +170,8 @@ export class PlayerBossFight extends PlayerBaseOneD { /// Using PlayerBaseOneD a
}
} else {
alert("Titan is not dead. You may not proceed");
this.setX(0);
this.state.animation = 'idle';
break;
}

Expand Down
4 changes: 4 additions & 0 deletions assets/js/platformer/PlayerGreece.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ export class PlayerGreece extends PlayerBase {
}
break;
case "finishline":
if(this.collisionData.touchPoints.this.other.id && GameEnv.hasFlag.length == 1){
const index = GameEnv.levels.findIndex(level => level.tag === "Quidditch");
GameControl.transitionToLevel(GameEnv.levels[index]);
}
console.log("finish line checks")
console.log(GameEnv.gameObjects)
var collectedCoin
Expand Down
2 changes: 1 addition & 1 deletion assets/js/platformer/PlayerSkibidi.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class PlayerSkibidi extends PlayerBaseOneD {
this.handleCollisionEvent("finishline");
this.handleCollisionEvent("SkibidiToilet");
this.handleCollisionEvent("laser");
this.handleCollisionEvent("powerup"); // created a new case where it detects for collision between player and power-up
//this.handleCollisionEvent("powerup"); // created a new case where it detects for collision between player and power-up
}

handleDeath() {
Expand Down
Loading

0 comments on commit 2fead5d

Please # to comment.