forked from nighthawkcoders/platformer3x
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
This week I was working on the skibidi titan positioning which utilizes the GameEnv.innerHeight/GameEnv.innerWidth. This allows the skibidi titan to be having the same position on any screen. I didn't have much time to work on this though because our branch got reverted and we were having trouble merging our branch which resulted in me being unable to edit the skibidi titan. Here is the updated code for the skibidi titan in SkibidiTitan.js.
super.update();
this.immune = 1;
var laser = document.getElementById("Laser")
if(debounce < 240 && debounce > -1){
laser.style.left = `-2000px`;
this.x = GameEnv.PlayerPosition.playerX - 0.14*GameEnv.innerWidth; //Changed this from - 200 to using the GameEnv.innerWidth
debounce += 1;
}
if(debounce < -120){
debounce += 1;
if(debounce == -235){GameEnv.playSound("laserCharge");}
this.canvas.style.filter = `invert(${debounce+240}%)`
}else if(debounce < 0 && debounce >= -120){
debounce += 1;
this.canvas.style.filter = `invert(0%)`
laser.style.left = `${this.x + 0.14*GameEnv.innerWidth}px`;
if(debounce == -115){GameEnv.playSound("laserSound");}
var plrPos = GameEnv.PlayerPosition.playerX
if (this.x >= plrPos - 250 && this.x <= plrPos - 150) {
//setTimeout(Plr.goombaCollision.bind(this), 50);
this.killBeam(GameEnv.player);
debounce = 0;
laser.style.left = `${this.x+0.14*GameEnv.innerWidth}px`; //Changed this from - 200 to using the GameEnv.innerWidth
}
}
if(debounce == 240){
debounce = -240;
}
//console.log((GameEnv.PlayerPosition.playerX - 200) + " " + this.x);
//Immunize Goomba & Texture It
if (GameEnv.difficulty === "hard") {
this.canvas.style.filter = "invert(100%)";
this.canvas.style.scale = 1.25;
this.immune = 1;
} else if (GameEnv.difficulty === "impossible") {
this.canvas.style.filter = 'brightness(1000%)';
this.immune = 1;
}
// Move the enemy
//this.x -= this.speed;
this.y = 0.25*GameEnv.innerHeight; //Fixed this too.
this.playerBottomCollision = false;Here is the code for resizing the laser in Laser.js
size() {
// Update canvas size
this.canvas.width = this.width*2;
this.canvas.height = this.height;
this.canvas.style.position = 'absolute';
this.canvas.style.left = `20px`;
this.canvas.style.top = `${GameEnv.innerHeight*0.25}px`; //This is the ratio that was added instead of a fixed number
}Next week, im planning to make the laser shoot down instead of randomly appearing, along with fixing the hitbox. If i have enough time, I will also add other projectiles the skibidi titan will shoot if the difficulty is set to a harder mode.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels