User prompt
liderlik tablosunu biraz sağa taşı
User prompt
liderlik tablosunu biraz sağa taşı
User prompt
liderlik tablosunu biraz sağa taşı
User prompt
liderlik tablosunu biraz sağa taşı
User prompt
sağa al liderlik tablosunu
User prompt
bi bu kadar daha sola al liderlik tablosunu
User prompt
tuşları çok sağa al
User prompt
tuşları biraz sağa al
User prompt
biraz yukarı al
User prompt
yazı fontunu büyüt
User prompt
biraz sola al çok a
User prompt
biraz sola az
User prompt
biraz sola al
User prompt
biraz sola al
User prompt
biraz sola al
User prompt
bi bu kadar daha sola al
User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'storage.leaderboard.push([playerName, score]);' Line Number: 246
User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'storage.leaderboard.push({' Line Number: 246
User prompt
yapılan skorların yanında kimin yaptığını yaz bunun için sitedeki ismin kullan
User prompt
bi bu kadar daha sola al
User prompt
şimdi sola al biraz
User prompt
liderlik tablosunun yazı fontunu büyüt
User prompt
liderlik tablosunu tuşların hemen soluna ekle
User prompt
liderlik tablosunu sol alta taşı 4 kademesi olsun ilk 3 bütün zamanlarda en yüksek skorları yapanlar sıralansın 4.de oynayan kişinin en yüksek skorunu göstersin
User prompt
ldierlik tablosnu ekrana yerleştir
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
// Define the Button class
var Button = Container.expand(function () {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('button', {
anchorX: 0.5,
anchorY: 0.5
});
return self;
});
// Define the Obstacle class
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5; // Initial speed
// Update method for obstacle movement
self.update = function () {
self.x -= self.speed;
};
return self;
});
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Define the Player class
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('character', {
anchorX: 0.5,
anchorY: 0.5
});
self.layer = 1; // Start on the middle layer
self.speed = 10; // Initial speed
// Method to move the player up a layer
self.moveUp = function () {
if (self.layer > 0) {
LK.getSound('jump').play();
self.layer--;
tween(self, {
y: self.y - 450
}, {
duration: 300,
easing: tween.easeInOut
});
}
};
// Method to move the player down a layer
self.moveDown = function () {
if (self.layer < 2) {
LK.getSound('jump').play();
self.layer++;
tween(self, {
y: self.y + 450
}, {
duration: 300,
easing: tween.easeInOut
});
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x0000FF //Init game with blue background
});
/****
* Game Code
****/
var background = game.attachAsset('background', {
anchorX: 0.0,
anchorY: 0.0
});
background.x = 0;
background.y = 0;
// Play 'macera' music track in a loop
LK.playMusic('macera');
var player = new Player();
player.x = 200;
player.y = 1366 - 450; // Start on the middle layer
game.addChild(player);
// Add squares to each layer
var layers = [-450, 0, 450];
layers.forEach(function (layer) {
var square = LK.getAsset('box1', {
anchorX: 0.5,
anchorY: 0.5
});
square.x = 1024; // Center horizontally
square.y = 1366 - 300 + layer; // Position based on layer, moved further down
game.addChild(square);
});
// Create a variable to keep track of the current character asset
var characterAssets = ['character', 'c2', 'c3', 'c4'];
var currentCharacterAsset = 0;
// Create a timer to change the character asset every 0.2 seconds
LK.setInterval(function () {
// Remove the current character asset
player.removeChild(player.children[0]);
// Update the current character asset index
currentCharacterAsset = (currentCharacterAsset + 1) % characterAssets.length;
// Attach the new character asset
player.attachAsset(characterAssets[currentCharacterAsset], {
anchorX: 0.5,
anchorY: 0.5
});
}, 200);
// Initialize buttons
var buttonUp = new Button();
buttonUp.x = 1024;
buttonUp.y = 2732 - 600; // Position at the bottom of the screen
buttonUp.scale.set(2); // Increase the size of the button
game.addChild(buttonUp);
var buttonDown = new Button();
buttonDown.x = 1024;
buttonDown.y = 2732 - 300; // Position at the bottom of the screen
buttonDown.scale.set(2); // Increase the size of the button
buttonDown.rotation = Math.PI; // Rotate the button by 180 degrees
game.addChild(buttonDown);
// Initialize obstacles array
var obstacles = [];
// Initialize score
var score = 0;
var scoreTxt = new Text2('0', {
size: 150,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Display leaderboard
var leaderboardTxt = new Text2('Leaderboard:\n' + (storage.leaderboard || []).join('\n'), {
size: 50,
fill: 0xFFFFFF
});
leaderboardTxt.anchor.set(0, 0);
LK.gui.topLeft.addChild(leaderboardTxt);
// Function to create obstacles
function createObstacle() {
var lanes = [-450, 0, 450];
var selectedLanes = [lanes[Math.floor(Math.random() * lanes.length)]];
// 30% chance to spawn a second obstacle in a different lane
if (Math.random() < 0.3) {
var secondLane;
do {
secondLane = lanes[Math.floor(Math.random() * lanes.length)];
} while (selectedLanes.includes(secondLane));
selectedLanes.push(secondLane);
}
selectedLanes.forEach(function (lane) {
var obstacle = new Obstacle();
obstacle.x = 2048;
obstacle.y = 1366 - 350 + lane;
obstacles.push(obstacle);
game.addChild(obstacle);
});
}
// Function to update game speed
function updateSpeed() {
var speedIncrease = score * 0.01; // Increase speed based on score
player.speed += speedIncrease;
obstacles.forEach(function (obstacle) {
obstacle.speed += speedIncrease;
});
}
// Handle swipe up and down
game.move = function (x, y, obj) {
if (obj.event && obj.event.deltaY < 0) {
player.moveUp();
} else if (obj.event && obj.event.deltaY > 0) {
player.moveDown();
}
};
// Handle button presses
buttonUp.down = function (x, y, obj) {
if (!buttonUp.cooldown && !buttonDown.cooldown) {
player.moveUp();
buttonUp.cooldown = true;
buttonDown.cooldown = true;
LK.setTimeout(function () {
buttonUp.cooldown = false;
buttonDown.cooldown = false;
}, 310);
}
};
buttonDown.down = function (x, y, obj) {
if (!buttonUp.cooldown && !buttonDown.cooldown) {
player.moveDown();
buttonUp.cooldown = true;
buttonDown.cooldown = true;
LK.setTimeout(function () {
buttonUp.cooldown = false;
buttonDown.cooldown = false;
}, 310);
}
};
// Game update loop
game.update = function () {
// Update obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
obstacles[i].update();
if (obstacles[i].x < -100) {
obstacles[i].destroy();
obstacles.splice(i, 1);
score++;
scoreTxt.setText(score);
// Save the score to the leaderboard
storage.leaderboard = storage.leaderboard || [];
storage.leaderboard.push(score);
storage.leaderboard.sort(function (a, b) {
return b - a;
});
storage.leaderboard = storage.leaderboard.slice(0, 10);
}
if (obstacles[i] && obstacles[i].intersects(player)) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
}
// Create new obstacles
if (LK.ticks % 120 == 0) {
createObstacle();
}
// Update speed
updateSpeed();
};