Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: startFX is not defined' in or related to this line: 'startFX.direction = i;' Line Number: 276
Code edit (1 edits merged)
Please save this source code
User prompt
the starFX should have a direction and move to that direction.
Code edit (3 edits merged)
Please save this source code
User prompt
when a path step disapear, 5 stars should goes from it in every directions.
Code edit (13 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: iffX is not defined' in or related to this line: 'return iffX * diffX + diffY * diffY <= 100;' Line Number: 298
Code edit (1 edits merged)
Please save this source code
User prompt
the startfx playfx function should start a timer which increase each 10 milliseconds the scale and decrease the alpha of the startfx.
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
===================================================================
--- original.js
+++ change.js
@@ -22,8 +22,18 @@
self.attachAsset('firstStep', {
anchorX: 0.5,
anchorY: 0.5
});
+ self.disapear = function () {
+ self.alpha = 1;
+ self.timer = LK.setInterval(function () {
+ self.alpha -= 0.01;
+ if (self.alpha <= 0) {
+ LK.clearInterval(self.timer);
+ self.destroy();
+ }
+ }, 10);
+ };
});
var LastPathStep = Container.expand(function () {
var self = Container.call(this);
self.attachAsset('lastStep', {
@@ -190,8 +200,18 @@
self.attachAsset('step', {
anchorX: 0.5,
anchorY: 0.5
});
+ self.disapear = function () {
+ self.alpha = 1;
+ self.timer = LK.setInterval(function () {
+ self.alpha -= 0.01;
+ if (self.alpha <= 0) {
+ LK.clearInterval(self.timer);
+ self.destroy();
+ }
+ }, 10);
+ };
});
var Player = Container.expand(function () {
var self = Container.call(this);
var ball1 = self.addChild(new Ball('playerBall1'));
@@ -215,26 +235,23 @@
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]) {
+ if (IsMatching(path.pathSteps[i], ball1)) {
+ onStep1 = true;
+ smallPathStep = Math.min(smallPathStep, i);
+ }
+ if (IsMatching(path.pathSteps[i], ball2)) {
+ onStep2 = 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 {
- var starFX = new StarFX();
- starFX.x = path.pathSteps[smallPathStep].x;
- starFX.y = path.pathSteps[smallPathStep].y;
- game.addChild(starFX);
- starFX.playFX();
- path.removeChild(path.pathSteps[smallPathStep]);
+ path.pathSteps[smallPathStep].disapear();
path.pathSteps.splice(smallPathStep, 1);
path.nextStep();
if (path.pathSteps.length == 1) {
showCongratsPopup();
@@ -248,27 +265,8 @@
ball2.rotateAround(ball1);
}
};
});
-var StarFX = Container.expand(function () {
- var self = Container.call(this);
- self.attachAsset('starFX', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.playFX = function () {
- self.scale = 1;
- self.alpha = 1;
- self.timer = LK.setInterval(function () {
- self.scale += 0.01;
- self.alpha -= 0.01;
- if (self.alpha <= 0) {
- LK.clearInterval(self.timer);
- self.destroy();
- }
- }, 100);
- };
-});
/****
* Initialize Game
****/
@@ -281,23 +279,20 @@
****/
// Initialize player ship asset
// Initialize obstacle asset
// Initialize background stars
+var IsMatching = function IsMatching(obj1, obj2) {
+ var diffX = obj1.x - obj2.x;
+ var diffY = obj1.y - obj2.y;
+ return diffX * diffX + diffY * diffY <= 100;
+};
function showCongratsPopup() {
- /*var popup = new LK.Popup();
- popup.setTitle('Congratulations !');
- var nextLevelButton = new LK.Button('Next level');
- nextLevelButton.on('down', function () {*/
- // Add code here to go to the next level
game.removeChild(path);
game.removeChild(player);
path = new Path(path.level + 1);
path.setupPlayer(player);
game.addChild(path);
game.addChild(player);
- /*});
- popup.addButton(nextLevelButton);
- popup.show();*/
}
var background = game.addChild(LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
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.