Skip to content

Commit

Permalink
no holding allowed for attack
Browse files Browse the repository at this point in the history
  • Loading branch information
aaryavlal committed Feb 27, 2025
1 parent 5de7174 commit 8697c0f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
10 changes: 6 additions & 4 deletions assets/js/platformer/GameSetterSkibidi.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,12 @@ const assets = {
},
escaper: {
src: "/images/platformer/sprites/skibidiMan.png",
width: 54,
height: 60,
width: 53,
height: 61,
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
idle: {row: 3, frames: 4 }, // idle animation
walk: { row: 1, frames: 6 }, // walking animation
run: { row: 2, frames: 6}, // running animation
jump: {row: 4, frames: 6 }, // jumping animation
Expand Down Expand Up @@ -509,7 +509,9 @@ const assets = {
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.sand, xPercentage: 0.6, yPercentage: 0.71 } ,
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.sand, xPercentage: 0.14, yPercentage: 0.84 },
{ 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: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.sand, xPercentage: 0.4, yPercentage: 0.4 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.sand, xPercentage: 0.36, yPercentage: 0.4 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.sand, xPercentage: 0.38, 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: BlockPlatform, data: assets.platforms.itemBlock2, xPercentage: 0.56, yPercentage: 0.8 }, //item block is a platform
Expand Down
28 changes: 20 additions & 8 deletions assets/js/platformer/PlayerSkibidi.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,28 @@ export class PlayerSkibidi extends PlayerBaseOneD {
GameEnv.playerAttack = false;
break;
case 'b':
this.state.animation = 'attack'; // Always trigger attack when b is pressed
GameEnv.playerAttack = true;
break;
default:
this.state.animation = 'idle';
GameEnv.playerAttack = false;
break;
}
// Trigger attack once per key press, no holding allowed
if (!this.state.isAttacking) { // Check if player isn't already attacking
this.state.animation = 'attack'; // Set the animation to attack
GameEnv.playerAttack = true; // Set player attack state to true
this.state.isAttacking = true; // Set the player as attacking

// Reset the attack state after the animation ends (set it to 500ms for now)
setTimeout(() => {
this.state.isAttacking = false;
GameEnv.playerAttack = false;
}, 500); // 500ms delay for one attack per key tap (adjust timing based on animation)
}
break;
default:
this.state.animation = 'idle';
GameEnv.playerAttack = false;
break;
}
}



/**
* @override
* gameloop: Handles additional Player reaction / state updates to the collision for game level
Expand Down
2 changes: 1 addition & 1 deletion assets/js/platformer/SkibidiTitan.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class skibidiTitan extends Character {

hpLoss() {
if (GameEnv.playerAttack && !this.state.isDead) {
this.currentHp -= 1;
this.currentHp -= 2.5;
}
}

Expand Down
Binary file added images/platformer/sprites/beta.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/platformer/sprites/luffy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8697c0f

Please # to comment.