User prompt
each time the player successfully goes to the next path step, a star FX should be displayed around the path step.
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading '0')' in or related to this line: 'if (self.pathPositions[0]) {' Line Number: 191
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in or related to this line: 'if (self.curStep < self.pathPositions.length) {' Line Number: 181
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in or related to this line: 'if (self.curStep < self.pathPositions.length) {' Line Number: 178
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'x')' in or related to this line: 'player.init(self.pathPositions[0].x, self.pathPositions[0].y);' Line Number: 176
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: popup is not defined' in or related to this line: 'popup.close();' Line Number: 251
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: LK.Popup is not a constructor' in or related to this line: 'var popup = new LK.Popup();' Line Number: 247
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: LK.createPopup is not a function' in or related to this line: 'var popup = LK.createPopup();' Line Number: 247
User prompt
Please fix the bug: 'TypeError: LK.Popup is not a function' in or related to this line: 'var popup = LK.Popup();' Line Number: 247
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'create')' in or related to this line: 'var popup = LK.Popup.create();' Line Number: 247
User prompt
Please fix the bug: 'TypeError: LK.Popup is not a constructor' in or related to this line: 'var popup = new LK.Popup();' Line Number: 247
Code edit (1 edits merged)
Please save this source code
Code edit (5 edits merged)
Please save this source code
User prompt
create a function that display a popup with title "Congratulations !" and a button "Next level".
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'x')' in or related to this line: 'player.ball1.x = self.pathSteps[0].x;' Line Number: 170
Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'x')' in or related to this line: 'player.ball1.x = self.pathSteps[0].x;' Line Number: 169
Code edit (1 edits merged)
Please save this source code
/**** * Classes ****/ var Ball = Container.expand(function (assetName) { var self = Container.call(this); self.rotating = false; self.angle = 0; self.attachAsset(assetName, { anchorX: 0.5, anchorY: 0.5 }); self.rotateAround = function (otherBall) { self.angle += 0.05; self.rotation = self.angle + 1.57; otherBall.rotation = self.rotation + 3.14; self.x = otherBall.x + otherBall.width * 2 * Math.cos(self.angle); self.y = otherBall.y + otherBall.width * 2 * Math.sin(self.angle); }; }); var FirstPathStep = Container.expand(function () { var self = Container.call(this); self.attachAsset('firstStep', { anchorX: 0.5, anchorY: 0.5 }); }); var LastPathStep = Container.expand(function () { var self = Container.call(this); self.attachAsset('lastStep', { anchorX: 0.5, anchorY: 0.5 }); }); var Path = Container.expand(function () { var self = Container.call(this); self.pathSteps = []; self.pathPositions = [{ x: 1024, y: 2400 }, { x: 1024, y: 2200 }, { x: 824, y: 2200 }, { x: 824, y: 2000 }, { x: 824, y: 1800 }, { x: 1024, y: 1800 }, { x: 1224, y: 1800 } /*, { x: 1424, y: 1800 }, { x: 1424, y: 2000 }, { x: 1424, y: 2200 }, { x: 1624, y: 2200 }, { x: 1824, y: 2200 }, { x: 1824, y: 2000 }, { x: 1824, y: 1800 }, { x: 1824, y: 1600 }, { x: 1824, y: 1400 }, { x: 1824, y: 1200 }, { x: 1624, y: 1200 }, { x: 1424, y: 1200 }, { x: 1224, y: 1200 }, { x: 1024, y: 1200 }, { x: 824, y: 1200 }, { x: 624, y: 1200 }, { x: 624, y: 1000 }, { x: 624, y: 800 }, { x: 624, y: 600 }, { x: 624, y: 400 }, { x: 624, y: 200 }, { x: 824, y: 200 }, { x: 1024, y: 200 }, { x: 1224, y: 200 }, { x: 1424, y: 200 }*/]; self.addPathStep = function (position) { var step; if (self.curStep == 0) { step = self.addChild(new FirstPathStep()); } else if (self.curStep == self.pathPositions.length - 1) { step = self.addChild(new LastPathStep()); } else { step = self.addChild(new PathStep()); } step.x = position.x; step.y = position.y; self.pathSteps.push(step); }; self.curStep = 0; self.nextStep = function () { if (self.curStep < self.pathPositions.length) { self.addPathStep(self.pathPositions[self.curStep]); self.curStep++; } }; self.setupPlayer = function (player) { for (var i = 0; i < 10; i++) { self.nextStep(); } ball1.x = self.pathSteps[0].x; ball1.y = self.pathSteps[0].y; ball1.rotating = false; ball2.rotating = true; }; }); var PathStep = Container.expand(function () { var self = Container.call(this); self.attachAsset('step', { anchorX: 0.5, anchorY: 0.5 }); }); var Player = Container.expand(function () { var self = Container.call(this); var ball1 = self.addChild(new Ball('playerBall1')); var ball2 = self.addChild(new Ball('playerBall2')); ball2.rotating = true; self.move = function (x, y) { self.x = x; self.y = y; }; self.click = function () { var tempRotating = ball1.rotating; ball1.rotating = ball2.rotating; ball2.rotating = tempRotating; if (ball1.rotating) { ball1.rotation = ball1.angle = Math.atan2(ball1.y - ball2.y, ball1.x - ball2.x); } else if (ball2.rotating) { ball2.rotation = ball2.angle = Math.atan2(ball2.y - ball1.y, ball2.x - ball1.x); } var onStep1 = false; var onStep2 = false; var smallPathStep = 9999; for (var i = 0; i < path.pathSteps.length; i++) { if (path.pathSteps[i] && path.pathSteps[i].intersects(ball1)) { onStep1 = true; smallPathStep = Math.min(smallPathStep, i); } if (path.pathSteps[i] && path.pathSteps[i].intersects(ball2)) { onStep2 = true; smallPathStep = Math.min(smallPathStep, i); } } if (!(onStep1 && onStep2)) { LK.showGameOver(); } else { path.removeChild(path.pathSteps[smallPathStep]); path.pathSteps.splice(smallPathStep, 1); path.nextStep(); if (path.pathSteps.length == 1) { path = new Path(); path.setupPlayer(player); game.addChild(path); } } }; self.rotate = function () { if (ball1.rotating) { ball1.rotateAround(ball2); } else if (ball2.rotating) { ball2.rotateAround(ball1); } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Init game with black background }); /**** * Game Code ****/ // Initialize player ship asset // Initialize obstacle asset // Initialize background stars var background = game.addChild(LK.getAsset('background', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366 })); var player = new Player(); player.x = 1024; // Center horizontally player.y = 2400; // Position towards the bottom var path = new Path(); path.setupPlayer(player); game.addChild(path); game.addChild(player); game.on('down', function (obj) { player.click(); }); LK.on('tick', function () { // Move obstacles player.rotate(); });
===================================================================
--- original.js
+++ change.js
@@ -154,14 +154,12 @@
self.setupPlayer = function (player) {
for (var i = 0; i < 10; i++) {
self.nextStep();
}
- if (self.pathSteps[0]) {
- player.ball1.x = self.pathSteps[0].x;
- player.ball1.y = self.pathSteps[0].y;
- player.ball1.rotating = false;
- player.ball2.rotating = true;
- }
+ ball1.x = self.pathSteps[0].x;
+ ball1.y = self.pathSteps[0].y;
+ ball1.rotating = false;
+ ball2.rotating = true;
};
});
var PathStep = Container.expand(function () {
var self = Container.call(this);
tête de mort rouge. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
tête de mort coter droit en bleu coter gauche en rouge. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
tourbillon bleu et rouge. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
bone. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
tourbillon rouge et bleu. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.