Code edit (7 edits merged)
Please save this source code
User prompt
factorize punch() function by using the deltas method
Code edit (1 edits merged)
Please save this source code
Code edit (6 edits merged)
Please save this source code
User prompt
in guard() adjustments, handle also width and height (deltaW and deltaH)
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (8 edits merged)
Please save this source code
User prompt
in guard(), also add a deltaY to adjustments array
User prompt
add deltaY to the adjustments
User prompt
in guard(), also add a deltaY
Code edit (1 edits merged)
Please save this source code
User prompt
in adjustPosition(), simplify by making direction depend on setGuard also
User prompt
in adjustPosition(), simplify by defining a direction variable that depends on index and setGuard
User prompt
in guard, also Invert deltaR for the second element
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
===================================================================
--- original.js
+++ change.js
@@ -115,37 +115,35 @@
self.isPunching = false;
}, 300);
};
// Guard function to handle guarding action
- self.guard = function (setGard) {
- // 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;
- if (setGard) {
- self.isGuarding = true;
- // Move hands and forearms closer to the center of the torso for guarding
- 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 -= handXDelta; // Move left hand back to original position
- self.leftHand.rotation -= handRDelta;
- self.rightHand.x += handXDelta; // Move right hand back to original position
- self.rightHand.rotation += handRDelta;
- self.leftForearm.x -= forearmXDelta; // Move left forearm back to original position
- self.leftForearm.rotation -= forearmRDelta;
- self.rightForearm.x += forearmXDelta; // Move right forearm back to original position
- self.rightForearm.rotation += forearmRDelta;
- self.isGuarding = false;
- }
+ self.guard = function (setGuard) {
+ var adjustPosition = function adjustPosition(element, deltaX, deltaR, setGuard) {
+ element.x += setGuard ? deltaX : -deltaX;
+ element.rotation += setGuard ? deltaR : -deltaR;
+ };
+ // Adjustments for guarding
+ var adjustments = [{
+ element: self.leftHand,
+ deltaX: 60,
+ deltaR: 0.2
+ }, {
+ element: self.rightHand,
+ deltaX: -60,
+ deltaR: -0.2
+ }, {
+ element: self.leftForearm,
+ deltaX: 30,
+ deltaR: 0.2
+ }, {
+ element: self.rightForearm,
+ deltaX: -30,
+ deltaR: -0.2
+ }];
+ adjustments.forEach(function (adj) {
+ return adjustPosition(adj.element, adj.deltaX, adj.deltaR, setGuard);
+ });
+ self.isGuarding = setGuard;
};
// Update player position based on input
self.update = function () {
if (false && isPlaying) {
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..