Code edit (10 edits merged)
Please save this source code
User prompt
when victory, flash the screen green 1sec
Code edit (3 edits merged)
Please save this source code
User prompt
in handleHitImpact, also display a resultText in the top center of the screen with "VICTORY!" or "DEFEAT!"
Code edit (1 edits merged)
Please save this source code
User prompt
replace LK.effects.flashScreen(pictureToShow === 'victoryPicture' ? 0x00FF00 : 0xFF0000, 2000); by adding the asset to the game
User prompt
Please fix the bug: 'Timeout.tick error: LK.showPicture is not a function' in or related to this line: 'LK.showPicture(pictureToShow);' Line Number: 307
Code edit (22 edits merged)
Please save this source code
User prompt
before gameover, show victoryPicture or defeatPicture for 2 sec
Code edit (1 edits merged)
Please save this source code
Code edit (14 edits merged)
Please save this source code
User prompt
in thinkAboutTarget, when going to the other take into account attackDistance self.targetX = other.x; self.targetY = other.y;
User prompt
in mainAIMove, Implement acceleration and deceleration in the AI's movement. The AI could start moving slowly, gradually increase its speed as it moves away from its starting point, and then slow down as it approaches the target. This would add a more natural feel to the movement. Don't alter the other logic, only the movement
User prompt
Please fix the bug: 'TypeError: Math.rancomd is not a function' in or related to this line: 'if (Math.rancomd() < 0.5) {' Line Number: 367
Code edit (1 edits merged)
Please save this source code
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
===================================================================
--- original.js
+++ change.js
@@ -20,9 +20,11 @@
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 = 600; // Timestamp of the last hit
+ self.immunityDelayMs = 300; // Timestamp of the last hit
+ self.lastTargetReachTime = 0;
+ self.targetStayTimeMs = 3000;
self.body = new Container();
game.addChild(self.body);
var punchDistance = 60; // Define punch distance for punching animation
var attackDistance = 500;
@@ -315,33 +317,40 @@
//var target = self.thinkAboutTarget();
self.mainAiMove();
};
self.thinkAboutTarget = function () {
+ var other = self.isPlayer ? opponent : player;
// If Guard level < 25% or Energy < 25% retreat to closest ring corner
- if (self.energy < 15) {
- self.retreat = true;
+ if (self.energy < 5) {
+ if (!self.retreat) {
+ self.retreat = true;
+ self.guard(true);
+ }
+ self.gard(true);
if (!self.isPlayer) {
log("AI RETREAT !!!");
}
- var other = self.isPlayer ? opponent : player;
if (other.x > 1024) {
self.targetX = ring.leftCorner;
} else {
self.targetX = ring.rightCorner;
}
- if (self.y > 1024) {
+ if (other.y > 1044) {
self.targetY = ring.topCorner;
} else {
self.targetY = ring.bottomCorner;
}
} else {
self.retreat = false;
- var target = self.isPlayer ? opponent : player;
- self.targetX = target.x;
- self.targetY = target.y;
+ self.targetX = other.x;
+ self.targetY = other.y;
}
};
self.mainAiMove = function () {
+ if (Date.now() - self.lastTargetReachTime < self.targetStayTimeMs) {
+ // Wait a bit before going to next target
+ return;
+ }
var target = self.thinkAboutTarget();
// 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 (!self.retreat && distanceToTarget < attackDistance) {
@@ -356,8 +365,10 @@
var moveX = (self.targetX - self.x) / distanceToTarget * self.speed;
var moveY = (self.targetY - self.y) / distanceToTarget * self.speed;
self.x += moveX;
self.y += moveY;
+ } else {
+ self.lastTargetReachTime = Date.now();
}
}
};
self.aiFight = function () {
@@ -365,18 +376,18 @@
if (!self.isGuarding && self.guardLevel > 0) {
self.guard(true);
}
} else {
- if (LK.ticks % 33 == 0 && !self.isPunching && !self.isFighting) {
+ if (LK.ticks % 10 == 0 && !self.isPunching && !self.isFighting) {
self.punch(Math.random() < 0.5);
- // Punch during 2sec
+ // Punch during 4-5sec
LK.setTimeout(function () {
self.isFighting = true;
- // Stop durring 2 sec
+ // Stop durring 2-4 sec
LK.setTimeout(function () {
self.isFighting = false;
}, 4000 - 2000 * Math.random());
- }, 4000 - 2000 * Math.random());
+ }, 5000 - 1000 * Math.random());
}
}
};
self.miniMove = function () {
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..