User prompt
topu vurduktan sonra gitmeye devam etmesin
User prompt
topları vurduğundan patlama ve yok olma efekti olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
mor renkli topa vurunca score sıfırlansın
User prompt
function handleBallHit(projectileColor, targetBallColor) { if (targetBallColor === "purple") { // MOR topa ne olursa olsun vurulunca puan azalacak score -= 10; playEffect("buzz"); // sinek efekti return; } if (projectileColor === targetBallColor) { // Doğru renge vurulduysa score += 5; playEffect("sparkle"); } else { // Yanlış renge vurulduysa score -= 5; playEffect("wrong"); } }
User prompt
function handleBallHit(projectileColor, targetBallColor) { if (targetBallColor === "purple") { // Mor top: ceza score -= 10; playEffect("buzz"); // pis sinek efekti return; } if (projectileColor === targetBallColor) { // Doğru renge vurdu: ödül score += 5; playEffect("sparkle"); // başarı efekti } else { // Yanlış renge vurdu: ceza score -= 5; playEffect("wrong"); // yanlış efekt } }
User prompt
if (ball.speed > MAX_SPEED) { ball.speed = MAX_SPEED; }
User prompt
mor renkli topu vurunca puan eksilsin
User prompt
aynı renkte toplar vurulmazsa puan verilmesin ve mor top hariç diğerleri puan versin.
User prompt
çok hızlı ara ara geçen toplar olmasın
User prompt
bukalemunun ortasında olan top daire içine alınıp daha belirgin hale gelsin. arada sırada çok hızlı geçen toplar yok edilsin.
User prompt
Please fix the bug: 'TypeError: Cannot read properties of null (reading 'ballGraphics')' in or related to this line: 'tween(hitBall.ballGraphics, {' Line Number: 605
User prompt
daha fazla top olsun ve daha ağır adımlarla hareket etsinler. aynı renkte olan toplar sürü şeklinde ara ara gelebilir. hepsi ilk vuruşta gitsin mor renkli top hariç.
User prompt
bukalemun topu ağızından fırlattığında topa efekt eklensin
User prompt
bukalemun topu gönderirken o tarafa doğru ağzında uzun dili dışarıya doğru gittiğini gösteren efekt eklensin
User prompt
toplara doğru gönderilen top bukalemunun ağız kısmında olsun ve bukalemunun kafasını döndürdüğü yöne doğru atılsın
User prompt
topları doğru vurdukça daha çok top gelsin
User prompt
her aynı renk vurulduğunda efekt olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
aynı renge top atıldığında oyunun temasına uygun olarak bir efekt olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
toplar daha çok olsun ve her aynı renkte top vurulduğunda daha çok gelsin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
yuvarlaklar komple dağıllınca ve ekrandan yok olunca oyun bitsin
User prompt
1. bukalemunun ağzında yuvarlaklar ve rengi gözüksün ve ağzındaki yuvarlağın rengine göre kendi rengide o ağzındaki yuvarlağın rengine dönüşsün 2. yuvarlaklar her bir yana saçılsın ve düzenli bir biçimde tek sıra olarak hareket etsin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Generate the first version of the source code of my game: Maya Frog Zuma. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Maya Frog Zuma
Initial prompt
Zuma tarzı, merkezde sabit duran bir kurbağanın renkli topları dönen bir zincire doğru fırlattığı, aynı renkten 3 veya daha fazla top yan yana geldiğinde patlayarak zinciri yavaşlattığı, toplar son noktaya ulaşmadan tüm zinciri bitirmeyi hedefleyen, antik Maya temalı, ses efektleri ve skor sistemi olan bir 2D oyun yap. retro piksel stilinde yap,mobil uyumlu yap.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Ball = Container.expand(function (color) { var self = Container.call(this); self.ballColor = color || 'red'; self.ballGraphics = self.attachAsset('ball_' + self.ballColor, { anchorX: 0.5, anchorY: 0.5 }); self.chainIndex = 0; self.pathPosition = 0; self.isExploding = false; self.lastPathPosition = 0; self.isOffScreen = false; self.lastX = 0; self.lastY = 0; self.checkOffScreen = function () { // Check if ball has moved completely off screen var margin = 100; // Extra margin to ensure ball is truly gone var wasOnScreen = self.lastX >= -margin && self.lastX <= 2048 + margin && self.lastY >= -margin && self.lastY <= 2732 + margin; var isNowOffScreen = self.x < -margin || self.x > 2048 + margin || self.y < -margin || self.y > 2732 + margin; // Detect transition from on-screen to off-screen if (wasOnScreen && isNowOffScreen && !self.isOffScreen) { self.isOffScreen = true; } // Update last known positions self.lastX = self.x; self.lastY = self.y; }; self.explode = function () { if (self.isExploding) return; self.isExploding = true; tween(self.ballGraphics, { scaleX: 1.5, scaleY: 1.5, alpha: 0 }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { if (self.parent) { self.parent.removeChild(self); } } }); LK.getSound('explosion').play(); }; self.destroyOnHit = function () { // Purple balls require multiple hits, others destroyed immediately if (self.ballColor === 'purple') { if (!self.hitCount) self.hitCount = 0; self.hitCount++; if (self.hitCount >= 2) { self.explode(); return true; } else { // Flash purple ball to show it was hit tween(self.ballGraphics, { tint: 0xFF00FF, scaleX: 1.2, scaleY: 1.2 }, { duration: 150, easing: tween.easeOut, onFinish: function onFinish() { tween(self.ballGraphics, { tint: 0xFFFFFF, scaleX: 1.0, scaleY: 1.0 }, { duration: 100, easing: tween.easeIn }); } }); return false; } } else { self.explode(); return true; } }; return self; }); var Frog = Container.expand(function () { var self = Container.call(this); self.frogGraphics = self.attachAsset('frog', { anchorX: 0.5, anchorY: 0.5 }); self.currentBallColor = ballColors[Math.floor(Math.random() * ballColors.length)]; self.nextBallColor = ballColors[Math.floor(Math.random() * ballColors.length)]; self.currentBall = self.attachAsset('ball_' + self.currentBallColor, { anchorX: 0.5, anchorY: 0.5, x: 0, y: -40, scaleX: 0.6, scaleY: 0.6 }); // Add highlight circle around current ball self.highlightCircle = self.attachAsset('path_marker', { anchorX: 0.5, anchorY: 0.5, x: 0, y: -40, scaleX: 0.08, scaleY: 0.08, alpha: 0.3, tint: 0xFFD700 }); self.aimAngle = 0; self.canShoot = true; self.updateFrogColor = function () { // Color mapping for frog tinting based on ball color var colorMap = { 'red': 0xff8888, 'blue': 0x8888ff, 'yellow': 0xffff88, 'green': 0x88ff88, 'purple': 0xff88ff }; self.frogGraphics.tint = colorMap[self.currentBallColor] || 0xffffff; }; // Initialize frog color self.updateFrogColor(); self.updateAim = function (targetX, targetY) { var dx = targetX - self.x; var dy = targetY - self.y; self.aimAngle = Math.atan2(dy, dx); self.frogGraphics.rotation = self.aimAngle + Math.PI / 2; }; self.shoot = function () { if (!self.canShoot) return null; var projectile = new Projectile(self.currentBallColor); projectile.x = self.x; projectile.y = self.y; projectile.velocityX = Math.cos(self.aimAngle) * projectile.speed; projectile.velocityY = Math.sin(self.aimAngle) * projectile.speed; // Add visual effect when projectile is fired // Create shooting effect with glow and scale animation tween(projectile.projectileGraphics, { scaleX: 1.2, scaleY: 1.2, tint: 0xFFFFFF }, { duration: 100, easing: tween.easeOut, onFinish: function onFinish() { tween(projectile.projectileGraphics, { scaleX: 0.8, scaleY: 0.8, tint: 0xFFFFFF }, { duration: 100, easing: tween.easeIn }); } }); // Create muzzle flash effect at frog's mouth var muzzleFlash = LK.getAsset('ball_yellow', { anchorX: 0.5, anchorY: 0.5, x: self.x + Math.cos(self.aimAngle) * 30, y: self.y + Math.sin(self.aimAngle) * 30, scaleX: 0.4, scaleY: 0.4, alpha: 0.8, tint: 0xFFD700 }); game.addChild(muzzleFlash); // Animate muzzle flash tween(muzzleFlash, { scaleX: 0.8, scaleY: 0.8, alpha: 0 }, { duration: 200, easing: tween.easeOut, onFinish: function onFinish() { if (muzzleFlash.parent) { muzzleFlash.parent.removeChild(muzzleFlash); } } }); // Update frog's current ball self.currentBallColor = self.nextBallColor; self.nextBallColor = ballColors[Math.floor(Math.random() * ballColors.length)]; if (self.currentBall.parent) { self.currentBall.parent.removeChild(self.currentBall); } self.currentBall = self.attachAsset('ball_' + self.currentBallColor, { anchorX: 0.5, anchorY: 0.5, x: 0, y: -40, scaleX: 0.6, scaleY: 0.6 }); // Update highlight circle for new ball if (self.highlightCircle.parent) { self.highlightCircle.parent.removeChild(self.highlightCircle); } self.highlightCircle = self.attachAsset('path_marker', { anchorX: 0.5, anchorY: 0.5, x: 0, y: -40, scaleX: 0.08, scaleY: 0.08, alpha: 0.3, tint: 0xFFD700 }); // Add pulsing animation to highlight circle function pulseHighlight() { tween(self.highlightCircle, { scaleX: 0.12, scaleY: 0.12, alpha: 0.6 }, { duration: 800, easing: tween.easeInOut, onFinish: function onFinish() { tween(self.highlightCircle, { scaleX: 0.08, scaleY: 0.08, alpha: 0.3 }, { duration: 800, easing: tween.easeInOut, onFinish: pulseHighlight }); } }); } pulseHighlight(); // Update frog color to match new ball self.updateFrogColor(); LK.getSound('shoot').play(); return projectile; }; return self; }); // Game constants var Projectile = Container.expand(function (color) { var self = Container.call(this); self.ballColor = color; self.projectileGraphics = self.attachAsset('ball_' + self.ballColor, { anchorX: 0.5, anchorY: 0.5, scaleX: 0.8, scaleY: 0.8 }); self.velocityX = 0; self.velocityY = 0; self.speed = 12; self.active = true; self.update = function () { if (!self.active) return; self.x += self.velocityX; self.y += self.velocityY; // Check bounds if (self.x < 0 || self.x > 2048 || self.y < 0 || self.y > 2732) { self.active = false; if (self.parent) { self.parent.removeChild(self); } } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x2d5016 }); /**** * Game Code ****/ // Initialize game assets with Maya theme and retro pixel style // Game constants var ballColors = ['red', 'blue', 'yellow', 'green', 'purple']; var pathRadius = 400; var centerX = 2048 / 2; var centerY = 2732 / 2; var chainSpeed = 0.4; var maxChainLength = 120; var MAX_SPEED = 8; // Maximum allowed speed for balls // Game variables var ballChain = []; var projectiles = []; var gameRunning = true; var chainProgress = 0; var matchCombo = 0; // Create temple center var templeCenter = LK.getAsset('temple_center', { anchorX: 0.5, anchorY: 0.5, x: centerX, y: centerY }); game.addChild(templeCenter); // Create frog var frog = new Frog(); frog.x = centerX; frog.y = centerY; game.addChild(frog); // Create score display var scoreTxt = new Text2('Score: 0', { size: 80, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Create chain length display var chainTxt = new Text2('Chain: 0', { size: 60, fill: 0xFFFF00 }); chainTxt.anchor.set(0, 0); chainTxt.x = 50; chainTxt.y = 50; LK.gui.topLeft.addChild(chainTxt); // Initialize ball chain function createInitialChain() { for (var i = 0; i < 50; i++) { var color = ballColors[Math.floor(Math.random() * ballColors.length)]; var ball = new Ball(color); ball.chainIndex = i; ball.pathPosition = i * 70; ballChain.push(ball); game.addChild(ball); updateBallPosition(ball); } } // Update ball position along scattered path with orderly movement function updateBallPosition(ball) { if (!ball.scatterDirection) { // Initialize scatter direction for each ball var angleOffset = ball.chainIndex * 137.5 % 360; // Golden angle for even distribution ball.scatterDirection = angleOffset * Math.PI / 180; ball.scatterRadius = 200 + ball.chainIndex % 3 * 50; // Varying distances } var totalProgress = chainProgress + ball.pathPosition; var moveDistance = totalProgress * 0.5; var targetX = centerX + Math.cos(ball.scatterDirection) * (ball.scatterRadius + moveDistance); var targetY = centerY + Math.sin(ball.scatterDirection) * (ball.scatterRadius + moveDistance); // Smooth movement towards target position ball.x = ball.x + (targetX - ball.x) * 0.1; ball.y = ball.y + (targetY - ball.y) * 0.1; } // Add new ball to front of chain function addBallToChain() { if (ballChain.length >= maxChainLength) return; var color = ballColors[Math.floor(Math.random() * ballColors.length)]; var ball = new Ball(color); ball.chainIndex = ballChain.length; ball.pathPosition = ballChain.length > 0 ? ballChain[ballChain.length - 1].pathPosition + 70 : 0; ballChain.push(ball); game.addChild(ball); updateBallPosition(ball); } // Add group of same color balls occasionally function addBallGroup() { if (ballChain.length >= maxChainLength - 5) return; var groupColor = ballColors[Math.floor(Math.random() * ballColors.length)]; var groupSize = 3 + Math.floor(Math.random() * 3); // 3-5 balls for (var i = 0; i < groupSize; i++) { if (ballChain.length >= maxChainLength) break; var ball = new Ball(groupColor); ball.chainIndex = ballChain.length; ball.pathPosition = ballChain.length > 0 ? ballChain[ballChain.length - 1].pathPosition + 70 : 0; ballChain.push(ball); game.addChild(ball); updateBallPosition(ball); } } // Check for matches in chain function checkMatches() { var matches = []; var currentColor = null; var currentGroup = []; for (var i = 0; i < ballChain.length; i++) { var ball = ballChain[i]; if (ball.isExploding) continue; if (ball.ballColor === currentColor) { currentGroup.push(ball); } else { if (currentGroup.length >= 3) { matches = matches.concat(currentGroup); } currentColor = ball.ballColor; currentGroup = [ball]; } } // Check last group if (currentGroup.length >= 3) { matches = matches.concat(currentGroup); } if (matches.length > 0) { // Award points var points = matches.length * 10; if (matchCombo > 0) { points *= matchCombo + 1; } LK.setScore(LK.getScore() + points); matchCombo++; // Explode matched balls with Maya-themed effects for (var j = 0; j < matches.length; j++) { var matchedBall = matches[j]; // Create temple-themed glow effect tween(matchedBall.ballGraphics, { tint: 0xFFD700, // Golden glow scaleX: 1.3, scaleY: 1.3 }, { duration: 150, easing: tween.easeOut }); // Add screen flash effect for larger matches if (matches.length >= 5) { LK.effects.flashScreen(0xFFD700, 400); // Golden flash } matchedBall.explode(); } // Remove exploded balls from chain ballChain = ballChain.filter(function (ball) { return !ball.isExploding; }); // Reindex remaining balls for (var k = 0; k < ballChain.length; k++) { ballChain[k].chainIndex = k; } // Create energy burst effect at match location if (matches.length > 0) { var centerMatchX = 0; var centerMatchY = 0; for (var effectIndex = 0; effectIndex < matches.length; effectIndex++) { centerMatchX += matches[effectIndex].x; centerMatchY += matches[effectIndex].y; } centerMatchX /= matches.length; centerMatchY /= matches.length; // Create energy orbs radiating from match center for (var orbIndex = 0; orbIndex < 6; orbIndex++) { var energyOrb = LK.getAsset('ball_yellow', { anchorX: 0.5, anchorY: 0.5, x: centerMatchX, y: centerMatchY, scaleX: 0.3, scaleY: 0.3, alpha: 0.8 }); game.addChild(energyOrb); var angle = orbIndex * 60 * Math.PI / 180; var distance = 120 + Math.random() * 80; tween(energyOrb, { x: centerMatchX + Math.cos(angle) * distance, y: centerMatchY + Math.sin(angle) * distance, alpha: 0, scaleX: 0.1, scaleY: 0.1 }, { duration: 800, easing: tween.easeOut, onFinish: function onFinish() { if (energyOrb.parent) { energyOrb.parent.removeChild(energyOrb); } } }); } } LK.getSound('match').play(); // Add new balls after successful matches to increase difficulty // Add more balls for larger matches to reward skillful play var ballsToAdd = 3 + Math.floor(matches.length / 3); // Base 3 + bonus for larger matches for (var addCount = 0; addCount < ballsToAdd; addCount++) { addBallToChain(); } // Check for chain reactions LK.setTimeout(function () { checkMatches(); }, 300); } else { matchCombo = 0; } } // Insert projectile into chain function insertProjectileIntoChain(projectile, insertIndex) { var newBall = new Ball(projectile.ballColor); newBall.chainIndex = insertIndex; // Adjust positions of balls after insertion point for (var i = insertIndex; i < ballChain.length; i++) { ballChain[i].chainIndex++; ballChain[i].pathPosition += 70; } // Set position for new ball if (insertIndex < ballChain.length) { newBall.pathPosition = ballChain[insertIndex].pathPosition - 70; } else { newBall.pathPosition = insertIndex * 70; } ballChain.splice(insertIndex, 0, newBall); game.addChild(newBall); updateBallPosition(newBall); // Remove projectile if (projectile.parent) { projectile.parent.removeChild(projectile); } // Check for matches LK.setTimeout(function () { checkMatches(); }, 100); } function handleBallHit(projectileColor, targetBallColor) { if (targetBallColor === "purple") { // MOR topa ne olursa olsun vurulunca puan azalacak LK.setScore(Math.max(0, LK.getScore() - 10)); LK.getSound('explosion').play(); // sinek efekti return; } if (projectileColor === targetBallColor) { // Doğru renge vurulduysa LK.setScore(LK.getScore() + 5); LK.getSound('match').play(); } else { // Yanlış renge vurulduysa LK.setScore(Math.max(0, LK.getScore() - 5)); LK.getSound('shoot').play(); } } // Handle touch input game.down = function (x, y, obj) { if (!gameRunning) return; frog.updateAim(x, y); var projectile = frog.shoot(); if (projectile) { projectiles.push(projectile); game.addChild(projectile); } }; game.move = function (x, y, obj) { if (!gameRunning) return; frog.updateAim(x, y); }; // Main game update loop game.update = function () { if (!gameRunning) return; // Update chain progress chainProgress += chainSpeed; // Update ball positions for (var i = 0; i < ballChain.length; i++) { var ball = ballChain[i]; if (!ball.isExploding) { ball.lastPathPosition = ball.pathPosition; var lastX = ball.x; var lastY = ball.y; updateBallPosition(ball); // Check off-screen status ball.checkOffScreen(); // Detect very fast moving balls and occasionally destroy them var deltaX = ball.x - lastX; var deltaY = ball.y - lastY; var speed = Math.sqrt(deltaX * deltaX + deltaY * deltaY); // Limit ball speed to MAX_SPEED if (speed > MAX_SPEED) { var speedRatio = MAX_SPEED / speed; var limitedDeltaX = deltaX * speedRatio; var limitedDeltaY = deltaY * speedRatio; ball.x = lastX + limitedDeltaX; ball.y = lastY + limitedDeltaY; speed = MAX_SPEED; } if (speed > 8 && Math.random() < 0.02) { // 2% chance to destroy fast balls ball.explode(); ballChain.splice(i, 1); i--; // Adjust index after removal // Reindex remaining balls for (var reindexI = 0; reindexI < ballChain.length; reindexI++) { ballChain[reindexI].chainIndex = reindexI; } continue; } // Check if chain reached center (game over condition) var totalProgress = chainProgress + ball.pathPosition; var distanceFromCenter = Math.sqrt((ball.x - centerX) * (ball.x - centerX) + (ball.y - centerY) * (ball.y - centerY)); if (distanceFromCenter <= 120 && ball.chainIndex === 0) { gameRunning = false; LK.showGameOver(); return; } } } // Update projectiles for (var j = projectiles.length - 1; j >= 0; j--) { var projectile = projectiles[j]; if (!projectile.active) { projectiles.splice(j, 1); continue; } // Check collision with chain balls var hitBall = null; var insertIndex = -1; for (var k = 0; k < ballChain.length; k++) { var chainBall = ballChain[k]; if (chainBall.isExploding) continue; var dx = projectile.x - chainBall.x; var dy = projectile.y - chainBall.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < 55) { hitBall = chainBall; insertIndex = k; break; } } if (hitBall) { // Check if projectile color matches hit ball color for scoring var isColorMatch = projectile.ballColor === hitBall.ballColor; var isPurpleBall = hitBall.ballColor === 'purple'; // Destroy ball on hit (purple balls need multiple hits) var ballDestroyed = hitBall.destroyOnHit(); if (ballDestroyed) { // Remove destroyed ball from chain for (var removeIndex = 0; removeIndex < ballChain.length; removeIndex++) { if (ballChain[removeIndex] === hitBall) { ballChain.splice(removeIndex, 1); break; } } // Reindex remaining balls for (var reindexK = 0; reindexK < ballChain.length; reindexK++) { ballChain[reindexK].chainIndex = reindexK; } // Use centralized scoring function handleBallHit(projectile.ballColor, hitBall.ballColor); } // Only create special effects for matching colors (excluding purple) if (isColorMatch && !isPurpleBall && hitBall && hitBall.ballGraphics) { // Create Maya-themed matching effect tween(hitBall.ballGraphics, { tint: 0xFFD700, // Golden glow scaleX: 1.4, scaleY: 1.4 }, { duration: 200, easing: tween.easeOut, onFinish: function onFinish() { if (hitBall && hitBall.ballGraphics) { tween(hitBall.ballGraphics, { tint: 0xFFFFFF, // Return to normal scaleX: 1.0, scaleY: 1.0 }, { duration: 100, easing: tween.easeIn }); } } }); // Create energy burst effect around the hit ball for (var effectIndex = 0; effectIndex < 4; effectIndex++) { var energyParticle = LK.getAsset('ball_yellow', { anchorX: 0.5, anchorY: 0.5, x: hitBall.x, y: hitBall.y, scaleX: 0.2, scaleY: 0.2, alpha: 0.9 }); game.addChild(energyParticle); var angle = effectIndex * 90 * Math.PI / 180; var distance = 80; tween(energyParticle, { x: hitBall.x + Math.cos(angle) * distance, y: hitBall.y + Math.sin(angle) * distance, alpha: 0, scaleX: 0.05, scaleY: 0.05 }, { duration: 500, easing: tween.easeOut, onFinish: function onFinish() { if (energyParticle.parent) { energyParticle.parent.removeChild(energyParticle); } } }); } // Only add bonus balls for correct color matches (not purple) if (isColorMatch && !isPurpleBall) { addBallToChain(); addBallToChain(); } } projectiles.splice(j, 1); if (!ballDestroyed) { insertProjectileIntoChain(projectile, insertIndex); } } } // Add new balls periodically - more frequently if (LK.ticks % 180 === 0 && ballChain.length < maxChainLength) { addBallToChain(); } // Add extra balls occasionally for increased challenge if (LK.ticks % 360 === 0 && ballChain.length < maxChainLength) { addBallToChain(); addBallToChain(); } // Add groups of same color balls occasionally if (LK.ticks % 480 === 0 && ballChain.length < maxChainLength - 5) { addBallGroup(); } // Update UI scoreTxt.setText('Score: ' + LK.getScore()); chainTxt.setText('Chain: ' + ballChain.length); // Check if all balls are scattered off screen (game over condition) var allBallsOffScreen = ballChain.length > 0; for (var m = 0; m < ballChain.length; m++) { if (!ballChain[m].isOffScreen && !ballChain[m].isExploding) { allBallsOffScreen = false; break; } } if (allBallsOffScreen && ballChain.length > 0) { gameRunning = false; LK.showGameOver(); return; } // Win condition - clear all balls if (ballChain.length === 0) { gameRunning = false; LK.setScore(LK.getScore() + 1000); // Bonus for clearing LK.showYouWin(); } }; // Initialize the game createInitialChain();
===================================================================
--- original.js
+++ change.js
@@ -523,8 +523,25 @@
LK.setTimeout(function () {
checkMatches();
}, 100);
}
+function handleBallHit(projectileColor, targetBallColor) {
+ if (targetBallColor === "purple") {
+ // MOR topa ne olursa olsun vurulunca puan azalacak
+ LK.setScore(Math.max(0, LK.getScore() - 10));
+ LK.getSound('explosion').play(); // sinek efekti
+ return;
+ }
+ if (projectileColor === targetBallColor) {
+ // Doğru renge vurulduysa
+ LK.setScore(LK.getScore() + 5);
+ LK.getSound('match').play();
+ } else {
+ // Yanlış renge vurulduysa
+ LK.setScore(Math.max(0, LK.getScore() - 5));
+ LK.getSound('shoot').play();
+ }
+}
// Handle touch input
game.down = function (x, y, obj) {
if (!gameRunning) return;
frog.updateAim(x, y);
@@ -626,22 +643,10 @@
// Reindex remaining balls
for (var reindexK = 0; reindexK < ballChain.length; reindexK++) {
ballChain[reindexK].chainIndex = reindexK;
}
- // Implement color-based scoring system
- if (isPurpleBall) {
- // Purple ball: always deduct points
- LK.setScore(Math.max(0, LK.getScore() - 10));
- LK.getSound('explosion').play(); // Buzz effect for penalty
- } else if (isColorMatch) {
- // Correct color match: award points
- LK.setScore(LK.getScore() + 5);
- LK.getSound('match').play(); // Success effect
- } else {
- // Wrong color: deduct points
- LK.setScore(Math.max(0, LK.getScore() - 5));
- LK.getSound('shoot').play(); // Wrong effect
- }
+ // Use centralized scoring function
+ handleBallHit(projectile.ballColor, hitBall.ballColor);
}
// Only create special effects for matching colors (excluding purple)
if (isColorMatch && !isPurpleBall && hitBall && hitBall.ballGraphics) {
// Create Maya-themed matching effect
kocaman gözleri olan ve ağzında olan her renge göre renk değiştiren bir bukalemun. In-Game asset. 2d. High contrast. No shadows
minik ve çok sevimli bir yusufçuk. In-Game asset. 2d. High contrast. No shadows
minik sevimli bir tırtıl. In-Game asset. 2d. High contrast. No shadows
çirkin ve sevimsiz kara sinek mor renkli bir kısmı. In-Game asset. 2d. High contrast. No shadows
çok güzel renkleri olan ağırlıklı olarak kırmızı renkli kelebek. In-Game asset. 2d. High contrast. No shadows
yeşil yapraklar ve ağaçlar olan orta bir alan. In-Game asset. 2d. High contrast. No shadows
oval kütük küçük bir meydan gibi üstten görünümlü. In-Game asset. 2d. High contrast. No shadows
çember şeklinde bir görseli çerçeve içine alan çevresi yeşillik çerçeve. In-Game asset. 2d. High contrast. No shadows