User prompt
leveller ekranda yazsın ve bir ana menü olsun
User prompt
10 level olsun
User prompt
Let the enemies not come to us, but let them stand in the middle like stars
User prompt
Meteors come very fast and we have 10 lives. If the enemy meteor passes us or hits us, we lose our lives.
User prompt
düşmanalar hızlı gelsin
User prompt
biz onlara ateş edelim hemde oyuncunun gözünden olsun
Code edit (1 edits merged)
Please save this source code
User prompt
Survival Rush
Initial prompt
hayatta kalmayla ilgili bir oyun yap
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -8;
self.update = function () {
self.y += self.speed;
};
return self;
});
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5 + Math.random() * 6;
self.direction = Math.random() < 0.5 ? -1 : 1;
self.update = function () {
self.x += self.speed * self.direction;
// Bounce off screen edges
if (self.x <= 50 || self.x >= 2048 - 50) {
self.direction *= -1;
}
};
return self;
});
var Meteor = Container.expand(function () {
var self = Container.call(this);
var meteorGraphics = self.attachAsset('meteor', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 3 + Math.random() * 4;
self.rotationSpeed = (Math.random() - 0.5) * 0.1;
self.update = function () {
self.y += self.speed;
meteorGraphics.rotation += self.rotationSpeed;
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.maxHealth = 100;
self.health = self.maxHealth;
self.shieldActive = false;
self.shieldTimer = 0;
self.update = function () {
// Update shield timer
if (self.shieldActive) {
self.shieldTimer--;
if (self.shieldTimer <= 0) {
self.shieldActive = false;
playerGraphics.tint = 0xffffff;
}
}
};
self.takeDamage = function (amount) {
if (self.shieldActive) return;
self.health -= amount;
if (self.health <= 0) {
self.health = 0;
LK.showGameOver();
return;
}
// Flash red when taking damage
LK.effects.flashObject(self, 0xff0000, 500);
LK.effects.flashScreen(0xff0000, 300);
LK.getSound('damage').play();
// Update health display
healthBar.width = self.health / self.maxHealth * 300;
};
self.activateShield = function () {
self.shieldActive = true;
self.shieldTimer = 300; // 5 seconds at 60fps
playerGraphics.tint = 0x8844ff;
};
self.heal = function (amount) {
self.health = Math.min(self.maxHealth, self.health + amount);
healthBar.width = self.health / self.maxHealth * 300;
};
return self;
});
var PowerUp = Container.expand(function (type) {
var self = Container.call(this);
var powerUpGraphics;
self.type = type;
if (type === 'health') {
powerUpGraphics = self.attachAsset('healthPack', {
anchorX: 0.5,
anchorY: 0.5
});
} else if (type === 'shield') {
powerUpGraphics = self.attachAsset('shield', {
anchorX: 0.5,
anchorY: 0.5
});
}
self.floatOffset = 0;
self.floatSpeed = 0.05;
self.update = function () {
self.floatOffset += self.floatSpeed;
powerUpGraphics.y = Math.sin(self.floatOffset) * 5;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x001122
});
/****
* Game Code
****/
// Game variables
var player;
var meteors = [];
var enemies = [];
var powerUps = [];
var bullets = [];
var gameTime = 0;
var meteorSpawnRate = 120; // frames between meteor spawns
var enemySpawnRate = 180; // frames between enemy spawns
var powerUpSpawnRate = 600; // frames between power-up spawns
var difficultyTimer = 0;
var survivalTime = 0;
var baseScore = 0;
var shootTimer = 0;
var shootRate = 15; // frames between shots
// UI Elements
var scoreText = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreText.anchor.set(0, 0);
scoreText.x = 120;
scoreText.y = 50;
LK.gui.topLeft.addChild(scoreText);
var timeText = new Text2('Time: 0s', {
size: 50,
fill: 0xFFFFFF
});
timeText.anchor.set(0.5, 0);
LK.gui.top.addChild(timeText);
var healthBarBg = LK.getAsset('healthPack', {
anchorX: 0,
anchorY: 0,
scaleX: 7.5,
scaleY: 0.5
});
healthBarBg.tint = 0x440000;
healthBarBg.x = 150;
healthBarBg.y = 2650;
LK.gui.bottomLeft.addChild(healthBarBg);
var healthBar = LK.getAsset('healthPack', {
anchorX: 0,
anchorY: 0,
scaleX: 7.5,
scaleY: 0.5
});
healthBar.tint = 0x44ff44;
healthBar.x = 150;
healthBar.y = 2650;
LK.gui.bottomLeft.addChild(healthBar);
var healthText = new Text2('Health', {
size: 40,
fill: 0xFFFFFF
});
healthText.anchor.set(0, 0.5);
healthText.x = 50;
healthText.y = 2665;
LK.gui.bottomLeft.addChild(healthText);
// Initialize player
player = game.addChild(new Player());
player.x = 1024;
player.y = 2000;
// Drag controls
var dragNode = null;
game.down = function (x, y, obj) {
dragNode = player;
player.x = x;
player.y = y;
};
game.move = function (x, y, obj) {
if (dragNode) {
dragNode.x = Math.max(40, Math.min(2048 - 40, x));
dragNode.y = Math.max(40, Math.min(2732 - 40, y));
}
};
game.up = function (x, y, obj) {
dragNode = null;
};
// Spawn functions
function spawnMeteor() {
var meteor = new Meteor();
meteor.x = Math.random() * (2048 - 100) + 50;
meteor.y = -30;
meteor.lastY = meteor.y;
meteor.lastIntersecting = false;
meteors.push(meteor);
game.addChild(meteor);
}
function spawnEnemy() {
var enemy = new Enemy();
enemy.x = Math.random() < 0.5 ? -35 : 2048 + 35;
enemy.y = 200 + Math.random() * 1800;
enemy.lastIntersecting = false;
enemies.push(enemy);
game.addChild(enemy);
}
function spawnPowerUp() {
var type = Math.random() < 0.7 ? 'health' : 'shield';
var powerUp = new PowerUp(type);
powerUp.x = Math.random() * (2048 - 100) + 50;
powerUp.y = 200 + Math.random() * 1500;
powerUp.lastIntersecting = false;
powerUps.push(powerUp);
game.addChild(powerUp);
}
function shootBullet() {
var bullet = new Bullet();
bullet.x = player.x;
bullet.y = player.y - 40;
bullet.lastY = bullet.y;
bullet.lastIntersecting = false;
bullets.push(bullet);
game.addChild(bullet);
LK.getSound('shoot').play();
}
// Main game loop
game.update = function () {
gameTime++;
survivalTime = Math.floor(gameTime / 60);
// Update UI
var currentScore = baseScore + survivalTime;
LK.setScore(currentScore);
scoreText.setText('Score: ' + currentScore);
timeText.setText('Time: ' + survivalTime + 's');
// Increase difficulty over time
difficultyTimer++;
if (difficultyTimer >= 300) {
// Every 5 seconds
difficultyTimer = 0;
meteorSpawnRate = Math.max(30, meteorSpawnRate - 2);
enemySpawnRate = Math.max(60, enemySpawnRate - 8);
}
// Automatic shooting
shootTimer++;
if (shootTimer >= shootRate) {
shootTimer = 0;
shootBullet();
}
// Spawn meteors
if (gameTime % meteorSpawnRate === 0) {
spawnMeteor();
}
// Spawn enemies
if (gameTime % enemySpawnRate === 0) {
spawnEnemy();
}
// Spawn power-ups
if (gameTime % powerUpSpawnRate === 0) {
spawnPowerUp();
}
// Update meteors
for (var i = meteors.length - 1; i >= 0; i--) {
var meteor = meteors[i];
// Off-screen check
if (meteor.lastY < 2800 && meteor.y >= 2800) {
meteor.destroy();
meteors.splice(i, 1);
continue;
}
// Collision with player
var currentIntersecting = meteor.intersects(player);
if (!meteor.lastIntersecting && currentIntersecting) {
player.takeDamage(25);
meteor.destroy();
meteors.splice(i, 1);
continue;
}
meteor.lastY = meteor.y;
meteor.lastIntersecting = currentIntersecting;
}
// Update enemies
for (var i = enemies.length - 1; i >= 0; i--) {
var enemy = enemies[i];
// Off-screen check
if (enemy.x < -100 || enemy.x > 2148) {
enemy.destroy();
enemies.splice(i, 1);
continue;
}
// Collision with player
var currentIntersecting = enemy.intersects(player);
if (!enemy.lastIntersecting && currentIntersecting) {
player.takeDamage(15);
}
enemy.lastIntersecting = currentIntersecting;
}
// Update power-ups
for (var i = powerUps.length - 1; i >= 0; i--) {
var powerUp = powerUps[i];
// Collection check
var currentIntersecting = powerUp.intersects(player);
if (!powerUp.lastIntersecting && currentIntersecting) {
if (powerUp.type === 'health') {
player.heal(30);
baseScore += 50;
LK.getSound('collect').play();
} else if (powerUp.type === 'shield') {
player.activateShield();
baseScore += 100;
LK.getSound('powerup').play();
}
powerUp.destroy();
powerUps.splice(i, 1);
continue;
}
powerUp.lastIntersecting = currentIntersecting;
}
// Update bullets
for (var i = bullets.length - 1; i >= 0; i--) {
var bullet = bullets[i];
// Off-screen check
if (bullet.lastY >= -50 && bullet.y < -50) {
bullet.destroy();
bullets.splice(i, 1);
continue;
}
// Check collision with meteors
var hitMeteor = false;
for (var j = meteors.length - 1; j >= 0; j--) {
var meteor = meteors[j];
if (bullet.intersects(meteor)) {
// Destroy both bullet and meteor
bullet.destroy();
bullets.splice(i, 1);
meteor.destroy();
meteors.splice(j, 1);
baseScore += 100;
hitMeteor = true;
break;
}
}
if (hitMeteor) continue;
// Check collision with enemies
for (var j = enemies.length - 1; j >= 0; j--) {
var enemy = enemies[j];
if (bullet.intersects(enemy)) {
// Destroy both bullet and enemy
bullet.destroy();
bullets.splice(i, 1);
enemy.destroy();
enemies.splice(j, 1);
baseScore += 200;
break;
}
}
bullet.lastY = bullet.y;
}
}; ===================================================================
--- original.js
+++ change.js
@@ -23,9 +23,9 @@
var enemyGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
- self.speed = 2 + Math.random() * 3;
+ self.speed = 5 + Math.random() * 6;
self.direction = Math.random() < 0.5 ? -1 : 1;
self.update = function () {
self.x += self.speed * self.direction;
// Bounce off screen edges
@@ -136,9 +136,9 @@
var powerUps = [];
var bullets = [];
var gameTime = 0;
var meteorSpawnRate = 120; // frames between meteor spawns
-var enemySpawnRate = 300; // frames between enemy spawns
+var enemySpawnRate = 180; // frames between enemy spawns
var powerUpSpawnRate = 600; // frames between power-up spawns
var difficultyTimer = 0;
var survivalTime = 0;
var baseScore = 0;
@@ -258,9 +258,9 @@
if (difficultyTimer >= 300) {
// Every 5 seconds
difficultyTimer = 0;
meteorSpawnRate = Math.max(30, meteorSpawnRate - 2);
- enemySpawnRate = Math.max(180, enemySpawnRate - 5);
+ enemySpawnRate = Math.max(60, enemySpawnRate - 8);
}
// Automatic shooting
shootTimer++;
if (shootTimer >= shootRate) {
silah mermisi. In-Game asset. 2d. High contrast. No shadows
medkit. In-Game asset. 2d. High contrast. No shadows
meteor. In-Game asset. 2d. High contrast. No shadows
uzay aracı. In-Game asset. 2d. High contrast. No shadows
a red shield with a white cross on it. In-Game asset. 2d. High contrast. No shadows
alien. In-Game asset. 2d. High contrast. No shadows