User prompt
adda background
User prompt
make yoshı transform after earnıng 100 poınts
User prompt
track the players hıghest score from prevıous plays ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
show the hıghest score of the player
User prompt
play yu sound when the game ends
User prompt
allow yoshı to eat 3 poısonous apples before dyıng
User prompt
play yu sound every tıme yoshı eats a poısonous apple
User prompt
play yosh sound every tıme yoshı eats an apple
User prompt
add a poısonous apple whıch kılls yoshı ıf he eats ıt
User prompt
make yoshı follow the mouse
User prompt
Please fix the bug: 'Uncaught TypeError: setTimeout is not a function' in or related to this line: 'setTimeout(function () {' Line Number: 42
User prompt
Please fix the bug: 'Uncaught TypeError: LK.effects.move is not a function' in or related to this line: 'LK.effects.move(self, {' Line Number: 41
User prompt
Please fix the bug: 'Uncaught TypeError: LK.effects.moveTo is not a function' in or related to this line: 'LK.effects.moveTo(self, self.x, self.y - self.jumpHeight, 500, function () {' Line Number: 41
Initial prompt
Super Yoshı
/****
* Plugins
****/
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
// Class for the apples
var Apple = Container.expand(function () {
var self = Container.call(this);
var appleGraphics = self.attachAsset('apple', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
};
return self;
});
// Class for the poisonous apples
var PoisonousApple = Container.expand(function () {
var self = Container.call(this);
var appleGraphics = self.attachAsset('poisonousApple', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
};
return self;
});
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Class for the main character, Super Yoshi
var SuperYoshi = Container.expand(function () {
var self = Container.call(this);
var yoshiGraphics = self.attachAsset('yoshi', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 10;
self.jumpHeight = 200;
self.isJumping = false;
self.jump = function () {
if (!self.isJumping) {
self.isJumping = true;
self.y -= self.jumpHeight;
LK.setTimeout(function () {
self.y += self.jumpHeight;
self.isJumping = false;
}, 500);
}
};
self.update = function () {
// Add any continuous updates for Yoshi here
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB // Init game with sky blue background
});
/****
* Game Code
****/
var background = game.addChild(LK.getAsset('background', {
anchorX: 0.0,
anchorY: 0.0,
x: 0,
y: 0
}));
// Black color for poisonous apple
var poisonousApples = [];
var poisonousApplesEaten = 0;
// Function to spawn poisonous apples
function spawnPoisonousApple() {
var poisonousApple = new PoisonousApple();
poisonousApple.x = Math.random() * 2048;
poisonousApple.y = -50;
poisonousApples.push(poisonousApple);
game.addChild(poisonousApple);
}
game.move = function (x, y, obj) {
yoshi.x = x;
yoshi.y = y;
};
var yoshi = game.addChild(new SuperYoshi());
yoshi.x = 2048 / 2;
yoshi.y = 2732 - 150; // Position Yoshi at the bottom of the screen
var apples = [];
var score = 0;
var highestScore = storage.highestScore || 0;
var scoreTxt = new Text2('Score: 0', {
size: 100,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Function to spawn apples
function spawnApple() {
var apple = new Apple();
apple.x = Math.random() * 2048;
apple.y = -50;
apples.push(apple);
game.addChild(apple);
}
// Handle touch events for jumping
game.down = function (x, y, obj) {
yoshi.jump();
};
// Update game state
game.update = function () {
yoshi.update();
for (var i = apples.length - 1; i >= 0; i--) {
apples[i].update();
if (yoshi.intersects(apples[i])) {
score += 1;
if (score > highestScore) {
highestScore = score;
storage.highestScore = highestScore;
if (score >= 100) {
yoshiGraphics = yoshi.attachAsset('superYoshi', {
anchorX: 0.5,
anchorY: 0.5
});
}
}
scoreTxt.setText('Score: ' + score + ', Highest Score: ' + highestScore);
apples[i].destroy();
apples.splice(i, 1);
LK.getSound('yosh').play(); // Play 'yosh' sound
}
}
for (var i = poisonousApples.length - 1; i >= 0; i--) {
poisonousApples[i].update();
if (yoshi.intersects(poisonousApples[i])) {
LK.getSound('yu').play(); // Play 'yu' sound
poisonousApplesEaten += 1;
if (poisonousApplesEaten >= 3) {
LK.getSound('yu').play(); // Play 'yu' sound
LK.showGameOver(); // Game over when Yoshi eats 3 poisonous apples
score = 0;
storage.highestScore = highestScore;
}
poisonousApples[i].destroy();
poisonousApples.splice(i, 1);
}
}
if (LK.ticks % 60 === 0) {
spawnApple();
}
if (LK.ticks % 120 === 0) {
// Spawn a poisonous apple every 120 frames
spawnPoisonousApple();
}
}; ===================================================================
--- original.js
+++ change.js
@@ -75,8 +75,14 @@
/****
* Game Code
****/
+var background = game.addChild(LK.getAsset('background', {
+ anchorX: 0.0,
+ anchorY: 0.0,
+ x: 0,
+ y: 0
+}));
// Black color for poisonous apple
var poisonousApples = [];
var poisonousApplesEaten = 0;
// Function to spawn poisonous apples