Code edit (4 edits merged)
Please save this source code
User prompt
add a global nbDecorations
Code edit (5 edits merged)
Please save this source code
User prompt
in Decoration update, also log y
Code edit (4 edits merged)
Please save this source code
User prompt
in decoration class reset(), log assetIndex and size
User prompt
pass i index to Decoration constructor and store it in an index property
User prompt
add a global array for decorations
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: mainGraphics is undefined' in or related to this line: 'mainGraphics.width = startSize;' Line Number: 200
User prompt
Please fix the bug: 'TypeError: mainGraphics is undefined' in or related to this line: 'mainGraphics.width = startSize;' Line Number: 200
User prompt
Please fix the bug: 'TypeError: mainGraphics is undefined' in or related to this line: 'mainGraphics.width = startSize;' Line Number: 200
User prompt
Please fix the bug: 'ReferenceError: mainGraphics is not defined' in or related to this line: 'mainGraphics.width = startSize;' Line Number: 199
User prompt
Please fix the bug: 'ReferenceError: rand is not defined' in or related to this line: 'var leftStartX = baseLeftStartX - rand * xOffset / 2;' Line Number: 180
User prompt
ok apply this
User prompt
Please fix the bug: 'ReferenceError: mainGraphics is not defined' in or related to this line: 'mainGraphics.texture = LK.getAsset(randomAsset, {}).texture;' Line Number: 170
User prompt
I think calling self.attachAsset at each reset may not be performant, there should be a better way
Code edit (1 edits merged)
Please save this source code
User prompt
add a drop shadow to score text
Code edit (9 edits merged)
Please save this source code
User prompt
stop stipes update when isKilled
User prompt
when level == 1; make lampPost not visible
Code edit (1 edits merged)
Please save this source code
Code edit (5 edits merged)
Please save this source code
User prompt
replace if (self.y > roadTop + roadHeight) { self.y -= roadHeight; // Move stripe back to the top self.stripeGraphics.height = 0; // Reset height to initial value self.stripeGraphics.tint = 0xFFFFFF; // Reset tint to initial value } to place thestipe just before the stripe with lowest y
===================================================================
--- original.js
+++ change.js
@@ -148,22 +148,12 @@
var leftEndX = leftStartX - xOffset * (1 + rand);
var baseRightStartX = 1280;
var rightStartX = baseRightStartX + rand * xOffset / 2;
var rightEndX = rightStartX + xOffset * (1 + rand);
- var assetWidthRatio = 1;
- var startSize, endSize;
+ self.assetWidthRatios = [100 / 300, 1];
+ self.endSizes = [600, 400];
+ var startSize = 1;
self.assetIndex = Math.floor(Math.random() * self.assets.length);
- if (self.assetIndex == 0) {
- startSize = 3;
- endSize = 600;
- assetWidthRatio = 100 / 300;
- } else if (self.assetIndex == 1) {
- startSize = 1;
- endSize = 400;
- } else if (self.assetIndex == 2) {
- startSize = 2;
- endSize = 250;
- }
mainGraphics = self.assets[self.assetIndex];
mainGraphics.width = startSize;
mainGraphics.height = startSize;
self.pathIndex = 0;
@@ -173,11 +163,11 @@
}
var newTint = intensityHalf << 16 | intensityHalf << 8 | intensityHalf;
mainGraphics.tint = newTint;
self.progress = Math.max(0, self.y - startY) / (endY - startY); // Update progress property
- mainGraphics = self.assets[self.assetIndex];
- mainGraphics.height = startSize + (endSize - startSize) * self.progress;
- mainGraphics.width = mainGraphics.height * assetWidthRatio;
+ //mainGraphics = self.assets[self.assetIndex];
+ mainGraphics.height = startSize + (self.endSizes[self.assetIndex] - startSize) * self.progress;
+ mainGraphics.width = mainGraphics.height * self.assetWidthRatios[self.assetIndex];
var tempSpeed = currentSpeed * 0.05 + currentSpeed * (self.progress * 3);
var newSpeed = currentSpeed; // + 10 * self.progress;
newSpeed = tempSpeed * 1; // TEMP DEBUG !!!
self.y += newSpeed;
@@ -187,9 +177,9 @@
}
if (self.pathIndex == 1 && self.x != rightEndX) {
self.x = rightStartX + (rightEndX - rightStartX) * self.progress;
}
- if (self.y > endY + endSize / 2) {
+ if (self.y > endY + self.endSizes[self.assetIndex] / 2) {
//self.y = -startSize; // Move obstacle back to the top
self.reset();
}
};
@@ -201,10 +191,10 @@
self.assets.forEach(function (asset, index) {
asset.visible = index === self.assetIndex;
});
mainGraphics = self.assets[self.assetIndex];
- mainGraphics.width = startSize;
mainGraphics.height = startSize;
+ mainGraphics.width = mainGraphics.height * self.assetWidthRatios[self.assetIndex];
leftStartX = baseLeftStartX - rand * xOffset / 2;
leftEndX = leftStartX - xOffset * (1 + rand);
rightStartX = baseRightStartX + rand * xOffset / 2;
rightEndX = rightStartX + xOffset * (1 + rand);
@@ -257,9 +247,9 @@
LK.effects.flashScreen(0xff0000, 1000);
// Spawn MurderShape at player's last position
var murderShape = new MurderShape();
murderShape.x = player.x;
- murderShape.y = player.y;
+ murderShape.y = playerBaseY;
murderShape.fixPosition();
game.addChildAt(murderShape, game.getChildIndex(road) + 1);
return;
}
@@ -869,8 +859,9 @@
}
return n;
}
var stripes = [];
+var decorations = [];
// Initialize arrays and variables
var currentLevel = 1;
var isPlaying = false;
var isKilled = false;
@@ -905,8 +896,9 @@
var isIntersectingObstacle = false; // Flag to track if the player is currently intersecting an obstacle
var lastObstacleHitTime = 0; // Timestamp of the last obstacle hit
var immunityDelay = 500; // Immunity delay in milliseconds
var playerPositionIndex = 1; // Initialize player position index
+var playerBaseY = 2732 - 300;
// Define the three fixed x positions for the player
var playerPositions = [2048 / 5, 2048 / 2, 4 * 2048 / 5];
// Create player
var player;
@@ -1007,12 +999,15 @@
game.addChild(stripe);
stripe.stripeGraphics.height = 1 + 400 * stripe.progress; // Adjust height based on progress
//console.log("Stripe ", i, " y=", stripe.y, " h=", stripe.stripeGraphics.height, " p=", stripe.progress);
}
- // Create and attach a decoration instance to the game
- var newDecoration = new Decoration();
- newDecoration.reset();
- game.addChild(newDecoration);
+ // Create and attach decoration instances to the game
+ for (var i = 0; i < 5; i++) {
+ var newDecoration = new Decoration();
+ newDecoration.reset();
+ decorations.push(newDecoration);
+ game.addChild(newDecoration);
+ }
// Create and attach the road instance to the game
road = game.addChild(new Road());
road.x = 2048 / 2;
road.y = 0;
@@ -1053,9 +1048,9 @@
// Create player
player = game.addChild(new Player());
player.frame = 0;
player.x = playerPositions[playerPositionIndex]; // Start at the center position
- player.y = 2732 - 300;
+ player.y = playerBaseY;
// Attach a debugMarker asset to the game at position (1000, 0)
debugMarker = game.attachAsset('debugMarker', {
anchorX: 0.5,
anchorY: 0.5
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