54
1
7mo
User prompt
Repair butonu ekle item kırıldığında 100 coin e onarsın
User prompt
Başarılı yükseltme olduğunda ekrana havai fişek efekti ver
User prompt
Başarılı arttırma olduğunda havai fişek efekti yap
User prompt
Ekranda parçacıklı ışık patlat yükseltme başarılı olursa
User prompt
Yükseltme başarılı olursa havai fişek patlat. Düşerse kırmızı kırılma efekti.
User prompt
Parayı arttırmak için sağ tarafa bir buton ekle. Butona her basıldığında 1 coin artmalı.
User prompt
Please fix the bug: 'undefined is not an object (evaluating 'armorSelectBtn.setText')' in or related to this line: 'armorSelectBtn.setText("Armor");' Line Number: 229
User prompt
Yazılar ingilizce olmalı
User prompt
Hatayı gider
User prompt
Devam et
User prompt
Please fix the bug: 'undefined is not an object (evaluating 'swordLabel.style.fill = getLevelColor(swordLevel)')' in or related to this line: 'return "#fff";' Line Number: 373
Code edit (1 edits merged)
Please save this source code
User prompt
Efsanevi Geliştir: Idle Ekipman Yükseltme
Initial prompt
Oyuncunun kılıç, zırh gibi eşyaları bir "Geliştir" tuşuna basarak seviye atlattığı bir 2D idle RPG tarzı oyun yap. +5’te mavi, +10’da altın sarısı, +15’te kırmızı alev şeklinde parlamaya başlasın. Her seviye arttıkça başarı oranı azalsın. Oyuncu her denemede altın ve geliştirme taşı harcasın. Başarısız olursa item seviyesi düşebilir ya da kırılabilir. Basit arayüz, ilerleme çubuğu ve tatmin edici ses efektleri olsun.
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// Equipment class (for both sword and armor)
var Equipment = Container.expand(function () {
var self = Container.call(this);
self.type = 'sword'; // or 'armor'
self.level = 0;
self.maxLevel = 15;
self.broken = false;
self.asset = null;
self.flame = null;
self.setType = function (type) {
self.type = type;
self.updateVisual();
};
self.setLevel = function (level) {
self.level = level;
self.updateVisual();
};
self.breakItem = function () {
self.broken = true;
self.updateVisual();
};
self.repair = function () {
self.broken = false;
self.updateVisual();
};
self.updateVisual = function () {
// Remove old asset
if (self.asset) {
self.removeChild(self.asset);
self.asset.destroy();
self.asset = null;
}
if (self.flame) {
self.removeChild(self.flame);
self.flame.destroy();
self.flame = null;
}
var assetId;
if (self.type === 'sword') {
if (self.broken) assetId = 'sword_basic';else if (self.level >= 15) assetId = 'sword_red';else if (self.level >= 10) assetId = 'sword_gold';else if (self.level >= 5) assetId = 'sword_blue';else assetId = 'sword_basic';
} else {
if (self.broken) assetId = 'armor_basic';else if (self.level >= 15) assetId = 'armor_red';else if (self.level >= 10) assetId = 'armor_gold';else if (self.level >= 5) assetId = 'armor_blue';else assetId = 'armor_basic';
}
self.asset = self.attachAsset(assetId, {
anchorX: 0.5,
anchorY: 0.5
});
// Add flame effect for +15
if (!self.broken && self.level >= 15) {
self.flame = new Container();
var flameShape = LK.getAsset('sword_red', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.2,
scaleY: 1.2
});
flameShape.alpha = 0.4;
self.flame.addChild(flameShape);
self.flame.x = 0;
self.flame.y = 0;
self.addChild(self.flame);
// Animate flame
tween(self.flame, {
alpha: 0.2
}, {
duration: 400,
easing: tween.sineInOut,
onFinish: function onFinish() {
tween(self.flame, {
alpha: 0.4
}, {
duration: 400,
easing: tween.sineInOut,
onFinish: function onFinish() {
// Loop
if (self.flame) self.updateVisual();
}
});
}
});
}
// If broken, gray out
if (self.broken) {
self.asset.alpha = 0.3;
} else {
self.asset.alpha = 1;
}
};
self.updateVisual();
return self;
});
// Button class
var UIButton = Container.expand(function () {
var self = Container.call(this);
self.bg = self.attachAsset('button', {
anchorX: 0.5,
anchorY: 0.5
});
self.label = new Text2('Button', {
size: 60,
fill: "#fff"
});
self.label.anchor.set(0.5, 0.5);
self.addChild(self.label);
self.setText = function (txt) {
self.label.setText(txt);
};
self.setColor = function (color) {
self.bg.tint = color;
};
self.down = function (x, y, obj) {
// Visual feedback
tween(self.bg, {
scaleX: 0.95,
scaleY: 0.95
}, {
duration: 60
});
};
self.up = function (x, y, obj) {
tween(self.bg, {
scaleX: 1,
scaleY: 1
}, {
duration: 60
});
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x181818
});
/****
* Game Code
****/
// --- State ---
// Equipment shapes
// Stones and gold
// Button
// SFX
// Tween plugin
var gold = 1000;
var stones = 20;
var selectedEquip = 'sword'; // 'sword' or 'armor'
var swordLevel = 0;
var armorLevel = 0;
var swordBroken = false;
var armorBroken = false;
// --- UI Elements ---
var sword = new Equipment();
sword.setType('sword');
sword.x = 2048 / 2 - 250;
sword.y = 1100;
var armor = new Equipment();
armor.setType('armor');
armor.x = 2048 / 2 + 250;
armor.y = 1100;
var swordLabel = new Text2('', {
size: 60,
fill: "#fff"
});
swordLabel.anchor.set(0.5, 0.5);
swordLabel.x = sword.x;
swordLabel.y = sword.y + 120;
var armorLabel = new Text2('', {
size: 60,
fill: "#fff"
});
armorLabel.anchor.set(0.5, 0.5);
armorLabel.x = armor.x;
armorLabel.y = armor.y + 120;
// Select buttons
var swordSelectBtn = new UIButton();
swordSelectBtn.setText("Kılıç");
swordSelectBtn.x = sword.x;
swordSelectBtn.y = sword.y + 250;
var armorSelectBtn = new UIButton();
armorSelectBtn.setText("Zırh");
armorSelectBtn.x = armor.x;
armorSelectBtn.y = armor.y + 250;
// Upgrade button
var upgradeBtn = new UIButton();
upgradeBtn.setText("Geliştir");
upgradeBtn.x = 2048 / 2;
upgradeBtn.y = 1800;
// Resource display
var goldIcon = LK.getAsset('gold', {
anchorX: 0.5,
anchorY: 0.5
});
goldIcon.x = 2048 / 2 - 200;
goldIcon.y = 300;
var goldText = new Text2('', {
size: 60,
fill: 0xFFD700
});
goldText.anchor.set(0, 0.5);
goldText.x = goldIcon.x + 50;
goldText.y = goldIcon.y;
var stoneIcon = LK.getAsset('stone', {
anchorX: 0.5,
anchorY: 0.5
});
stoneIcon.x = 2048 / 2 + 100;
stoneIcon.y = 300;
var stoneText = new Text2('', {
size: 60,
fill: 0x6EC6FF
});
stoneText.anchor.set(0, 0.5);
stoneText.x = stoneIcon.x + 50;
stoneText.y = stoneIcon.y;
// Info text
var infoText = new Text2('', {
size: 54,
fill: "#fff"
});
infoText.anchor.set(0.5, 0.5);
infoText.x = 2048 / 2;
infoText.y = 400;
// Progress bar
var progressBarBg = LK.getAsset('button', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.2,
scaleY: 0.4
});
progressBarBg.tint = 0x222222;
progressBarBg.x = 2048 / 2;
progressBarBg.y = 1550;
var progressBar = LK.getAsset('button', {
anchorX: 0,
anchorY: 0.5,
scaleX: 0,
scaleY: 0.4
});
progressBar.tint = 0x3a8fff;
progressBar.x = 2048 / 2 - 250;
progressBar.y = 1550;
// --- Add to game ---
game.addChild(sword);
game.addChild(armor);
game.addChild(swordLabel);
game.addChild(armorLabel);
game.addChild(swordSelectBtn);
game.addChild(armorSelectBtn);
game.addChild(upgradeBtn);
game.addChild(goldIcon);
game.addChild(goldText);
game.addChild(stoneIcon);
game.addChild(stoneText);
game.addChild(infoText);
game.addChild(progressBarBg);
game.addChild(progressBar);
// --- Helper Functions ---
function getEquipLevel(type) {
return type === 'sword' ? swordLevel : armorLevel;
}
function setEquipLevel(type, lvl) {
if (type === 'sword') swordLevel = lvl;else armorLevel = lvl;
}
function isEquipBroken(type) {
return type === 'sword' ? swordBroken : armorBroken;
}
function setEquipBroken(type, val) {
if (type === 'sword') swordBroken = val;else armorBroken = val;
}
function getEquipObj(type) {
return type === 'sword' ? sword : armor;
}
function getUpgradeCost(level) {
// Cost increases with level
return {
gold: 50 + level * 30,
stone: 1 + Math.floor(level / 3)
};
}
function getUpgradeChance(level) {
// +0: 100%, +1: 90%, +2: 80%, ... +10: 30%, +15: 10%
if (level < 1) return 1;
if (level < 5) return 1 - level * 0.1; // 90%, 80%, 70%, 60%
if (level < 10) return 0.5 - (level - 5) * 0.08; // 42%, 34%, 26%, 18%, 10%
if (level < 15) return 0.3 - (level - 10) * 0.04; // 26%, 22%, 18%, 14%, 10%
return 0.1;
}
function getFailType(level) {
// At +0~+4: only downgrade, +5+: 50% downgrade, 50% break
if (level < 5) return 'down';
return Math.random() < 0.5 ? 'down' : 'break';
}
function getLevelColor(level) {
if (level >= 15) return "#ff2222";
if (level >= 10) return "#ffd700";
if (level >= 5) return "#3a8fff";
return "#fff";
}
function getLevelText(level, broken) {
if (broken) return "Kırık";
if (level === 0) return "+0";
return "+" + level;
}
function updateUI() {
// Equipment visuals
sword.setLevel(swordLevel);
sword.broken = swordBroken;
sword.updateVisual();
armor.setLevel(armorLevel);
armor.broken = armorBroken;
armor.updateVisual();
// Labels
swordLabel.setText(getLevelText(swordLevel, swordBroken));
swordLabel.setStyle({
fill: getLevelColor(swordLevel)
});
armorLabel.setText(getLevelText(armorLevel, armorBroken));
armorLabel.setStyle({
fill: getLevelColor(armorLevel)
});
// Resource
goldText.setText(gold.toString());
stoneText.setText(stones.toString());
// Info
var selLevel = getEquipLevel(selectedEquip);
var selBroken = isEquipBroken(selectedEquip);
var cost = getUpgradeCost(selLevel);
var chance = getUpgradeChance(selLevel);
if (selBroken) {
infoText.setText("Ekipman kırıldı! Onarmak için 'Geliştir' tuşuna bas.");
} else if (selLevel >= 15) {
infoText.setText("Maksimum seviye! Daha fazla geliştirilemez.");
} else {
infoText.setText("Seviye: +" + selLevel + " | Başarı: %" + Math.round(chance * 100) + "\nMaliyet: " + cost.gold + " altın, " + cost.stone + " taş");
}
// Progress bar
progressBar.scaleX = 0;
}
function showResult(text, color) {
infoText.setText(text);
infoText.setStyle({
fill: color
});
tween(infoText, {
alpha: 0.2
}, {
duration: 200,
onFinish: function onFinish() {
tween(infoText, {
alpha: 1
}, {
duration: 200
});
}
});
}
function animateProgressBar(success, cb) {
progressBar.tint = success ? 0x3a8fff : 0xff2222;
tween(progressBar, {
scaleX: 1
}, {
duration: 600,
easing: tween.cubicOut,
onFinish: function onFinish() {
tween(progressBar, {
scaleX: 0
}, {
duration: 200,
onFinish: cb
});
}
});
}
// --- Button Events ---
swordSelectBtn.down = function (x, y, obj) {
selectedEquip = 'sword';
swordSelectBtn.setColor(0x3a8fff);
armorSelectBtn.setColor(0x444444);
updateUI();
};
armorSelectBtn.down = function (x, y, obj) {
selectedEquip = 'armor';
armorSelectBtn.setColor(0x3a8fff);
swordSelectBtn.setColor(0x444444);
updateUI();
};
upgradeBtn.down = function (x, y, obj) {
var equip = selectedEquip;
var level = getEquipLevel(equip);
var broken = isEquipBroken(equip);
var cost = getUpgradeCost(level);
var chance = getUpgradeChance(level);
LK.getSound('upgrade_click').play();
if (broken) {
// Repair: pay half cost, reset to +0
if (gold >= Math.floor(cost.gold / 2) && stones >= Math.max(1, Math.floor(cost.stone / 2))) {
gold -= Math.floor(cost.gold / 2);
stones -= Math.max(1, Math.floor(cost.stone / 2));
setEquipLevel(equip, 0);
setEquipBroken(equip, false);
showResult("Ekipman onarıldı! Seviye sıfırlandı.", "#3a8fff");
LK.getSound('upgrade_success').play();
updateUI();
} else {
showResult("Onarmak için yeterli kaynak yok!", "#ff2222");
LK.getSound('upgrade_fail').play();
}
return;
}
if (level >= 15) {
showResult("Maksimum seviye!", "#ffd700");
return;
}
if (gold < cost.gold || stones < cost.stone) {
showResult("Yetersiz altın veya taş!", "#ff2222");
LK.getSound('upgrade_fail').play();
return;
}
// Deduct cost
gold -= cost.gold;
stones -= cost.stone;
updateUI();
// Animate progress bar, then resolve
animateProgressBar(true, function () {
var roll = Math.random();
if (roll < chance) {
// Success
setEquipLevel(equip, level + 1);
showResult("Başarılı! +" + (level + 1), "#3a8fff");
LK.getSound('upgrade_success').play();
// Flash effect
LK.effects.flashObject(getEquipObj(equip), 0x3a8fff, 400);
} else {
// Fail
var failType = getFailType(level);
if (failType === 'down') {
setEquipLevel(equip, Math.max(0, level - 1));
showResult("Başarısız! Seviye düştü.", "#ff2222");
LK.getSound('upgrade_fail').play();
LK.effects.flashObject(getEquipObj(equip), 0x222222, 400);
} else {
setEquipBroken(equip, true);
showResult("Ekipman kırıldı!", "#ff2222");
LK.getSound('upgrade_break').play();
LK.effects.flashObject(getEquipObj(equip), 0xff2222, 600);
}
}
updateUI();
});
};
// --- Initial UI State ---
swordSelectBtn.setColor(0x3a8fff);
armorSelectBtn.setColor(0x444444);
updateUI();
// --- Game update (idle resource gain) ---
game.update = function () {
// Idle: gain 1 gold every 60 ticks (~1s), 1 stone every 300 ticks (~5s)
if (LK.ticks % 60 === 0) {
gold += 1;
goldText.setText(gold.toString());
}
if (LK.ticks % 300 === 0) {
stones += 1;
stoneText.setText(stones.toString());
}
};
// --- Touch: allow tapping equipment to show effect ---
sword.down = function (x, y, obj) {
LK.effects.flashObject(sword, 0x3a8fff, 200);
};
armor.down = function (x, y, obj) {
LK.effects.flashObject(armor, 0x3a8fff, 200);
}; ===================================================================
--- original.js
+++ change.js
@@ -348,9 +348,11 @@
progressBar.scaleX = 0;
}
function showResult(text, color) {
infoText.setText(text);
- infoText.style.fill = color;
+ infoText.setStyle({
+ fill: color
+ });
tween(infoText, {
alpha: 0.2
}, {
duration: 200,
Basic sword. In-Game asset. 2d. High contrast. No shadows
Blue light sword. In-Game asset. 2d. High contrast. No shadows
Stone volcanic. In-Game asset. 2d. High contrast. No shadows
Basic armor. In-Game asset. 2d. High contrast. No shadows
Armor light blue neon. In-Game asset. 2d. High contrast.
Armor grand red neon. In-Game asset. 2d. High contrast. No shadows
Stone effect button. In-Game asset. 2d. High contrast. No shadows
Game coin. In-Game asset. 2d. High contrast. No shadows
Armor grand master gold neon. In-Game asset. 2d. High contrast. No shadows
Sword, effect master red neon. In-Game asset. 2d. High contrast. No shadows
Sword, effect grand master neon. In-Game asset. 2d. High contrast. No shadows