Code edit (1 edits merged)
Please save this source code
User prompt
in handleHit, if defenser isn't withinLimits, move the attacker back
User prompt
in handleHit, use the ring border properties to check if within borders
User prompt
in Ring class, replace the limits array, by properties : leftBorder, rightBorder, topBorder and bottomBorder
Code edit (21 edits merged)
Please save this source code
User prompt
now, in handleHit(), check if newX and newY are out of ring's limits
User prompt
store the following coordinates as ring limits properties in ring class : [300,200], [1800,200], [300,1750], [1800,1750]
Code edit (1 edits merged)
Please save this source code
Code edit (9 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: target is not defined' in or related to this line: 'self.targetX = target.x;' Line Number: 223
Code edit (1 edits merged)
Please save this source code
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
===================================================================
--- original.js
+++ change.js
@@ -9,10 +9,11 @@
self.isPunching = false; // Indicates if the athlete is currently punching
self.isPlayer = isPlayer;
self.body = new Container();
game.addChild(self.body);
- // Define punch distance for punching animation
- var punchDistance = 50;
+ var punchDistance = 50; // Define punch distance for punching animation
+ self.targetX = self.targetX || 1024; // Default target X
+ self.targetY = self.targetY || 1366; // Default target Y
// Left Arm
self.leftForearm = self.body.attachAsset('forearm', {
anchorX: 0.5,
anchorY: 0.5,
@@ -23,11 +24,11 @@
});
self.leftHand = self.body.attachAsset(isPlayer ? 'hand' : 'hand2', {
anchorX: 0.5,
anchorY: 0.5,
- x: isPlayer ? -110 : -120,
+ x: isPlayer ? -100 : -120,
y: isPlayer ? -250 : -245,
- width: 80,
+ width: 90,
height: 180,
rotation: isPlayer ? -Math.PI * 0.05 : -Math.PI * 0.17
});
self.leftArm = self.body.attachAsset('arm', {
@@ -48,9 +49,9 @@
});
self.rightHand = self.body.attachAsset(isPlayer ? 'hand' : 'hand2', {
anchorX: 0.5,
anchorY: 0.5,
- x: isPlayer ? 110 : 120,
+ x: isPlayer ? 100 : 120,
y: isPlayer ? -250 : -245,
scaleX: -1,
width: 80,
height: 180,
@@ -96,9 +97,9 @@
y: -punchDistance * 1.5,
rotation: isLeft ? 0.5 : -0.5
},
hand: {
- x: isLeft ? 15 : -15,
+ x: 30 * (isLeft ? 1 : -1),
y: -punchDistance * 2
},
head: {
x: isLeft ? 15 : -15,
@@ -185,11 +186,10 @@
}
};
// Update player position based on input
self.update = function () {
- if (false && isPlaying) {
+ if (isPlaying) {
// TEMP DEBUG !!
- // Only move player if it's human controlled automatically
self.mainMove();
}
// Player is idle
self.miniMove();
@@ -200,10 +200,8 @@
var target = self.isPlayer ? opponent : player; // Determine target based on whether self is Player or Opponent
var angleToOpponent = Math.atan2(target.y - self.y, target.x - self.x) + Math.PI * 0.5;
self.body.rotation = angleToOpponent;
};
- self.targetX = self.targetX || 1024; // Default target X
- self.targetY = self.targetY || 1366; // Default target Y
self.mainMove = function () {
// Check if athlete has reached the target
var distanceToTarget = Math.sqrt(Math.pow(self.targetX - self.x, 2) + Math.pow(self.targetY - self.y, 2));
if (distanceToTarget < 10) {
@@ -413,9 +411,9 @@
},
rightHand: {
x: 110,
y: -250,
- w: 80,
+ w: 90,
h: 180,
r: Math.PI * 0.05
},
rightArm: {
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..