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ı
/**** * 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; }); //<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; LK.effects.moveTo(self, self.x, self.y - self.jumpHeight, 500, function () { LK.effects.moveTo(self, self.x, self.y + self.jumpHeight, 500, function () { self.isJumping = false; }); }); } }; 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 ****/ // Initialize game variables 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 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; scoreTxt.setText('Score: ' + score); apples[i].destroy(); apples.splice(i, 1); } } // Spawn a new apple every 60 frames if (LK.ticks % 60 === 0) { spawnApple(); } };
/****
* 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;
});
//<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;
LK.effects.moveTo(self, self.x, self.y - self.jumpHeight, 500, function () {
LK.effects.moveTo(self, self.x, self.y + self.jumpHeight, 500, function () {
self.isJumping = false;
});
});
}
};
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
****/
// Initialize game variables
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 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;
scoreTxt.setText('Score: ' + score);
apples[i].destroy();
apples.splice(i, 1);
}
}
// Spawn a new apple every 60 frames
if (LK.ticks % 60 === 0) {
spawnApple();
}
};