Code edit (6 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: self is undefined' in or related to this line: 'self.setWinnerFace = function () {' Line Number: 2127
User prompt
in athlete class, add a setWinnerFace function
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (11 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: groundLevels is not defined' in or related to this line: 'self.shadow.y = groundLevels[0] - self.y - self.trunk.y;' Line Number: 366
Code edit (1 edits merged)
Please save this source code
Code edit (21 edits merged)
Please save this source code
User prompt
Using the following instructions, add shadows to the athletes, you would modify the Athlete class to include a shadow asset for each athlete instance. Here's a conceptual outline of the code changes you would make, described in human language: 1. **Define a Shadow Asset in the Athlete Class Initialization:** - Within the Athlete class constructor, after initializing the athlete's body parts (like the trunk, head, arms, and legs), you would attach a new asset to represent the shadow. This could be done using the `self.attachAsset` method similar to how other body parts are attached. - The shadow asset could be a simple ellipse or a custom shape that resembles the shadow cast by an athlete. You would set its color to a dark gray or black with reduced alpha to make it semi-transparent, mimicking a real shadow. - Position the shadow asset directly below the athlete, offsetting its `x` and `y` properties to ensure it appears right under the athlete's feet. The `y` offset might be slightly larger than the athlete's height to place it on the ground, and you might need to adjust the `scaleX` and `scaleY` properties to stretch the shadow horizontally to make it look more realistic. 2. **Update Shadow Position in the Athlete's Update Method:** - In the Athlete class's update method (`self._update_migrated`), along with updating the athlete's position and handling animations, you would also update the shadow's position to follow the athlete. This ensures that the shadow remains correctly positioned under the athlete as they move. - If the athlete jumps, you could optionally adjust the shadow's `scaleX` and `scaleY` to make the shadow grow or shrink, simulating the shadow's behavior in real life as the athlete moves away from or closer to the ground. 3. **Adjust Shadow Visibility Based on Athlete's State:** - You might want to adjust the shadow's visibility or opacity based on the athlete's state. For example, if the athlete is jumping, the shadow could become fainter or slightly larger to reflect the increased distance from the ground. - When the athlete is falling or has collided with an obstacle, you could temporarily hide the shadow or make it more prominent based on the game's visual feedback requirements.
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
when isReached and athlete had won, show the confettis
Code edit (14 edits merged)
Please save this source code
User prompt
add a confetti class to celebrate player victory
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: messageTextBig is not defined' in or related to this line: 'messageTextBig.visible = false;' Line Number: 548
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -38,16 +38,16 @@
anchorY: 0.5,
scaleX: 1,
scaleY: 1,
rotation: 0.125,
- tint: 0x000000 //self.tint // TEMP DEBUG
+ tint: 0x000000
});
self.head = self.trunk.attachAsset('head', {
anchorX: 0.5,
anchorY: 2,
scaleX: 1,
scaleY: 1,
- tint: 0x000000 // self.tint
+ tint: 0x000000
});
self.rightArm = self.trunk.attachAsset('bodyPart', {
anchorX: 0.5,
anchorY: 0,
@@ -90,9 +90,11 @@
// Check if the target posture for hands and legs is reached
//log("self.targetPosture: " + self.targetPosture.name + " : self.rightHand.x: " + self.rightHand.x, " self.targetPosture.rightHand.x: " + self.targetPosture.rightHand.x);
var handsAndLegsReached = Math.abs(self.rightLeg.x - self.targetPosture.rightLeg.x) < 1 && Math.abs(self.rightLeg.y - self.targetPosture.rightLeg.y) < 1 && Math.abs(self.leftLeg.x - self.targetPosture.leftLeg.x) < 1 && Math.abs(self.leftLeg.y - self.targetPosture.leftLeg.y) < 1 && Math.abs(self.head.x - self.targetPosture.head.x) < 1 && Math.abs(self.head.y - self.targetPosture.head.y) < 1;
if (handsAndLegsReached) {
- log("handsAndLegsReached !");
+ if (self.lineIndex == 1) {
+ log("handsAndLegsReached !");
+ }
// Update currentPosture to the name of the targetPosture when hands and legs posture is reached
self.currentPosture = self.targetPosture.name;
self.targetPosture = null;
self.isChangingPosture = false;
@@ -227,19 +229,24 @@
if (self.isOnGround) {
// Running
self.leftLeg.height = 200;
self.leftArm.height = 200;
+ self.trunk.rotation = 0.125;
+ self.runAnim();
+ /*
if (globalSpeedPerLine[0] != 0) {
- self.isWaiting = false;
- self.trunk.rotation = 0.125;
- self.runAnim();
+ self.isWaiting = false;
+ self.trunk.rotation = 0.125;
+ self.runAnim();
} else {
- if (!self.isWaiting) {
- self.isWaiting = true;
- self.trunk.rotation = 0.0;
- self.setPosture(idlePosture);
- }
+ if (!self.isWaiting) {
+ log("NOW Player Waiting...");
+ self.isWaiting = true;
+ self.trunk.rotation = 0.0;
+ self.setPosture(idlePosture);
}
+ }
+ */
} else {
// Jumping
self.speedY += self.gravity * 2;
self.y += self.speedY * 2;
@@ -302,13 +309,13 @@
}
self.updatePosture();
};
self.jump = function () {
- if (self.isAI || Date.now() - self.lastJumpTime > self.interJumpDelayMs) {
+ if (self.isAi || Date.now() - self.lastJumpTime > self.interJumpDelayMs) {
if (self.isOnGround) {
self.isOnGround = false;
// Handle jump bonus
- if (!self.isAI && self.justTookBonus) {
+ if (!self.isAi && self.justTookBonus) {
self.nbJumps++;
if (self.nbJumps > nbBonusJumps) {
log("JUMPS FINISHED " + self.nbJumps);
self.justTookBonus = false;
@@ -329,13 +336,16 @@
}
};
self.runAnim = function () {
if (self.lineIndex == 1) {
- //log("Check finish for #3 at x=" + opponents[self.lineIndex].x + " vs " + (finishLine.x + 512));
+ log("runAnim #1...self.rightArm.rotation=" + self.rightArm.rotation);
}
- if (!self.isAI && speedGauge < 0.2) {
+ if (!self.isAi && speedGauge < 0.2) {
return;
}
+ if (self.lineIndex == 1) {
+ log("runAnim #1...go anim!");
+ }
var ocsilDelay = 5 * (self.isAi ? 1 : 2 - speedGauge);
var armsAmplitude = 0.5;
var legsAmplitude = 0.5;
// Simulate running by continuously balancing the arms and legs
@@ -355,9 +365,9 @@
self.head.width = 50 - 10 * (runningArmAngle * Math.PI * 0.5);
};
self.jumpAnim = function () {
if (self.lineIndex == 1) {
- //log("Check finish for #3 at x=" + opponents[line - 1].x + " vs " + (finishLine.x + 512));
+ log("jumpAnim #1...");
}
var ocsilDelay = 5;
var armsAmplitude = 1;
var runningArmAngle = Math.sin(LK.ticks / ocsilDelay) * armsAmplitude; // Oscillate arm angle to simulate running faster
@@ -509,25 +519,26 @@
var nbLineFeeds = (newMessage.match(/\r\n|\r|\n/g) || []).length;
self.messageText.y = 220 + 42 * nbLineFeeds;
self.messageText.setText(newMessage);
};
- self.setLevelMessage = function () {
+ self.setLevelMessage = function (go) {
var newMessage = "";
self.messageTextBig.visible = false;
switch (difficultyLevel) {
case 2:
- newMessage = "Level 2: Amateurs\r\n \r\n \r\n GET READY!";
+ newMessage = "Level 2: Amateurs\r\n \r\n \r\n ";
break;
case 3:
- newMessage = "Level 3: Pros\r\n \r\n \r\nGET READY!";
+ newMessage = "Level 3: Pros\r\n \r\n \r\n";
break;
case 4:
- newMessage = "Level 4: Super Heroes\r\n \r\n \r\n GET READY!";
+ newMessage = "Level 4: Super Heroes\r\n \r\n \r\n ";
break;
default:
- newMessage = "Level 1: Juniors\r\n \r\n \r\n GET READY!";
+ newMessage = "Level 1: Juniors\r\n \r\n \r\n ";
break;
}
+ newMessage += go ? "GO!" : "GET READY!";
billboard.setMessage(newMessage);
};
self.setMessage(self.welcomeMessage);
});
@@ -876,9 +887,9 @@
});
/*
x: 150,
y: 2732 - 115,
- */
+ */
self.speedX = globalSpeedPerLine[0];
self._update_migrated = function () {
self.speedX = globalSpeedPerLine[0];
self.x += self.speedX;
@@ -980,9 +991,9 @@
// Purple
0x008080 // Teal;
];
var currentRoundColors = [];
-var isDebug = false;
+var isDebug = true;
var debugMarker;
// UI
var hintMobileText;
var startText;
@@ -1294,25 +1305,25 @@
// Spawn obstacles
spawnObstacles();
// Add starting blocks to each athlete's starting position
for (var i = 0; i <= numberOfOpponents; i++) {
- startingBlocks[i] = new StartingBlocks(startX + 20 + 100 * i, linesGroundLevels[i] + 145, i);
+ startingBlocks[i] = new StartingBlocks(startX + 10 + 100 * i, linesGroundLevels[i] + 145, i);
game.addChild(startingBlocks[i]);
}
// Initialize opponents
for (var i = numberOfOpponents - 1; i >= 0; i--) {
opponents[i] = game.addChild(new Athlete(i + 1));
opponents[i].restore();
opponents[i].isRunning = false;
opponents[i].setPosture(startingBlockPosture);
- opponents[i].y += 150;
+ opponents[i].y += 120;
}
// Initialize athlete
athlete = game.addChild(new Athlete(0));
athlete.restore();
athlete.isRunning = false;
athlete.setPosture(startingBlockPosture);
- athlete.y += 150;
+ athlete.y += 120;
runButton = LK.getAsset('runButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 4,
@@ -1365,9 +1376,9 @@
runButtonHelpText.visible = false;
jumpButtonHelpText.visible = false;
}
function gameStarting() {
- log("gameStarting...");
+ //log("gameStarting...");
for (var i = 0; i <= numberOfOpponents; i++) {
var athletes = [athlete].concat(opponents);
athletes[i]._update_migrated();
}
@@ -1385,18 +1396,19 @@
LK.gui.top.addChild(scoreTxt); // Add the score text to the GUI overlay at the top center
currentFinishPosition = 1;
// Remove starting blocks offset
for (var i = numberOfOpponents - 1; i >= 0; i--) {
- opponents[i].y -= 150;
+ opponents[i].y -= 120;
}
- athlete.y -= 150;
+ athlete.y -= 120;
speedGauge = 0.6;
globalSpeedPerLine[0] = globalBaseSpeed * speedGauge;
drone = new DeliveryDrone(); // false for odd drone graphic
drone.prepare();
bonusManager.endBonus();
game.addChild(drone);
raceStartTime = Date.now();
+ billboard.setLevelMessage(true);
gameState = GAME_STATE.PLAYING;
}
function gamePlaying() {
//log("Game playing...");
Elongated elipse with black top half and white bottom half.
full close and front view of empty stands. retro gaming style
delete
delete
Basquettes à ressort futuriste. vue de profile. Retro gaming style
a blue iron man style armor flying. Retro gaming style
a blue iron man style armor flying horizontally. Retro gaming style
round button with a big "up" arrow icon and a small line under it. UI
A big black horizontal arrow pointing left with centred text 'YOU' in capital letters, painted on an orange floor.. horizontal and pointing left
remove
gold athletics medal with ribbon. retro gaming style
a black oval with a crying smiley face.