Code edit (3 edits merged)
Please save this source code
User prompt
in updateBackgroundColor, color should not reach full black, but only very dark gray
Code edit (15 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: xOffset is not a function' in or related to this line: 'leftEndX = leftStartX - xOffset(1 + rand);' Line Number: 210
Code edit (1 edits merged)
Please save this source code
Code edit (17 edits merged)
Please save this source code
User prompt
in game initialize, add a Decoration to the game
Code edit (1 edits merged)
Please save this source code
Code edit (22 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: math is not defined' in or related to this line: 'self.progress = math.max(0, self.y - startY) / (endY - startY); // Update progress property' Line Number: 64
Code edit (1 edits merged)
Please save this source code
Code edit (16 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: roadtop is not defined' in or related to this line: 'self.y = roadtop;' Line Number: 183
User prompt
Please fix the bug: 'ReferenceError: roadtop is not defined' in or related to this line: 'self.y = roadtop;' Line Number: 183
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 (2 edits merged)
Please save this source code
User prompt
NO, now it goes to black !!
User prompt
it's ok, now it goes from gray to white, but just invert it to go from white to gray
User prompt
in Landscape update, newTint should go from gray to white, not from black to gray
===================================================================
--- original.js
+++ change.js
@@ -23,12 +23,10 @@
var leftStartX = 1024 - 100;
var leftEndX = 1024 - 650;
var rightStartX = 1024 + 100;
var rightEndX = 1024 + 650;
- var innerLeftLineStartX = -150;
- var innerLeftLineEndX = -390;
var startSize = 2;
- var endSize = coinGraphics.width;
+ var endSize = 140;
coinGraphics.width = startSize;
coinGraphics.height = startSize;
coinGraphics2.width = startSize;
coinGraphics2.height = startSize;
@@ -122,8 +120,79 @@
self.destroy(); // Remove the coin when it becomes invisible
}
};
});
+// Decoration class
+var Decoration = Container.expand(function () {
+ var self = Container.call(this);
+ var assets = ['decoration1'];
+ self.assetIndex = Math.floor(Math.random() * assets.length);
+ var randomAsset = assets[self.assetIndex];
+ var mainGraphics = self.attachAsset(randomAsset, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var speed = 5;
+ var startY = roadTop + 50;
+ var endY = startY + roadHeight;
+ var leftStartX = 1024 - 100;
+ var leftEndX = 1024 - 650;
+ var rightStartX = 1024 + 100;
+ var rightEndX = 1024 + 650;
+ var innerLeftLineStartX = -150;
+ var innerLeftLineEndX = -390;
+ var startSize, endSize;
+ if (self.assetIndex == 0) {
+ startSize = 3;
+ endSize = 500;
+ } else if (self.assetIndex == 1) {
+ startSize = 1;
+ endSize = 140;
+ } else if (self.assetIndex == 2) {
+ startSize = 2;
+ endSize = 250;
+ }
+ mainGraphics.width = startSize;
+ mainGraphics.height = startSize;
+ self.pathIndex = 0;
+ self.update = function () {
+ if (!isPlaying) {
+ return;
+ }
+ self.progress = Math.max(0, self.y - startY) / (endY - startY); // Update progress property
+ mainGraphics.width = startSize + (endSize - startSize) * self.progress;
+ mainGraphics.height = startSize + (endSize - startSize) * self.progress;
+ var tempSpeed = currentSpeed * 0.05 + currentSpeed * (self.progress * 3);
+ var newSpeed = currentSpeed; // + 10 * self.progress;
+ newSpeed = tempSpeed * 1; // TEMP DEBUG !!!
+ self.y += newSpeed;
+ // Move innerLineLeft x progressively to innerLeftLineEndX
+ if (self.pathIndex == 0 && self.x != leftEndX) {
+ self.x = leftStartX + (leftEndX - leftStartX) * self.progress;
+ }
+ if (self.pathIndex == 2 && self.x != rightEndX) {
+ self.x = rightStartX + (rightEndX - rightStartX) * self.progress;
+ }
+ if (self.y > endY + endSize / 2) {
+ //self.y = -startSize; // Move obstacle back to the top
+ self.reset();
+ }
+ };
+ self.reset = function () {
+ self.y = startY;
+ self.progress = 0; // Initialize progress property
+ mainGraphics.width = startSize;
+ mainGraphics.height = startSize;
+ self.pathIndex = Math.floor(Math.random() * 3);
+ if (self.pathIndex === 0) {
+ self.x = leftStartX;
+ } else if (self.pathIndex === 2) {
+ self.x = rightStartX;
+ } else {
+ self.x = 1024;
+ }
+ };
+});
var Landscape = Container.expand(function () {
var self = Container.call(this);
var landscapeGraphics = self.attachAsset('landscape1', {
anchorX: 0.5,
@@ -154,9 +223,9 @@
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var assets = ['obstacle1', 'obstacle2', 'obstacle3'];
self.assetIndex = Math.floor(Math.random() * assets.length);
- self.assetIndex = 0; // TEMP DEBUG
+ self.assetIndex = 2; // TEMP DEBUG
var randomAsset = assets[self.assetIndex];
var obstacleGraphics = self.attachAsset(randomAsset, {
anchorX: 0.5,
anchorY: 0.5
@@ -174,13 +243,13 @@
if (self.assetIndex == 0) {
startSize = 3;
endSize = 500;
} else if (self.assetIndex == 1) {
- startSize = 60;
- endSize = 120;
+ startSize = 1;
+ endSize = 140;
} else if (self.assetIndex == 2) {
- startSize = 150;
- endSize = 200;
+ startSize = 2;
+ endSize = 250;
}
obstacleGraphics.width = startSize;
obstacleGraphics.height = startSize;
self.pathIndex = 0;
@@ -336,19 +405,19 @@
// Left Lamp
var leftLampStartX = -130;
var leftLampEndX = -2300;
var leftLampStartY = roadTop;
- var leftLampEndY = roadTop + roadHeight + 500; // Define leftLampEndY variable
+ var leftLampEndY = roadTop + roadHeight + 0; // Define leftLampEndY variable
var leftLampStartH = 2;
- var leftLampEndH = 1000;
+ var leftLampEndH = 1600;
var leftLampWRatio = 1 / 3;
// Right Lamp
var rightLampStartX = 130;
var rightLampEndX = 2300;
var rightLampStartY = roadTop;
- var rightLampEndY = roadTop + roadHeight + 500; // Define leftLampEndY variable
+ var rightLampEndY = roadTop + roadHeight + 0; // Define leftLampEndY variable
var rightLampStartH = 2;
- var rightLampEndH = 1000;
+ var rightLampEndH = 1600;
var rightLampWRatio = 1 / 3;
var leftLine = self.attachAsset('triangle', {
anchorX: 0.5,
anchorY: 0,
@@ -501,9 +570,9 @@
// Lamp posts
for (var i = 0; i < self.leftLampPosts.length; i++) {
var leftLampPost = self.leftLampPosts[i];
//leftLampPost.tint = newTint;
- var tempProgress = Math.max(0, leftLampPost.y - leftLampStartY) / leftLampEndY;
+ var tempProgress = Math.max(0, leftLampPost.y - leftLampStartY) / (leftLampEndY - leftLampStartY);
var tempSpeed = currentSpeed * 0.05 + currentSpeed * (tempProgress * 3);
leftLampPost.y += tempSpeed;
/*
if (tempProgress < 0.1) {
@@ -517,9 +586,9 @@
leftLampPost.x = leftLampStartX;
leftLampPost.height = leftLampStartH;
}
leftLampPost.progress = (leftLampPost.y - leftLampStartY) / leftLampEndY; // Update progress property
- leftLampPost.alpha = 0.5 + Math.min(0.5, leftLampPost.progress);
+ leftLampPost.alpha = 0.75 + Math.min(0.25, leftLampPost.progress);
if (i == 0) {
debugTxt.setText(leftLampPost.progress.toFixed(2));
//debugTxt.setText(leftLampPost.y.toFixed(2));
}
@@ -533,9 +602,9 @@
}
for (var i = 0; i < self.rightLampPosts.length; i++) {
var rightLampPost = self.rightLampPosts[i];
//rightLampPost.tint = newTint;
- var tempProgress = Math.max(0, rightLampPost.y - rightLampStartY) / rightLampEndY;
+ var tempProgress = Math.max(0, rightLampPost.y - rightLampStartY) / (rightLampEndY - rightLampStartY);
;
var tempSpeed = currentSpeed * 0.05 + currentSpeed * (tempProgress * 3);
rightLampPost.y += tempSpeed;
/*
@@ -550,9 +619,9 @@
rightLampPost.x = rightLampStartX;
rightLampPost.height = rightLampStartH;
}
rightLampPost.progress = (rightLampPost.y - rightLampStartY) / rightLampEndY;
- rightLampPost.alpha = 0.5 + Math.min(0.5, rightLampPost.progress);
+ rightLampPost.alpha = 0.75 + Math.min(0.25, rightLampPost.progress);
if (rightLampPost.x != rightLampEndX) {
rightLampPost.x = rightLampStartX + (rightLampEndX - rightLampStartX) * rightLampPost.progress;
}
if (rightLampPost.height != leftLampEndH) {
@@ -608,15 +677,17 @@
var intensity = 0;
var intensityHalf = 0;
var leftLampPosts = [];
var rightLampPosts = [];
+var leftDecorations = [];
+var rightDecorationss = [];
var maxSpeed = 50; // Define a maximum speed limit
var currentSpeed = 10; //20; // Initialize currentSpeed
var coinsCollected = 0; // Initialize coins collected counter
var isIntersectingObstacle = false; // Flag to track if the player is currently intersecting an obstacle
var playerPositionIndex = 1; // Initialize player position index
// Define the three fixed x positions for the player
-var playerPositions = [2048 / 6, 2048 / 2, 5 * 2048 / 6];
+var playerPositions = [2048 / 4, 2048 / 2, 3 * 2048 / 4];
// Create player
var player;
var debugMarker;
var debugText;
@@ -764,8 +835,12 @@
var newObstacle = new Obstacle();
newObstacle.reset();
obstacles.push(newObstacle);
game.addChild(newObstacle);
+ // Create and attach a decoration instance to the game
+ var newDecoration = new Decoration();
+ newDecoration.reset();
+ game.addChild(newDecoration);
// Create player
player = game.addChild(new Player());
player.frame = 0;
player.x = playerPositions[playerPositionIndex]; // Start at the center position
Directly overhead, plumb view of a beggar heading top (we see his back).. Zenith view, directly overhead, plumb view. NOT PERSPECTIVE! Fantasy theme. Pixel art
a traffic cone. video game sprite
face view of a big start button in the shape of a dollar bill. video game style
a tree. video game style
a black garbage bag. video game style
Dollar bill. Perspective. video game sprite
perspective of a simple snake rolled up on itself.. video game sprite
Ball of dry desert bushes. video game sprite
tractor. high definition video game sprite
street ad billboard with 1 or 2 posts with "Get rich!" on it. high definition video game sprite
a dog sleeping on a street. video game sprite
desert bush. video game sprite
profile view of an empty motorcycle helmet. black with a white vertical central band and another thiner orange band on the center. NOT PERSPECTIVE!. Pixel art high definition
simple red and white magnet. video game style
gold sign with a "X" and a "2". video game style
bgMusic
Music
coin_1
Sound effect
hit_1
Sound effect
hit_2
Sound effect
hit_3
Sound effect
levelWin_1
Sound effect
car_1
Sound effect
police_1
Sound effect
ambulance_1
Sound effect
accident_1
Sound effect
killed_1
Sound effect
jump_1
Sound effect
rip_1
Sound effect
bonus_take
Sound effect
bonus_approaching
Sound effect