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
in gamePlayingDown when "// Make the athlete run" animate the button width and height to simulate a button press
Code edit (1 edits merged)
Please save this source code
Code edit (13 edits merged)
Please save this source code
User prompt
add a 'down' handler for runbutton
Code edit (1 edits merged)
Please save this source code
User prompt
I didn't say to remove the previous button!
User prompt
in initMenuState, add two semi-transparent runButtons in the upper half of the screen
Code edit (20 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: difficulty is not defined' in or related to this line: 'self.nextHurdleSpeedX = -1 * Math.min(0, 2 - difficulty) + (-5 + 10 * Math.random() * (1 + 0.5 * (difficulty - 1))); // Level n' Line Number: 216
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: bonusGraphics is not defined' in or related to this line: 'bonusGraphics.visible = false;' Line Number: 502
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: BonusManager is not defined' in or related to this line: 'bonusManager = new BonusManager();' Line Number: 1041
Code edit (4 edits merged)
Please save this source code
User prompt
add a new class Bonus
Code edit (10 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: drone is undefined' in or related to this line: 'drone._update_migrated();' Line Number: 1076
Code edit (2 edits merged)
Please save this source code
User prompt
in DeliveryDrone class, add a bonus1 asset to the class and make it pop from the box when on ground
User prompt
in DeliveryDrone class, add an asset for the bonus that pops up from the box when on ground
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -261,9 +261,9 @@
}
// Update athlete speed
if (self.isOnGround && !finishLine.isCut && Date.now() - lastRunTime > 1000) {
// Decelerate when not pressing button
- speedGauge = Math.max(0, speedGauge - 0.01 * (Date.now() - lastRunTime) / 1000);
+ speedGauge = Math.max(0, speedGauge - 0.02 * (Date.now() - lastRunTime) / 1000);
globalSpeedPerLine[0] = globalBaseSpeed * speedGauge;
}
} else {
// Falling
@@ -540,10 +540,10 @@
self.drone2 = self.droneLayer.attachAsset('drone2', {
anchorX: 0.5,
anchorY: 0.5
});
- self.drone1.visible = true; // Visibility based on isEven flag
- self.drone2.visible = false; // Visibility based on isEven flag
+ self.drone1.visible = true;
+ self.drone2.visible = false;
self.dropPacket = function () {
if (!self.packetDropped) {
// Make packet fall to the ground
self.packetDropped = true;
@@ -671,21 +671,21 @@
anchorX: 0.5,
anchorY: 1,
y: -200,
rotation: Math.PI * 0.125,
- tint: 0xFF0000
+ tint: 0x1188FF
});
self.centralRodLeft = self.attachAsset('finishLine', {
anchorX: 0.5,
anchorY: 0,
x: 355,
y: -1060,
rotation: Math.PI * 2.125,
- tint: 0xFF0000,
+ tint: 0x1188FF,
height: 450
});
- self.leftRod = self.attachAsset('obstacle', {
- anchorX: 0.5,
+ self.leftRod = self.attachAsset('finishFlag', {
+ anchorX: 0,
anchorY: 1.0 // Anchor at the bottom for collision detection
});
self.flag = self.attachAsset('finishFlag', {
anchorX: 0.5,
@@ -980,12 +980,12 @@
var speedGaugeDelta = 0;
if (x < game.width / 2) {
lastRunTime = Date.now();
// Make the athlete run
- speedGaugeDelta = speedGauge ? 0.2 : 0.6;
+ speedGaugeDelta = speedGauge ? 0.1 : 0.6;
animateButtonPress(runButton);
} else {
- speedGaugeDelta = speedGauge ? 0.1 : 0.2;
+ speedGaugeDelta = speedGauge ? 0.05 : 0.1;
// Make the athlete jump
athlete.jump();
animateButtonPress(jumpButton);
}
@@ -999,27 +999,9 @@
cleanPlayingHurdlesState();
initMenuState();
}
}
- /*
- runButton.down = function (x, y, obj) {
- log("Run Forest, Run!");
- speedGauge = 1;
- globalSpeedPerLine[0] = globalBaseSpeed * speedGauge;
- };
- */
}
-function animateButtonPress(button) {
- // Animate runButton to simulate a button press
- button.width = 512 * 0.95;
- button.height = 512 * 0.95;
- button.alpha = 0.8;
- LK.setTimeout(function () {
- button.width = 512;
- button.height = 512;
- button.alpha = 0.6;
- }, 100);
-}
/****************************************************************************************** */
/************************************* AI FUNCTIONS *************************************** */
/****************************************************************************************** */
/****************************************************************************************** */
@@ -1038,42 +1020,44 @@
game.addChild(background);
field = LK.getAsset('field', {
anchorX: 0.0,
anchorY: 0.0,
+ x: -50,
y: 2732 - 1024 - 600
});
game.addChild(field);
fieldOdd = LK.getAsset('fieldOdd', {
anchorX: 0.0,
anchorY: 0.0,
- x: 2048,
+ x: 2048 + 50,
y: 2732 - 1024 - 600
});
game.addChild(fieldOdd);
farField = LK.getAsset('farField', {
anchorX: 0.0,
anchorY: 0.0,
+ x: -50,
y: 2732 - 1024 - 600 - 512
});
game.addChild(farField);
farFieldOdd = LK.getAsset('farFieldOdd', {
anchorX: 0.0,
anchorY: 0.0,
- x: 2048,
+ x: 2048 + 50,
y: 2732 - 1024 - 600 - 512
});
game.addChild(farFieldOdd);
stadium = LK.getAsset('stadium', {
anchorX: 0.0,
anchorY: 0.0,
- x: 0,
+ x: -50,
y: 150
});
game.addChild(stadium);
stadiumOdd = LK.getAsset('stadiumOdd', {
anchorX: 0.0,
anchorY: 0.0,
- x: 2048,
+ x: 2048 + 50,
y: 150
});
game.addChild(stadiumOdd);
// Initialize track using Track class
@@ -1109,14 +1093,11 @@
log("initMenuState...");
// Add Button in the center of the screen
startButton = LK.getAsset('button', {
anchorX: 0.5,
- // Center the button horizontally
anchorY: 0.5,
- // Center the button vertically
x: 2048 / 2,
- // Position horizontally in the center
- y: 2732 / 2 // Position vertically above the start text
+ y: 2732 / 2
});
game.addChild(startButton);
// Add Start Text in the center of the screen
startText = new Text2('START', {
@@ -1126,45 +1107,16 @@
startText.anchor.set(0.5, 0.5); // Center the text horizontally and vertically
startText.x = 2048 / 2; // Center horizontally
startText.y = 2732 / 2; // Center vertically
game.addChild(startText);
- // TEMP DEBUG TEST BLOCKER
- //var blocker = new Blocker(-1024, groundLevel - 200 - 475 * 1);
- //game.addChild(blocker);
- /*
- drone = new DeliveryDrone(); // false for odd drone graphic
- drone.x = 2048 - 300;
- drone.y = 128; // Positioning the drone
- game.addChild(drone);
- */
- /// TEST overboard
- /*
- var hoverboard = LK.getAsset('hoverboard', {
- anchorX: 0.5,
- // Center the button horizontally
- anchorY: 0.5,
- // Center the button vertically
- x: 600,
- // Position horizontally in the center
- y: groundLevel + 75
- });
- game.addChild(hoverboard);
- */
gameState = GAME_STATE.MENU;
+ // TEMP DEBUG
+ finishLine = new FinishLine();
+ finishLine.x = 2048 - 1024;
+ finishLine.y = groundLevel + 200;
+ game.addChild(finishLine);
}
function menuHandling() {
- // Alternate visibility of drones every 2 seconds
- // Use game ticks for drone visibility alternation, assuming 60 ticks per second
- /*var droneVisibilityTicks = 20; //120; // Equivalent to 2 seconds
- var lastDroneToggleTick = 0;
- if (LK.ticks - lastDroneToggleTick >= droneVisibilityTicks) {
- if (drone && drone2) {
- drone.visible = !drone.visible;
- drone2.visible = !drone2.visible;
- }
- lastDroneToggleTick = LK.ticks;
- }
- */
if (drone) {
drone._update_migrated();
}
}
@@ -1208,9 +1160,10 @@
anchorY: 0.5,
x: 2048 / 4,
y: 2732 / 3,
alpha: 0.7,
- tint: 0xcccccc
+ tint: 0xcccccc,
+ visible: false
});
game.addChild(runButton);
// Add second semi-transparent runButton in the upper half of the screen
jumpButton = LK.getAsset('runButton', {
@@ -1219,11 +1172,13 @@
x: 2048 * 3 / 4,
y: 2732 / 3,
alpha: 0.7,
tint: 0xcccccc,
- rotation: -1 * Math.PI / 2
+ rotation: -1 * Math.PI / 2,
+ visible: false
});
game.addChild(jumpButton);
+ showRunButtons();
gameState = GAME_STATE.STARTING;
}
function cleanHurdlesStartingState() {
for (var i = numberOfOpponents - 1; i >= 0; i--) {
@@ -1248,19 +1203,21 @@
scoreTxt = new Text2("0/" + numberOfObstacles.toString(), {
size: 80,
fill: "#FFFFFF"
});
- //scoreTxt.anchor.set(1.1, 0.15); // Center the score text horizontally
scoreTxt.anchor.set(0.25, 0.125); // Center the score text horizontally
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;
}
athlete.y -= 150;
+ speedGauge = 0.6;
+ globalSpeedPerLine[0] = globalBaseSpeed * speedGauge;
drone = new DeliveryDrone(); // false for odd drone graphic
drone.prepare();
+ bonusManager.endBonus();
game.addChild(drone);
gameState = GAME_STATE.PLAYING;
}
function cleanPlayingHurdlesState() {
@@ -1315,36 +1272,36 @@
function updateFields() {
if (!(athlete.isFalling && athlete.isOnGround)) {
field.x += globalSpeedPerLine[0];
// Reset position to create a continuous effect
- if (field.x <= -2048 - globalSpeedPerLine[0]) {
- field.x = 2048 + globalSpeedPerLine[0];
+ if (field.x <= -2048 - 50) {
+ field.x = 2048 + 50;
}
fieldOdd.x += globalSpeedPerLine[0];
// Reset position to create a continuous effect
- if (fieldOdd.x <= -2048 - globalSpeedPerLine[0]) {
- fieldOdd.x = 2048 + globalSpeedPerLine[0];
+ if (fieldOdd.x <= -2048 - 50) {
+ fieldOdd.x = 2048 + 50;
}
// Far field
farField.x += globalSpeedPerLine[0] * 0.8;
// Reset position to create a continuous effect
- if (farField.x <= -2048 - globalSpeedPerLine[0]) {
- farField.x = 2048 + globalSpeedPerLine[0];
+ if (farField.x <= -2048 - 50) {
+ farField.x = 2048 + 50;
}
farFieldOdd.x += globalSpeedPerLine[0] * 0.8;
// Reset position to create a continuous effect
- if (farFieldOdd.x <= -2048 - globalSpeedPerLine[0]) {
- farFieldOdd.x = 2048 + globalSpeedPerLine[0];
+ if (farFieldOdd.x <= -2048 - 50) {
+ farFieldOdd.x = 2048 + 50;
}
stadium.x += globalSpeedPerLine[0] * 0.4;
// Reset position to create a continuous effect
- if (stadium.x <= -2048 - globalSpeedPerLine[0]) {
- stadium.x = 2048 + globalSpeedPerLine[0];
+ if (stadium.x <= -2048 - 50) {
+ stadium.x = 2048 + 50;
}
stadiumOdd.x += globalSpeedPerLine[0] * 0.4;
// Reset position to create a continuous effect
- if (stadiumOdd.x <= -2048 - globalSpeedPerLine[0]) {
- stadiumOdd.x = 2048 + globalSpeedPerLine[0];
+ if (stadiumOdd.x <= -2048 - 50) {
+ stadiumOdd.x = 2048 + 50;
}
}
}
function spawnObstacles() {
@@ -1375,17 +1332,8 @@
finishLine = new FinishLine();
finishLine.x = 2048 * obstacleSpawnDistanceRate * (numberOfObstacles + 1) + 1024; // Start from the right edge
finishLine.y = groundLevel + 200;
game.addChild(finishLine);
- // Spawn Blockers
- /*
- for (var line = 1; line < numberOfLines; line++) {
- if (line == 3) {
- blockers[line] = new Blocker(startX + 2048, linesGroundLevels[1] - 675); // TODO : Fic index 1
- game.addChild(blockers[line]);
- }
- }
- */
}
function updateObstacles() {
// Update obstacles
for (var line = 0; line < numberOfLines; line++) {
@@ -1535,8 +1483,10 @@
if (isReached) {
raceFinishTime = Date.now();
finishLine.isCut = true;
finishLine.cut();
+ bonusManager.endBonus();
+ hideRunButtons();
}
}
// Take Bonus
if (drone && drone.bonus && !drone.bonus.isUsed && athlete.trunk.intersects(drone.bonus)) {
@@ -1573,8 +1523,27 @@
}
function getFinishPosition() {
return currentFinishPosition++;
}
+function showRunButtons() {
+ runButton.visible = true;
+ jumpButton.visible = true;
+}
+function hideRunButtons() {
+ runButton.visible = false;
+ jumpButton.visible = false;
+}
+function animateButtonPress(button) {
+ // Animate runButton to simulate a button press
+ button.width = 512 * 0.95;
+ button.height = 512 * 0.95;
+ button.alpha = 0.8;
+ LK.setTimeout(function () {
+ button.width = 512;
+ button.height = 512;
+ button.alpha = 0.6;
+ }, 100);
+}
/****************************************************************************************** */
/************************************** MAIN GAME LOOP ************************************ */
/****************************************************************************************** */
LK.on('tick', function () {
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.