/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Define a class for bullets var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -15; self.update = function () { if (self.y < 0 || self.x < 0 || self.x > 2048) { self.destroy(); return; // Exit early if bullet is destroyed } for (var i = 0; i < ground.length; i++) { if (self.intersects(ground[i])) { if (LK.getSound('patlama1') && !this.soundPlayed) { LK.getSound('patlama1').play(); this.soundPlayed = true; } self.destroy(); return; } } self.y += self.speed; if (self.speedX) { self.x += self.speedX; // Update x position if horizontal speed is set } // Play bullet sound only on the first bullet shot if (!this.soundPlayed) { if (LK.getSound('mermi')) { LK.getSound('mermi').play(); } this.soundPlayed = true; } }; }); // Define a class for enemies var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { if (self.y > 2732) { self.y = 0; self.x = Math.random() * 2048; // Always reset x position return; // Exit early if enemy is reset } self.speed += 0.1; // Increase speed to simulate acceleration self.y += self.speed; }; }); // Define a class for the entity // Define a class for the ground var Ground = Container.expand(function () { var self = Container.call(this); var groundGraphics = self.attachAsset('ground', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Check for intersection with falling entities for (var i = 0; i < enemies.length; i++) { if (self.intersects(enemies[i])) { enemies[i].destroy(); // Destroy the enemy if (LK.getSound('patlama1')) { LK.getSound('patlama1').play(); // Play explosion sound } self.destroy(); // Destroy the ground piece ground.splice(ground.indexOf(self), 1); // Remove the destroyed ground piece from the array enemyKillCounterText.setText('Ground Blocks: ' + ground.length); // Update ground block counter break; // Exit loop after handling collision } } }; }); //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Define a class for the MainCharacter var MainCharacter = Container.expand(function () { var self = Container.call(this); var mainCharacterGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.update = function () { // MainCharacter update logic with gravity, jumping, and horizontal movement if (self.y > 2732 - self.height / 2) { // Check if on the ground self.y = 2732 - self.height / 2 - 300; // Further decrease the y-axis position of the player by 100 self.speedY = 0; self.canJump = true; } else { self.y += self.speedY; // Apply gravity self.speedY += 1; // Gravity effect } if (game.isMouseDown && self.canJump) { self.speedY = -20; // Jump strength self.canJump = false; } // Horizontal movement if (game.keys['ArrowLeft']) { self.x -= self.speed; // Move left } if (game.keys['ArrowRight']) { self.x += self.speed; // Move right } for (var i = 0; i < ground.length; i++) { if (self.intersects(ground[i])) { if (self.y + self.height / 2 >= ground[i].y) { self.y = ground[i].y - self.height / 2 - 1; // Ensure player is slightly above the ground } self.speedY = 0; // Stop falling self.canJump = true; // Allow jumping break; } } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ //<Write imports for supported plugins here> //<Assets used in the game will automatically appear here> var newEntity = LK.getAsset('entity', { anchorX: 0.0, anchorY: 0.0, x: 0, y: 0, scaleX: 2.048, scaleY: 2.732 }); if (!game.children.includes(newEntity)) { game.addChild(newEntity); } // Play background music continuously LK.playMusic('fon'); var protectMessage = new Text2('Protect the Ground', { size: 100, fill: 0x000000 }); protectMessage.anchor.set(0.5, 0.5); protectMessage.x = 0; protectMessage.y = 0; LK.gui.center.addChild(protectMessage); // Remove the message after 3 seconds LK.setTimeout(function () { LK.gui.center.removeChild(protectMessage); }, 3000); // Initialize ground with a flat surface for the character var ground = []; var groundPositions = []; var xPositions = []; var groundWidth = 200; // Width of each ground block var totalGroundWidth = 0; var maxGroundWidth = 2048; // Maximum width of the game area while (totalGroundWidth < maxGroundWidth) { var xPos; do { xPos = Math.floor(Math.random() * (maxGroundWidth / groundWidth)) * groundWidth + groundWidth / 2; } while (xPositions.includes(xPos)); xPositions.push(xPos); groundPositions.push({ x: xPos, y: 2650 // Slightly more increased y position for all ground blocks }); totalGroundWidth += groundWidth; } for (var i = 0; i < groundPositions.length; i++) { var groundPiece = new Ground(); groundPiece.x = groundPositions[i].x; groundPiece.y = groundPositions[i].y; ground.push(groundPiece); game.addChild(groundPiece); } // Create a new layer of ground blocks slightly above the current ground var upperGroundPositions = groundPositions.map(function (pos) { return { x: pos.x, y: pos.y - 200 // Position the new layer 200 pixels above the current ground }; }); for (var i = 0; i < upperGroundPositions.length; i++) { var upperGroundPiece = new Ground(); upperGroundPiece.x = upperGroundPositions[i].x; upperGroundPiece.y = upperGroundPositions[i].y; ground.push(upperGroundPiece); game.addChild(upperGroundPiece); } // Initialize main character with gravity and jumping mechanics var mainCharacter = game.addChild(new MainCharacter()); mainCharacter.x = 2048 / 2; mainCharacter.y = 0; // Set the player's y position to 0 mainCharacter.speedY = 0; // Initial vertical speed mainCharacter.canJump = false; // Initial jump state // Initialize bullets var bullets = []; // Initialize key states for movement game.keys = {}; // Initialize click counter and timing for shooting var clickCounter = 0; var lastClickTime = 0; // Initialize collectibles var collectibles = []; // Initialize enemies with spawning logic var enemies = []; function spawnEnemy() { if (enemies.length < 3) { // Limit to 3 enemies at a time var enemy = new Enemy(); if (ground.length > 0) { var randomGroundIndex = Math.floor(Math.random() * ground.length); enemy.x = ground[randomGroundIndex].x; } else { enemy.x = Math.random() * 2048; // Fallback to random x position if ground is empty } enemy.y = -enemy.height; // Set initial y position above the screen enemies.push(enemy); game.addChild(enemy); } } // Display countdown timer for enemy spawn delay var countdownText = new Text2('Enemies in: 5', { size: 100, fill: 0xFFFFFF }); countdownText.anchor.set(0.5, 0.5); countdownText.x = 2048 / 2; countdownText.y = 2732 / 2 + 150; // Position below the 'Protect the Cave' message LK.gui.center.addChild(countdownText); var countdown = 5; var countdownInterval = LK.setInterval(function () { countdown--; countdownText.setText('Enemies in: ' + countdown); if (countdown <= 0) { LK.clearInterval(countdownInterval); LK.gui.center.removeChild(countdownText); } }, 1000); // Delay enemy spawning to give player time to build a shelter LK.setTimeout(function () { // Initialize enemy spawn interval var enemySpawnInterval = 2000; // Set to 2 seconds // Spawn an enemy at the current interval LK.setInterval(function () { spawnEnemy(); }, enemySpawnInterval); }, 5000); // 5-second delay before enemies start spawning // Handle player movement game.down = function (x, y, obj) { mainCharacter.x = x; // Set the main character's x position to the mouse x position }; // Handle shooting game.up = function (x, y, obj) { // Check if the time between clicks is greater than or equal to 300ms (0.30 seconds) var currentTime = Date.now(); // Check if the time between clicks is greater than or equal to 500ms (0.5 seconds) if (currentTime - lastClickTime >= 500) { // Shoot bullet to the left var leftBullet = new Bullet(); leftBullet.x = mainCharacter.x - mainCharacter.width / 2; leftBullet.y = mainCharacter.y; leftBullet.speedX = -10; // Set horizontal speed for left bullet bullets.push(leftBullet); game.addChild(leftBullet); // Shoot bullet to the right var rightBullet = new Bullet(); rightBullet.x = mainCharacter.x + mainCharacter.width / 2; rightBullet.y = mainCharacter.y; rightBullet.speedX = 10; // Set horizontal speed for right bullet bullets.push(rightBullet); game.addChild(rightBullet); // Shoot bullet forward var forwardBullet = new Bullet(); forwardBullet.x = mainCharacter.x; forwardBullet.y = mainCharacter.y - mainCharacter.height; bullets.push(forwardBullet); game.addChild(forwardBullet); } // Update last click time lastClickTime = currentTime; }; // Initialize enemy kill counter display var enemyKillCounterText = new Text2('Ground Blocks: ' + ground.length, { size: 50, fill: 0xFFFFFF }); enemyKillCounterText.anchor.set(0, 0); enemyKillCounterText.x = 0; enemyKillCounterText.y = 150; LK.gui.topLeft.addChild(enemyKillCounterText); // Initialize survival time display var survivalTimeText = new Text2('Survival Time: 0s', { size: 100, fill: 0xFFFFFF }); survivalTimeText.anchor.set(0.5, 0); survivalTimeText.x = 2048 / 2 - 1000; survivalTimeText.y = 30; // Decrease y position to move text slightly higher LK.gui.top.addChild(survivalTimeText); // Initialize survival time counter var survivalTime = 0; LK.setInterval(function () { survivalTime++; survivalTimeText.setText('Survival Time: ' + survivalTime + 's'); }, 1000); // Add "Glaud" text to top right corner var glaudText = new Text2('Glaud', { size: 50, fill: 0xFF8C00 // Orange color }); glaudText.anchor.set(1, 0); // Anchor to top right glaudText.x = 0; glaudText.y = 10; LK.gui.topRight.addChild(glaudText); // Add a subtle animation to the Glaud text tween(glaudText, { alpha: 0.7 }, { duration: 1000, easing: tween.easeInOut, onFinish: function onFinish() { tween(glaudText, { alpha: 1 }, { duration: 1000, easing: tween.easeInOut, onFinish: function onFinish() { // Repeat the animation tween(glaudText, { alpha: 0.7 }, { duration: 1000, easing: tween.easeInOut }); } }); } }); // Game update loop game.update = function () { // Update main character mainCharacter.update(); // Update enemies for (var i = enemies.length - 1; i >= 0; i--) { if (mainCharacter.intersects(enemies[i])) { if (LK.getSound('deth')) { LK.getSound('deth').play(); // Play 'deth' sound } LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); break; // Exit loop early if game over is triggered } enemies[i].update(); if (enemies[i].y > 2732) { enemies[i].destroy(); enemies.splice(i, 1); } } // Update bullets for (var j = bullets.length - 1; j >= 0; j--) { bullets[j].update(); if (bullets[j].y < 0 || bullets[j].x < 0 || bullets[j].x > 2048) { bullets[j].destroy(); bullets.splice(j, 1); continue; } for (var k = enemies.length - 1; k >= 0; k--) { if (bullets[j].intersects(enemies[k])) { if (LK.getSound('patlama')) { LK.getSound('patlama').play(); } bullets[j].destroy(); bullets.splice(j, 1); enemies[k].destroy(); enemies.splice(k, 1); // Update ground block counter enemyKillCounterText.setText('Survival Time: ' + survivalTime + 's'); // Update survival time display break; } } } };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// Define a class for bullets
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -15;
self.update = function () {
if (self.y < 0 || self.x < 0 || self.x > 2048) {
self.destroy();
return; // Exit early if bullet is destroyed
}
for (var i = 0; i < ground.length; i++) {
if (self.intersects(ground[i])) {
if (LK.getSound('patlama1') && !this.soundPlayed) {
LK.getSound('patlama1').play();
this.soundPlayed = true;
}
self.destroy();
return;
}
}
self.y += self.speed;
if (self.speedX) {
self.x += self.speedX; // Update x position if horizontal speed is set
}
// Play bullet sound only on the first bullet shot
if (!this.soundPlayed) {
if (LK.getSound('mermi')) {
LK.getSound('mermi').play();
}
this.soundPlayed = true;
}
};
});
// Define a class for enemies
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.update = function () {
if (self.y > 2732) {
self.y = 0;
self.x = Math.random() * 2048; // Always reset x position
return; // Exit early if enemy is reset
}
self.speed += 0.1; // Increase speed to simulate acceleration
self.y += self.speed;
};
});
// Define a class for the entity
// Define a class for the ground
var Ground = Container.expand(function () {
var self = Container.call(this);
var groundGraphics = self.attachAsset('ground', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Check for intersection with falling entities
for (var i = 0; i < enemies.length; i++) {
if (self.intersects(enemies[i])) {
enemies[i].destroy(); // Destroy the enemy
if (LK.getSound('patlama1')) {
LK.getSound('patlama1').play(); // Play explosion sound
}
self.destroy(); // Destroy the ground piece
ground.splice(ground.indexOf(self), 1); // Remove the destroyed ground piece from the array
enemyKillCounterText.setText('Ground Blocks: ' + ground.length); // Update ground block counter
break; // Exit loop after handling collision
}
}
};
});
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Define a class for the MainCharacter
var MainCharacter = Container.expand(function () {
var self = Container.call(this);
var mainCharacterGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 10;
self.update = function () {
// MainCharacter update logic with gravity, jumping, and horizontal movement
if (self.y > 2732 - self.height / 2) {
// Check if on the ground
self.y = 2732 - self.height / 2 - 300; // Further decrease the y-axis position of the player by 100
self.speedY = 0;
self.canJump = true;
} else {
self.y += self.speedY; // Apply gravity
self.speedY += 1; // Gravity effect
}
if (game.isMouseDown && self.canJump) {
self.speedY = -20; // Jump strength
self.canJump = false;
}
// Horizontal movement
if (game.keys['ArrowLeft']) {
self.x -= self.speed; // Move left
}
if (game.keys['ArrowRight']) {
self.x += self.speed; // Move right
}
for (var i = 0; i < ground.length; i++) {
if (self.intersects(ground[i])) {
if (self.y + self.height / 2 >= ground[i].y) {
self.y = ground[i].y - self.height / 2 - 1; // Ensure player is slightly above the ground
}
self.speedY = 0; // Stop falling
self.canJump = true; // Allow jumping
break;
}
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
//<Write imports for supported plugins here>
//<Assets used in the game will automatically appear here>
var newEntity = LK.getAsset('entity', {
anchorX: 0.0,
anchorY: 0.0,
x: 0,
y: 0,
scaleX: 2.048,
scaleY: 2.732
});
if (!game.children.includes(newEntity)) {
game.addChild(newEntity);
}
// Play background music continuously
LK.playMusic('fon');
var protectMessage = new Text2('Protect the Ground', {
size: 100,
fill: 0x000000
});
protectMessage.anchor.set(0.5, 0.5);
protectMessage.x = 0;
protectMessage.y = 0;
LK.gui.center.addChild(protectMessage);
// Remove the message after 3 seconds
LK.setTimeout(function () {
LK.gui.center.removeChild(protectMessage);
}, 3000);
// Initialize ground with a flat surface for the character
var ground = [];
var groundPositions = [];
var xPositions = [];
var groundWidth = 200; // Width of each ground block
var totalGroundWidth = 0;
var maxGroundWidth = 2048; // Maximum width of the game area
while (totalGroundWidth < maxGroundWidth) {
var xPos;
do {
xPos = Math.floor(Math.random() * (maxGroundWidth / groundWidth)) * groundWidth + groundWidth / 2;
} while (xPositions.includes(xPos));
xPositions.push(xPos);
groundPositions.push({
x: xPos,
y: 2650 // Slightly more increased y position for all ground blocks
});
totalGroundWidth += groundWidth;
}
for (var i = 0; i < groundPositions.length; i++) {
var groundPiece = new Ground();
groundPiece.x = groundPositions[i].x;
groundPiece.y = groundPositions[i].y;
ground.push(groundPiece);
game.addChild(groundPiece);
}
// Create a new layer of ground blocks slightly above the current ground
var upperGroundPositions = groundPositions.map(function (pos) {
return {
x: pos.x,
y: pos.y - 200 // Position the new layer 200 pixels above the current ground
};
});
for (var i = 0; i < upperGroundPositions.length; i++) {
var upperGroundPiece = new Ground();
upperGroundPiece.x = upperGroundPositions[i].x;
upperGroundPiece.y = upperGroundPositions[i].y;
ground.push(upperGroundPiece);
game.addChild(upperGroundPiece);
}
// Initialize main character with gravity and jumping mechanics
var mainCharacter = game.addChild(new MainCharacter());
mainCharacter.x = 2048 / 2;
mainCharacter.y = 0; // Set the player's y position to 0
mainCharacter.speedY = 0; // Initial vertical speed
mainCharacter.canJump = false; // Initial jump state
// Initialize bullets
var bullets = [];
// Initialize key states for movement
game.keys = {};
// Initialize click counter and timing for shooting
var clickCounter = 0;
var lastClickTime = 0;
// Initialize collectibles
var collectibles = [];
// Initialize enemies with spawning logic
var enemies = [];
function spawnEnemy() {
if (enemies.length < 3) {
// Limit to 3 enemies at a time
var enemy = new Enemy();
if (ground.length > 0) {
var randomGroundIndex = Math.floor(Math.random() * ground.length);
enemy.x = ground[randomGroundIndex].x;
} else {
enemy.x = Math.random() * 2048; // Fallback to random x position if ground is empty
}
enemy.y = -enemy.height; // Set initial y position above the screen
enemies.push(enemy);
game.addChild(enemy);
}
}
// Display countdown timer for enemy spawn delay
var countdownText = new Text2('Enemies in: 5', {
size: 100,
fill: 0xFFFFFF
});
countdownText.anchor.set(0.5, 0.5);
countdownText.x = 2048 / 2;
countdownText.y = 2732 / 2 + 150; // Position below the 'Protect the Cave' message
LK.gui.center.addChild(countdownText);
var countdown = 5;
var countdownInterval = LK.setInterval(function () {
countdown--;
countdownText.setText('Enemies in: ' + countdown);
if (countdown <= 0) {
LK.clearInterval(countdownInterval);
LK.gui.center.removeChild(countdownText);
}
}, 1000);
// Delay enemy spawning to give player time to build a shelter
LK.setTimeout(function () {
// Initialize enemy spawn interval
var enemySpawnInterval = 2000; // Set to 2 seconds
// Spawn an enemy at the current interval
LK.setInterval(function () {
spawnEnemy();
}, enemySpawnInterval);
}, 5000); // 5-second delay before enemies start spawning
// Handle player movement
game.down = function (x, y, obj) {
mainCharacter.x = x; // Set the main character's x position to the mouse x position
};
// Handle shooting
game.up = function (x, y, obj) {
// Check if the time between clicks is greater than or equal to 300ms (0.30 seconds)
var currentTime = Date.now();
// Check if the time between clicks is greater than or equal to 500ms (0.5 seconds)
if (currentTime - lastClickTime >= 500) {
// Shoot bullet to the left
var leftBullet = new Bullet();
leftBullet.x = mainCharacter.x - mainCharacter.width / 2;
leftBullet.y = mainCharacter.y;
leftBullet.speedX = -10; // Set horizontal speed for left bullet
bullets.push(leftBullet);
game.addChild(leftBullet);
// Shoot bullet to the right
var rightBullet = new Bullet();
rightBullet.x = mainCharacter.x + mainCharacter.width / 2;
rightBullet.y = mainCharacter.y;
rightBullet.speedX = 10; // Set horizontal speed for right bullet
bullets.push(rightBullet);
game.addChild(rightBullet);
// Shoot bullet forward
var forwardBullet = new Bullet();
forwardBullet.x = mainCharacter.x;
forwardBullet.y = mainCharacter.y - mainCharacter.height;
bullets.push(forwardBullet);
game.addChild(forwardBullet);
}
// Update last click time
lastClickTime = currentTime;
};
// Initialize enemy kill counter display
var enemyKillCounterText = new Text2('Ground Blocks: ' + ground.length, {
size: 50,
fill: 0xFFFFFF
});
enemyKillCounterText.anchor.set(0, 0);
enemyKillCounterText.x = 0;
enemyKillCounterText.y = 150;
LK.gui.topLeft.addChild(enemyKillCounterText);
// Initialize survival time display
var survivalTimeText = new Text2('Survival Time: 0s', {
size: 100,
fill: 0xFFFFFF
});
survivalTimeText.anchor.set(0.5, 0);
survivalTimeText.x = 2048 / 2 - 1000;
survivalTimeText.y = 30; // Decrease y position to move text slightly higher
LK.gui.top.addChild(survivalTimeText);
// Initialize survival time counter
var survivalTime = 0;
LK.setInterval(function () {
survivalTime++;
survivalTimeText.setText('Survival Time: ' + survivalTime + 's');
}, 1000);
// Add "Glaud" text to top right corner
var glaudText = new Text2('Glaud', {
size: 50,
fill: 0xFF8C00 // Orange color
});
glaudText.anchor.set(1, 0); // Anchor to top right
glaudText.x = 0;
glaudText.y = 10;
LK.gui.topRight.addChild(glaudText);
// Add a subtle animation to the Glaud text
tween(glaudText, {
alpha: 0.7
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(glaudText, {
alpha: 1
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
// Repeat the animation
tween(glaudText, {
alpha: 0.7
}, {
duration: 1000,
easing: tween.easeInOut
});
}
});
}
});
// Game update loop
game.update = function () {
// Update main character
mainCharacter.update();
// Update enemies
for (var i = enemies.length - 1; i >= 0; i--) {
if (mainCharacter.intersects(enemies[i])) {
if (LK.getSound('deth')) {
LK.getSound('deth').play(); // Play 'deth' sound
}
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
break; // Exit loop early if game over is triggered
}
enemies[i].update();
if (enemies[i].y > 2732) {
enemies[i].destroy();
enemies.splice(i, 1);
}
}
// Update bullets
for (var j = bullets.length - 1; j >= 0; j--) {
bullets[j].update();
if (bullets[j].y < 0 || bullets[j].x < 0 || bullets[j].x > 2048) {
bullets[j].destroy();
bullets.splice(j, 1);
continue;
}
for (var k = enemies.length - 1; k >= 0; k--) {
if (bullets[j].intersects(enemies[k])) {
if (LK.getSound('patlama')) {
LK.getSound('patlama').play();
}
bullets[j].destroy();
bullets.splice(j, 1);
enemies[k].destroy();
enemies.splice(k, 1);
// Update ground block counter
enemyKillCounterText.setText('Survival Time: ' + survivalTime + 's'); // Update survival time display
break;
}
}
}
};
bomb pikcel. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
güzel minecraft arka plan gün batımı. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
minecraft steve pikcel. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
ışın yuvarlak lazer skrol. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.