User prompt
kullanıcı verilerini kayıt edebiliyormusun yani sol alta liderlik tablosu ekleyebilirmisin ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
döngüdeki her yeni gelen fotoğraf bir önceki fotoğrafın y eksenine göre tersi olsun
User prompt
arka planı döngüye al sürekli sola kaysın ve bitişiğine tekrardan aynı resmi ekle
User prompt
arka planı döngüye al sola doğru kaysın
User prompt
her yer değiştirdiğimizde "jump" efekti çalsın
User prompt
"macera" şarkısı arkada süerkli döngüde çalsın
User prompt
anahtarları koddan kaldır
User prompt
resimlerin katman düzeni şöyle olsun en altta background onun üstünde box1, geri kalan herşey bunların üstünde
User prompt
çoook az ufacık üste taşı
User prompt
bi bu kadar daha taşı
User prompt
mermileri çok az alta taşı ufacık
User prompt
mermileri çok az alta ataşı
User prompt
birazcık üste taşı
User prompt
bi bu kadar daha alta taşı mermileri
User prompt
mermileri biraz alta taşı
User prompt
bi bu kadar daha alta taşı
User prompt
box1 leri biraz alta taşı
User prompt
her katmana bir kare eklensin istiyorum bunlar üzerinde oynama yapıcam
User prompt
döngü istiyorum her 5 puanda bir tekrar anahtar gelsin
User prompt
artık anahtar geldiğinde 3 koridordan birlikte gelsin
User prompt
bunu döngüye çevir Her 5 puanda bir tekrar dan rastgele anahtar gelsin
User prompt
anahtarlar mermilerle aynı koridordan gelemez zaten maksimum 2 mermi geliyor anahtar boş 3.koridordan gelmeli (boş olan koridordan)
User prompt
her 5 puanda bir "key1","key2","key3" herhangi bir koridordan gelsin ve bunları alabilelim alıncadaa 10 ile 1 arasında rastgele bir sayı scoreye eklensin
User prompt
keyleri toplayınca bize 10 ile 1 arasındaa rastgele puan versin bu skora eklensin
User prompt
key1 i alınca skora +2 puan eklensin
/****
* Plugins
****/
var tween = LK.import("@upit/tween.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 Key class
var Key = Container.expand(function () {
var self = Container.call(this);
var keyTypes = ['key1', 'key2', 'key3'];
var keyType = keyTypes[Math.floor(Math.random() * keyTypes.length)];
var keyGraphics = self.attachAsset(keyType, {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
self.x -= 5; // Move the key to the left
};
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) {
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) {
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
****/
function spawnKey() {
var lanes = [-450, 0, 450];
var lane = lanes[Math.floor(Math.random() * lanes.length)];
var key = new Key();
key.x = 2048;
key.y = 1366 - 450 + lane;
game.addChild(key);
// Check for collision with player
key.update = function () {
this.x -= 5;
if (this.intersects(player)) {
if (keyType === 'key1') {
LK.setScore(LK.getScore() + 2); // Increase score by 2 when key1 is collected
} else {
LK.setScore(LK.getScore() + 5); // Increase score by 5 for other keys
}
this.destroy();
}
};
}
var background = game.attachAsset('background', {
anchorX: 0.0,
anchorY: 0.0
});
background.x = 0;
background.y = 0;
// Initialize player
var player = new Player();
player.x = 200;
player.y = 1366 - 450; // Start on the middle layer
game.addChild(player);
// 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);
// 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 - 450 + 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);
}
if (score > 0 && score % 15 === 0 && !game.keySpawned) {
spawnKey();
game.keySpawned = true;
} else if (score % 15 !== 0) {
game.keySpawned = false;
}
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();
};