User prompt
in gard(), simplify the adjustments as they are symetrical. use an array for elements
User prompt
now in guard(), add adjustments for arms too
User prompt
now refactor the gard() function
User prompt
in guar(), use the deltas in the else block
Code edit (18 edits merged)
Please save this source code
User prompt
simplify guard() function bt defining local variables for the deltas (like handXDelta, handRDelta, forearmXDelta, ....)
Code edit (1 edits merged)
Please save this source code
User prompt
in guard() function, move the hands ,forearms and hands closer to the center of the torso then restore them when leaving guard state the system for guard & guard button: set & keep athlete in guard state when button is down, restore when button is up
User prompt
change the system for guard & guard button: keep athlete in guard state when button is down, restore when button is up
User prompt
in guard() funciton, move the hands ,forearms and hands closer to the center of the torso then restore them when button is released
User prompt
in guard() funciton, move the hands ,forearms and hands closer to the center of the torso
Code edit (19 edits merged)
Please save this source code
User prompt
implement the athlete guard action
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
use the Ring class in gameInitialize
User prompt
create a Class for the ring
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: player is undefined' in or related to this line: 'if ((player.leftHand.intersects(opponent.head) || player.rightHand.intersects(opponent.head)) && player.isPunching) {' Line Number: 293
Code edit (1 edits merged)
Please save this source code
User prompt
only flash on hit when an athlete is Punching
User prompt
restore self.isPunching
User prompt
update self.isPunching
User prompt
add a propoery isPunching to athlete class
===================================================================
--- original.js
+++ change.js
@@ -75,8 +75,11 @@
// Player movement speed
self.speed = 5;
// Punch function to handle punching action
self.punch = function (isLeft) {
+ if (self.isPunching) {
+ return;
+ }
var arm = isLeft ? self.leftArm : self.rightArm;
var forearm = isLeft ? self.leftForearm : self.rightForearm;
var hand = isLeft ? self.leftHand : self.rightHand;
// Punch animation logic
@@ -86,9 +89,10 @@
arm.y -= punchDistance;
forearm.height += punchDistance;
forearm.y -= punchDistance * 1.5; // Move forearm up for punch
forearm.rotation *= 0.5; //= -Math.PI * 0.1; //-Math.PI * 0.2
- hand.x += 5; // Move hand up for punch
+ hand.x += isLeft ? 15 : -15;
+ ; // Move hand up for punch
hand.y -= punchDistance * 2; // Move hand up for punch
// Add head movement to mimic boxer's dodge
self.head.x += isLeft ? 15 : -15; // Move head opposite to punching arm
self.head.width *= 0.95; // Simulate head tilt by narrowing the width
@@ -100,32 +104,46 @@
arm.y += punchDistance;
forearm.height -= punchDistance;
forearm.y += punchDistance * 1.5; // Move forearm up for punch
forearm.rotation *= 2; //-Math.PI * 0.2
- hand.x -= 5; // Move hand up for punch
+ hand.x += isLeft ? -15 : 15;
+ ; // Move hand up for punch
hand.y += punchDistance * 2; // Move hand up for punch
self.head.x += isLeft ? -15 : 15; // Move head opposite to punching arm
self.head.width /= 0.95; // Reset head width to simulate head tilt back
self.head.height /= 1.05; // Reset head width to simulate head tilt back
self.head.rotation += isLeft ? -0.1 : 0.1; // Simulate head tilt by narrowing the width
self.isPunching = false;
- }, 200);
+ }, 300);
};
// Guard function to handle guarding action
self.guard = function (setGard) {
- self.isGuarding = true;
if (setGard) {
+ self.isGuarding = true;
// Move hands and forearms closer to the center of the torso for guarding
- self.leftHand.x += 30; // Move left hand closer to the center
- self.rightHand.x -= 30; // Move right hand closer to the center
- self.leftForearm.x += 15; // Move left forearm closer to the center
- self.rightForearm.x -= 15; // Move right forearm closer to the center
+ // Define deltas for moving hands and forearms closer to the center
+ var handXDelta = 60;
+ var handRDelta = 0.2;
+ var forearmXDelta = 30;
+ var forearmRDelta = 0.2;
+ self.leftHand.x += handXDelta; // Move left hand closer to the center
+ self.leftHand.rotation += handRDelta;
+ self.rightHand.x -= handXDelta; // Move right hand closer to the center
+ self.rightHand.rotation -= handRDelta;
+ self.leftForearm.x += forearmXDelta; // Move left forearm closer to the center
+ self.leftForearm.rotation += forearmRDelta;
+ self.rightForearm.x -= forearmXDelta; // Move right forearm closer to the center
+ self.rightForearm.rotation -= forearmRDelta;
} else {
// Restore hands and forearms position after leaving guard state
- self.leftHand.x -= 30; // Move left hand back to original position
- self.rightHand.x += 30; // Move right hand back to original position
- self.leftForearm.x -= 15; // Move left forearm back to original position
- self.rightForearm.x += 15; // Move right forearm back to original position
+ self.leftHand.x -= 60; // Move left hand back to original position
+ self.leftHand.rotation -= 0.2;
+ self.rightHand.x += 60; // Move right hand back to original position
+ self.rightHand.rotation += 0.2;
+ self.leftForearm.x -= 30; // Move left forearm back to original position
+ self.leftForearm.rotation -= 0.2;
+ self.rightForearm.x += 30; // Move right forearm back to original position
+ self.rightForearm.rotation += 0.2;
self.isGuarding = false;
}
};
// Update player position based on input
@@ -166,8 +184,11 @@
self.y += moveY;
}
};
self.miniMove = function () {
+ if (self.isPunching || self.isGuarding) {
+ return;
+ }
// Mini head movement with added randomness
self.head.y = -40 + Math.sin(LK.ticks / 10 + Math.random() * 0.2) * 2;
// Mini arm and forearm movement with added randomness
self.leftArm.rotation += Math.sin(LK.ticks / 15 + Math.random() * 0.2) * 0.005;
clear
basic light gray convex round button with a red boxing glove icon. UI
Un gant de boxe bleu vu de dessus. video game
basic light round convex gray button with a raised blue shield icon.. UI
un éclair. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
remove
a basic white heart.. game icon
A boxer has lost the match..
man boxer with red gloves is KO on the ring..