/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var FeedbackEffect = Container.expand(function () { var self = Container.call(this); self.showEffect = function (type, x, y) { var effectGraphics; if (type === 'perfect') { effectGraphics = self.attachAsset('perfectHit', { anchorX: 0.5, anchorY: 0.5 }); } else if (type === 'good') { effectGraphics = self.attachAsset('goodHit', { anchorX: 0.5, anchorY: 0.5 }); } else { effectGraphics = self.attachAsset('missHit', { anchorX: 0.5, anchorY: 0.5 }); } self.x = x; self.y = y; effectGraphics.alpha = 0.8; effectGraphics.scaleX = 0.5; effectGraphics.scaleY = 0.5; tween(effectGraphics, { alpha: 0, scaleX: 1.5, scaleY: 1.5 }, { duration: 500, easing: tween.easeOut, onFinish: function onFinish() { self.destroy(); } }); }; return self; }); var MovingIndicator = Container.expand(function () { var self = Container.call(this); var indicatorGraphics = self.attachAsset('indicator', { anchorX: 0.5, anchorY: 0.5 }); self.angle = 0; self.speed = 0.03; self.radius = 450; self.centerX = 1024; self.centerY = 1366; self.update = function () { self.angle += self.speed; if (self.angle > Math.PI * 2) { self.angle = 0; } self.x = self.centerX + Math.cos(self.angle) * self.radius; self.y = self.centerY + Math.sin(self.angle) * self.radius; }; self.increaseSpeed = function () { self.speed += 0.01; if (self.speed > 0.15) { self.speed = 0.15; } }; return self; }); var TargetZone = Container.expand(function () { var self = Container.call(this); var targetGraphics = self.attachAsset('targetZone', { anchorX: 0.5, anchorY: 0.5 }); targetGraphics.alpha = 0.8; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1a1a1a }); /**** * Game Code ****/ var gameScore = 0; var missCount = 0; var maxMisses = 3; var level = 1; var isGameRunning = true; var lastTapTime = 0; // Create track background var trackBg = game.addChild(LK.getAsset('trackBackground', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366, alpha: 0.3 })); // Create target zone var targetZone = game.addChild(new TargetZone()); targetZone.x = 1024 + 450; // Position on the right side of the circle targetZone.y = 1366; // Create moving indicator var indicator = game.addChild(new MovingIndicator()); // Create UI elements var scoreText = new Text2('Puan: 0', { size: 80, fill: 0xFFFFFF }); scoreText.anchor.set(0.5, 0); LK.gui.top.addChild(scoreText); var levelText = new Text2('Seviye: 1', { size: 60, fill: 0xFFFFFF }); levelText.anchor.set(0, 0); levelText.x = 50; levelText.y = 150; LK.gui.topLeft.addChild(levelText); var missesText = new Text2('Kaçırma: 0/3', { size: 60, fill: 0xFF6B6B }); missesText.anchor.set(1, 0); LK.gui.topRight.addChild(missesText); var instructionText = new Text2('Yeşil daire turuncu hedefe değdiğinde dokun!', { size: 50, fill: 0xCCCCCC }); instructionText.anchor.set(0.5, 1); LK.gui.bottom.addChild(instructionText); function updateUI() { scoreText.setText('Puan: ' + gameScore); levelText.setText('Seviye: ' + level); missesText.setText('Kaçırma: ' + missCount + '/' + maxMisses); } function calculateDistance(x1, y1, x2, y2) { var dx = x2 - x1; var dy = y2 - y1; return Math.sqrt(dx * dx + dy * dy); } function handleTap() { if (!isGameRunning) return; var currentTime = LK.ticks; if (currentTime - lastTapTime < 10) return; // Prevent rapid tapping lastTapTime = currentTime; var distance = calculateDistance(indicator.x, indicator.y, targetZone.x, targetZone.y); var targetRadius = 100; // Half of target zone width var feedbackEffect = game.addChild(new FeedbackEffect()); if (distance <= 50) { // Perfect hit gameScore += 100; feedbackEffect.showEffect('perfect', indicator.x, indicator.y); LK.getSound('perfectSound').play(); LK.effects.flashObject(targetZone, 0x00FF00, 300); } else if (distance <= targetRadius) { // Good hit gameScore += 50; feedbackEffect.showEffect('good', indicator.x, indicator.y); LK.getSound('goodSound').play(); LK.effects.flashObject(targetZone, 0xFFFF00, 300); } else { // Miss missCount++; feedbackEffect.showEffect('miss', indicator.x, indicator.y); LK.getSound('missSound').play(); LK.effects.flashObject(targetZone, 0xFF0000, 500); if (missCount >= maxMisses) { isGameRunning = false; LK.setScore(gameScore); LK.showGameOver(); return; } } // Level progression if (gameScore > 0 && gameScore % 250 === 0) { level++; indicator.increaseSpeed(); LK.effects.flashScreen(0x4CAF50, 500); } updateUI(); } game.down = function (x, y, obj) { handleTap(); }; game.update = function () { if (!isGameRunning) return; // Check if indicator passed target zone without being tapped var distance = calculateDistance(indicator.x, indicator.y, targetZone.x, targetZone.y); if (indicator.lastDistance !== undefined) { if (indicator.lastDistance > 100 && distance <= 100) { // Indicator just entered target zone indicator.inTargetZone = true; } else if (indicator.lastDistance <= 100 && distance > 100 && indicator.inTargetZone) { // Indicator just left target zone without being tapped indicator.inTargetZone = false; if (LK.ticks - lastTapTime > 30) { // Only count as miss if no recent tap missCount++; var missEffect = game.addChild(new FeedbackEffect()); missEffect.showEffect('miss', targetZone.x, targetZone.y); LK.getSound('missSound').play(); if (missCount >= maxMisses) { isGameRunning = false; LK.setScore(gameScore); LK.showGameOver(); return; } updateUI(); } } } indicator.lastDistance = distance; };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var FeedbackEffect = Container.expand(function () {
var self = Container.call(this);
self.showEffect = function (type, x, y) {
var effectGraphics;
if (type === 'perfect') {
effectGraphics = self.attachAsset('perfectHit', {
anchorX: 0.5,
anchorY: 0.5
});
} else if (type === 'good') {
effectGraphics = self.attachAsset('goodHit', {
anchorX: 0.5,
anchorY: 0.5
});
} else {
effectGraphics = self.attachAsset('missHit', {
anchorX: 0.5,
anchorY: 0.5
});
}
self.x = x;
self.y = y;
effectGraphics.alpha = 0.8;
effectGraphics.scaleX = 0.5;
effectGraphics.scaleY = 0.5;
tween(effectGraphics, {
alpha: 0,
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 500,
easing: tween.easeOut,
onFinish: function onFinish() {
self.destroy();
}
});
};
return self;
});
var MovingIndicator = Container.expand(function () {
var self = Container.call(this);
var indicatorGraphics = self.attachAsset('indicator', {
anchorX: 0.5,
anchorY: 0.5
});
self.angle = 0;
self.speed = 0.03;
self.radius = 450;
self.centerX = 1024;
self.centerY = 1366;
self.update = function () {
self.angle += self.speed;
if (self.angle > Math.PI * 2) {
self.angle = 0;
}
self.x = self.centerX + Math.cos(self.angle) * self.radius;
self.y = self.centerY + Math.sin(self.angle) * self.radius;
};
self.increaseSpeed = function () {
self.speed += 0.01;
if (self.speed > 0.15) {
self.speed = 0.15;
}
};
return self;
});
var TargetZone = Container.expand(function () {
var self = Container.call(this);
var targetGraphics = self.attachAsset('targetZone', {
anchorX: 0.5,
anchorY: 0.5
});
targetGraphics.alpha = 0.8;
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a1a1a
});
/****
* Game Code
****/
var gameScore = 0;
var missCount = 0;
var maxMisses = 3;
var level = 1;
var isGameRunning = true;
var lastTapTime = 0;
// Create track background
var trackBg = game.addChild(LK.getAsset('trackBackground', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366,
alpha: 0.3
}));
// Create target zone
var targetZone = game.addChild(new TargetZone());
targetZone.x = 1024 + 450; // Position on the right side of the circle
targetZone.y = 1366;
// Create moving indicator
var indicator = game.addChild(new MovingIndicator());
// Create UI elements
var scoreText = new Text2('Puan: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
var levelText = new Text2('Seviye: 1', {
size: 60,
fill: 0xFFFFFF
});
levelText.anchor.set(0, 0);
levelText.x = 50;
levelText.y = 150;
LK.gui.topLeft.addChild(levelText);
var missesText = new Text2('Kaçırma: 0/3', {
size: 60,
fill: 0xFF6B6B
});
missesText.anchor.set(1, 0);
LK.gui.topRight.addChild(missesText);
var instructionText = new Text2('Yeşil daire turuncu hedefe değdiğinde dokun!', {
size: 50,
fill: 0xCCCCCC
});
instructionText.anchor.set(0.5, 1);
LK.gui.bottom.addChild(instructionText);
function updateUI() {
scoreText.setText('Puan: ' + gameScore);
levelText.setText('Seviye: ' + level);
missesText.setText('Kaçırma: ' + missCount + '/' + maxMisses);
}
function calculateDistance(x1, y1, x2, y2) {
var dx = x2 - x1;
var dy = y2 - y1;
return Math.sqrt(dx * dx + dy * dy);
}
function handleTap() {
if (!isGameRunning) return;
var currentTime = LK.ticks;
if (currentTime - lastTapTime < 10) return; // Prevent rapid tapping
lastTapTime = currentTime;
var distance = calculateDistance(indicator.x, indicator.y, targetZone.x, targetZone.y);
var targetRadius = 100; // Half of target zone width
var feedbackEffect = game.addChild(new FeedbackEffect());
if (distance <= 50) {
// Perfect hit
gameScore += 100;
feedbackEffect.showEffect('perfect', indicator.x, indicator.y);
LK.getSound('perfectSound').play();
LK.effects.flashObject(targetZone, 0x00FF00, 300);
} else if (distance <= targetRadius) {
// Good hit
gameScore += 50;
feedbackEffect.showEffect('good', indicator.x, indicator.y);
LK.getSound('goodSound').play();
LK.effects.flashObject(targetZone, 0xFFFF00, 300);
} else {
// Miss
missCount++;
feedbackEffect.showEffect('miss', indicator.x, indicator.y);
LK.getSound('missSound').play();
LK.effects.flashObject(targetZone, 0xFF0000, 500);
if (missCount >= maxMisses) {
isGameRunning = false;
LK.setScore(gameScore);
LK.showGameOver();
return;
}
}
// Level progression
if (gameScore > 0 && gameScore % 250 === 0) {
level++;
indicator.increaseSpeed();
LK.effects.flashScreen(0x4CAF50, 500);
}
updateUI();
}
game.down = function (x, y, obj) {
handleTap();
};
game.update = function () {
if (!isGameRunning) return;
// Check if indicator passed target zone without being tapped
var distance = calculateDistance(indicator.x, indicator.y, targetZone.x, targetZone.y);
if (indicator.lastDistance !== undefined) {
if (indicator.lastDistance > 100 && distance <= 100) {
// Indicator just entered target zone
indicator.inTargetZone = true;
} else if (indicator.lastDistance <= 100 && distance > 100 && indicator.inTargetZone) {
// Indicator just left target zone without being tapped
indicator.inTargetZone = false;
if (LK.ticks - lastTapTime > 30) {
// Only count as miss if no recent tap
missCount++;
var missEffect = game.addChild(new FeedbackEffect());
missEffect.showEffect('miss', targetZone.x, targetZone.y);
LK.getSound('missSound').play();
if (missCount >= maxMisses) {
isGameRunning = false;
LK.setScore(gameScore);
LK.showGameOver();
return;
}
updateUI();
}
}
}
indicator.lastDistance = distance;
};