Code edit (2 edits merged)
Please save this source code
User prompt
in gameInitialize, mirror vertically track3 and track4
User prompt
in gameInitialize, vertically reverse track3 and track4
Code edit (18 edits merged)
Please save this source code
User prompt
when use taps a lot, movement stops. prenvent that
Code edit (1 edits merged)
Please save this source code
Code edit (12 edits merged)
Please save this source code
User prompt
in gamePlaying(), invert opponents game.addChild order
Code edit (1 edits merged)
Please save this source code
Code edit (8 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'intersects')' in or related to this line: 'if (opponents[line - 1].intersects(obstacle.centralRod)) {' Line Number: 630
Code edit (13 edits merged)
Please save this source code
User prompt
reverse opponents spawn order
User prompt
reverse opponents spawn
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'restore')' in or related to this line: 'opponents[i].restore();' Line Number: 633
Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'restore')' in or related to this line: 'opponents[i].restore();' Line Number: 632
Code edit (3 edits merged)
Please save this source code
User prompt
in gameInitialize, after startButton init, on button press, call cleanMenuState and switch to playing state
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'on')' in or related to this line: 'startButton.on('down', function () {' Line Number: 419
User prompt
on button press, call cleanMenuState and switch to playing state
Code edit (1 edits merged)
Please save this source code
User prompt
add a button Asset at the center of the screen before the Start text. don't replace Start text
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -114,11 +114,8 @@
// Right foot updates removed due to foot assets being removed
self.leftLeg.x += (self.targetPosture.leftLeg.x - self.leftLeg.x) * speed;
self.leftLeg.y += (self.targetPosture.leftLeg.y - self.leftLeg.y) * speed;
};
- self.moveRight = function () {
- self.x += self.speedX;
- };
self.jump = function () {
globalSpeedPerLine[self.lineIndex] = globalSpeedPerLine[self.lineIndex] * 0.9;
if (self.isOnGround && Date.now() - self.lastJumpTime > self.interJumpDelayMs) {
self.isOnGround = false;
@@ -157,13 +154,17 @@
self.updatePosture();
/* ********************************************************** ATHLETE AI **************************************************** */
if (self.isAi) {
if (athlete.isFalling) {
- self.moveRight();
+ self.x += self.speedX;
} else {
//self.x += 4 - 8 * Math.random();
self.x += globalSpeedPerLine[self.lineIndex] * 0.05 * Math.random();
}
+ if (!athlete.isOnGround) {
+ // Little advance when player plays jumping
+ self.x += self.speedX * 0.1;
+ }
// Auto jump hurdles in obstacles[self.lineIndex]
if (self.isOnGround) {
for (var i = 0; i < obstacles[self.lineIndex].length; i++) {
var distance = obstacles[self.lineIndex][i].x - self.x;
@@ -404,10 +405,27 @@
/************************************** INPUT HANDLERS ************************************ */
/****************************************************************************************** */
// Touch event to make the athlete jump
game.on('down', function () {
- athlete.jump();
+ switch (gameState) {
+ case GAME_STATE.MENU:
+ // Handle menu logic here
+ break;
+ case GAME_STATE.STARTING:
+ // Handle game starting logic here
+ break;
+ case GAME_STATE.PLAYING:
+ gamePlayingDown();
+ break;
+ case GAME_STATE.SCORE:
+ // Handle score display logic here
+ break;
+ }
});
+function gamePlayingDown() {
+ // Make the athlete jump
+ athlete.jump();
+}
/****************************************************************************************** */
/************************************* AI FUNCTIONS *************************************** */
/****************************************************************************************** */
/****************************************************************************************** */
@@ -427,8 +445,16 @@
anchorY: 0.0,
visible: false // TEMP DEBUG
});
game.addChild(background);
+ var field = LK.getAsset('field', {
+ anchorX: 0.0,
+ anchorY: 0.0,
+ visible: true,
+ // TEMP DEBUG
+ y: 712
+ });
+ game.addChild(field);
// Initialize track using Track class
track = game.addChild(new Track());
track.x = 0;
track.y = 2732 - 512;
@@ -448,16 +474,8 @@
for (var line = 0; line < numberOfLines; line++) {
linesGroundLevels[line] = groundLevel - 200 - 220 * line;
globalSpeedPerLine[line] = -10;
}
- // Initialize athlete
- athlete = game.addChild(new Athlete(0));
- athlete.restore();
- // Initialize opponents
- for (var i = 0; i < numberOfOpponents; i++) {
- opponents[i] = game.addChild(new Athlete(i + 1));
- opponents[i].restore();
- }
// Add Button in the center of the screen
startButton = LK.getAsset('button', {
anchorX: 0.5,
// Center the button horizontally
@@ -469,9 +487,9 @@
});
game.addChild(startButton);
startButton.on('down', function () {
cleanMenuState();
- gameState = GAME_STATE.PLAYING;
+ initPlayingState();
});
// Add Start Text in the center of the screen
startText = new Text2('START', {
size: 200,
@@ -517,8 +535,19 @@
function cleanMenuState() {
game.removeChild(startText);
game.removeChild(startButton);
}
+function initPlayingState() {
+ // Initialize athlete
+ athlete = game.addChild(new Athlete(0));
+ athlete.restore();
+ // Initialize opponents
+ for (var i = 0; i < numberOfOpponents; i++) {
+ opponents[i] = game.addChild(new Athlete(i + 1));
+ opponents[i].restore();
+ }
+ gameState = GAME_STATE.PLAYING;
+}
/****************************************************************************************** */
/************************************** GAME FUNCTIONS ************************************ */
/****************************************************************************************** */
function updateTracks() {
@@ -611,18 +640,17 @@
globalSpeedPerLine[0] = -10;
athlete.restore();
}, 1000); // Delay game over to allow fall animation to be seen
}
- for (var i = 0; i < numberOfOpponents; i++) {
- var opponent = opponents[i];
+ opponents.forEach(function (opponent, index) {
if (opponent.isFalling && !opponent.hasFlashed) {
opponent.hasFlashed = true;
LK.setTimeout(function () {
globalSpeedPerLine[opponent.lineIndex] = -10;
opponent.restore();
}, 1000);
}
- }
+ });
}
/****************************************************************************************** */
/************************************** MAIN GAME LOOP ************************************ */
/****************************************************************************************** */
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.