/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
musicVolume: 1,
soundVolume: 1
});
/****
* Classes
****/
var Gallows = Container.expand(function () {
var self = Container.call(this);
// Create stand structure first
var standBase = self.attachAsset('standBase', {
anchorX: 0.5,
anchorY: 1.0,
y: 0
});
var standSupport1 = self.attachAsset('standSupport1', {
anchorX: 0.5,
anchorY: 1.0,
x: -80,
y: -25
});
var standSupport2 = self.attachAsset('standSupport2', {
anchorX: 0.5,
anchorY: 1.0,
x: 80,
y: -25
});
// Create gallows structure on top of stand
var gallowsBase = self.attachAsset('gallowsBase', {
anchorX: 0.5,
anchorY: 1.0,
y: -145
});
var gallowsPost = self.attachAsset('gallowsPost', {
anchorX: 0.5,
anchorY: 1.0,
x: -75,
y: -145
});
var gallowsBeam = self.attachAsset('gallowsBeam', {
anchorX: 0.0,
anchorY: 0.5,
x: -75,
y: -435
});
var rope = self.attachAsset('rope', {
anchorX: 0.5,
anchorY: 0.0,
x: 0,
y: -445
});
self.bodyParts = [];
var head = LK.getAsset('head', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -380
});
head.alpha = 0;
self.addChild(head);
self.bodyParts.push(head);
var body = LK.getAsset('body', {
anchorX: 0.5,
anchorY: 0.0,
x: 0,
y: -350
});
body.alpha = 0;
self.addChild(body);
self.bodyParts.push(body);
var leftArm = LK.getAsset('leftArm', {
anchorX: 1.0,
anchorY: 0.5,
x: -4,
y: -320
});
leftArm.alpha = 0;
leftArm.rotation = Math.PI / 4;
self.addChild(leftArm);
self.bodyParts.push(leftArm);
var rightArm = LK.getAsset('rightArm', {
anchorX: 0.0,
anchorY: 0.5,
x: 4,
y: -320
});
rightArm.alpha = 0;
rightArm.rotation = -Math.PI / 4;
self.addChild(rightArm);
self.bodyParts.push(rightArm);
var leftLeg = LK.getAsset('leftLeg', {
anchorX: 1.0,
anchorY: 0.5,
x: -4,
y: -250
});
leftLeg.alpha = 0;
leftLeg.rotation = Math.PI / 6 + Math.PI;
self.addChild(leftLeg);
self.bodyParts.push(leftLeg);
var rightLeg = LK.getAsset('rightLeg', {
anchorX: 0.0,
anchorY: 0.5,
x: 4,
y: -250
});
rightLeg.alpha = 0;
rightLeg.rotation = -Math.PI / 6 + Math.PI;
self.addChild(rightLeg);
self.bodyParts.push(rightLeg);
self.showBodyPart = function (partIndex) {
if (partIndex < self.bodyParts.length) {
self.bodyParts[partIndex].alpha = 1;
tween(self.bodyParts[partIndex], {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200,
onFinish: function onFinish() {
tween(self.bodyParts[partIndex], {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 200
});
}
});
}
};
self.changeToDeadHead = function () {
if (self.bodyParts.length > 0) {
var headPart = self.bodyParts[0];
self.removeChild(headPart);
var deadHead = LK.getAsset('deadHead', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -380
});
deadHead.tint = 0x666666; // Make it greyish to show death
self.addChild(deadHead);
self.bodyParts[0] = deadHead;
}
// Animate arms rotation 200 degrees in 0.2 seconds
if (self.bodyParts.length >= 4) {
var leftArm = self.bodyParts[2];
var rightArm = self.bodyParts[3];
// Convert 130 degrees to radians
var rotationAmount = 130 * Math.PI / 180;
// Animate left arm counterclockwise (negative rotation)
tween(leftArm, {
rotation: leftArm.rotation - rotationAmount
}, {
duration: 200
});
// Animate right arm clockwise (positive rotation)
tween(rightArm, {
rotation: rightArm.rotation + rotationAmount
}, {
duration: 200
});
}
// Animate legs rotation 45 degrees in 0.2 seconds
if (self.bodyParts.length >= 6) {
var leftLeg = self.bodyParts[4];
var rightLeg = self.bodyParts[5];
// Convert 45 degrees to radians
var legRotationAmount = 45 * Math.PI / 180;
// Animate right leg counterclockwise (negative rotation)
tween(rightLeg, {
rotation: rightLeg.rotation - legRotationAmount
}, {
duration: 200
});
// Animate left leg clockwise (positive rotation)
tween(leftLeg, {
rotation: leftLeg.rotation + legRotationAmount
}, {
duration: 200
});
}
};
return self;
});
var GameOverMenu = Container.expand(function (isWin) {
var self = Container.call(this);
// Semi-transparent background overlay
var overlay = LK.getAsset('menuOverlay', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.95,
scaleX: 2,
scaleY: 4
});
self.addChild(overlay);
// Title text - show MENÜ for paused game, TEBRİKLER for win, OYUN BİTTİ for loss
var titleText = new Text2(isWin ? 'TEBRİKLER!' : gameOver ? 'OYUN BİTTİ' : 'MENÜ', {
size: 120,
fill: isWin ? 0x00AA00 : gameOver ? 0xAA0000 : 0x333333
});
titleText.anchor.set(0.5, 0.5);
titleText.y = -300;
self.addChild(titleText);
// Result text - only show for completed games
if (isWin || gameOver) {
var resultText = new Text2(isWin ? 'Kelimeyi doğru tahmin ettiniz!' : 'Kelime: ' + currentWord, {
size: 80,
fill: 0x333333
});
resultText.anchor.set(0.5, 0.5);
resultText.y = -160;
self.addChild(resultText);
}
// Restart button
var restartButton = LK.getAsset('menuButton', {
anchorX: 0.5,
anchorY: 0.5,
y: -20,
scaleX: 2,
scaleY: 2
});
self.addChild(restartButton);
var restartText = new Text2('YENİDEN BAŞLA', {
size: 60,
fill: 0xFFFFFF
});
restartText.anchor.set(0.5, 0.5);
restartText.y = -20;
self.addChild(restartText);
// Settings button
var settingsButton = LK.getAsset('menuButton', {
anchorX: 0.5,
anchorY: 0.5,
y: 160,
scaleX: 2,
scaleY: 2
});
self.addChild(settingsButton);
var settingsText = new Text2('AYARLAR', {
size: 60,
fill: 0xFFFFFF
});
settingsText.anchor.set(0.5, 0.5);
settingsText.y = 160;
self.addChild(settingsText);
// Continue button (only show if not game over)
var continueButton = null;
var continueText = null;
if (!isWin && currentWord && !gameOver) {
continueButton = LK.getAsset('menuButton', {
anchorX: 0.5,
anchorY: 0.5,
y: 340,
scaleX: 2,
scaleY: 2
});
self.addChild(continueButton);
continueText = new Text2('DEVAM ET', {
size: 60,
fill: 0xFFFFFF
});
continueText.anchor.set(0.5, 0.5);
continueText.y = 340;
self.addChild(continueText);
}
// Credits button
var creditsButton = LK.getAsset('menuButton', {
anchorX: 0.5,
anchorY: 0.5,
y: continueButton ? 520 : 340,
scaleX: 2,
scaleY: 2
});
self.addChild(creditsButton);
var creditsText = new Text2('YAPIMCILAR', {
size: 60,
fill: 0xFFFFFF
});
creditsText.anchor.set(0.5, 0.5);
creditsText.y = continueButton ? 520 : 340;
self.addChild(creditsText);
// Button interactions
self.down = function (x, y, obj) {
// Use the x, y coordinates directly instead of complex coordinate conversion
// Check restart button
if (y >= -100 && y <= 60) {
var buttonSound = LK.getSound('button');
buttonSound.volume = storage.soundVolume || 1.0;
buttonSound.play();
restartGame();
}
// Check settings button
else if (y >= 80 && y <= 240) {
var buttonSound = LK.getSound('button');
buttonSound.volume = storage.soundVolume || 1.0;
buttonSound.play();
showSettings();
}
// Check continue button
else if (continueButton && y >= 260 && y <= 420) {
var buttonSound = LK.getSound('button');
buttonSound.volume = storage.soundVolume || 1.0;
buttonSound.play();
hideInGameMenu();
}
// Check credits button
else if (y >= (continueButton ? 440 : 260) && y <= (continueButton ? 600 : 420)) {
var buttonSound = LK.getSound('button');
buttonSound.volume = storage.soundVolume || 1.0;
buttonSound.play();
showCredits();
}
};
return self;
});
var LetterButton = Container.expand(function (letter) {
var self = Container.call(this);
self.letter = letter;
self.isUsed = false;
var buttonBg = self.attachAsset('letterButton', {
anchorX: 0.5,
anchorY: 0.5
});
var letterText = new Text2(letter.toUpperCase(), {
size: 75,
fill: 0xFFFFFF
});
letterText.anchor.set(0.5, 0.5);
self.addChild(letterText);
self.markAsUsed = function () {
if (!self.isUsed) {
self.isUsed = true;
self.removeChild(buttonBg);
var usedBg = self.attachAsset('usedLetterButton', {
anchorX: 0.5,
anchorY: 0.5
});
letterText.tint = 0x999999;
}
};
self.down = function (x, y, obj) {
if (!self.isUsed && !gameMenuOpen) {
guessLetter(self.letter);
}
};
return self;
});
var VolumeSlider = Container.expand(function (title, initialValue, onValueChange) {
var self = Container.call(this);
// Title text
var titleText = new Text2(title, {
size: 50,
fill: 0x333333
});
titleText.anchor.set(0.5, 0.5);
titleText.y = -40;
self.addChild(titleText);
// Slider track
var track = LK.getAsset('menuButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 0.3
});
track.tint = 0x999999;
self.addChild(track);
// Slider handle
var handle = LK.getAsset('menuButtonSmall', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.5,
scaleY: 0.5
});
handle.tint = 0x4a90e2;
self.addChild(handle);
// Value text
var valueText = new Text2(Math.round(initialValue * 100) + '%', {
size: 40,
fill: 0x666666
});
valueText.anchor.set(0.5, 0.5);
valueText.y = 40;
self.addChild(valueText);
// Set initial handle position
var trackWidth = 300 * 1.5; // track width * scaleX
handle.x = (initialValue - 0.5) * trackWidth;
self.setValue = function (value) {
var clampedValue = Math.max(0, Math.min(1, value));
handle.x = (clampedValue - 0.5) * trackWidth;
valueText.setText(Math.round(clampedValue * 100) + '%');
if (onValueChange) {
onValueChange(clampedValue);
}
};
self.down = function (x, y, obj) {
// Calculate relative position on track
var relativeX = x / trackWidth + 0.5;
var newValue = Math.max(0, Math.min(1, relativeX));
self.setValue(newValue);
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xF5F5F5
});
/****
* Game Code
****/
var wordCategories = {
'HAYVAN': {
words: ['AKREP', 'ASLAN', 'BALIK', 'BİZON', 'BÖCEK', 'ÇAKAL', 'DEVE', 'GEYIK', 'GÜVERCIN', 'HOROZ', 'KARTAL', 'KEDİ', 'KIRPI', 'KÖPEK', 'KUĞU', 'KURBAĞA', 'KURT', 'KUZU', 'LEOPAR', 'MAYMUN', 'ÖRDEK', 'PAPAĞAN', 'SALYANGOZ', 'TAVŞAN', 'TURNA', 'VAŞAK', 'ZEBRA'],
hint: 'HAYVAN'
},
'GIDA': {
words: ['ARMUT', 'BADEM', 'BÖREK', 'ÇORBA', 'DOMATES', 'ELMA', 'FASULYE', 'GÜVEÇ', 'HELVA', 'IZGARA', 'JAMBON', 'KAHVE', 'LAHMACUN', 'MEYVE', 'NOHUT', 'OMLET', 'PEYNIR', 'REÇEL', 'SALATA', 'TAVUK', 'ÜZÜM', 'VIŞNE', 'YOĞURT', 'ZEYTİN'],
hint: 'GIDA'
},
'EŞYA': {
words: ['ANAHTAR', 'BAVUL', 'ÇANTA', 'DOLAP', 'FINCAN', 'GÖZLÜK', 'HALKA', 'IBRIK', 'KALEM', 'LAMBA', 'MASA', 'PERDE', 'RADYO', 'SAAT', 'TELEFON', 'VAZO', 'YAZICI', 'ZINCIR'],
hint: 'EŞYA'
},
'DUYGU': {
words: ['AŞKA', 'BAHAR', 'CESARET', 'DOSTLUK', 'EMEK', 'FIKIR', 'GÜVEN', 'HAYAL', 'IŞIK', 'KORKU', 'LÜTUF', 'MUTLULUK', 'NEFRET', 'OZLEM', 'PIŞMANLIK', 'RAHAT', 'SEVGI', 'TATLILUK', 'UMUT', 'VICDAN', 'YAŞAM', 'ZEVK'],
hint: 'DUYGU/KAVRAM'
},
'MESLEK': {
words: ['AVUKAT', 'BERBER', 'CERRAH', 'DOKTOR', 'ELEKTRIKÇI', 'GARSON', 'HEMŞIRE', 'IŞÇI', 'JOKEY', 'KAPICI', 'LABORANT', 'MIMAR', 'NOTER', 'ÖĞRETMEN', 'PILOT', 'RESSAM', 'SÜRÜCÜ', 'TERZI', 'USTA', 'VETERINER', 'YAZAR', 'ZOOLOG'],
hint: 'MESLEK'
},
'MEKAN': {
words: ['BAHÇE', 'ÇARŞI', 'DERSHANE', 'ECZANE', 'FABRIKA', 'GALERİ', 'HASTANE', 'KAHVEHANE', 'LIMAN', 'MÜZE', 'OTOPARK', 'PLAZA', 'RESTORAN', 'STADYUM', 'TIYATRO', 'ÜNİVERSİTE', 'VİLLA', 'ZOO'],
hint: 'MEKAN'
},
'RENK': {
words: ['AÇIK', 'BEYAZ', 'EFLATUN', 'FÜME', 'GRİ', 'HAKI', 'INDIGO', 'KAHVE', 'LACİVERT', 'MAVI', 'NARİN', 'OPAK', 'PEMBE', 'RENK', 'SARMAL', 'TURQUAZ', 'ULTRAMARIN', 'VİOLE', 'YEMYEŞIL', 'ZEYTUNİ'],
hint: 'RENK/ŞEKİL'
},
'ULAŞIM': {
words: ['ARABA', 'BISIKLET', 'DOLMUŞ', 'EKSPRES', 'FERIBOT', 'GEMI', 'HELIKOPTER', 'JET', 'KAMYON', 'LİMUZİN', 'METRO', 'OTOBÜS', 'ROKET', 'SCOOTER', 'TAKSI', 'UÇAK', 'VAPUR', 'ZEPLİN'],
hint: 'ULAŞIM'
},
'TEKNOLOJİ': {
words: ['ALGORITMA', 'BLUETOOTH', 'DATABASE', 'EMAIL', 'FIRMWARE', 'HARDWARE', 'INTERNET', 'JAVA', 'KLAVYE', 'LAPTOP', 'MODEM', 'NETWORK', 'ONLINE', 'PROGRAM', 'ROUTER', 'SOFTWARE', 'TABLET', 'USB', 'VİRÜS', 'WİFİ'],
hint: 'TEKNOLOJİ'
},
'SPOR': {
words: ['ATLETIZM', 'BASKETBOL', 'ESKRİM', 'FUTBOL', 'GOLF', 'HALTER', 'KARATE', 'MARATON', 'NIŞAN', 'OLIMPIK', 'PENALTI', 'RUGBY', 'TENIS', 'VOLEYBOL', 'YOGA'],
hint: 'SPOR'
},
'SANAT': {
words: ['AKORD', 'BALE', 'CELLO', 'DANS', 'ESTETIK', 'FLÜT', 'GITAR', 'HEYKEL', 'JAZZ', 'KLASIK', 'MÜZIK', 'NOTA', 'OPERA', 'PIYANO', 'RITIM', 'SENFONI', 'TABLO', 'VİOLİN', 'YAYLI', 'ZURNA'],
hint: 'SANAT/MÜZİK'
}
};
var turkishWords = [];
var currentHint = '';
// Flatten all words from categories into single array
for (var category in wordCategories) {
turkishWords = turkishWords.concat(wordCategories[category].words);
}
function getWordWithHint() {
var selectedWord = turkishWords[Math.floor(Math.random() * turkishWords.length)];
// Find which category this word belongs to
for (var category in wordCategories) {
if (wordCategories[category].words.indexOf(selectedWord) !== -1) {
currentHint = wordCategories[category].hint;
break;
}
}
return selectedWord;
}
var currentWord = '';
var guessedLetters = [];
var wrongGuesses = 0;
var maxWrongGuesses = 6;
var gameOver = false;
var gallows;
var wordDisplay;
var letterButtons = [];
var statusText;
var hintDisplay;
function initializeGame() {
currentWord = getWordWithHint();
guessedLetters = [];
wrongGuesses = 0;
gameOver = false;
// Add background
var background = LK.getAsset('background', {
anchorX: 0,
anchorY: 0
});
background.x = 0;
background.y = 0;
game.addChild(background);
// Create gallows
gallows = game.addChild(new Gallows());
gallows.x = 300;
gallows.y = 1200; // Move further down to 1200
gallows.scaleX = 2; // Scale to 2x size
gallows.scaleY = 2; // Scale to 2x size
// Create hint display
hintDisplay = new Text2('İpucu: ' + currentHint, {
size: 60,
fill: 0x007ACC
});
hintDisplay.anchor.set(0.5, 0.5);
hintDisplay.x = 1024;
hintDisplay.y = 880;
game.addChild(hintDisplay);
// Create word display
wordDisplay = new Text2(getDisplayWord(), {
size: 120,
fill: 0x333333
});
wordDisplay.anchor.set(0.5, 0.5);
wordDisplay.x = 1024;
wordDisplay.y = 1000;
game.addChild(wordDisplay);
// Create letter buttons
var alphabet = 'ABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZ';
var buttonsPerRow = 6;
var buttonSpacing = 280; // Increased spacing between larger buttons
var rowSpacing = 180; // Increased spacing between rows
var totalKeyboardWidth = (buttonsPerRow - 1) * buttonSpacing;
var buttonStartX = (2048 - totalKeyboardWidth) / 2; // Center horizontally
var buttonStartY = 1750; // Move keyboard to bottom area
for (var i = 0; i < alphabet.length; i++) {
var button = new LetterButton(alphabet[i]);
var row = Math.floor(i / buttonsPerRow);
var col = i % buttonsPerRow;
button.x = buttonStartX + col * buttonSpacing;
button.y = buttonStartY + row * rowSpacing;
letterButtons.push(button);
game.addChild(button);
}
// Create status text
statusText = new Text2('Kelimeyi tahmin edin!', {
size: 70,
fill: 0x666666
});
statusText.anchor.set(0.5, 0.5);
statusText.x = 1024;
statusText.y = 1150;
game.addChild(statusText);
// Create in-game menu button at top right
var inGameMenuButton = LK.getAsset('menuButtonSmall', {
anchorX: 1.0,
anchorY: 0.0,
scaleX: 2,
scaleY: 2
});
inGameMenuButton.x = 1948; // 100px from right edge
inGameMenuButton.y = 100; // 100px from top
game.addChild(inGameMenuButton);
var menuButtonText = new Text2('MENÜ', {
size: 60,
fill: 0xFFFFFF
});
menuButtonText.anchor.set(0.5, 0.5);
menuButtonText.x = 1828; // Center of scaled button
menuButtonText.y = 180; // Center of scaled button
game.addChild(menuButtonText);
// Add click handler for menu button
inGameMenuButton.down = function (x, y, obj) {
if (!gameOver && !gameMenuOpen) {
var buttonSound = LK.getSound('button');
buttonSound.volume = storage.soundVolume || 1.0;
buttonSound.play();
showInGameMenu();
}
};
}
function getDisplayWord() {
var display = '';
for (var i = 0; i < currentWord.length; i++) {
var letter = currentWord[i];
if (guessedLetters.indexOf(letter) !== -1) {
display += letter + ' ';
} else {
display += '_ ';
}
}
return display.trim();
}
function guessLetter(letter) {
if (gameOver || guessedLetters.indexOf(letter) !== -1) {
return;
}
guessedLetters.push(letter);
// Find and mark button as used
for (var i = 0; i < letterButtons.length; i++) {
if (letterButtons[i].letter === letter) {
letterButtons[i].markAsUsed();
break;
}
}
if (currentWord.indexOf(letter) !== -1) {
// Correct guess
var correctSound = LK.getSound('correct');
correctSound.volume = storage.soundVolume || 1.0;
correctSound.play();
statusText.setText('Doğru tahmin!');
statusText.tint = 0x00AA00;
// Check if word is complete
var wordComplete = true;
for (var i = 0; i < currentWord.length; i++) {
if (guessedLetters.indexOf(currentWord[i]) === -1) {
wordComplete = false;
break;
}
}
if (wordComplete) {
gameOver = true;
statusText.setText('Tebrikler! Kazandınız!');
var winSound = LK.getSound('win');
winSound.volume = storage.soundVolume || 1.0;
winSound.play();
createConfetti(); // Trigger confetti celebration
LK.setTimeout(function () {
showCustomGameOver(true);
}, 2000);
}
} else {
// Wrong guess
wrongGuesses++;
var wrongSound = LK.getSound('wrong');
wrongSound.volume = storage.soundVolume || 1.0;
wrongSound.play();
statusText.setText('Yanlış tahmin!');
statusText.tint = 0xAA0000;
gallows.showBodyPart(wrongGuesses - 1);
if (wrongGuesses >= maxWrongGuesses) {
gameOver = true;
gallows.changeToDeadHead();
statusText.setText('Kaybettiniz! Kelime: ' + currentWord);
var loseSound = LK.getSound('lose');
loseSound.volume = storage.soundVolume || 1.0;
loseSound.play();
LK.setTimeout(function () {
showCustomGameOver(false);
}, 2000);
}
}
wordDisplay.setText(getDisplayWord());
// Reset status color after a delay
if (!gameOver) {
LK.setTimeout(function () {
statusText.setText('Kelimeyi tahmin edin!');
statusText.tint = 0x666666;
}, 1500);
}
}
var gameOverMenu;
var gameOverBackground;
var gameMenuOpen = false;
function showCustomGameOver(isWin) {
gameMenuOpen = true;
// Create semi-transparent background overlay for entire screen
gameOverBackground = LK.getAsset('menuOverlay', {
anchorX: 0,
anchorY: 0,
alpha: 0.5,
scaleX: 4,
scaleY: 8
});
gameOverBackground.x = 0;
gameOverBackground.y = 0;
gameOverBackground.tint = 0x000000;
game.addChild(gameOverBackground);
gameOverMenu = game.addChild(new GameOverMenu(isWin));
gameOverMenu.x = 1024;
gameOverMenu.y = 1366;
}
function restartGame() {
gameMenuOpen = false;
if (gameOverMenu) {
game.removeChild(gameOverMenu);
gameOverMenu = null;
}
if (gameOverBackground) {
game.removeChild(gameOverBackground);
gameOverBackground = null;
}
// Clear confetti particles
for (var i = 0; i < confettiParticles.length; i++) {
if (confettiParticles[i].parent) {
game.removeChild(confettiParticles[i]);
}
}
confettiParticles = [];
// Clear existing game elements
game.removeChild(gallows);
game.removeChild(wordDisplay);
game.removeChild(hintDisplay);
game.removeChild(statusText);
for (var i = 0; i < letterButtons.length; i++) {
game.removeChild(letterButtons[i]);
}
letterButtons = [];
// Remove any menu buttons from previous game
var children = game.children.slice();
for (var i = 0; i < children.length; i++) {
var child = children[i];
if (child.alpha !== undefined) {
game.removeChild(child);
}
}
// Restart the game
initializeGame();
}
function showInGameMenu() {
gameMenuOpen = true;
// Create semi-transparent background overlay for entire screen
gameOverBackground = LK.getAsset('menuOverlay', {
anchorX: 0,
anchorY: 0,
alpha: 0.5,
scaleX: 4,
scaleY: 8
});
gameOverBackground.x = 0;
gameOverBackground.y = 0;
gameOverBackground.tint = 0x000000;
game.addChild(gameOverBackground);
gameOverMenu = game.addChild(new GameOverMenu(false));
gameOverMenu.x = 1024;
gameOverMenu.y = 1366;
}
function hideInGameMenu() {
gameMenuOpen = false;
if (gameOverMenu) {
game.removeChild(gameOverMenu);
gameOverMenu = null;
}
if (gameOverBackground) {
game.removeChild(gameOverBackground);
gameOverBackground = null;
}
}
function showSettings() {
if (gameOverMenu) {
game.removeChild(gameOverMenu);
gameOverMenu = null;
}
var settingsMenu = game.addChild(new Container());
settingsMenu.x = 1024;
settingsMenu.y = 1366;
var settingsOverlay = LK.getAsset('menuOverlay', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.95,
scaleX: 2,
scaleY: 3
});
settingsMenu.addChild(settingsOverlay);
var settingsTitle = new Text2('AYARLAR', {
size: 100,
fill: 0x333333
});
settingsTitle.anchor.set(0.5, 0.5);
settingsTitle.y = -400;
settingsMenu.addChild(settingsTitle);
// Music volume slider
var musicSlider = new VolumeSlider('MÜZİK SESİ', storage.musicVolume || 1.0, function (value) {
storage.musicVolume = value;
// Apply music volume if music is playing
if (LK.currentMusic) {
LK.currentMusic.volume = value;
}
});
musicSlider.y = -200;
settingsMenu.addChild(musicSlider);
// Sound effects volume slider
var soundSlider = new VolumeSlider('SES EFEKTLERİ', storage.soundVolume || 1.0, function (value) {
storage.soundVolume = value;
});
soundSlider.y = -50;
settingsMenu.addChild(soundSlider);
var backButton = LK.getAsset('menuButton', {
anchorX: 0.5,
anchorY: 0.5,
y: 250,
scaleX: 2,
scaleY: 2
});
settingsMenu.addChild(backButton);
var backText = new Text2('GERİ', {
size: 60,
fill: 0xFFFFFF
});
backText.anchor.set(0.5, 0.5);
backText.y = 250;
settingsMenu.addChild(backText);
settingsMenu.down = function (x, y, obj) {
// Check if click is on back button
if (y >= 170 && y <= 330) {
var buttonSound = LK.getSound('button');
buttonSound.volume = storage.soundVolume || 1.0;
buttonSound.play();
game.removeChild(settingsMenu);
gameOverMenu = game.addChild(new GameOverMenu(false));
gameOverMenu.x = 1024;
gameOverMenu.y = 1366;
}
};
}
function showCredits() {
if (gameOverMenu) {
game.removeChild(gameOverMenu);
gameOverMenu = null;
}
var creditsMenu = game.addChild(new Container());
creditsMenu.x = 1024;
creditsMenu.y = 1366;
var creditsOverlay = LK.getAsset('menuOverlay', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.95,
scaleX: 2,
scaleY: 2
});
creditsMenu.addChild(creditsOverlay);
var creditsTitle = new Text2('YAPIMCILAR', {
size: 100,
fill: 0x333333
});
creditsTitle.anchor.set(0.5, 0.5);
creditsTitle.y = -300;
creditsMenu.addChild(creditsTitle);
var creditsInfo = new Text2('Geliştirici: FRVR\nTasarım: Ava\nTürk Dil Kurumu Sözlüğü\nkullanılmıştır', {
size: 50,
fill: 0x666666
});
creditsInfo.anchor.set(0.5, 0.5);
creditsInfo.y = -40;
creditsMenu.addChild(creditsInfo);
var backButton = LK.getAsset('menuButton', {
anchorX: 0.5,
anchorY: 0.5,
y: 240,
scaleX: 2,
scaleY: 2
});
creditsMenu.addChild(backButton);
var backText = new Text2('GERİ', {
size: 60,
fill: 0xFFFFFF
});
backText.anchor.set(0.5, 0.5);
backText.y = 240;
creditsMenu.addChild(backText);
creditsMenu.down = function (x, y, obj) {
var buttonSound = LK.getSound('button');
buttonSound.volume = storage.soundVolume || 1.0;
buttonSound.play();
game.removeChild(creditsMenu);
gameOverMenu = game.addChild(new GameOverMenu(false));
gameOverMenu.x = 1024;
gameOverMenu.y = 1366;
};
}
// Confetti system
var confettiParticles = [];
function createConfetti() {
// Clear any existing confetti
for (var i = 0; i < confettiParticles.length; i++) {
if (confettiParticles[i].parent) {
game.removeChild(confettiParticles[i]);
}
}
confettiParticles = [];
// Create confetti particles from left and right sides
var colors = [0xFF6B6B, 0x4ECDC4, 0x45B7D1, 0xFFA726, 0x66BB6A, 0xAB47BC];
var centerX = 1024; // Center of screen
var centerTopY = 400; // Center-top target area
// Left side confetti
for (var i = 0; i < 30; i++) {
var confetti = LK.getAsset('letterButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.3,
scaleY: 0.3
});
confetti.tint = colors[Math.floor(Math.random() * colors.length)];
confetti.x = Math.random() * 200; // Start from left edge
confetti.y = 1000 + Math.random() * 400; // Start from mid-screen height
confetti.rotation = Math.random() * Math.PI * 2; // Random initial rotation
confettiParticles.push(confetti);
game.addChild(confetti);
// Animate towards center-top with spread effect
var targetX = centerX + (Math.random() - 0.5) * 400; // Spread around center
var targetY = centerTopY + Math.random() * 200; // Spread around center-top
tween(confetti, {
x: targetX,
y: targetY,
rotation: confetti.rotation + (Math.random() - 0.5) * Math.PI * 4,
alpha: 0
}, {
duration: 1500 + Math.random() * 1000,
easing: tween.easeOut,
onFinish: function () {
if (this.parent) {
game.removeChild(this);
}
}.bind(confetti)
});
}
// Right side confetti
for (var i = 0; i < 30; i++) {
var confetti = LK.getAsset('letterButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.3,
scaleY: 0.3
});
confetti.tint = colors[Math.floor(Math.random() * colors.length)];
confetti.x = 1848 + Math.random() * 200; // Start from right edge
confetti.y = 1000 + Math.random() * 400; // Start from mid-screen height
confetti.rotation = Math.random() * Math.PI * 2; // Random initial rotation
confettiParticles.push(confetti);
game.addChild(confetti);
// Animate towards center-top with spread effect
var targetX = centerX + (Math.random() - 0.5) * 400; // Spread around center
var targetY = centerTopY + Math.random() * 200; // Spread around center-top
tween(confetti, {
x: targetX,
y: targetY,
rotation: confetti.rotation + (Math.random() - 0.5) * Math.PI * 4,
alpha: 0
}, {
duration: 1500 + Math.random() * 1000,
easing: tween.easeOut,
onFinish: function () {
if (this.parent) {
game.removeChild(this);
}
}.bind(confetti)
});
}
}
// Initialize the game
initializeGame();
; /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
musicVolume: 1,
soundVolume: 1
});
/****
* Classes
****/
var Gallows = Container.expand(function () {
var self = Container.call(this);
// Create stand structure first
var standBase = self.attachAsset('standBase', {
anchorX: 0.5,
anchorY: 1.0,
y: 0
});
var standSupport1 = self.attachAsset('standSupport1', {
anchorX: 0.5,
anchorY: 1.0,
x: -80,
y: -25
});
var standSupport2 = self.attachAsset('standSupport2', {
anchorX: 0.5,
anchorY: 1.0,
x: 80,
y: -25
});
// Create gallows structure on top of stand
var gallowsBase = self.attachAsset('gallowsBase', {
anchorX: 0.5,
anchorY: 1.0,
y: -145
});
var gallowsPost = self.attachAsset('gallowsPost', {
anchorX: 0.5,
anchorY: 1.0,
x: -75,
y: -145
});
var gallowsBeam = self.attachAsset('gallowsBeam', {
anchorX: 0.0,
anchorY: 0.5,
x: -75,
y: -435
});
var rope = self.attachAsset('rope', {
anchorX: 0.5,
anchorY: 0.0,
x: 0,
y: -445
});
self.bodyParts = [];
var head = LK.getAsset('head', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -380
});
head.alpha = 0;
self.addChild(head);
self.bodyParts.push(head);
var body = LK.getAsset('body', {
anchorX: 0.5,
anchorY: 0.0,
x: 0,
y: -350
});
body.alpha = 0;
self.addChild(body);
self.bodyParts.push(body);
var leftArm = LK.getAsset('leftArm', {
anchorX: 1.0,
anchorY: 0.5,
x: -4,
y: -320
});
leftArm.alpha = 0;
leftArm.rotation = Math.PI / 4;
self.addChild(leftArm);
self.bodyParts.push(leftArm);
var rightArm = LK.getAsset('rightArm', {
anchorX: 0.0,
anchorY: 0.5,
x: 4,
y: -320
});
rightArm.alpha = 0;
rightArm.rotation = -Math.PI / 4;
self.addChild(rightArm);
self.bodyParts.push(rightArm);
var leftLeg = LK.getAsset('leftLeg', {
anchorX: 1.0,
anchorY: 0.5,
x: -4,
y: -250
});
leftLeg.alpha = 0;
leftLeg.rotation = Math.PI / 6 + Math.PI;
self.addChild(leftLeg);
self.bodyParts.push(leftLeg);
var rightLeg = LK.getAsset('rightLeg', {
anchorX: 0.0,
anchorY: 0.5,
x: 4,
y: -250
});
rightLeg.alpha = 0;
rightLeg.rotation = -Math.PI / 6 + Math.PI;
self.addChild(rightLeg);
self.bodyParts.push(rightLeg);
self.showBodyPart = function (partIndex) {
if (partIndex < self.bodyParts.length) {
self.bodyParts[partIndex].alpha = 1;
tween(self.bodyParts[partIndex], {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200,
onFinish: function onFinish() {
tween(self.bodyParts[partIndex], {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 200
});
}
});
}
};
self.changeToDeadHead = function () {
if (self.bodyParts.length > 0) {
var headPart = self.bodyParts[0];
self.removeChild(headPart);
var deadHead = LK.getAsset('deadHead', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -380
});
deadHead.tint = 0x666666; // Make it greyish to show death
self.addChild(deadHead);
self.bodyParts[0] = deadHead;
}
// Animate arms rotation 200 degrees in 0.2 seconds
if (self.bodyParts.length >= 4) {
var leftArm = self.bodyParts[2];
var rightArm = self.bodyParts[3];
// Convert 130 degrees to radians
var rotationAmount = 130 * Math.PI / 180;
// Animate left arm counterclockwise (negative rotation)
tween(leftArm, {
rotation: leftArm.rotation - rotationAmount
}, {
duration: 200
});
// Animate right arm clockwise (positive rotation)
tween(rightArm, {
rotation: rightArm.rotation + rotationAmount
}, {
duration: 200
});
}
// Animate legs rotation 45 degrees in 0.2 seconds
if (self.bodyParts.length >= 6) {
var leftLeg = self.bodyParts[4];
var rightLeg = self.bodyParts[5];
// Convert 45 degrees to radians
var legRotationAmount = 45 * Math.PI / 180;
// Animate right leg counterclockwise (negative rotation)
tween(rightLeg, {
rotation: rightLeg.rotation - legRotationAmount
}, {
duration: 200
});
// Animate left leg clockwise (positive rotation)
tween(leftLeg, {
rotation: leftLeg.rotation + legRotationAmount
}, {
duration: 200
});
}
};
return self;
});
var GameOverMenu = Container.expand(function (isWin) {
var self = Container.call(this);
// Semi-transparent background overlay
var overlay = LK.getAsset('menuOverlay', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.95,
scaleX: 2,
scaleY: 4
});
self.addChild(overlay);
// Title text - show MENÜ for paused game, TEBRİKLER for win, OYUN BİTTİ for loss
var titleText = new Text2(isWin ? 'TEBRİKLER!' : gameOver ? 'OYUN BİTTİ' : 'MENÜ', {
size: 120,
fill: isWin ? 0x00AA00 : gameOver ? 0xAA0000 : 0x333333
});
titleText.anchor.set(0.5, 0.5);
titleText.y = -300;
self.addChild(titleText);
// Result text - only show for completed games
if (isWin || gameOver) {
var resultText = new Text2(isWin ? 'Kelimeyi doğru tahmin ettiniz!' : 'Kelime: ' + currentWord, {
size: 80,
fill: 0x333333
});
resultText.anchor.set(0.5, 0.5);
resultText.y = -160;
self.addChild(resultText);
}
// Restart button
var restartButton = LK.getAsset('menuButton', {
anchorX: 0.5,
anchorY: 0.5,
y: -20,
scaleX: 2,
scaleY: 2
});
self.addChild(restartButton);
var restartText = new Text2('YENİDEN BAŞLA', {
size: 60,
fill: 0xFFFFFF
});
restartText.anchor.set(0.5, 0.5);
restartText.y = -20;
self.addChild(restartText);
// Settings button
var settingsButton = LK.getAsset('menuButton', {
anchorX: 0.5,
anchorY: 0.5,
y: 160,
scaleX: 2,
scaleY: 2
});
self.addChild(settingsButton);
var settingsText = new Text2('AYARLAR', {
size: 60,
fill: 0xFFFFFF
});
settingsText.anchor.set(0.5, 0.5);
settingsText.y = 160;
self.addChild(settingsText);
// Continue button (only show if not game over)
var continueButton = null;
var continueText = null;
if (!isWin && currentWord && !gameOver) {
continueButton = LK.getAsset('menuButton', {
anchorX: 0.5,
anchorY: 0.5,
y: 340,
scaleX: 2,
scaleY: 2
});
self.addChild(continueButton);
continueText = new Text2('DEVAM ET', {
size: 60,
fill: 0xFFFFFF
});
continueText.anchor.set(0.5, 0.5);
continueText.y = 340;
self.addChild(continueText);
}
// Credits button
var creditsButton = LK.getAsset('menuButton', {
anchorX: 0.5,
anchorY: 0.5,
y: continueButton ? 520 : 340,
scaleX: 2,
scaleY: 2
});
self.addChild(creditsButton);
var creditsText = new Text2('YAPIMCILAR', {
size: 60,
fill: 0xFFFFFF
});
creditsText.anchor.set(0.5, 0.5);
creditsText.y = continueButton ? 520 : 340;
self.addChild(creditsText);
// Button interactions
self.down = function (x, y, obj) {
// Use the x, y coordinates directly instead of complex coordinate conversion
// Check restart button
if (y >= -100 && y <= 60) {
var buttonSound = LK.getSound('button');
buttonSound.volume = storage.soundVolume || 1.0;
buttonSound.play();
restartGame();
}
// Check settings button
else if (y >= 80 && y <= 240) {
var buttonSound = LK.getSound('button');
buttonSound.volume = storage.soundVolume || 1.0;
buttonSound.play();
showSettings();
}
// Check continue button
else if (continueButton && y >= 260 && y <= 420) {
var buttonSound = LK.getSound('button');
buttonSound.volume = storage.soundVolume || 1.0;
buttonSound.play();
hideInGameMenu();
}
// Check credits button
else if (y >= (continueButton ? 440 : 260) && y <= (continueButton ? 600 : 420)) {
var buttonSound = LK.getSound('button');
buttonSound.volume = storage.soundVolume || 1.0;
buttonSound.play();
showCredits();
}
};
return self;
});
var LetterButton = Container.expand(function (letter) {
var self = Container.call(this);
self.letter = letter;
self.isUsed = false;
var buttonBg = self.attachAsset('letterButton', {
anchorX: 0.5,
anchorY: 0.5
});
var letterText = new Text2(letter.toUpperCase(), {
size: 75,
fill: 0xFFFFFF
});
letterText.anchor.set(0.5, 0.5);
self.addChild(letterText);
self.markAsUsed = function () {
if (!self.isUsed) {
self.isUsed = true;
self.removeChild(buttonBg);
var usedBg = self.attachAsset('usedLetterButton', {
anchorX: 0.5,
anchorY: 0.5
});
letterText.tint = 0x999999;
}
};
self.down = function (x, y, obj) {
if (!self.isUsed && !gameMenuOpen) {
guessLetter(self.letter);
}
};
return self;
});
var VolumeSlider = Container.expand(function (title, initialValue, onValueChange) {
var self = Container.call(this);
// Title text
var titleText = new Text2(title, {
size: 50,
fill: 0x333333
});
titleText.anchor.set(0.5, 0.5);
titleText.y = -40;
self.addChild(titleText);
// Slider track
var track = LK.getAsset('menuButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 0.3
});
track.tint = 0x999999;
self.addChild(track);
// Slider handle
var handle = LK.getAsset('menuButtonSmall', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.5,
scaleY: 0.5
});
handle.tint = 0x4a90e2;
self.addChild(handle);
// Value text
var valueText = new Text2(Math.round(initialValue * 100) + '%', {
size: 40,
fill: 0x666666
});
valueText.anchor.set(0.5, 0.5);
valueText.y = 40;
self.addChild(valueText);
// Set initial handle position
var trackWidth = 300 * 1.5; // track width * scaleX
handle.x = (initialValue - 0.5) * trackWidth;
self.setValue = function (value) {
var clampedValue = Math.max(0, Math.min(1, value));
handle.x = (clampedValue - 0.5) * trackWidth;
valueText.setText(Math.round(clampedValue * 100) + '%');
if (onValueChange) {
onValueChange(clampedValue);
}
};
self.down = function (x, y, obj) {
// Calculate relative position on track
var relativeX = x / trackWidth + 0.5;
var newValue = Math.max(0, Math.min(1, relativeX));
self.setValue(newValue);
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xF5F5F5
});
/****
* Game Code
****/
var wordCategories = {
'HAYVAN': {
words: ['AKREP', 'ASLAN', 'BALIK', 'BİZON', 'BÖCEK', 'ÇAKAL', 'DEVE', 'GEYIK', 'GÜVERCIN', 'HOROZ', 'KARTAL', 'KEDİ', 'KIRPI', 'KÖPEK', 'KUĞU', 'KURBAĞA', 'KURT', 'KUZU', 'LEOPAR', 'MAYMUN', 'ÖRDEK', 'PAPAĞAN', 'SALYANGOZ', 'TAVŞAN', 'TURNA', 'VAŞAK', 'ZEBRA'],
hint: 'HAYVAN'
},
'GIDA': {
words: ['ARMUT', 'BADEM', 'BÖREK', 'ÇORBA', 'DOMATES', 'ELMA', 'FASULYE', 'GÜVEÇ', 'HELVA', 'IZGARA', 'JAMBON', 'KAHVE', 'LAHMACUN', 'MEYVE', 'NOHUT', 'OMLET', 'PEYNIR', 'REÇEL', 'SALATA', 'TAVUK', 'ÜZÜM', 'VIŞNE', 'YOĞURT', 'ZEYTİN'],
hint: 'GIDA'
},
'EŞYA': {
words: ['ANAHTAR', 'BAVUL', 'ÇANTA', 'DOLAP', 'FINCAN', 'GÖZLÜK', 'HALKA', 'IBRIK', 'KALEM', 'LAMBA', 'MASA', 'PERDE', 'RADYO', 'SAAT', 'TELEFON', 'VAZO', 'YAZICI', 'ZINCIR'],
hint: 'EŞYA'
},
'DUYGU': {
words: ['AŞKA', 'BAHAR', 'CESARET', 'DOSTLUK', 'EMEK', 'FIKIR', 'GÜVEN', 'HAYAL', 'IŞIK', 'KORKU', 'LÜTUF', 'MUTLULUK', 'NEFRET', 'OZLEM', 'PIŞMANLIK', 'RAHAT', 'SEVGI', 'TATLILUK', 'UMUT', 'VICDAN', 'YAŞAM', 'ZEVK'],
hint: 'DUYGU/KAVRAM'
},
'MESLEK': {
words: ['AVUKAT', 'BERBER', 'CERRAH', 'DOKTOR', 'ELEKTRIKÇI', 'GARSON', 'HEMŞIRE', 'IŞÇI', 'JOKEY', 'KAPICI', 'LABORANT', 'MIMAR', 'NOTER', 'ÖĞRETMEN', 'PILOT', 'RESSAM', 'SÜRÜCÜ', 'TERZI', 'USTA', 'VETERINER', 'YAZAR', 'ZOOLOG'],
hint: 'MESLEK'
},
'MEKAN': {
words: ['BAHÇE', 'ÇARŞI', 'DERSHANE', 'ECZANE', 'FABRIKA', 'GALERİ', 'HASTANE', 'KAHVEHANE', 'LIMAN', 'MÜZE', 'OTOPARK', 'PLAZA', 'RESTORAN', 'STADYUM', 'TIYATRO', 'ÜNİVERSİTE', 'VİLLA', 'ZOO'],
hint: 'MEKAN'
},
'RENK': {
words: ['AÇIK', 'BEYAZ', 'EFLATUN', 'FÜME', 'GRİ', 'HAKI', 'INDIGO', 'KAHVE', 'LACİVERT', 'MAVI', 'NARİN', 'OPAK', 'PEMBE', 'RENK', 'SARMAL', 'TURQUAZ', 'ULTRAMARIN', 'VİOLE', 'YEMYEŞIL', 'ZEYTUNİ'],
hint: 'RENK/ŞEKİL'
},
'ULAŞIM': {
words: ['ARABA', 'BISIKLET', 'DOLMUŞ', 'EKSPRES', 'FERIBOT', 'GEMI', 'HELIKOPTER', 'JET', 'KAMYON', 'LİMUZİN', 'METRO', 'OTOBÜS', 'ROKET', 'SCOOTER', 'TAKSI', 'UÇAK', 'VAPUR', 'ZEPLİN'],
hint: 'ULAŞIM'
},
'TEKNOLOJİ': {
words: ['ALGORITMA', 'BLUETOOTH', 'DATABASE', 'EMAIL', 'FIRMWARE', 'HARDWARE', 'INTERNET', 'JAVA', 'KLAVYE', 'LAPTOP', 'MODEM', 'NETWORK', 'ONLINE', 'PROGRAM', 'ROUTER', 'SOFTWARE', 'TABLET', 'USB', 'VİRÜS', 'WİFİ'],
hint: 'TEKNOLOJİ'
},
'SPOR': {
words: ['ATLETIZM', 'BASKETBOL', 'ESKRİM', 'FUTBOL', 'GOLF', 'HALTER', 'KARATE', 'MARATON', 'NIŞAN', 'OLIMPIK', 'PENALTI', 'RUGBY', 'TENIS', 'VOLEYBOL', 'YOGA'],
hint: 'SPOR'
},
'SANAT': {
words: ['AKORD', 'BALE', 'CELLO', 'DANS', 'ESTETIK', 'FLÜT', 'GITAR', 'HEYKEL', 'JAZZ', 'KLASIK', 'MÜZIK', 'NOTA', 'OPERA', 'PIYANO', 'RITIM', 'SENFONI', 'TABLO', 'VİOLİN', 'YAYLI', 'ZURNA'],
hint: 'SANAT/MÜZİK'
}
};
var turkishWords = [];
var currentHint = '';
// Flatten all words from categories into single array
for (var category in wordCategories) {
turkishWords = turkishWords.concat(wordCategories[category].words);
}
function getWordWithHint() {
var selectedWord = turkishWords[Math.floor(Math.random() * turkishWords.length)];
// Find which category this word belongs to
for (var category in wordCategories) {
if (wordCategories[category].words.indexOf(selectedWord) !== -1) {
currentHint = wordCategories[category].hint;
break;
}
}
return selectedWord;
}
var currentWord = '';
var guessedLetters = [];
var wrongGuesses = 0;
var maxWrongGuesses = 6;
var gameOver = false;
var gallows;
var wordDisplay;
var letterButtons = [];
var statusText;
var hintDisplay;
function initializeGame() {
currentWord = getWordWithHint();
guessedLetters = [];
wrongGuesses = 0;
gameOver = false;
// Add background
var background = LK.getAsset('background', {
anchorX: 0,
anchorY: 0
});
background.x = 0;
background.y = 0;
game.addChild(background);
// Create gallows
gallows = game.addChild(new Gallows());
gallows.x = 300;
gallows.y = 1200; // Move further down to 1200
gallows.scaleX = 2; // Scale to 2x size
gallows.scaleY = 2; // Scale to 2x size
// Create hint display
hintDisplay = new Text2('İpucu: ' + currentHint, {
size: 60,
fill: 0x007ACC
});
hintDisplay.anchor.set(0.5, 0.5);
hintDisplay.x = 1024;
hintDisplay.y = 880;
game.addChild(hintDisplay);
// Create word display
wordDisplay = new Text2(getDisplayWord(), {
size: 120,
fill: 0x333333
});
wordDisplay.anchor.set(0.5, 0.5);
wordDisplay.x = 1024;
wordDisplay.y = 1000;
game.addChild(wordDisplay);
// Create letter buttons
var alphabet = 'ABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZ';
var buttonsPerRow = 6;
var buttonSpacing = 280; // Increased spacing between larger buttons
var rowSpacing = 180; // Increased spacing between rows
var totalKeyboardWidth = (buttonsPerRow - 1) * buttonSpacing;
var buttonStartX = (2048 - totalKeyboardWidth) / 2; // Center horizontally
var buttonStartY = 1750; // Move keyboard to bottom area
for (var i = 0; i < alphabet.length; i++) {
var button = new LetterButton(alphabet[i]);
var row = Math.floor(i / buttonsPerRow);
var col = i % buttonsPerRow;
button.x = buttonStartX + col * buttonSpacing;
button.y = buttonStartY + row * rowSpacing;
letterButtons.push(button);
game.addChild(button);
}
// Create status text
statusText = new Text2('Kelimeyi tahmin edin!', {
size: 70,
fill: 0x666666
});
statusText.anchor.set(0.5, 0.5);
statusText.x = 1024;
statusText.y = 1150;
game.addChild(statusText);
// Create in-game menu button at top right
var inGameMenuButton = LK.getAsset('menuButtonSmall', {
anchorX: 1.0,
anchorY: 0.0,
scaleX: 2,
scaleY: 2
});
inGameMenuButton.x = 1948; // 100px from right edge
inGameMenuButton.y = 100; // 100px from top
game.addChild(inGameMenuButton);
var menuButtonText = new Text2('MENÜ', {
size: 60,
fill: 0xFFFFFF
});
menuButtonText.anchor.set(0.5, 0.5);
menuButtonText.x = 1828; // Center of scaled button
menuButtonText.y = 180; // Center of scaled button
game.addChild(menuButtonText);
// Add click handler for menu button
inGameMenuButton.down = function (x, y, obj) {
if (!gameOver && !gameMenuOpen) {
var buttonSound = LK.getSound('button');
buttonSound.volume = storage.soundVolume || 1.0;
buttonSound.play();
showInGameMenu();
}
};
}
function getDisplayWord() {
var display = '';
for (var i = 0; i < currentWord.length; i++) {
var letter = currentWord[i];
if (guessedLetters.indexOf(letter) !== -1) {
display += letter + ' ';
} else {
display += '_ ';
}
}
return display.trim();
}
function guessLetter(letter) {
if (gameOver || guessedLetters.indexOf(letter) !== -1) {
return;
}
guessedLetters.push(letter);
// Find and mark button as used
for (var i = 0; i < letterButtons.length; i++) {
if (letterButtons[i].letter === letter) {
letterButtons[i].markAsUsed();
break;
}
}
if (currentWord.indexOf(letter) !== -1) {
// Correct guess
var correctSound = LK.getSound('correct');
correctSound.volume = storage.soundVolume || 1.0;
correctSound.play();
statusText.setText('Doğru tahmin!');
statusText.tint = 0x00AA00;
// Check if word is complete
var wordComplete = true;
for (var i = 0; i < currentWord.length; i++) {
if (guessedLetters.indexOf(currentWord[i]) === -1) {
wordComplete = false;
break;
}
}
if (wordComplete) {
gameOver = true;
statusText.setText('Tebrikler! Kazandınız!');
var winSound = LK.getSound('win');
winSound.volume = storage.soundVolume || 1.0;
winSound.play();
createConfetti(); // Trigger confetti celebration
LK.setTimeout(function () {
showCustomGameOver(true);
}, 2000);
}
} else {
// Wrong guess
wrongGuesses++;
var wrongSound = LK.getSound('wrong');
wrongSound.volume = storage.soundVolume || 1.0;
wrongSound.play();
statusText.setText('Yanlış tahmin!');
statusText.tint = 0xAA0000;
gallows.showBodyPart(wrongGuesses - 1);
if (wrongGuesses >= maxWrongGuesses) {
gameOver = true;
gallows.changeToDeadHead();
statusText.setText('Kaybettiniz! Kelime: ' + currentWord);
var loseSound = LK.getSound('lose');
loseSound.volume = storage.soundVolume || 1.0;
loseSound.play();
LK.setTimeout(function () {
showCustomGameOver(false);
}, 2000);
}
}
wordDisplay.setText(getDisplayWord());
// Reset status color after a delay
if (!gameOver) {
LK.setTimeout(function () {
statusText.setText('Kelimeyi tahmin edin!');
statusText.tint = 0x666666;
}, 1500);
}
}
var gameOverMenu;
var gameOverBackground;
var gameMenuOpen = false;
function showCustomGameOver(isWin) {
gameMenuOpen = true;
// Create semi-transparent background overlay for entire screen
gameOverBackground = LK.getAsset('menuOverlay', {
anchorX: 0,
anchorY: 0,
alpha: 0.5,
scaleX: 4,
scaleY: 8
});
gameOverBackground.x = 0;
gameOverBackground.y = 0;
gameOverBackground.tint = 0x000000;
game.addChild(gameOverBackground);
gameOverMenu = game.addChild(new GameOverMenu(isWin));
gameOverMenu.x = 1024;
gameOverMenu.y = 1366;
}
function restartGame() {
gameMenuOpen = false;
if (gameOverMenu) {
game.removeChild(gameOverMenu);
gameOverMenu = null;
}
if (gameOverBackground) {
game.removeChild(gameOverBackground);
gameOverBackground = null;
}
// Clear confetti particles
for (var i = 0; i < confettiParticles.length; i++) {
if (confettiParticles[i].parent) {
game.removeChild(confettiParticles[i]);
}
}
confettiParticles = [];
// Clear existing game elements
game.removeChild(gallows);
game.removeChild(wordDisplay);
game.removeChild(hintDisplay);
game.removeChild(statusText);
for (var i = 0; i < letterButtons.length; i++) {
game.removeChild(letterButtons[i]);
}
letterButtons = [];
// Remove any menu buttons from previous game
var children = game.children.slice();
for (var i = 0; i < children.length; i++) {
var child = children[i];
if (child.alpha !== undefined) {
game.removeChild(child);
}
}
// Restart the game
initializeGame();
}
function showInGameMenu() {
gameMenuOpen = true;
// Create semi-transparent background overlay for entire screen
gameOverBackground = LK.getAsset('menuOverlay', {
anchorX: 0,
anchorY: 0,
alpha: 0.5,
scaleX: 4,
scaleY: 8
});
gameOverBackground.x = 0;
gameOverBackground.y = 0;
gameOverBackground.tint = 0x000000;
game.addChild(gameOverBackground);
gameOverMenu = game.addChild(new GameOverMenu(false));
gameOverMenu.x = 1024;
gameOverMenu.y = 1366;
}
function hideInGameMenu() {
gameMenuOpen = false;
if (gameOverMenu) {
game.removeChild(gameOverMenu);
gameOverMenu = null;
}
if (gameOverBackground) {
game.removeChild(gameOverBackground);
gameOverBackground = null;
}
}
function showSettings() {
if (gameOverMenu) {
game.removeChild(gameOverMenu);
gameOverMenu = null;
}
var settingsMenu = game.addChild(new Container());
settingsMenu.x = 1024;
settingsMenu.y = 1366;
var settingsOverlay = LK.getAsset('menuOverlay', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.95,
scaleX: 2,
scaleY: 3
});
settingsMenu.addChild(settingsOverlay);
var settingsTitle = new Text2('AYARLAR', {
size: 100,
fill: 0x333333
});
settingsTitle.anchor.set(0.5, 0.5);
settingsTitle.y = -400;
settingsMenu.addChild(settingsTitle);
// Music volume slider
var musicSlider = new VolumeSlider('MÜZİK SESİ', storage.musicVolume || 1.0, function (value) {
storage.musicVolume = value;
// Apply music volume if music is playing
if (LK.currentMusic) {
LK.currentMusic.volume = value;
}
});
musicSlider.y = -200;
settingsMenu.addChild(musicSlider);
// Sound effects volume slider
var soundSlider = new VolumeSlider('SES EFEKTLERİ', storage.soundVolume || 1.0, function (value) {
storage.soundVolume = value;
});
soundSlider.y = -50;
settingsMenu.addChild(soundSlider);
var backButton = LK.getAsset('menuButton', {
anchorX: 0.5,
anchorY: 0.5,
y: 250,
scaleX: 2,
scaleY: 2
});
settingsMenu.addChild(backButton);
var backText = new Text2('GERİ', {
size: 60,
fill: 0xFFFFFF
});
backText.anchor.set(0.5, 0.5);
backText.y = 250;
settingsMenu.addChild(backText);
settingsMenu.down = function (x, y, obj) {
// Check if click is on back button
if (y >= 170 && y <= 330) {
var buttonSound = LK.getSound('button');
buttonSound.volume = storage.soundVolume || 1.0;
buttonSound.play();
game.removeChild(settingsMenu);
gameOverMenu = game.addChild(new GameOverMenu(false));
gameOverMenu.x = 1024;
gameOverMenu.y = 1366;
}
};
}
function showCredits() {
if (gameOverMenu) {
game.removeChild(gameOverMenu);
gameOverMenu = null;
}
var creditsMenu = game.addChild(new Container());
creditsMenu.x = 1024;
creditsMenu.y = 1366;
var creditsOverlay = LK.getAsset('menuOverlay', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.95,
scaleX: 2,
scaleY: 2
});
creditsMenu.addChild(creditsOverlay);
var creditsTitle = new Text2('YAPIMCILAR', {
size: 100,
fill: 0x333333
});
creditsTitle.anchor.set(0.5, 0.5);
creditsTitle.y = -300;
creditsMenu.addChild(creditsTitle);
var creditsInfo = new Text2('Geliştirici: FRVR\nTasarım: Ava\nTürk Dil Kurumu Sözlüğü\nkullanılmıştır', {
size: 50,
fill: 0x666666
});
creditsInfo.anchor.set(0.5, 0.5);
creditsInfo.y = -40;
creditsMenu.addChild(creditsInfo);
var backButton = LK.getAsset('menuButton', {
anchorX: 0.5,
anchorY: 0.5,
y: 240,
scaleX: 2,
scaleY: 2
});
creditsMenu.addChild(backButton);
var backText = new Text2('GERİ', {
size: 60,
fill: 0xFFFFFF
});
backText.anchor.set(0.5, 0.5);
backText.y = 240;
creditsMenu.addChild(backText);
creditsMenu.down = function (x, y, obj) {
var buttonSound = LK.getSound('button');
buttonSound.volume = storage.soundVolume || 1.0;
buttonSound.play();
game.removeChild(creditsMenu);
gameOverMenu = game.addChild(new GameOverMenu(false));
gameOverMenu.x = 1024;
gameOverMenu.y = 1366;
};
}
// Confetti system
var confettiParticles = [];
function createConfetti() {
// Clear any existing confetti
for (var i = 0; i < confettiParticles.length; i++) {
if (confettiParticles[i].parent) {
game.removeChild(confettiParticles[i]);
}
}
confettiParticles = [];
// Create confetti particles from left and right sides
var colors = [0xFF6B6B, 0x4ECDC4, 0x45B7D1, 0xFFA726, 0x66BB6A, 0xAB47BC];
var centerX = 1024; // Center of screen
var centerTopY = 400; // Center-top target area
// Left side confetti
for (var i = 0; i < 30; i++) {
var confetti = LK.getAsset('letterButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.3,
scaleY: 0.3
});
confetti.tint = colors[Math.floor(Math.random() * colors.length)];
confetti.x = Math.random() * 200; // Start from left edge
confetti.y = 1000 + Math.random() * 400; // Start from mid-screen height
confetti.rotation = Math.random() * Math.PI * 2; // Random initial rotation
confettiParticles.push(confetti);
game.addChild(confetti);
// Animate towards center-top with spread effect
var targetX = centerX + (Math.random() - 0.5) * 400; // Spread around center
var targetY = centerTopY + Math.random() * 200; // Spread around center-top
tween(confetti, {
x: targetX,
y: targetY,
rotation: confetti.rotation + (Math.random() - 0.5) * Math.PI * 4,
alpha: 0
}, {
duration: 1500 + Math.random() * 1000,
easing: tween.easeOut,
onFinish: function () {
if (this.parent) {
game.removeChild(this);
}
}.bind(confetti)
});
}
// Right side confetti
for (var i = 0; i < 30; i++) {
var confetti = LK.getAsset('letterButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.3,
scaleY: 0.3
});
confetti.tint = colors[Math.floor(Math.random() * colors.length)];
confetti.x = 1848 + Math.random() * 200; // Start from right edge
confetti.y = 1000 + Math.random() * 400; // Start from mid-screen height
confetti.rotation = Math.random() * Math.PI * 2; // Random initial rotation
confettiParticles.push(confetti);
game.addChild(confetti);
// Animate towards center-top with spread effect
var targetX = centerX + (Math.random() - 0.5) * 400; // Spread around center
var targetY = centerTopY + Math.random() * 200; // Spread around center-top
tween(confetti, {
x: targetX,
y: targetY,
rotation: confetti.rotation + (Math.random() - 0.5) * Math.PI * 4,
alpha: 0
}, {
duration: 1500 + Math.random() * 1000,
easing: tween.easeOut,
onFinish: function () {
if (this.parent) {
game.removeChild(this);
}
}.bind(confetti)
});
}
}
// Initialize the game
initializeGame();
;