Skip to content

Commit d19c179

Browse files
authored
Merge pull request #121 from Parallaxes/main
Can't leave until titan is dead
2 parents 558c63b + 2bda96e commit d19c179

File tree

4 files changed

+52
-31
lines changed

4 files changed

+52
-31
lines changed

assets/js/platformer/GameEnv.js

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export class GameEnv {
7878
static bottom;
7979
static prevBottom;
8080
static invincible = false;
81+
static visible = false;
8182
static goombaInvincible = false;
8283
static goombaBounce = false;
8384
static goombaBounce1 = false;

assets/js/platformer/GameSetterSkibidi.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,19 @@ const assets = {
104104
island: { src: "/images/platformer/platforms/island.png" },
105105
island: { src: "/images/platformer/platforms/island.png" },
106106
block: { src: "/images/platformer/platforms/brick_block.png" }, //MAY need 3 new variables: sizeRatio, widthRatio, and heightRatio
107+
108+
107109
itemBlock2: { //power-up
108110
src: "/images/platformer/sprites/jumppowerup.png", //spritesheet
109-
sizeRatio: 2.0,
111+
sizeRatio: 0.000000001,
110112
widthRatio: 1.0,
111113
heightRatio: 1.0,
112-
width: 205, // 205
113-
height: 246, // 246
114-
scaleSize: 1, // 1
114+
width: 0, // 205
115+
height: 0, // 246
116+
scaleSize: 0, // 1
115117
speedRatio: 0.7, // framerate, how fast it goes through between displaying each frame or animation
116-
hitbox: { widthPercentage: 0.4, heightPercentage: -0.2 }
118+
hitbox: { widthPercentage: 0, heightPercentage: 0 }
119+
117120
},
118121
},
119122
backgrounds: {
@@ -518,7 +521,7 @@ const assets = {
518521
{ name: 'SkibidiToilet', id: 'SkibidiToilet', class: SkibidiToilet, data: assets.enemies.skibidiToilet, xPercentage: 0.75, minPosition: 0.5 },
519522
{ name: 'escaper', id: 'player', class: PlayerSkibidi, data: assets.players.escaper },
520523
{ name: 'laser', id: 'Laser', class: Laser, data: assets.obstacles.laser, xPercentage: 0.75, yPercentage: 0.5 },
521-
{ name: 'tolietfinish', id: 'finishline', class: FinishLine, data: assets.obstacles.toiletfinish, xPercentage: 0.85, yPercentage: 0.77 },
524+
{ name: 'tolietfinish', id: 'finishline', class: FinishLine, data: assets.obstacles.toiletfinish, xPercentage: 0.85, yPercentage: 0.77, isVisible: false },
522525
{ name: 'complete3', id: 'background', class: BackgroundTransitions, data: assets.backgrounds.complete3 },
523526
];
524527

assets/js/platformer/PlayerSkibidi.js

+28-22
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,15 @@
11
import GameEnv from './GameEnv.js';
22
import GameControl from './GameControl.js';
3-
import PlayerBaseOneD from './PlayerBaseOneD.js'; ///With this you can change the direction of the sprite sheet with just the sprite rows.
3+
import PlayerBaseOneD from './PlayerBaseOneD.js';
4+
import SkibidiTitan from './SkibidiTitan.js'; // Import SkibidiTitan
45

5-
/**
6-
* @class PlayerSkibidi class
7-
* @description PlayerSkibidi.js key objective is to eent the user-controlled character in the game.
8-
*
9-
* The Player class extends the Character class, which in turn extends the GameObject class.
10-
* Animations and events are activated by key presses, collisions, and gravity.
11-
* WASD keys are used by user to control The Player object.
12-
*
13-
* @extends PlayerBase
14-
*/
15-
export class PlayerSkibidi extends PlayerBaseOneD { /// Using PlayerBaseOneD added the sprite mirror but deleted the sprite not showing the animations
16-
17-
/** GameObject instantiation: constructor for PlayerSkibidi object
18-
* @extends Character
19-
* @param {HTMLCanvasElement} canvas - The canvas element to draw the player on.
20-
* @param {HTMLImageElement} image - The image to draw the player with.
21-
* @param {Object} data - The data object containing the player's properties.
22-
*/
6+
export class PlayerSkibidi extends PlayerBaseOneD {
237
constructor(canvas, image, data) {
248
super(canvas, image, data);
259
this.invincible = true;
2610
this.timer = false;
2711
GameEnv.invincible = false; // Player is NOT invincible
2812

29-
3013
this.animationSpeed = data?.animationSpeed;
3114
this.counter = this.animationSpeed;
3215
// Goomba variables, deprecate?
@@ -62,7 +45,6 @@ export class PlayerSkibidi extends PlayerBaseOneD { /// Using PlayerBaseOneD add
6245

6346
console.log("New Y Position:", this.y);
6447
}
65-
6648

6749
updateFrameX(){
6850
if (this.frameX < this.maxFrame) {
@@ -90,9 +72,20 @@ export class PlayerSkibidi extends PlayerBaseOneD { /// Using PlayerBaseOneD add
9072
this.handleCollisionEvent("SkibidiToilet");
9173
this.handleCollisionEvent("laser");
9274
this.handleCollisionEvent("powerup"); // created a new case where it detects for collision between player and power-up
75+
}
76+
77+
handleDeath() {
78+
if (this.state.isDying) {
79+
this.canvas.style.transition = "transform 0.5s";
80+
this.canvas.style.transform = "rotate(-90deg) translate(-26px, 0%)";
81+
GameEnv.playSound("PlayerDeath");
82+
setTimeout(async () => {
83+
await GameControl.transitionToLevel(GameEnv.levels[GameEnv.levels.indexOf(GameEnv.currentLevel)]);
84+
}, 900);
85+
}
9386
}
9487

95-
handleKeyUp(event) {
88+
handleKeyUp(event) {
9689
const key = event.key;
9790
if (key in this.pressedKeys) {
9891
delete this.pressedKeys[key];
@@ -153,6 +146,15 @@ export class PlayerSkibidi extends PlayerBaseOneD { /// Using PlayerBaseOneD add
153146
// handles additional player reactions
154147
switch (this.state.collision) {
155148
case "finishline":
149+
const skibidiTitan = GameEnv.gameObjects.find(obj => obj.name === 'skibidiTitan');
150+
if (skibidiTitan.currentHp > 0) {
151+
alert("Kill the titan with B buddy, why do you think theres a health bar");
152+
this.setX(0)
153+
this.setY(700)
154+
this.state.animation = 'idle';
155+
break;
156+
}
157+
156158
// 1. Caught in finishline
157159
if (this.collisionData.touchPoints.this.onTopofOther || this.state.isFinishing ) {
158160
// Position player in the center of the finishline
@@ -175,6 +177,8 @@ export class PlayerSkibidi extends PlayerBaseOneD { /// Using PlayerBaseOneD add
175177
this.state.movement.right = true;
176178
}
177179
break;
180+
181+
178182
case "SkibidiToilet": // Note: Goomba.js and Player.js could be refactored
179183
// 1. Player jumps on goomba, interaction with Goomba.js
180184
if (this.collisionData.touchPoints.this.top && this.collisionData.touchPoints.other.bottom && this.state.isDying == false) {
@@ -227,6 +231,7 @@ export class PlayerSkibidi extends PlayerBaseOneD { /// Using PlayerBaseOneD add
227231

228232
}
229233
break;
234+
/*
230235
case "powerup":
231236
if (GameEnv.powerUpCollected) {
232237
console.log("Power-up collision detected! Changing difficulty...");
@@ -246,6 +251,7 @@ export class PlayerSkibidi extends PlayerBaseOneD { /// Using PlayerBaseOneD add
246251
GameEnv.update();
247252
console.log("Power Up",GameEnv.gameObjects[GameEnv.gameObjects.length - 1]);
248253
break;
254+
*/
249255
}
250256

251257
}

assets/js/platformer/SkibidiTitan.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import GameControl from './GameControl.js';
44
import Laser from './Laser.js';
55
import Enemy from './Enemy.js';
66
import TitanHealth from './TitanHealth.js';
7+
import GameSetterSkibidi from './GameSetterSkibidi.js';
8+
import BackgroundTransitions from './BackgroundTransitions.js';
79

810
export class skibidiTitan extends Character {
911
// Constructor sets up Character object
@@ -18,10 +20,10 @@ export class skibidiTitan extends Character {
1820
this.maxPosition = this.x + xPercentage * GameEnv.innerWidth;
1921

2022
// Health properties
21-
this.maxHp = 100; // Maximum health points
22-
this.currentHp = 100; // Current health points
23+
this.maxHp = 200; // Maximum health points
24+
this.currentHp = 200; // Current health points
2325
this.titanHealthBar = new TitanHealth(
24-
150, 10, // Width and height of the health bar
26+
160, 10, // Width and height of the health bar
2527
this.canvas.width, this.canvas.height, // Titan dimensions
2628
this.maxHp, this.currentHp, // Titan's max and current health
2729
this.x, this.y // Titan's position
@@ -51,10 +53,17 @@ export class skibidiTitan extends Character {
5153
// Method to handle Titan's death state (makes the Titan disappear)
5254
handleDeath() {
5355
if (this.currentHp <= 0 && !this.state.isDead) {
56+
this.titanHealthBar = null; // Remove the health bar
5457
this.state.isDead = true; // Set the Titan as dead
5558
GameEnv.invincible = true; // Make invincible
5659
this.canvas.style.display = "none"; // Hide the Titan's canvas (makes it disappear)
5760
GameEnv.playSound("goombaDeath"); // Play the death sound
61+
//tolietfinish.hitbox.widthPercentage = 0;
62+
//tolietfinish.hitbox.heightPercentage = 0;
63+
//} else {
64+
//tolietfinish.hitbox.widthPercentage = 0.5;
65+
//tolietfinish.hitbox.heightPercentage = 0.5;
66+
5867
}
5968
}
6069

@@ -108,6 +117,8 @@ export class skibidiTitan extends Character {
108117
);
109118
this.titanHealthBar.update();
110119

120+
121+
111122
// Laser-related logic
112123
this.immune = 1;
113124

0 commit comments

Comments
 (0)