Code edit (1 edits merged)
Please save this source code
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
===================================================================
--- original.js
+++ change.js
@@ -117,9 +117,9 @@
self.leftLeg.y += (self.targetPosture.leftLeg.y - self.leftLeg.y) * speed;
};
self.jump = function () {
globalSpeedPerLine[self.lineIndex] = globalSpeedPerLine[self.lineIndex] * 0.9;
- if (self.isOnGround && Date.now() - self.lastJumpTime > self.interJumpDelayMs) {
+ if (self.isOnGround) {
self.isOnGround = false;
self.speedY = self.jumpSpeed;
self.lastJumpTime = Date.now();
if (self.lineIndex == 3) {
@@ -134,10 +134,10 @@
self.leftArm.height = 200;
self.trunk.rotation = 0.125;
self.runAnim();
} else {
- self.speedY += self.gravity * Math.abs(globalSpeedPerLine[0] / 10); //self.lineIndex
- self.y += self.speedY * Math.abs(globalSpeedPerLine[0] / 10); //self.lineIndex
+ self.speedY += self.gravity * Math.abs(globalSpeedPerLine[self.lineIndex] / 10); //self.lineIndex
+ self.y += self.speedY * Math.abs(globalSpeedPerLine[self.lineIndex] / 10); //self.lineIndex
//log("self.speedY=" + self.speedY, " / self.y=" + self.y);
if (self.y >= linesGroundLevels[self.lineIndex]) {
self.y = linesGroundLevels[self.lineIndex];
self.isOnGround = true;
@@ -157,30 +157,35 @@
self.updatePosture();
/* ********************************************************** ATHLETE AI **************************************************** */
if (self.isAi) {
var nextX = self.x;
- if (athlete.isFalling) {
- if (self.lineIndex == 3) {
- log("Player fall add=" + self.speedX);
+ if (!self.isFalling) {
+ if (athlete.isFalling) {
+ if (self.lineIndex == 3) {
+ log("Player falls add=" + self.speedX);
+ }
+ //nextX += self.speedX;
+ nextX -= globalSpeedPerLine[self.lineIndex];
+ } else {
+ nextX += globalSpeedPerLine[self.lineIndex] * 0.05 * Math.random();
}
- nextX += self.speedX;
- } else {
- nextX += globalSpeedPerLine[self.lineIndex] * 0.05 * Math.random();
+ if (!athlete.isFalling && !athlete.isOnGround) {
+ // Little advance when player plays jumping
+ if (self.lineIndex == 3) {
+ log("Player jumping add=" + self.speedX * 0.1);
+ }
+ nextX += self.speedX * 0.1;
+ }
}
- if (!athlete.isOnGround) {
- // Little advance when player plays jumping
- nextX += 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 - nextX;
+ if (obstacles[self.lineIndex].length) {
+ var distance = obstacles[self.lineIndex][0].x - nextX;
if (self.lineIndex == 3) {
log("distance=" + distance);
}
if (distance > 0 && distance <= 250 + self.speedX) {
self.jump();
- break; // Jump once for the closest obstacle within range
}
}
}
self.x = nextX;
@@ -348,24 +353,23 @@
var athlete;
var opponents = [];
var numberOfOpponents = 3; // Adjust based on the actual number of opponents in the game
var groundLevel = 2732 - 200; // Ground level set 200px from the bottom
-var linesGroundLevels = [groundLevel - 200, groundLevel - 420, groundLevel - 640]; // Ground level set 200px from the bottom
-var groundLevelLine1 = 2732 - 200; // Ground level set 200px from the bottom
+var linesGroundLevels = []; // Ground level set 200px from the bottom
var numberOfLines = 1 + numberOfOpponents;
-var numberOfObstacles = 3;
-var obstacles = [[], []];
+var numberOfObstacles = 20;
+var obstacles = [[]];
var obstacleSpawnTicker = 0;
var obstacleSpawnRate = 180; // Spawn an obstacle every 2 seconds //TEMP DEBUG
+var obstacleSpawnDistanceRate = 1.5; // Spawn an obstacle 1 screen * 1.5
var obstacleJustPassed = false;
var track;
var track2;
var track3;
var track4;
var scoreTxt;
-var globalSpeed = -10; //-10; // Global speed for tracks and obstacles min = -4
var globalSpeedIncreaseStep = 5;
-var globalSpeedPerLine = [-10, -10];
+var globalSpeedPerLine = []; // Global speed for tracks and obstacles default -10 / min = -4
var colorsArray = [0x1188FF, 0xFF0000, 0x00FF00, 0xFFFF00, 0xFF00FF, 0x00FFFF, 0xFFFFFF, 0xFF8811];
var isDebug = true;
var debugMarker;
// UI
@@ -572,30 +576,27 @@
track4.update();
}
}
function spawnObstacles() {
- /*
- // Spawn obstacles - V1 : Each obstacle is spawned at a specific rate
- obstacleSpawnTicker += athlete.isFalling ? 0 : 1;
- if (obstacleSpawnTicker >= obstacleSpawnRate) {
- obstacleSpawnTicker = 0;
- for (var line = 0; line < numberOfLines; line++) {
- obstacles[line] = obstacles[line] || [];
- var newObstacle = new Obstacle(line);
- newObstacle.x = 2048 + 100 * line; // Start from the right edge
- newObstacle.y = groundLevel + 200 - 220 * line;
- obstacles[line].push(newObstacle);
- game.addChild(newObstacle);
+ // Set obstacles for line 0
+ obstacles[0] = [];
+ for (var i = 0; i < numberOfObstacles; i++) {
+ // 3 obstacles per line
+ var newObstacle = new Obstacle(0);
+ newObstacle.x = 2048 * obstacleSpawnDistanceRate * (i + 1); // Start from the right edge
+ //log("Obstacle "+ 0+","+i+" +> x="+ newObstacle.x);
+ newObstacle.y = groundLevel + 200;
+ obstacles[0].push(newObstacle);
+ game.addChild(newObstacle);
}
- }
- */
- // Spawn obstacles - V2 : All obstacles are spawned at the same time
- for (var line = 0; line < numberOfLines; line++) {
+ // Set obstacles for other lines
+ for (var line = 1; line < numberOfLines; line++) {
obstacles[line] = [];
for (var i = 0; i < numberOfObstacles; i++) {
// 3 obstacles per line
var newObstacle = new Obstacle(line);
- newObstacle.x = (2048 + 90 * line) * (i + 1); // Start from the right edge
+ newObstacle.x = obstacles[0][i].x + 100 * line; // Start from the right edge
+ //log("Obstacle "+ line+","+i+" +> x="+ newObstacle.x);
newObstacle.y = groundLevel + 200 - 220 * line;
obstacles[line].push(newObstacle);
game.addChild(newObstacle);
}
@@ -633,10 +634,10 @@
}
function checkForCollisions() {
for (var line = 0; line < numberOfLines; line++) {
obstacles[line] = obstacles[line] || [];
- for (var i = 0; i < obstacles[line].length; i++) {
- var obstacle = obstacles[line][i];
+ if (obstacles[line].length) {
+ var obstacle = obstacles[line][0]; // Check only the first obstacle in the line
if (line === 0) {
if (athlete.intersects(obstacle.centralRod)) {
athlete.isFalling = true;
athlete.isOnGround = false;
@@ -670,9 +671,9 @@
athlete.restore();
}, 1000); // Delay game over to allow fall animation to be seen
}
opponents.forEach(function (opponent, index) {
- if (opponent.isFalling && !opponent.hasFlashed) {
+ if (opponent.isFalling && !opponent.hasFlashed && !opponent.isOnGround) {
opponent.hasFlashed = true;
LK.setTimeout(function () {
globalSpeedPerLine[opponent.lineIndex] = -10;
opponent.restore();
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.