Code edit (23 edits merged)
Please save this source code
User prompt
add a global array levelConfigs that contains an object for each level. each object is the config of a level and have the following properties : name, coinValue, baseSpeed
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
in decoration reset log // Add left & right startX & endX here
Code edit (1 edits merged)
Please save this source code
User prompt
inside Decoration replace all leftEndX by self.leftEndX
User prompt
Please fix the bug: 'ReferenceError: leftStartX is not defined' in or related to this line: 'self.x = leftStartX;' Line Number: 259
User prompt
in Decoration, make leftEndX a property self.leftEndX; don't forget any previous ref
User prompt
Please fix the bug: 'ReferenceError: leftStartX is not defined' in or related to this line: 'leftEndX = leftStartX - xOffset * rand;' Line Number: 254
User prompt
Please fix the bug: 'ReferenceError: leftStartX is not defined' in or related to this line: 'var leftEndX = leftStartX - xOffset * (1.5 + rand);' Line Number: 184
User prompt
in Decoration, make leftStartX a property self.leftStartX
Code edit (8 edits merged)
Please save this source code
User prompt
Make the killing hit flash last longer
Code edit (1 edits merged)
Please save this source code
Code edit (8 edits merged)
Please save this source code
User prompt
There's a problem for decorations, they sometimes appear with a big size, not respecting the height dependency on progress. can you find why ?
Code edit (1 edits merged)
Please save this source code
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
===================================================================
--- original.js
+++ change.js
@@ -44,10 +44,10 @@
var tempSpeed = currentSpeed * 0.05 + currentSpeed * (self.progress * 3);
newSpeed = tempSpeed;
self.y += newSpeed;
// Move innerLineLeft x progressively to innerLeftLineEndX
- if (self.pathIndex == 0 && self.x != self.leftEndX) {
- self.x = self.leftStartX + (self.leftEndX - self.leftStartX) * self.progress;
+ 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;
}
@@ -148,10 +148,10 @@
var rand = Math.random();
self.leftStartX = baseLeftStartX; // - rand * xOffset;
self.leftEndX = self.leftStartX - xOffset * (1.5 + rand);
var baseRightStartX = 1280;
- var rightStartX = baseRightStartX; // + rand * xOffset / 2;
- var rightEndX = rightStartX + xOffset * (1.5 + rand);
+ self.rightStartX = baseRightStartX; // + rand * xOffset / 2;
+ self.rightEndX = self.rightStartX + xOffset * (1.5 + rand);
self.assetWidthRatios = [100 / 300, 1];
self.endSizes = [600, 600];
var startSize = 1;
self.assetIndex = Math.floor(Math.random() * self.assets.length);
@@ -172,21 +172,22 @@
self.progress = Math.max(0, self.y - startY) / (endY - startY); // Update progress property
// Move innerLineLeft x progressively to innerLeftLineEndX
if (self.index == 7) {
//console.log("Decoration " + self.index + " update - p=", self.progress, "x:", Math.round(self.x), "y:", Math.round(self.y));
+ //console.log(self.progress);
}
if (self.pathIndex == 0 && self.x > self.leftEndX) {
- self.x = self.leftStartX + (self.leftEndX - self.leftStartX) * self.progress;
+ self.x = self.leftStartX + (self.leftEndX - self.leftStartX) * self.progress * 3;
}
- if (self.pathIndex == 1 && self.x < rightEndX) {
- self.x = rightStartX + (rightEndX - rightStartX) * self.progress;
+ if (self.pathIndex == 1 && self.x < self.rightEndX) {
+ self.x = self.rightStartX + (self.rightEndX - self.rightStartX) * self.progress * 3;
}
if (self.y > endY + self.endSizes[self.assetIndex] / 2) {
//self.y = -startSize; // Move obstacle back to the top
self.reset();
}
//mainGraphics = self.assets[self.assetIndex];
- mainGraphics.height = startSize + (self.endSizes[self.assetIndex] - startSize) * self.progress;
+ mainGraphics.height = startSize + (self.endSizes[self.assetIndex] - startSize) * self.progress * 2;
mainGraphics.width = mainGraphics.height * self.assetWidthRatios[self.assetIndex];
if (self.index == 8 && mainGraphics.width > 200) {
//console.log("Decoration " + self.index + " update - assetIndex:", self.assetIndex, "width:", mainGraphics.width, "x:", Math.round(self.x), "y:", Math.round(self.y));
}
@@ -219,21 +220,21 @@
if (self.index == 1 && mainGraphics.width > 200) {
//console.log("=== Decoration " + self.index + " reset - assetIndex:", self.assetIndex, "width:", mainGraphics.width, "y:", self.y, " ===");
}
self.leftStartX = baseLeftStartX; // - rand * xOffset;
- self.leftEndX = self.leftStartX - xOffset * (0.5 + rand);
- rightStartX = baseRightStartX; // + rand * xOffset;
- rightEndX = rightStartX + xOffset * (0.5 + rand);
+ self.leftEndX = self.leftStartX - xOffset * (1 + rand);
+ self.rightStartX = baseRightStartX; // + rand * xOffset;
+ self.rightEndX = self.rightStartX + xOffset * (1 + rand);
if (self.index == 1) {
console.log("=== Decoration " + self.index);
console.log("Left StartX:", self.leftStartX, "Left EndX:", self.leftEndX);
- console.log("Right StartX:", rightStartX, "Right EndX:", rightEndX);
+ console.log("Right StartX:", self.rightStartX, "Right EndX:", self.rightEndX);
}
self.pathIndex = Math.floor(rand * 2);
if (self.pathIndex === 0) {
self.x = self.leftStartX;
} else {
- self.x = rightStartX;
+ self.x = self.rightStartX;
}
self.ready = true;
};
});
@@ -246,9 +247,9 @@
anchorX: 0.5,
anchorY: 0.5
});
var speed = 5;
- var startY = roadTop - 1;
+ var startY = roadTop - 20;
var endY = startY + roadHeight;
var leftStartX = 1024 - 100;
var leftEndX = 1024 - 650;
var rightStartX = 1024 + 100;
@@ -287,10 +288,10 @@
self.progress = Math.max(0, self.y - startY) / (endY - startY);
killerGraphics.width = startSize + (endSize - startSize) * self.progress;
debugTxt.setText(self.progress.toFixed(2));
killerGraphics.height = assetHeightRatio * killerGraphics.width;
- var tempSpeed = currentSpeed * 0.5 + currentSpeed * (self.progress * 5);
- var newSpeed = currentSpeed * 5;
+ var tempSpeed = currentSpeed * 0.5 + currentSpeed * (self.progress * 3);
+ var newSpeed = currentSpeed * 3;
newSpeed = tempSpeed * 1;
self.y += newSpeed;
if (self.pathIndex == 0 && self.x != leftEndX) {
self.x = leftStartX + (leftEndX - leftStartX) * self.progress;
@@ -857,40 +858,21 @@
/****
* Game Code
****/
-function _toConsumableArray(r) {
- return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
-}
-function _nonIterableSpread() {
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
-}
-function _unsupportedIterableToArray(r, a) {
- if (r) {
- if ("string" == typeof r) {
- return _arrayLikeToArray(r, a);
- }
- var t = {}.toString.call(r).slice(8, -1);
- return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
- }
-}
-function _iterableToArray(r) {
- if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) {
- return Array.from(r);
- }
-}
-function _arrayWithoutHoles(r) {
- if (Array.isArray(r)) {
- return _arrayLikeToArray(r);
- }
-}
-function _arrayLikeToArray(r, a) {
- (null == a || a > r.length) && (a = r.length);
- for (var e = 0, n = Array(a); e < a; e++) {
- n[e] = r[e];
- }
- return n;
-}
+var levelConfigs = [{
+ name: "Level 1",
+ coinValue: 1,
+ baseSpeed: 10
+}, {
+ name: "Level 2",
+ coinValue: 5,
+ baseSpeed: 15
+}, {
+ name: "Level 3",
+ coinValue: 10,
+ baseSpeed: 20
+}];
var stripes = [];
var nbDecorations = 10;
var decorations = [];
// Initialize arrays and variables
@@ -940,9 +922,9 @@
function easeInOutQuad(t) {
return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
}
function updateBackgroundColor() {
- var time = new Date().getTime() * 0.0002;
+ var time = 1000 + new Date().getTime() * 0.0002;
intensity = Math.sin(time) * 127 + 128;
var color = Math.max(32, intensity) << 16 | Math.max(32, intensity) << 8 | Math.max(32, intensity);
background.tint = color;
isNight = intensity < 128;
@@ -1042,10 +1024,8 @@
// Create and attach the road instance to the game
road = game.addChild(new Road());
road.x = 2048 / 2;
road.y = 0;
- // Create and attach the landscape instance to the game
- var landscape = game.addChild(new Landscape());
score = 0;
scoreTxt = new Text2(currentLevel == 1 ? '0¢' : '$0', {
size: 150,
fill: "#ffffff",
@@ -1081,8 +1061,16 @@
player = game.addChild(new Player());
player.frame = 0;
player.x = playerPositions[playerPositionIndex]; // Start at the center position
player.y = playerBaseY;
+ // Create and attach the landscape instance to the game
+ var landscape = game.addChild(new Landscape());
+ var startButton = game.addChild(new StartButton());
+ startButton.x = 2048 / 2;
+ startButton.y = 2732 / 4;
+ // TEMP DEBUG !!!
+ startButton.width = 100;
+ startButton.height = 100;
// Attach a debugMarker asset to the game at position (1000, 0)
debugMarker = game.attachAsset('debugMarker', {
anchorX: 0.5,
anchorY: 0.5
@@ -1094,14 +1082,8 @@
fill: "#ff0000"
});
debugTxt.anchor.set(1, 1); // Set anchor to the bottom right corner
LK.gui.bottomRight.addChild(debugTxt);
- var startButton = game.addChild(new StartButton());
- startButton.x = 2048 / 2;
- startButton.y = 2732 / 4;
- // TEMP DEBUG !!!
- startButton.width = 100;
- startButton.height = 100;
isPlaying = false;
}
gameInitialize();
for (var i = 0; i < stripes.length; i++) {
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