Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: self.gard is not a function' in or related to this line: 'self.gard(true);' Line Number: 360
Code edit (9 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: self.gard is not a function' in or related to this line: 'self.gard(true);' Line Number: 352
Code edit (5 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: target is undefined' in or related to this line: 'self.targetX = target.x;' Line Number: 370
User prompt
in thinkAboutTarget, when self.energy < 15, select a corner far from the other player
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: opponent.isPunching is not a function' in or related to this line: 'if (opponent.isPunching(opponent.leftHand.intersects(player.torso) || opponent.rightHand.intersects(player.torso))) {' Line Number: 860
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
in handleHit, fix the scope problem for members in the settimeout
Code edit (1 edits merged)
Please save this source code
User prompt
in handleHit, also use members array for the restoration of the positions
User prompt
in handleHit, move the members back in the setTimout function
User prompt
in handleHit, use members array to determine which members to move back and forth
Code edit (9 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: guardLevel is not defined' in or related to this line: 'if (guardLevel > 25) {' Line Number: 360
Code edit (1 edits merged)
Please save this source code
Code edit (14 edits merged)
Please save this source code
User prompt
add the opponent health bar at the top of the screen
Code edit (1 edits merged)
Please save this source code
Code edit (12 edits merged)
Please save this source code
User prompt
in handleHitImpact when KO call game over
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -20,9 +20,9 @@
self.currentPunchEnergy = 2; // Punch cost in energy
self.punchCount = 0; // Initialize punch count
self.lastPunchTime = 0; // Timestamp of the last punch
self.lastHitTime = 0; // Timestamp of the last hit
- self.immunityDelayMs = 0; // Timestamp of the last hit
+ self.immunityDelayMs = 600; // Timestamp of the last hit
self.body = new Container();
game.addChild(self.body);
var punchDistance = 60; // Define punch distance for punching animation
var attackDistance = 500;
@@ -262,9 +262,13 @@
if (Date.now() - self.lastHitTime < self.immunityDelayMs) {
return false;
}
self.lastHitTime = Date.now();
- self.health = Math.max(0, self.health - attacker.punchCount * (self.isGuarding ? 0.01 : 0.5));
+ var damage = attacker.punchCount * (self.isGuarding ? 0.01 : 0.5);
+ if (!self.isPlayer) {
+ log("AI Received damage=" + damage);
+ }
+ self.health = Math.max(0, self.health - damage);
(self.isPlayer ? playerHealthBar : opponentHealthBar).updateHealth(self.health);
if (self.health <= 0) {
// KO, call game over
LK.showGameOver();
@@ -317,17 +321,23 @@
self.retreat = true;
if (!self.isPlayer) {
log("AI RETREAT !!!");
}
- if (self.x < 1024) {
- self.targetX = ring.leftCorner;
- } else {
+ // Determine the farthest corner based on the opponent's position
+ var opponent = self.isPlayer ? opponent : player;
+ if (opponent.x < 1024) {
+ // Opponent is closer to the left side, move to the right corner
self.targetX = ring.rightCorner;
- }
- if (self.y < 1024) {
- self.targetY = ring.topCorner;
} else {
+ // Opponent is closer to the right side, move to the left corner
+ self.targetX = ring.leftCorner;
+ }
+ if (opponent.y < 1366) {
+ // Opponent is closer to the top, move to the bottom corner
self.targetY = ring.bottomCorner;
+ } else {
+ // Opponent is closer to the bottom, move to the top corner
+ self.targetY = ring.topCorner;
}
} else {
self.retreat = false;
var target = self.isPlayer ? opponent : player;
@@ -759,10 +769,10 @@
var defenderDirection = Math.atan2(defender.y - attacker.y, defender.x - attacker.x);
// Move defender back
var newX = defender.x + Math.cos(defenderDirection) * backDelta;
var newY = defender.y + Math.sin(defenderDirection) * backDelta;
- // Check if newX and newY are within ring's borders
- var withinLimits = newX >= ring.leftBorder && newX <= ring.rightBorder && newY >= ring.topBorder && newY <= ring.bottomBorder;
+ // Check if newX and newY are within ring's corners
+ var withinLimits = newX >= ring.leftCorner && newX <= ring.rightCorner && newY >= ring.topCorner && newY <= ring.bottomCorner;
//log("Is in ring ?", withinLimits);
if (withinLimits) {
defender.x = newX; // Move defender back in the x direction of current movement
defender.y = newY; // Move defender back in the y direction of current movement
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..