User prompt
Mermiler düşmanı öldürdüğü an azda olsa kan fışkırsın çok az ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Yazılar mod yazan yerin alt kısımlarında olsun
User prompt
Please fix the bug: 'Cannot set properties of undefined (setting 'stroke')' in or related to this line: 'self.modeText.style.stroke = '#FFFFFF';' Line Number: 91
User prompt
Mod üzerindeki yazılar net gözüksün
User prompt
Başkarakter yolun üstünde gözüksün
User prompt
Sadece 1 yol olsun
User prompt
3 moddada yol olsun kara yolu olsun
User prompt
Ateş hiç bitmesin dümdüz gitsin
User prompt
Ateşim sonsuza dek uzun gitsin score puanı 1 asker ölünce hemen 1 puan artsın kod yaz
User prompt
Oyunu aşırı şekilde optimize et donma sorunu olmasın
User prompt
Hem gündüz modunda hem de gece modunda hemde sultan bize düşman oldu modunda taş,toprak yol falan olsun
Code edit (1 edits merged)
Please save this source code
User prompt
Legendary Name: My Sultan
Initial prompt
Sure! Here’s the full summary of your game “Legendary Name: My Sultan” in English: --- 🎮 Game Title: Legendary Name: My Sultan 🧱 Genre: Tower defense, romantic --- 👥 Characters: Omar: Main hero Sultan: Omar’s love, a sultan Aamir: Villain Vega: Aamir’s boss --- ⚔️ Gameplay Summary: Enemies come from the opposite side You shoot and defend using weapons When you kill 100 enemies, the game ends, you win the Sultan, and confetti explodes --- 🕹️ 3 Mode Options: 1. Night Mode: Fight in a dark setting, kill 100 enemies to win 2. Day Mode: Fight in a sunny setting, kill 100 enemies to win 3. My Sultan Became My Enemy: Sultan turns against you, kill 400 enemies to win, Sultan regrets it, confetti explodes --- Let me know if you want me to turn this into a game menu design!
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Confetti = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('confetti', {
anchorX: 0.5,
anchorY: 0.5
});
self.speedX = (Math.random() - 0.5) * 10;
self.speedY = Math.random() * -8 - 2;
self.gravity = 0.3;
self.life = 120;
self.update = function () {
self.x += self.speedX;
self.y += self.speedY;
self.speedY += self.gravity;
self.life--;
if (self.life <= 0) {
self.alpha = 0;
}
};
return self;
});
var Enemy = Container.expand(function () {
var self = Container.call(this);
self.enemyType = 'aamir';
self.health = 1;
self.speed = 2;
self.init = function (type) {
self.enemyType = type;
if (type === 'vega') {
self.health = 3;
self.speed = 1;
} else if (type === 'sultan') {
self.health = 2;
self.speed = 1.5;
}
var graphics = self.attachAsset(type, {
anchorX: 0.5,
anchorY: 0.5
});
};
self.update = function () {
self.y += self.speed;
};
self.takeDamage = function () {
self.health--;
if (self.health <= 0) {
return true;
}
return false;
};
return self;
});
var ModeButton = Container.expand(function () {
var self = Container.call(this);
var background = self.attachAsset('modeButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.modeText = new Text2('', {
size: 40,
fill: '#FFFFFF'
});
self.modeText.anchor.set(0.5, 0.5);
self.addChild(self.modeText);
self.setMode = function (text, mode, enemyCount) {
self.modeText.setText(text);
self.gameMode = mode;
self.enemyCount = enemyCount;
};
self.down = function (x, y, obj) {
startGame(self.gameMode, self.enemyCount);
};
return self;
});
var Omar = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('omar', {
anchorX: 0.5,
anchorY: 0.5
});
self.shootCooldown = 0;
self.update = function () {
if (self.shootCooldown > 0) {
self.shootCooldown--;
}
};
self.shoot = function () {
if (self.shootCooldown <= 0) {
var bullet = new OmarBullet();
bullet.x = self.x;
bullet.y = self.y - 40;
bullets.push(bullet);
game.addChild(bullet);
self.shootCooldown = 15;
LK.getSound('shoot').play();
}
};
return self;
});
var OmarBullet = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('omarBullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -8;
self.update = function () {
self.y += self.speed;
};
return self;
});
var Terrain = Container.expand(function () {
var self = Container.call(this);
self.init = function (type, x, y) {
var graphics = self.attachAsset(type, {
anchorX: 0.5,
anchorY: 0.5
});
self.x = x;
self.y = y;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000033
});
/****
* Game Code
****/
// Game state
// Hero assets
// Enemy assets
// UI assets
// Sound assets
var gameState = 'menu'; // 'menu', 'playing', 'victory'
var currentMode = '';
var enemiesRequired = 0;
var enemiesKilled = 0;
var gameStarted = false;
// Game objects
var omar;
var bullets = [];
var enemies = [];
var confettiParticles = [];
var terrainElements = [];
// UI elements
var titleText;
var scoreText;
var modeButtons = [];
// Enemy spawn timer - optimized for performance
var enemySpawnTimer = 0;
var enemySpawnRate = 60; // frames between spawns - faster to compensate for limited enemies
// Initialize menu
function initMenu() {
gameState = 'menu';
// Title
titleText = new Text2('My Sultan', {
size: 80,
fill: '#FFD700'
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 1024;
titleText.y = 400;
game.addChild(titleText);
// Subtitle
var subtitle = new Text2('Choose Your Quest', {
size: 50,
fill: '#FFFFFF'
});
subtitle.anchor.set(0.5, 0.5);
subtitle.x = 1024;
subtitle.y = 500;
game.addChild(subtitle);
// Mode buttons
var nightButton = new ModeButton();
nightButton.setMode('Night Mode (100 enemies)', 'night', 100);
nightButton.x = 1024;
nightButton.y = 800;
modeButtons.push(nightButton);
game.addChild(nightButton);
var dayButton = new ModeButton();
dayButton.setMode('Day Mode (100 enemies)', 'day', 100);
dayButton.x = 1024;
dayButton.y = 1000;
modeButtons.push(dayButton);
game.addChild(dayButton);
var betrayalButton = new ModeButton();
betrayalButton.setMode('My Sultan Became My Enemy (400)', 'betrayal', 400);
betrayalButton.x = 1024;
betrayalButton.y = 1200;
modeButtons.push(betrayalButton);
game.addChild(betrayalButton);
}
function startGame(mode, enemyCount) {
gameState = 'playing';
currentMode = mode;
enemiesRequired = enemyCount;
enemiesKilled = 0;
gameStarted = true;
// Clear menu
while (game.children.length > 0) {
var child = game.children[0];
child.destroy();
}
// Set background based on mode
if (mode === 'night') {
game.setBackgroundColor(0x000033);
} else if (mode === 'day') {
game.setBackgroundColor(0x87CEEB);
} else if (mode === 'betrayal') {
game.setBackgroundColor(0x8B0000);
}
// Create Omar
omar = new Omar();
omar.x = 1024;
omar.y = 2400;
game.addChild(omar);
// Generate terrain for the mode
generateTerrain(mode);
// Create score text
scoreText = new Text2('Enemies: 0 / ' + enemiesRequired, {
size: 60,
fill: '#FFFFFF'
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
// Reset arrays
bullets = [];
enemies = [];
confettiParticles = [];
terrainElements = [];
// Reset spawn timer
enemySpawnTimer = 0;
enemySpawnRate = Math.max(30, 90 - Math.floor(enemiesKilled / 20) * 10);
}
function generateTerrain(mode) {
// Clear existing terrain
for (var i = terrainElements.length - 1; i >= 0; i--) {
terrainElements[i].destroy();
}
terrainElements = [];
// Generate only one road for all modes
var road = new Terrain();
road.init('road', 1024, 2200);
terrainElements.push(road);
game.addChild(road);
}
function spawnEnemy() {
var enemy = new Enemy();
// Determine enemy type based on mode and progress
var enemyType = 'aamir';
var progress = enemiesKilled / enemiesRequired;
if (currentMode === 'betrayal') {
if (Math.random() < 0.3) {
enemyType = 'sultan';
} else if (progress > 0.7 && Math.random() < 0.2) {
enemyType = 'vega';
}
} else {
if (progress > 0.8 && Math.random() < 0.15) {
enemyType = 'vega';
}
}
enemy.init(enemyType);
enemy.x = Math.random() * 1800 + 124;
enemy.y = -50;
enemies.push(enemy);
game.addChild(enemy);
}
function checkVictory() {
if (enemiesKilled >= enemiesRequired) {
gameState = 'victory';
LK.getSound('victory').play();
// Create optimized confetti (reduced count for performance)
for (var i = 0; i < 20; i++) {
var confetti = new Confetti();
confetti.x = Math.random() * 2048;
confetti.y = Math.random() * 500 + 500;
// Random colors for confetti
var colors = [0xFFD700, 0xFF1493, 0x00FF00, 0x00BFFF, 0xFF4500];
confetti.tint = colors[Math.floor(Math.random() * colors.length)];
confettiParticles.push(confetti);
game.addChild(confetti);
}
// Victory text
var victoryText = new Text2('Victory! Love Conquers All!', {
size: 70,
fill: '#FFD700'
});
victoryText.anchor.set(0.5, 0.5);
victoryText.x = 1024;
victoryText.y = 1366;
game.addChild(victoryText);
// Return to menu after 5 seconds
LK.setTimeout(function () {
// Clear game
while (game.children.length > 0) {
var child = game.children[0];
child.destroy();
}
while (LK.gui.top.children.length > 0) {
var child = LK.gui.top.children[0];
child.destroy();
}
// Reset arrays
bullets = [];
enemies = [];
confettiParticles = [];
terrainElements = [];
modeButtons = [];
initMenu();
}, 5000);
}
}
// Touch controls
var isTouching = false;
game.down = function (x, y, obj) {
if (gameState === 'playing') {
isTouching = true;
omar.shoot();
}
};
game.up = function (x, y, obj) {
isTouching = false;
};
game.move = function (x, y, obj) {
if (gameState === 'playing' && omar) {
omar.x = Math.max(40, Math.min(2008, x));
if (isTouching) {
omar.shoot();
}
}
};
game.update = function () {
if (gameState === 'playing') {
// Spawn enemies
enemySpawnTimer++;
if (enemySpawnTimer >= enemySpawnRate) {
spawnEnemy();
enemySpawnTimer = 0;
enemySpawnRate = Math.max(30, 90 - Math.floor(enemiesKilled / 20) * 10);
}
// Update bullets - no limit, bullets travel infinitely
for (var i = bullets.length - 1; i >= 0; i--) {
var bullet = bullets[i];
if (bullet.lastY === undefined) bullet.lastY = bullet.y;
// Bullets now travel infinitely - no off-screen removal
// Optimized collision detection - only check nearby enemies
var hit = false;
for (var j = enemies.length - 1; j >= 0; j--) {
var enemy = enemies[j];
// Quick distance check before expensive intersection
var dx = bullet.x - enemy.x;
var dy = bullet.y - enemy.y;
if (dx * dx + dy * dy < 10000 && bullet.intersects(enemy)) {
if (enemy.takeDamage()) {
enemy.destroy();
enemies.splice(j, 1);
enemiesKilled++;
// Update score immediately when each enemy dies
scoreText.setText('Enemies: ' + enemiesKilled + ' / ' + enemiesRequired);
checkVictory();
}
// Bullet continues through enemy - no destruction
hit = true;
break;
}
}
if (!hit) {
bullet.lastY = bullet.y;
}
}
// Limit enemies on screen for performance
if (enemies.length > 8) {
var oldEnemy = enemies.shift();
oldEnemy.destroy();
}
// Update enemies
for (var i = enemies.length - 1; i >= 0; i--) {
var enemy = enemies[i];
if (enemy.lastY === undefined) enemy.lastY = enemy.y;
// Remove enemies that go off screen (game over condition)
if (enemy.lastY <= 2800 && enemy.y > 2800) {
LK.showGameOver();
return;
}
enemy.lastY = enemy.y;
}
// Reduced auto shoot frequency for better performance
if (LK.ticks % 20 === 0) {
omar.shoot();
}
}
// Update confetti
for (var i = confettiParticles.length - 1; i >= 0; i--) {
var confetti = confettiParticles[i];
if (confetti.life <= 0) {
confetti.destroy();
confettiParticles.splice(i, 1);
}
}
};
// Initialize the menu
initMenu(); ===================================================================
--- original.js
+++ change.js
@@ -251,70 +251,13 @@
for (var i = terrainElements.length - 1; i >= 0; i--) {
terrainElements[i].destroy();
}
terrainElements = [];
- // Generate terrain with roads for all modes
- if (mode === 'night') {
- // Night mode: roads, stones, and dirt
- for (var i = 0; i < 4; i++) {
- var road = new Terrain();
- road.init('road', Math.random() * 1400 + 324, Math.random() * 400 + 2000);
- terrainElements.push(road);
- game.addChild(road);
- }
- for (var i = 0; i < 6; i++) {
- var stone = new Terrain();
- stone.init('stone', Math.random() * 1800 + 124, Math.random() * 400 + 2000);
- terrainElements.push(stone);
- game.addChild(stone);
- }
- for (var i = 0; i < 5; i++) {
- var dirt = new Terrain();
- dirt.init('dirt', Math.random() * 1600 + 224, Math.random() * 300 + 2100);
- terrainElements.push(dirt);
- game.addChild(dirt);
- }
- } else if (mode === 'day') {
- // Day mode: roads, stones, and dirt
- for (var i = 0; i < 5; i++) {
- var road = new Terrain();
- road.init('road', Math.random() * 1400 + 324, Math.random() * 350 + 2000);
- terrainElements.push(road);
- game.addChild(road);
- }
- for (var i = 0; i < 4; i++) {
- var stone = new Terrain();
- stone.init('stone', Math.random() * 1700 + 174, Math.random() * 300 + 2100);
- terrainElements.push(stone);
- game.addChild(stone);
- }
- for (var i = 0; i < 3; i++) {
- var dirt = new Terrain();
- dirt.init('dirt', Math.random() * 1600 + 224, Math.random() * 300 + 2200);
- terrainElements.push(dirt);
- game.addChild(dirt);
- }
- } else if (mode === 'betrayal') {
- // Betrayal mode: roads, dirt, and stones
- for (var i = 0; i < 6; i++) {
- var road = new Terrain();
- road.init('road', Math.random() * 1200 + 424, Math.random() * 200 + 2200);
- terrainElements.push(road);
- game.addChild(road);
- }
- for (var i = 0; i < 4; i++) {
- var dirt = new Terrain();
- dirt.init('dirt', Math.random() * 1600 + 224, Math.random() * 400 + 1900);
- terrainElements.push(dirt);
- game.addChild(dirt);
- }
- for (var i = 0; i < 6; i++) {
- var stone = new Terrain();
- stone.init('stone', Math.random() * 1800 + 124, Math.random() * 450 + 1800);
- terrainElements.push(stone);
- game.addChild(stone);
- }
- }
+ // Generate only one road for all modes
+ var road = new Terrain();
+ road.init('road', 1024, 2200);
+ terrainElements.push(road);
+ game.addChild(road);
}
function spawnEnemy() {
var enemy = new Enemy();
// Determine enemy type based on mode and progress
Siyah saçlı,zayıf,uzun boylu bir erkek genç. In-Game asset. 2d. High contrast. No shadows
Uzun saçlı kahverengi renkte iri bir adam. In-Game asset. 2d. High contrast. No shadows
Yaşlı bir adam kısa boylu aksakallı. In-Game asset. 2d. High contrast. No shadows
Kapalı saçlı orta ağırlıkta bir kız bir sultan çok güzel. In-Game asset. 2d. High contrast. No shadows
Dikey bir yol yap kara yolu. In-Game asset. 2d. High contrast. No shadows
Tabanca mermisi tasarla. In-Game asset. 2d. High contrast. No shadows
Mod butonu tasarla böyle tarz olsun. In-Game asset. 2d. High contrast. No shadows
Konfeti tasarla patlayan. In-Game asset. 2d. High contrast. No shadows
Taş tasarla grey. In-Game asset. 2d. High contrast. No shadows
Bir dirt tasarla. In-Game asset. 2d. High contrast. No shadows