User prompt
Make the ocean, make the background to be ocean blue, and I want it to be an image.
User prompt
Make the background be an ocean
User prompt
Make the background ❤️
User prompt
Once the user collects points worth 100 points, increase the speed of the obstacles and the coins
User prompt
Please fix the bug: 'ReferenceError: newAdditionalObstacle is not defined' in or related to this line: 'if (penguin.intersects(obstacles[i]) || penguin.intersects(newAdditionalObstacle)) {' Line Number: 123
User prompt
Make the coins random too
User prompt
Jumping height should be 50
User prompt
Make the obstacles random
User prompt
Please fix the bug: 'ReferenceError: newAdditionalObstacle is not defined' in or related to this line: 'if (penguin.intersects(obstacles[i]) || penguin.intersects(newAdditionalObstacle)) {' Line Number: 123
User prompt
Add level 2
User prompt
Please fix the bug: 'TypeError: Cannot set properties of undefined (setting 'value')' in or related to this line: 'self.value = 5;' Line Number: 47
User prompt
Please fix the bug: 'TypeError: Cannot set properties of undefined (setting 'value')' in or related to this line: 'self.value = 5;' Line Number: 47
User prompt
The higher coins should be +5, the ones below should be +10. The game ends when the player collects 100 points
User prompt
Please make the game move from left to right
User prompt
Take the coins up near the pingos
User prompt
Include coins for the penguin to pick
User prompt
Include other obstacles
User prompt
Make the space between the pingos to alternate
Code edit (1 edits merged)
Please save this source code
User prompt
Add a counter
User prompt
Make the background to be an ocean
Initial prompt
Pingos
===================================================================
--- original.js
+++ change.js
@@ -9,9 +9,9 @@
anchorY: 0.5
});
self.speed = -5;
self.update = function () {
- self.x -= self.speed;
+ self.x += self.speed;
if (self.x < -100) {
self.destroy();
}
};
@@ -23,15 +23,21 @@
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -5;
+ self.value = 10;
self.update = function () {
- self.x -= self.speed;
+ self.x += self.speed;
if (self.x < -100) {
self.destroy();
}
};
});
+// HighCoin class representing higher coins for the penguin to pick
+var HighCoin = Coin.expand(function () {
+ var self = Coin.call(this);
+ self.value = 5;
+});
// Obstacle class representing obstacles on the path
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('obstacle', {
@@ -39,9 +45,9 @@
anchorY: 0.5
});
self.speed = -5;
self.update = function () {
- self.x -= self.speed;
+ self.x += self.speed;
if (self.x < -100) {
self.destroy();
}
};
@@ -58,14 +64,14 @@
self.jumpHeight = 100;
self.isJumping = false;
self.update = function () {
if (self.isJumping) {
- self.x += self.speed;
- if (self.x >= self.jumpHeight) {
+ self.y -= self.speed;
+ if (self.y <= self.jumpHeight) {
self.isJumping = false;
}
- } else if (self.x < 2048 / 2) {
- self.x += self.speed;
+ } else if (self.y < 2732 / 2) {
+ self.y += self.speed;
}
};
self.jump = function () {
if (!self.isJumping) {
@@ -125,9 +131,9 @@
game.addChild(newAdditionalObstacle);
}
// Add coins every 180 ticks
if (LK.ticks % 180 == 0) {
- var newCoin = new Coin();
+ var newCoin = alternate ? new HighCoin() : new Coin();
newCoin.x = 2048;
newCoin.y = alternate ? 2732 / 3 : 2732 / 2; // Position coins near the pingos
coins.push(newCoin);
game.addChild(newCoin);
@@ -136,13 +142,17 @@
for (var i = coins.length - 1; i >= 0; i--) {
if (penguin.intersects(coins[i])) {
coins[i].destroy();
coins.splice(i, 1);
- score += 10;
+ score += coins[i].value;
}
}
scoreTxt.setText(score);
};
// Event listener for touch down to make the penguin jump
game.down = function (x, y, obj) {
penguin.jump();
-};
\ No newline at end of file
+};
+// End the game when the player collects 100 points
+if (score >= 100) {
+ LK.showGameOver();
+}
\ No newline at end of file