Code edit (6 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
assets'e eklediğimiz trophy iconunu kaldırır mısın kullanmak istemiyorum.
Code edit (1 edits merged)
Please save this source code
User prompt
🏆 simgesini kaldır.
Code edit (1 edits merged)
Please save this source code
User prompt
yazılar ekrana sığmazsa alt alta yaz.
User prompt
ekranın üstündeki yazılar birbirine giriyor. Onları ayır alt alta olsun.
Code edit (1 edits merged)
Please save this source code
User prompt
Futbol Kariyerim: Rastgele Yıldız
Initial prompt
Futbol kariyeri simülasyonu gibi bir oyun oluştur. Oyuncunun kariyeri tamamen rastgele ilerlesin. Aşağıdaki adımlar sırasıyla rastgele sonuçlarla belirlenmeli ve her adım, futbolcunun kariyer yolculuğunu oluşturmalı. İlk olarak kullanıcı hangi mevkide oynamak istediğini seçiyor. Sonrasında rastgele bir futbol kulubunde kariyere başlıyor. sonra her sezonda transfer teklifleri geliyor isteğe bağlı olarak bunları kabul edip veya mevcut kulupte ilerleyebilir. 18 yaşında başlayıp 35 yaşında emekli olacak şekilde seçimlere göre ilerliyor. Ayrıca her sezon kaç gol atmış kaç asist yapmış belli bir yere yazılıyor. 35 yaşına geldiğinde emekli oluyor ve kariyerinde kaç gol atmış kaç kupa kazanmış bunları görebiliyor. Buna benzeyen tiktokta futbol kariyer efekti var. Aynı onun gibi bir oyun istiyorum.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Club class var Club = Container.expand(function () { var self = Container.call(this); var clubArt = self.attachAsset('club', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () {}; return self; }); // Player class var Player = Container.expand(function () { var self = Container.call(this); var playerArt = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () {}; return self; }); // Trophy class (for display on summary) var Trophy = Container.expand(function () { var self = Container.call(this); var trophyArt = self.attachAsset('trophy', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () {}; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x0a1a2f }); /**** * Game Code ****/ // Shapes for player, club, and trophy // --- Data --- var positions = [{ key: 'GK', name: 'Kaleci' }, { key: 'DEF', name: 'Defans' }, { key: 'MID', name: 'Orta Saha' }, { key: 'FWD', name: 'Forvet' }]; var clubs = ["Galatasaray", "Fenerbahçe", "Beşiktaş", "Trabzonspor", "Başakşehir", "Bursaspor", "Kasımpaşa", "Antalyaspor", "Real Madrid", "Barcelona", "Manchester United", "Liverpool", "Chelsea", "Bayern Münih", "Juventus", "PSG", "Ajax", "Porto", "Celtic", "Shakhtar", "Zenit", "Club Brugge", "Anderlecht", "Monaco", "Roma", "Napoli"]; var trophies = ["Süper Lig", "Türkiye Kupası", "Şampiyonlar Ligi", "UEFA Avrupa Ligi", "La Liga", "Premier Lig", "Bundesliga", "Serie A", "Ligue 1", "Eredivisie"]; // --- State --- var state = "choose_position"; // choose_position, season, transfer, summary var playerPosition = null; var playerPositionName = ""; var playerAge = 18; var playerClub = ""; var playerStats = []; // [{age, club, goals, assists, trophies:[]}] var playerTrophies = []; var playerTotalGoals = 0; var playerTotalAssists = 0; var playerTotalTrophies = 0; var currentSeasonStats = null; var transferOffers = []; var selectedTransfer = null; // --- UI Elements --- var mainContainer = new Container(); game.addChild(mainContainer); var infoText = new Text2("", { size: 90, fill: "#fff" }); infoText.anchor.set(0.5, 0); infoText.y = 0; LK.gui.top.addChild(infoText); var seasonText = new Text2("", { size: 70, fill: "#fff" }); seasonText.anchor.set(0.5, 0); seasonText.y = infoText.height + 10; LK.gui.top.addChild(seasonText); var clubNode = null; var playerNode = null; var trophyNodes = []; var statText = null; var transferButtons = []; var nextButton = null; var summaryText = null; // --- Helper Functions --- function randomInt(min, max) { return min + Math.floor(Math.random() * (max - min + 1)); } function randomPick(arr) { return arr[randomInt(0, arr.length - 1)]; } function clearMainContainer() { while (mainContainer.children.length) mainContainer.removeChild(mainContainer.children[0]); } function clearTransferButtons() { for (var i = 0; i < transferButtons.length; i++) { mainContainer.removeChild(transferButtons[i]); } transferButtons = []; } function clearTrophyNodes() { for (var i = 0; i < trophyNodes.length; i++) { mainContainer.removeChild(trophyNodes[i]); } trophyNodes = []; } function showInfo(msg) { // If text is too wide, split into multiple lines infoText.setText(msg); var maxWidth = 2048 - 200; if (infoText.width > maxWidth) { // Try to split by space var words = msg.split(" "); var lines = []; var current = ""; for (var i = 0; i < words.length; i++) { var test = current.length > 0 ? current + " " + words[i] : words[i]; infoText.setText(test); if (infoText.width > maxWidth && current.length > 0) { lines.push(current); current = words[i]; } else { current = test; } } if (current.length > 0) lines.push(current); infoText.setText(lines.join("\n")); } } function showSeasonText(msg) { // If text is too wide, split into multiple lines seasonText.setText(msg); var maxWidth = 2048 - 200; if (seasonText.width > maxWidth) { var words = msg.split(" "); var lines = []; var current = ""; for (var i = 0; i < words.length; i++) { var test = current.length > 0 ? current + " " + words[i] : words[i]; seasonText.setText(test); if (seasonText.width > maxWidth && current.length > 0) { lines.push(current); current = words[i]; } else { current = test; } } if (current.length > 0) lines.push(current); seasonText.setText(lines.join("\n")); } } function showNextButton(label, cb) { if (nextButton) mainContainer.removeChild(nextButton); nextButton = new Text2(label, { size: 80, fill: 0x00FF99 }); nextButton.anchor.set(0.5, 0.5); nextButton.x = 2048 / 2; nextButton.y = 2732 - 300; nextButton.interactive = true; nextButton.buttonMode = true; nextButton.down = function (x, y, obj) { cb(); }; mainContainer.addChild(nextButton); } function hideNextButton() { if (nextButton) { mainContainer.removeChild(nextButton); nextButton = null; } } function showStatText(msg) { if (statText) mainContainer.removeChild(statText); statText = new Text2(msg, { size: 70, fill: "#fff" }); statText.anchor.set(0.5, 0.5); statText.x = 2048 / 2; statText.y = 2732 / 2 + 320; mainContainer.addChild(statText); } function hideStatText() { if (statText) { mainContainer.removeChild(statText); statText = null; } } function showSummaryText(msg) { if (summaryText) mainContainer.removeChild(summaryText); summaryText = new Text2(msg, { size: 80, fill: "#fff" }); summaryText.anchor.set(0.5, 0.5); summaryText.x = 2048 / 2; summaryText.y = 2732 / 2 + 400; mainContainer.addChild(summaryText); } function hideSummaryText() { if (summaryText) { mainContainer.removeChild(summaryText); summaryText = null; } } // --- Game Flow Functions --- function startChoosePosition() { state = "choose_position"; clearMainContainer(); clearTrophyNodes(); hideStatText(); hideSummaryText(); showInfo("Mevkini Seç!"); showSeasonText(""); // Show position buttons var btns = []; for (var i = 0; i < positions.length; i++) { var pos = positions[i]; var btn = new Text2(pos.name, { size: 90, fill: 0x1E90FF }); btn.anchor.set(0.5, 0.5); btn.x = 2048 / 2; btn.y = 800 + i * 220; btn.interactive = true; btn.buttonMode = true; btn.down = function (pos) { return function (x, y, obj) { playerPosition = pos.key; playerPositionName = pos.name; startNewCareer(); }; }(pos); mainContainer.addChild(btn); btns.push(btn); } } function startNewCareer() { state = "season"; playerAge = 18; playerClub = randomPick(clubs); playerStats = []; playerTrophies = []; playerTotalGoals = 0; playerTotalAssists = 0; playerTotalTrophies = 0; clearMainContainer(); clearTrophyNodes(); hideStatText(); hideSummaryText(); showInfo(playerPositionName + " olarak kariyer başlıyor!"); showSeasonText(playerAge + " yaş | " + playerClub); // Show player and club playerNode = new Player(); playerNode.x = 2048 / 2; playerNode.y = 900; mainContainer.addChild(playerNode); clubNode = new Club(); clubNode.x = 2048 / 2; clubNode.y = 1200; mainContainer.addChild(clubNode); var clubNameText = new Text2(playerClub, { size: 70, fill: "#fff" }); clubNameText.anchor.set(0.5, 0.5); clubNameText.x = clubNode.x; clubNameText.y = clubNode.y; mainContainer.addChild(clubNameText); showNextButton("Sezona Başla", function () { mainContainer.removeChild(playerNode); mainContainer.removeChild(clubNode); mainContainer.removeChild(clubNameText); startSeason(); }); } function startSeason() { state = "season"; clearMainContainer(); clearTrophyNodes(); hideStatText(); hideSummaryText(); showInfo(playerAge + " yaşında, " + playerClub + " kulübünde sezon başlıyor!"); showSeasonText("Sezon: " + (playerAge - 17)); // Show player and club playerNode = new Player(); playerNode.x = 2048 / 2; playerNode.y = 900; mainContainer.addChild(playerNode); clubNode = new Club(); clubNode.x = 2048 / 2; clubNode.y = 1200; mainContainer.addChild(clubNode); var clubNameText = new Text2(playerClub, { size: 70, fill: "#fff" }); clubNameText.anchor.set(0.5, 0.5); clubNameText.x = clubNode.x; clubNameText.y = clubNode.y; mainContainer.addChild(clubNameText); // Random stats var goals = 0, assists = 0; if (playerPosition == "GK") { goals = randomInt(0, 1); assists = randomInt(0, 2); } else if (playerPosition == "DEF") { goals = randomInt(0, 4); assists = randomInt(0, 5); } else if (playerPosition == "MID") { goals = randomInt(2, 10); assists = randomInt(3, 12); } else if (playerPosition == "FWD") { goals = randomInt(5, 30); assists = randomInt(2, 10); } // Trophy chance var wonTrophies = []; if (randomInt(1, 100) <= 20) { // 20% chance var t = randomPick(trophies); wonTrophies.push(t); playerTrophies.push(t); } // Save season stats currentSeasonStats = { age: playerAge, club: playerClub, goals: goals, assists: assists, trophies: wonTrophies }; playerStats.push(currentSeasonStats); playerTotalGoals += goals; playerTotalAssists += assists; playerTotalTrophies += wonTrophies.length; // Show stats var statMsg = "Goller: " + goals + " | Asistler: " + assists; if (wonTrophies.length > 0) { statMsg += "\n🏆 " + wonTrophies.join(", "); } showStatText(statMsg); // Show trophies clearTrophyNodes(); for (var i = 0; i < wonTrophies.length; i++) { var trophy = new Trophy(); trophy.x = 2048 / 2 - 80 + i * 160; trophy.y = 1700; mainContainer.addChild(trophy); trophyNodes.push(trophy); var tText = new Text2("🏆", { size: 80, fill: 0xFFD700 }); tText.anchor.set(0.5, 0.5); tText.x = trophy.x; tText.y = trophy.y - 80; mainContainer.addChild(tText); trophyNodes.push(tText); } // Next: transfer offers or retirement showNextButton("Sezon Sonu", function () { mainContainer.removeChild(playerNode); mainContainer.removeChild(clubNode); mainContainer.removeChild(clubNameText); hideStatText(); clearTrophyNodes(); if (playerAge >= 35) { startSummary(); } else { startTransfer(); } }); } function startTransfer() { state = "transfer"; clearMainContainer(); clearTrophyNodes(); hideStatText(); hideSummaryText(); showInfo("Transfer Teklifleri Geldi!"); showSeasonText("Yaş: " + playerAge + " | " + playerClub); // Generate 2-3 random offers (not current club) transferOffers = []; var offerCount = randomInt(2, 3); var usedClubs = {}; usedClubs[playerClub] = true; for (var i = 0; i < offerCount; i++) { var c; do { c = randomPick(clubs); } while (usedClubs[c]); usedClubs[c] = true; transferOffers.push(c); } // Add "Stay" option transferOffers.push(playerClub); // Show buttons clearTransferButtons(); for (var i = 0; i < transferOffers.length; i++) { var c = transferOffers[i]; var isStay = c == playerClub; var btn = new Text2(isStay ? "Kulüpte Kal (" + c + ")" : c, { size: 80, fill: isStay ? "#00ff99" : "#fff" }); btn.anchor.set(0.5, 0.5); btn.x = 2048 / 2; btn.y = 900 + i * 180; btn.interactive = true; btn.buttonMode = true; btn.down = function (c) { return function (x, y, obj) { playerClub = c; playerAge += 1; clearTransferButtons(); startSeason(); }; }(c); mainContainer.addChild(btn); transferButtons.push(btn); } } function startSummary() { state = "summary"; clearMainContainer(); clearTrophyNodes(); hideStatText(); showInfo("Kariyer Tamamlandı!"); showSeasonText(""); // Show player playerNode = new Player(); playerNode.x = 2048 / 2; playerNode.y = 900; mainContainer.addChild(playerNode); // Show summary stats var summaryMsg = "Toplam Gol: " + playerTotalGoals + "\nToplam Asist: " + playerTotalAssists + "\nKazanılan Kupa: " + playerTotalTrophies; if (playerTrophies.length > 0) { summaryMsg += "\n🏆 " + playerTrophies.join(", "); } showSummaryText(summaryMsg); // Show "Yeniden Oyna" button showNextButton("Yeniden Oyna", function () { mainContainer.removeChild(playerNode); hideSummaryText(); startChoosePosition(); }); } // --- Start Game --- startChoosePosition();
===================================================================
--- original.js
+++ change.js
@@ -124,12 +124,51 @@
}
trophyNodes = [];
}
function showInfo(msg) {
+ // If text is too wide, split into multiple lines
infoText.setText(msg);
+ var maxWidth = 2048 - 200;
+ if (infoText.width > maxWidth) {
+ // Try to split by space
+ var words = msg.split(" ");
+ var lines = [];
+ var current = "";
+ for (var i = 0; i < words.length; i++) {
+ var test = current.length > 0 ? current + " " + words[i] : words[i];
+ infoText.setText(test);
+ if (infoText.width > maxWidth && current.length > 0) {
+ lines.push(current);
+ current = words[i];
+ } else {
+ current = test;
+ }
+ }
+ if (current.length > 0) lines.push(current);
+ infoText.setText(lines.join("\n"));
+ }
}
function showSeasonText(msg) {
+ // If text is too wide, split into multiple lines
seasonText.setText(msg);
+ var maxWidth = 2048 - 200;
+ if (seasonText.width > maxWidth) {
+ var words = msg.split(" ");
+ var lines = [];
+ var current = "";
+ for (var i = 0; i < words.length; i++) {
+ var test = current.length > 0 ? current + " " + words[i] : words[i];
+ seasonText.setText(test);
+ if (seasonText.width > maxWidth && current.length > 0) {
+ lines.push(current);
+ current = words[i];
+ } else {
+ current = test;
+ }
+ }
+ if (current.length > 0) lines.push(current);
+ seasonText.setText(lines.join("\n"));
+ }
}
function showNextButton(label, cb) {
if (nextButton) mainContainer.removeChild(nextButton);
nextButton = new Text2(label, {