User prompt
Oyunu bilmeyenler için sağ alt tarafa soru işaretli bir buton yap ve tıkladığında oyunun nasıl oynanacağı ile alakalı bir menü açılsın metin şu olacak: "Ekranda çıkan kelimelerin harf sayılarını rakamlara basarak yaz. Ok veya cevapla tuşuna basarak gönderebilirsiniz. Sile basarak yazınızı silebilirsiniz."
User prompt
Ekstra olarak zaman, insanlar, kural, üzgün ve mutluluk kelimelerini de ekle. Bu kelimelerin harf sayısını yazacağız. Yanlışsa oyun bitecek. Doğruysa oyun sonsuza kadar devam edecek
Code edit (1 edits merged)
Please save this source code
User prompt
Harfli Günlük: Sayıyla Yaz!
Initial prompt
Bana bir tane yazma yerinin olduğu ve istediğimizin yazabileceği bir yer olsun. Ayrıca onun üstünde tarih, okul, merhaba, günlük, kitap, hayat kelimeleri rastgele çıksın. Bunun harf sayılarını rakam kullanarak yazacağız. Yanlış ise oyun kaybedilecek. Doğru ise oyun sonsuza kadar devam edecektir
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xffffff // White background for clarity }); /**** * Game Code ****/ // --- HELP BUTTON & POPUP --- // Help button (bottom right, avoid bottom 100px for safe area) var helpBtnSize = 140; var helpBtnMargin = 80; var helpBtn = LK.getAsset('buttonBox', { width: helpBtnSize, height: helpBtnSize, color: 0xc3abe3, shape: 'box', anchorX: 0.5, anchorY: 0.5, x: 2048 - helpBtnSize / 2 - helpBtnMargin, y: 2732 - helpBtnSize / 2 - helpBtnMargin }); game.addChild(helpBtn); var helpBtnText = new Text2("?", { size: 100, fill: 0x4b2e83 }); helpBtnText.anchor.set(0.5, 0.5); helpBtnText.x = helpBtn.x; helpBtnText.y = helpBtn.y; game.addChild(helpBtnText); // Help popup (hidden by default) var helpPopupWidth = 1200; var helpPopupHeight = 900; var helpPopupBg = LK.getAsset('inputBox', { width: helpPopupWidth, height: helpPopupHeight, color: 0xffffff, shape: 'box', anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); helpPopupBg.visible = false; game.addChild(helpPopupBg); var helpPopupText = new Text2("Ekranda çıkan kelimelerin harf sayılarını rakamlara basarak yaz. Ok veya cevapla tuşuna basarak gönderebilirsiniz. Sile basarak yazınızı silebilirsiniz.", { size: 70, fill: 0x333333, wordWrap: true, wordWrapWidth: helpPopupWidth - 120, align: "center" }); helpPopupText.anchor.set(0.5, 0.5); helpPopupText.x = helpPopupBg.x; helpPopupText.y = helpPopupBg.y - 100; helpPopupText.visible = false; game.addChild(helpPopupText); // Close button for popup var closeBtnSize = 120; var closeBtn = LK.getAsset('buttonBox', { width: closeBtnSize, height: closeBtnSize, color: 0xc3abe3, shape: 'box', anchorX: 0.5, anchorY: 0.5, x: helpPopupBg.x + helpPopupWidth / 2 - closeBtnSize / 2 - 30, y: helpPopupBg.y - helpPopupHeight / 2 + closeBtnSize / 2 + 30 }); closeBtn.visible = false; game.addChild(closeBtn); var closeBtnText = new Text2("X", { size: 80, fill: 0x4b2e83 }); closeBtnText.anchor.set(0.5, 0.5); closeBtnText.x = closeBtn.x; closeBtnText.y = closeBtn.y; closeBtnText.visible = false; game.addChild(closeBtnText); // Show popup function function showHelpPopup() { helpPopupBg.visible = true; helpPopupText.visible = true; closeBtn.visible = true; closeBtnText.visible = true; inputActive = false; } // Hide popup function function hideHelpPopup() { helpPopupBg.visible = false; helpPopupText.visible = false; closeBtn.visible = false; closeBtnText.visible = false; inputActive = true; } // Button handlers helpBtn.down = function (x, y, obj) { showHelpPopup(); }; helpBtnText.down = helpBtn.down; closeBtn.down = function (x, y, obj) { hideHelpPopup(); }; closeBtnText.down = closeBtn.down; // --- END ---; var words = ["tarih", "okul", "merhaba", "günlük", "kitap", "hayat", "zaman", "insanlar", "kural", "üzgün", "mutluluk"]; var currentWord = ""; var score = 0; var inputValue = ""; var inputBoxes = []; var inputBoxWidth = 200; var inputBoxHeight = 180; var inputFontSize = 120; var wordFontSize = 180; var scoreFontSize = 100; var inputActive = true; // --- UI ELEMENTS --- // Show current word at the top center var wordText = new Text2("", { size: wordFontSize, fill: 0x222222 }); wordText.anchor.set(0.5, 0); wordText.x = 2048 / 2; wordText.y = 180; game.addChild(wordText); // Score display at top right (avoid top left for menu) var scoreText = new Text2("0", { size: scoreFontSize, fill: 0x008080 }); scoreText.anchor.set(1, 0); scoreText.x = 2048 - 80; scoreText.y = 80; game.addChild(scoreText); // Input box centered var inputBox = LK.getAsset('inputBox', { width: inputBoxWidth, height: inputBoxHeight, color: 0xeeeeee, shape: 'box', anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 + 200 }); game.addChild(inputBox); // Input text (user's answer) var inputText = new Text2("", { size: inputFontSize, fill: 0x333333 }); inputText.anchor.set(0.5, 0.5); inputText.x = inputBox.x; inputText.y = inputBox.y; game.addChild(inputText); // "Cevapla" button var buttonWidth = 400; var buttonHeight = 140; var buttonY = inputBox.y + inputBoxHeight / 2 + 120; var buttonBox = LK.getAsset('buttonBox', { width: buttonWidth, height: buttonHeight, color: 0x008080, shape: 'box', anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: buttonY }); game.addChild(buttonBox); var buttonText = new Text2("Cevapla", { size: 80, fill: 0xFFFFFF }); buttonText.anchor.set(0.5, 0.5); buttonText.x = buttonBox.x; buttonText.y = buttonBox.y; game.addChild(buttonText); // --- LOGIC --- function pickRandomWord() { var idx = Math.floor(Math.random() * words.length); return words[idx]; } function setNewWord() { currentWord = pickRandomWord(); wordText.setText(currentWord); inputValue = ""; inputText.setText(""); inputActive = true; } function updateScore() { scoreText.setText(score); } // --- INPUT HANDLING --- // Virtual number pad (0-9) for mobile var keypadButtons = []; var keypadLayout = [[1, 2, 3], [4, 5, 6], [7, 8, 9], ["Sil", 0, "OK"]]; var keypadStartX = 2048 / 2 - 1.5 * inputBoxWidth - 40; var keypadStartY = buttonBox.y + buttonHeight / 2 + 80; var keypadButtonW = inputBoxWidth; var keypadButtonH = 120; var keypadGap = 40; for (var row = 0; row < keypadLayout.length; row++) { for (var col = 0; col < keypadLayout[row].length; col++) { var val = keypadLayout[row][col]; var btnX = keypadStartX + col * (keypadButtonW + keypadGap); var btnY = keypadStartY + row * (keypadButtonH + keypadGap); var btnAsset = LK.getAsset('keypadBtn', { width: keypadButtonW, height: keypadButtonH, color: typeof val === "number" ? 0xffffff : 0xcccccc, shape: 'box', anchorX: 0.5, anchorY: 0.5, x: btnX + keypadButtonW / 2, y: btnY + keypadButtonH / 2 }); game.addChild(btnAsset); var btnText = new Text2(val + "", { size: 70, fill: 0x222222 }); btnText.anchor.set(0.5, 0.5); btnText.x = btnAsset.x; btnText.y = btnAsset.y; game.addChild(btnText); (function (val, btnAsset) { btnAsset.down = function (x, y, obj) { if (!inputActive) return; if (val === "Sil") { if (inputValue.length > 0) { inputValue = inputValue.slice(0, -1); inputText.setText(inputValue); } } else if (val === "OK") { submitInput(); } else { if (inputValue.length < 2) { // Max 2 digits (for 10+ letter words, not needed here) inputValue += val; inputText.setText(inputValue); } } }; })(val, btnAsset); keypadButtons.push(btnAsset); } } // Input box also focuses for input (for touch) inputBox.down = function (x, y, obj) { // No-op, just visual feedback if (!inputActive) return; LK.effects.flashObject(inputBox, 0x008080, 200); }; // "Cevapla" button handler buttonBox.down = function (x, y, obj) { if (!inputActive) return; submitInput(); }; buttonText.down = buttonBox.down; // --- SUBMIT LOGIC --- function submitInput() { if (!inputActive) return; inputActive = false; var correct = parseInt(inputValue) === currentWord.length; if (correct) { score += 1; updateScore(); LK.effects.flashObject(inputBox, 0x83de44, 300); LK.setTimeout(function () { setNewWord(); }, 350); } else { LK.effects.flashScreen(0xff0000, 600); LK.showGameOver(); } } // --- GAME STARTUP --- function resetGame() { score = 0; updateScore(); setNewWord(); inputActive = true; } resetGame(); // --- GAME UPDATE (not used, but required for tick-based logic if needed) --- game.update = function () { // No per-frame logic needed }; // --- END ---
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xffffff // White background for clarity
});
/****
* Game Code
****/
// --- HELP BUTTON & POPUP ---
// Help button (bottom right, avoid bottom 100px for safe area)
var helpBtnSize = 140;
var helpBtnMargin = 80;
var helpBtn = LK.getAsset('buttonBox', {
width: helpBtnSize,
height: helpBtnSize,
color: 0xc3abe3,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5,
x: 2048 - helpBtnSize / 2 - helpBtnMargin,
y: 2732 - helpBtnSize / 2 - helpBtnMargin
});
game.addChild(helpBtn);
var helpBtnText = new Text2("?", {
size: 100,
fill: 0x4b2e83
});
helpBtnText.anchor.set(0.5, 0.5);
helpBtnText.x = helpBtn.x;
helpBtnText.y = helpBtn.y;
game.addChild(helpBtnText);
// Help popup (hidden by default)
var helpPopupWidth = 1200;
var helpPopupHeight = 900;
var helpPopupBg = LK.getAsset('inputBox', {
width: helpPopupWidth,
height: helpPopupHeight,
color: 0xffffff,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
helpPopupBg.visible = false;
game.addChild(helpPopupBg);
var helpPopupText = new Text2("Ekranda çıkan kelimelerin harf sayılarını rakamlara basarak yaz. Ok veya cevapla tuşuna basarak gönderebilirsiniz. Sile basarak yazınızı silebilirsiniz.", {
size: 70,
fill: 0x333333,
wordWrap: true,
wordWrapWidth: helpPopupWidth - 120,
align: "center"
});
helpPopupText.anchor.set(0.5, 0.5);
helpPopupText.x = helpPopupBg.x;
helpPopupText.y = helpPopupBg.y - 100;
helpPopupText.visible = false;
game.addChild(helpPopupText);
// Close button for popup
var closeBtnSize = 120;
var closeBtn = LK.getAsset('buttonBox', {
width: closeBtnSize,
height: closeBtnSize,
color: 0xc3abe3,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5,
x: helpPopupBg.x + helpPopupWidth / 2 - closeBtnSize / 2 - 30,
y: helpPopupBg.y - helpPopupHeight / 2 + closeBtnSize / 2 + 30
});
closeBtn.visible = false;
game.addChild(closeBtn);
var closeBtnText = new Text2("X", {
size: 80,
fill: 0x4b2e83
});
closeBtnText.anchor.set(0.5, 0.5);
closeBtnText.x = closeBtn.x;
closeBtnText.y = closeBtn.y;
closeBtnText.visible = false;
game.addChild(closeBtnText);
// Show popup function
function showHelpPopup() {
helpPopupBg.visible = true;
helpPopupText.visible = true;
closeBtn.visible = true;
closeBtnText.visible = true;
inputActive = false;
}
// Hide popup function
function hideHelpPopup() {
helpPopupBg.visible = false;
helpPopupText.visible = false;
closeBtn.visible = false;
closeBtnText.visible = false;
inputActive = true;
}
// Button handlers
helpBtn.down = function (x, y, obj) {
showHelpPopup();
};
helpBtnText.down = helpBtn.down;
closeBtn.down = function (x, y, obj) {
hideHelpPopup();
};
closeBtnText.down = closeBtn.down;
// --- END ---;
var words = ["tarih", "okul", "merhaba", "günlük", "kitap", "hayat", "zaman", "insanlar", "kural", "üzgün", "mutluluk"];
var currentWord = "";
var score = 0;
var inputValue = "";
var inputBoxes = [];
var inputBoxWidth = 200;
var inputBoxHeight = 180;
var inputFontSize = 120;
var wordFontSize = 180;
var scoreFontSize = 100;
var inputActive = true;
// --- UI ELEMENTS ---
// Show current word at the top center
var wordText = new Text2("", {
size: wordFontSize,
fill: 0x222222
});
wordText.anchor.set(0.5, 0);
wordText.x = 2048 / 2;
wordText.y = 180;
game.addChild(wordText);
// Score display at top right (avoid top left for menu)
var scoreText = new Text2("0", {
size: scoreFontSize,
fill: 0x008080
});
scoreText.anchor.set(1, 0);
scoreText.x = 2048 - 80;
scoreText.y = 80;
game.addChild(scoreText);
// Input box centered
var inputBox = LK.getAsset('inputBox', {
width: inputBoxWidth,
height: inputBoxHeight,
color: 0xeeeeee,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2 + 200
});
game.addChild(inputBox);
// Input text (user's answer)
var inputText = new Text2("", {
size: inputFontSize,
fill: 0x333333
});
inputText.anchor.set(0.5, 0.5);
inputText.x = inputBox.x;
inputText.y = inputBox.y;
game.addChild(inputText);
// "Cevapla" button
var buttonWidth = 400;
var buttonHeight = 140;
var buttonY = inputBox.y + inputBoxHeight / 2 + 120;
var buttonBox = LK.getAsset('buttonBox', {
width: buttonWidth,
height: buttonHeight,
color: 0x008080,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: buttonY
});
game.addChild(buttonBox);
var buttonText = new Text2("Cevapla", {
size: 80,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
buttonText.x = buttonBox.x;
buttonText.y = buttonBox.y;
game.addChild(buttonText);
// --- LOGIC ---
function pickRandomWord() {
var idx = Math.floor(Math.random() * words.length);
return words[idx];
}
function setNewWord() {
currentWord = pickRandomWord();
wordText.setText(currentWord);
inputValue = "";
inputText.setText("");
inputActive = true;
}
function updateScore() {
scoreText.setText(score);
}
// --- INPUT HANDLING ---
// Virtual number pad (0-9) for mobile
var keypadButtons = [];
var keypadLayout = [[1, 2, 3], [4, 5, 6], [7, 8, 9], ["Sil", 0, "OK"]];
var keypadStartX = 2048 / 2 - 1.5 * inputBoxWidth - 40;
var keypadStartY = buttonBox.y + buttonHeight / 2 + 80;
var keypadButtonW = inputBoxWidth;
var keypadButtonH = 120;
var keypadGap = 40;
for (var row = 0; row < keypadLayout.length; row++) {
for (var col = 0; col < keypadLayout[row].length; col++) {
var val = keypadLayout[row][col];
var btnX = keypadStartX + col * (keypadButtonW + keypadGap);
var btnY = keypadStartY + row * (keypadButtonH + keypadGap);
var btnAsset = LK.getAsset('keypadBtn', {
width: keypadButtonW,
height: keypadButtonH,
color: typeof val === "number" ? 0xffffff : 0xcccccc,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5,
x: btnX + keypadButtonW / 2,
y: btnY + keypadButtonH / 2
});
game.addChild(btnAsset);
var btnText = new Text2(val + "", {
size: 70,
fill: 0x222222
});
btnText.anchor.set(0.5, 0.5);
btnText.x = btnAsset.x;
btnText.y = btnAsset.y;
game.addChild(btnText);
(function (val, btnAsset) {
btnAsset.down = function (x, y, obj) {
if (!inputActive) return;
if (val === "Sil") {
if (inputValue.length > 0) {
inputValue = inputValue.slice(0, -1);
inputText.setText(inputValue);
}
} else if (val === "OK") {
submitInput();
} else {
if (inputValue.length < 2) {
// Max 2 digits (for 10+ letter words, not needed here)
inputValue += val;
inputText.setText(inputValue);
}
}
};
})(val, btnAsset);
keypadButtons.push(btnAsset);
}
}
// Input box also focuses for input (for touch)
inputBox.down = function (x, y, obj) {
// No-op, just visual feedback
if (!inputActive) return;
LK.effects.flashObject(inputBox, 0x008080, 200);
};
// "Cevapla" button handler
buttonBox.down = function (x, y, obj) {
if (!inputActive) return;
submitInput();
};
buttonText.down = buttonBox.down;
// --- SUBMIT LOGIC ---
function submitInput() {
if (!inputActive) return;
inputActive = false;
var correct = parseInt(inputValue) === currentWord.length;
if (correct) {
score += 1;
updateScore();
LK.effects.flashObject(inputBox, 0x83de44, 300);
LK.setTimeout(function () {
setNewWord();
}, 350);
} else {
LK.effects.flashScreen(0xff0000, 600);
LK.showGameOver();
}
}
// --- GAME STARTUP ---
function resetGame() {
score = 0;
updateScore();
setNewWord();
inputActive = true;
}
resetGame();
// --- GAME UPDATE (not used, but required for tick-based logic if needed) ---
game.update = function () {
// No per-frame logic needed
};
// --- END ---