Code edit (9 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: LK.isSoundPlaying is not a function' in or related to this line: 'if (!LK.isSoundPlaying('ambience')) {' Line Number: 567
User prompt
Please fix the bug: 'TypeError: LK.getSound(...).isPlaying is not a function' in or related to this line: 'if (!LK.getSound('ambience').isPlaying()) {' Line Number: 567
Code edit (5 edits merged)
Please save this source code
User prompt
please play the bounce sound effect where it says so in the comment in line 113
Code edit (1 edits merged)
Please save this source code
Code edit (4 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'addChild')' in or related to this line: 'LK.gui.top.right.addChild(bestScoreTxt);' Line Number: 482
Code edit (10 edits merged)
Please save this source code
User prompt
Migrate to the latest version of LK
Code edit (6 edits merged)
Please save this source code
User prompt
create a graphic for a spiky platform.
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
User prompt
make this line work: ballGraphics.texture = LK.getAsset('newDeathSpriteId', {}).texture;
User prompt
Fix Bug: 'TypeError: ballGraphics.setTextureFromAsset is not a function' in or related to this line: '_iterator.f();' Line Number: 429
User prompt
Fix Bug: 'TypeError: ballGraphics.setTexture is not a function' in or related to this line: '_iterator.f();' Line Number: 429
User prompt
in the deathanim function, ball sprite should change to another one.
Code edit (10 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'setText')' in or related to this line: '_iterator.f();' Line Number: 466
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'setText')' in or related to this line: '_iterator.f();' Line Number: 466
Code edit (1 edits merged)
Please save this source code
User prompt
Every time the player gets points, they should be multiplied by the variable (multiplier-1).
===================================================================
--- original.js
+++ change.js
@@ -8,11 +8,9 @@
* Consider shaft method for difficulty ramping.
* The red platforms have to be really shining up in red, dangerous looking. maybe add spikes.
* Now that player graphic is bigger, it sometimes collides with platforms from below. Either adjust size, spacing
or jump height/logic.
-* The platforms array grows in length over time. Try to remove deleted elements from it, but make backup first,
-because this is where the AI started optimizing to make the game page freeze last time.
-* Player should have three lives - shown as little red hearts in top right corner.
+* Maybe player should have three lives - shown as little red hearts in top right corner.
---------------------
Interface/graphics:
* Show instructions on screen at start.
--------------
@@ -80,33 +78,15 @@
scoreText.setText(newScore.toString());
};
self.updateScore(0); // Initialize with 0 score
});
-/*
-var DepthLabel = Container.expand(function () {
- var self = Container.call(this);
- var depthText = new Text2('0', {
- size: 75,
- fill: "#dddddd"
- });
- depthText.anchor.set(0.5, 0);
- depthText.x = -150;
- self.addChild(depthText);
- self.updateDepthLabel = function (newDepth) {
- depthText.setText(maxDepth.toString());
- };
- self.updateDepthLabel(0); // Initialize with 0 score
-});*/
// Platform class to create movable platforms
var Platform = Container.expand(function () {
var self = Container.call(this);
var platformGraphics = self.attachAsset('platform', {
anchorX: 0.5,
anchorY: 0.5
});
- // Set initial position
- //self.x = game.width / 2;
- //self.y = game.height - 100;
self.width = 200;
self.height = 60; //20;
self.toxic = false;
self.row = 0;
@@ -115,9 +95,17 @@
self.collidable = true;
// Set platform tint based on toxicity
self.setTint = function () {
if (platformGraphics) {
- platformGraphics.tint = this.toxic ? 0xff0000 : 0xffffff;
+ if (this.toxic) {
+ self.removeChild(platformGraphics);
+ platformGraphics = self.attachAsset('spikyPlatform', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ } else {
+ platformGraphics.tint = 0xffffff;
+ }
}
};
self.setTint();
});
@@ -152,17 +140,8 @@
self.velocityBoost = 25;
self.immunityBoost = 0;
self.scoreBoost = 1;
self.rotation = Math.PI / 4;
- /*
- var mulText = new Text2('+1', {
- size: 50,
- fill: "#ffffff",
- outline: true
- });
- mulText.anchor.set(0.5, 0.5);
- self.addChild(mulText);
- */
});
var PowerupFollow = Container.expand(function () {
var self = Container.call(this);
var powerupFollowGraphics = self.attachAsset('powerupFollow', {
@@ -307,9 +286,8 @@
// Set initial position and velocity
self.x = game.width / 2 + 100;
self.y = game.height / 4;
self.velocity = {
- //x: -10,
x: 0,
y: -20
};
self.immunity = 0;
@@ -318,14 +296,8 @@
self.vely = 1;
// Function to update ball position
self.update = function () {
if (this.fallingActivated) {
- /*
- if (self.x > 1024) {
- this.x -= 4;
- } else {
- this.x += 4;
- }*/
this.vely *= 1.1;
this.width *= 1.02;
this.height *= 1.02;
this.rotation = -Math.PI / 4;
@@ -337,13 +309,9 @@
}
} else {
if (self.x > 500 && self.x < 1548) {
self.x += self.velocity.x;
- } /*else {
- platforms.forEach(function (platform) {
- platform.x -= self.velocity.x;
- });
- }*/
+ }
self.velocity.y += 1; // simple gravity
platforms.forEach(function (platform) {
platform.y -= self.velocity.y;
});
@@ -351,109 +319,79 @@
};
// Function to bounce the ball off platforms with a bounce counter
self.bounceCounter = 0;
self.bounce = function (platforms) {
- //platforms.forEach(function (platform) {
- var _iterator = _createForOfIteratorHelper(platforms),
- _step;
- try {
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
- var platform = _step.value;
- if (platform && platform.collidable && platform.alpha == 1) {
- if (self.intersects(platform) && self.velocity.y > 0) {
- // If player has immunity left (from a powerup) he just passes through the platform.
- if (self.immunity > 0) {
- self.immunity--;
- //platform.alpha = 0.2;
- platform.alpha = 0;
- // If immunity is spent, player jumps up, so he has time to dodge a possibly toxic platform below.
- if (self.immunity == 0) {
- self.velocity.y = -30;
- }
- break;
+ for (var i = platforms.length - 1; i > 0; i--) {
+ var platform = platforms[i];
+ if (platform && platform.collidable && platform.alpha == 1) {
+ if (self.intersects(platform) && self.velocity.y > 0) {
+ // If player has immunity left (from a powerup) he just passes through the platform.
+ if (self.immunity > 0) {
+ self.immunity--;
+ platform.alpha = 0;
+ // If immunity is spent, player jumps up, so he has time to dodge a possibly toxic platform below.
+ if (self.immunity == 0) {
+ self.velocity.y = -30;
}
- if (platform.toxic) {
- self.removeChild(self.getChildAt(0));
- //platform.attachAsset('powerupFollowFree', {
- self.attachAsset('newDeathSpriteId', {
+ break;
+ }
+ if (platform.toxic) {
+ self.removeChild(self.getChildAt(0));
+ self.attachAsset('newDeathSpriteId', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.fallingActivated = true;
+ gameEnding = true;
+ break;
+ }
+ self.velocity.y *= -1;
+ if (self.velocity.y < -40) {
+ self.velocity.y = -40;
+ }
+ if (platform.powerupType == "Multiply") {
+ multiplier++;
+ }
+ platform.alpha = 0;
+ if (platform.powerup == false) {
+ var scoreIncrement = multiplier - 1;
+ LK.setScore(LK.getScore() + scoreIncrement);
+ // Create and display score label
+ var scoreLabel = new ScoreLabel(scoreIncrement, self.x, self.y);
+ scoreLabel.updateScore(scoreIncrement);
+ scoreLabels.push(scoreLabel);
+ game.addChild(scoreLabel);
+ }
+ if (platform.powerup == true) {
+ self.velocity.y = platform.velocityBoost;
+ self.immunity = platform.immunityBoost;
+ var scoreIncrement = (multiplier - 1) * platform.scoreBoost;
+ LK.setScore(LK.getScore() + scoreIncrement);
+ // Create and display score label
+ var scoreLabel = new ScoreLabel(scoreIncrement, self.x, self.y);
+ scoreLabel.updateScore(scoreIncrement);
+ scoreLabels.push(scoreLabel);
+ game.addChild(scoreLabel);
+ if (platform.powerupType != "Follow") {
+ platform.destroy();
+ } else {
+ self.followers += 1;
+ platform.removeChild(platform.getChildAt(0));
+ platform.attachAsset(platform.freeGraphicName, {
anchorX: 0.5,
anchorY: 0.5
});
- //LK.effects.flashObject(a, 0xff0000, 1000);
- self.fallingActivated = true;
- gameEnding = true;
- //ballGraphics.texture = LK.getAsset('newDeathSpriteId', {}).texture;
- //LK.showGameOver();
- break;
+ platform.followActivated = true;
+ platform.alpha = 1;
+ platform.collidable = false;
}
- //self.velocity.y = -20;
- self.velocity.y *= -1;
- //self.velocity.y = Math.min ()
- if (self.velocity.y < -40) {
- self.velocity.y = -40;
- }
- //self.velocity.x *= -1;
- //platform.alpha = 0.2;
- if (platform.powerupType == "Multiply") {
- multiplier++;
- }
- platform.alpha = 0;
- if (platform.powerup == false) {
- var scoreIncrement = multiplier - 1;
- LK.setScore(LK.getScore() + scoreIncrement);
- // Create and display score label
- var scoreLabel = new ScoreLabel(scoreIncrement, self.x, self.y);
- scoreLabel.updateScore(scoreIncrement);
- scoreLabels.push(scoreLabel);
- game.addChild(scoreLabel);
- }
- if (platform.powerup == true) {
- //self.velocity.y = 50;
- self.velocity.y = platform.velocityBoost;
- //self.immunity = 10;
- self.immunity = platform.immunityBoost;
- //LK.setScore(LK.getScore() + 10);
- var scoreIncrement = (multiplier - 1) * platform.scoreBoost;
- LK.setScore(LK.getScore() + scoreIncrement);
- // Create and display score label
- var scoreLabel = new ScoreLabel(scoreIncrement, self.x, self.y);
- scoreLabel.updateScore(scoreIncrement);
- scoreLabels.push(scoreLabel);
- game.addChild(scoreLabel);
- if (platform.powerupType != "Follow") {
- platform.destroy();
- } else {
- self.followers += 1;
- /*
- if (platform.powerupFollowGraphics && platform.powerupFollowGraphicsFree) {
- platform.powerupFollowGraphics.visible = false;
- platform.powerupFollowGraphicsFree.visible = true;
- }*/
- platform.removeChild(platform.getChildAt(0));
- //platform.attachAsset('powerupFollowFree', {
- platform.attachAsset(platform.freeGraphicName, {
- anchorX: 0.5,
- anchorY: 0.5
- });
- platform.followActivated = true;
- platform.alpha = 1;
- platform.collidable = false;
- }
- }
- playerScoreLabel.updateScore(LK.getScore());
- if (platform.row > maxDepth) {
- maxDepth = platform.row;
- //maxDepthLabel.updateDepthLabel(maxDepth);
- }
}
+ playerScoreLabel.updateScore(LK.getScore());
+ if (platform.row > maxDepth) {
+ maxDepth = platform.row;
+ }
}
}
- } catch (err) {
- _iterator.e(err);
- } finally {
- if (_iterator && !_iterator.hadError && typeof _iterator.f === 'function') {
- _iterator.f();
- }
}
};
});
@@ -478,94 +416,8 @@
y: 1366 // Centered on y-axis
}));
backgroundGraphic.zIndex = -1; // Ensure it's beneath everything
backgroundGraphic.alpha = 0.8;
-function _createForOfIteratorHelper(o, allowArrayLike) {
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
- if (!it) {
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
- if (it) {
- o = it;
- }
- var i = 0;
- var F = function F() {};
- return {
- s: F,
- n: function n() {
- if (i >= o.length) {
- return {
- done: true
- };
- }
- return {
- done: false,
- value: o[i++]
- };
- },
- e: function e(_e) {
- throw _e;
- },
- f: F
- };
- }
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
- }
- var normalCompletion = true,
- didErr = false,
- err;
- return {
- s: function s() {
- it = it.call(o);
- },
- n: function n() {
- var step = it.next();
- normalCompletion = step.done;
- return step;
- },
- e: function e(_e2) {
- didErr = true;
- err = _e2;
- },
- f: function f() {
- try {
- if (!normalCompletion && it && typeof it["return"] === 'function') {
- it["return"]();
- }
- } finally {
- if (didErr) {
- throw err;
- }
- }
- }
- };
-}
-function _unsupportedIterableToArray(o, minLen) {
- if (!o) {
- return;
- }
- if (typeof o === "string") {
- return _arrayLikeToArray(o, minLen);
- }
- var n = Object.prototype.toString.call(o).slice(8, -1);
- if (n === "Object" && o.constructor) {
- n = o.constructor.name;
- }
- if (n === "Map" || n === "Set") {
- return Array.from(o);
- }
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) {
- return _arrayLikeToArray(o, minLen);
- }
-}
-function _arrayLikeToArray(arr, len) {
- if (len == null || len > arr.length) {
- len = arr.length;
- }
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
- arr2[i] = arr[i];
- }
- return arr2;
-}
var platforms = [];
var scoreLabels = [];
var moveLeftFrames = 0;
var moveRightFrames = 0;
@@ -575,54 +427,30 @@
var gameEnding = false;
// Create player score label
var playerScoreLabel = new PlayerScoreLabel();
LK.gui.top.addChild(playerScoreLabel);
-//var maxDepthLabel = new DepthLabel();
-//LK.gui.topRight.addChild(maxDepthLabel);
// Create 14 rows of 5 platforms each at game start
for (var row = 0; row < rowAmount; row++) {
- /*
- var leftBarrier = new SideBarrier();
- leftBarrier.x = 2048 / 2 - 1100; //-75;
- leftBarrier.y = game.height - 2000 + row * 300;
- leftBarrier.row = row;
- leftBarrier.col = -1;
- platforms.push(leftBarrier);
- game.addChild(leftBarrier);
- */
for (var col = 0; col < 5; col++) {
var platform = new Platform();
if (row < rowAmount / 2) {
- //platform.alpha = 0.2;
platform.alpha = 0;
platform.toxic = false;
} else if (row === Math.ceil(rowAmount / 2)) {
platform.alpha = 1;
platform.toxic = false;
} else {
- //platform.alpha = Math.random() < 0.5 ? 1 : 0.2;
platform.alpha = Math.random() < 0.5 ? 1 : 0;
platform.toxic = Math.random() < 0.1 ? true : false;
}
platform.setTint();
- platform.y = game.height - 2000 + row * 300; // Position platforms vertically
- //platform.x = col * (platform.width + 10) + (game.width - 5 * platform.width - 4 * 10) / 2; // Position platforms horizontally
- //platform.x = 200 + col * (platform.width + 200);
+ platform.y = game.height - 2000 + row * 300;
platform.x = 2048 / 2 + (2 - col) * (platform.width + 200);
platform.row = row;
platform.col = col;
platforms.push(platform);
game.addChild(platform);
}
- /*
- var rightBarrier = new SideBarrier();
- rightBarrier.x = 2048 / 2 + 1100; //2075;
- rightBarrier.y = game.height - 2000 + row * 300;
- rightBarrier.row = row;
- rightBarrier.col = 5;
- platforms.push(rightBarrier);
- game.addChild(rightBarrier);
- */
}
var ball = new Ball();
ball.x = 1024;
game.addChild(ball);
@@ -659,16 +487,12 @@
scoreLabel.update();
}
});
} else {
+ /*
if (LK.ticks % 120 == 0) {
- console.log('Platforms.length is now: ' + platforms.length);
- console.log('platforms[end]:' + platforms[platforms.length - 1]);
- var filteredPlatforms = platforms.filter(function (platform) {
- return platform.hasOwnProperty('powerup'); //.powerup == false;
- });
- platforms = filteredPlatforms;
- }
+ console.log('Platforms.length is now: ' + platforms.length);
+ }*/
scoreLabels.forEach(function (scoreLabel) {
if (scoreLabel.update) {
scoreLabel.update();
}
@@ -678,40 +502,27 @@
// Check for ball bouncing off platforms
ball.bounce(platforms);
if (moveLeftFrames > 0) {
moveLeftFrames--;
- /*
- platforms.forEach(function (platform) {
- platform.x -= 40;
- });
- */
ball.x -= 40;
}
if (moveRightFrames > 0) {
moveRightFrames--;
- /*
- platforms.forEach(function (platform) {
- platform.x += 40;
- });
- */
ball.x += 40;
}
- platforms.forEach(function (platform) {
+ var newPlatforms = [];
+ for (var i = platforms.length - 1; i > 0; i--) {
+ var platform = platforms[i];
if (platform.update) {
platform.update();
}
- /*if (platform instanceof ScoreLabel) {
- platform.update();
- } else*/
if (platform.y < -900) {
platform.y += rowAmount * 300;
platform.row += rowAmount;
// Only randomize normal platforms, not sidebarriers.
if (platform.height < 100) {
- //platform.alpha = Math.random() < 0.5 ? 1 : 0.2;
platform.alpha = Math.random() < 0.55 ? 1 : 0;
platform.toxic = Math.random() < 0.1 ? true : false;
- //platform.setTint();
// Make a shaft
var rowRel = platform.row % 100;
if (platform.col == 0) {
if (rowRel > 10 && rowRel < 20) {
@@ -745,23 +556,23 @@
if (Math.random() < 0.01) {
var t = new PowerupBurst();
t.x = platform.x;
t.y = platform.y - t.height;
- platforms.push(t);
+ newPlatforms.push(t);
game.addChild(t);
} else if (platform.row % 25 == 0 && Math.random() < 0.5) {
var t = new PowerupScore();
t.x = platform.x;
t.y = platform.y - t.height;
t.scoreVal = platform.row;
t.updateLabel(t.scoreVal);
- platforms.push(t);
+ newPlatforms.push(t);
game.addChild(t);
} else if (Math.random() < 0.1) {
var t = new PowerupMultiply();
t.x = platform.x;
t.y = platform.y - t.height / 1.7;
- platforms.push(t);
+ newPlatforms.push(t);
game.addChild(t);
} else if (Math.random() < 0.1) {
if (maxDepth < 50) {
var t = new PowerupFollow();
@@ -782,17 +593,19 @@
}
}
t.x = platform.x;
t.y = platform.y - t.height;
- platforms.push(t);
+ newPlatforms.push(t);
game.addChild(t);
}
}
}
// Powerups don't automatically respawn below when they move off screen top edge.
if (platform.powerup == true) {
platform.destroy();
+ platforms.splice(i, 1);
}
}
- });
+ }
+ platforms.push.apply(platforms, newPlatforms);
}
});
\ No newline at end of file
A happy blue elephant.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
erase.
Make the bird sit inside a birdcage.
Three green arrows pointing down.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A sad little bluebird sitting down.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A happy little bluebird flying.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A happy little green bird flying.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A lush jungle scenery with huge old trees covered in vines and overwrowth, blue sky and forested mountains in the background.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A dark wooden message board with vines and jungle moss growing on top.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A happy little blue elephant, looking scared, facing the viewer, legs flailing as it falls through the air.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A delicious peanut.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
delete