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
@@ -21,8 +21,9 @@
self.currentPosture = ""; // Store the name of the current posture
self.isChangingPosture = false; // 0 when idle or moving down, 1 when moving up
self.nextPosture = null;
self.tint = colorsArray[self.lineIndex % colorsArray.length];
+ self.previousX = 0;
// BODY PARTS
self.trunk = self.attachAsset('bodyPart', {
anchorX: 0.5,
anchorY: 0.5,
@@ -120,9 +121,11 @@
if (self.isOnGround && Date.now() - self.lastJumpTime > self.interJumpDelayMs) {
self.isOnGround = false;
self.speedY = self.jumpSpeed;
self.lastJumpTime = Date.now();
- log("--------------- JUMP --------------------");
+ if (self.lineIndex == 3) {
+ log("--------------- JUMP --------------------");
+ }
}
};
self.update = function () {
if (!self.isFalling) {
@@ -153,28 +156,36 @@
}
self.updatePosture();
/* ********************************************************** ATHLETE AI **************************************************** */
if (self.isAi) {
+ var nextX = self.x;
if (athlete.isFalling) {
- self.x += self.speedX;
+ if (self.lineIndex == 3) {
+ log("Player fall add=" + self.speedX);
+ }
+ nextX += self.speedX;
} else {
- //self.x += 4 - 8 * Math.random();
- self.x += globalSpeedPerLine[self.lineIndex] * 0.05 * Math.random();
+ nextX += globalSpeedPerLine[self.lineIndex] * 0.05 * Math.random();
}
if (!athlete.isOnGround) {
// Little advance when player plays jumping
- self.x += self.speedX * 0.1;
+ 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 - self.x;
- if (distance > 0 && distance <= 200) {
+ var distance = obstacles[self.lineIndex][i].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;
+ self.previousX = self.x;
}
};
self.runAnim = function () {
var ocsilDelay = 5;
@@ -242,9 +253,9 @@
self.targetPosture = newPosture;
};
self.restore = function () {
log("restore...");
- self.x = 400;
+ self.x = self.previousX || 400;
self.y = linesGroundLevels[self.lineIndex];
self.speedY = 0;
self.trunk.rotation = 0;
self.rightArm.rotation = idlePosture.rightArm.r;
@@ -340,11 +351,12 @@
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 numberOfLines = 1 + numberOfOpponents;
+var numberOfObstacles = 3;
var obstacles = [[], []];
var obstacleSpawnTicker = 0;
-var obstacleSpawnRate = 9999; // 180; // Spawn an obstacle every 2 seconds //TEMP DEBUG
+var obstacleSpawnRate = 180; // Spawn an obstacle every 2 seconds //TEMP DEBUG
var obstacleJustPassed = false;
var track;
var track2;
var track3;
@@ -513,9 +525,9 @@
}
function gamePlaying() {
//log("Game playing...");
// Spawn obstacles
- spawnObstacles();
+ //spawnObstacles();
// Update obstacles
updateObstacles();
// Update tracks
updateTracks();
@@ -525,14 +537,8 @@
for (var i = numberOfOpponents - 1; i >= 0; i--) {
opponents[i].update();
game.addChild(opponents[i]);
}
- /*
- opponents.forEach(function (opponent) {
- opponent.update();
- game.addChild(opponent);
- });
- */
// Update athlete
athlete.update();
game.addChild(athlete);
// Check for collisions
@@ -542,21 +548,15 @@
game.removeChild(startText);
game.removeChild(startButton);
}
function initPlayingState() {
+ // Spawn obstacles
+ spawnObstacles();
// Initialize opponents
for (var i = numberOfOpponents - 1; i >= 0; i--) {
opponents[i] = game.addChild(new Athlete(i + 1));
opponents[i].restore();
}
- /*
- opponents[2] = game.addChild(new Athlete(3));
- opponents[0] = game.addChild(new Athlete(1));
- opponents[1] = game.addChild(new Athlete(2));
- opponents[0].restore();
- opponents[1].restore();
- opponents[2].restore();
- */
// Initialize athlete
athlete = game.addChild(new Athlete(0));
athlete.restore();
gameState = GAME_STATE.PLAYING;
@@ -572,16 +572,30 @@
track4.update();
}
}
function spawnObstacles() {
- // Spawn obstacles
+ /*
+ // 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] || [];
+ 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);
+ }
+ }
+ */
+ // Spawn obstacles - V2 : All obstacles are spawned at the same time
+ for (var line = 0; line < numberOfLines; line++) {
+ obstacles[line] = [];
+ for (var i = 0; i < numberOfObstacles; i++) {
+ // 3 obstacles per line
var newObstacle = new Obstacle(line);
- newObstacle.x = 2048 + 100 * line; // Start from the right edge
+ newObstacle.x = (2048 + 90 * line) * (i + 1); // Start from the right edge
newObstacle.y = groundLevel + 200 - 220 * line;
obstacles[line].push(newObstacle);
game.addChild(newObstacle);
}
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.