User prompt
arı geldiğinde arı hızlınsan
User prompt
arı geldiğinde oyun dursun
User prompt
Please fix the bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'size')' in or related to this line: 'game.bigBeeInfoTxt.setStyle({' Line Number: 487
User prompt
yazıyı biraz sola al
User prompt
hatayı düzelt
User prompt
yazıyı biraz sola al
User prompt
yazıyı tam ortaya al
User prompt
skor her 30 artığında arı gelsin
Code edit (1 edits merged)
Please save this source code
User prompt
tam orta
User prompt
tam orta olsun yazı tam gözüksün
User prompt
yazıyı tam ortaya al tam gözüksün
User prompt
arı geldiğinde ekranda The bee will disappear after 5 seconds yazsın
User prompt
arı skor 30 olduğunda gelsin
User prompt
arı skor 10 olunca gelsin
User prompt
arı bir mavi kutu olsun assets kısmında gözüksğn
User prompt
skor 50 olduğunda büyük bir arı gelsin ve ona yakalınca 5 can gitsin arı 5 saniyede sonra gitsin
User prompt
sivrisinekler benden kaçsın
User prompt
her 1 saniyede bir 2 tane sivrisinek gelsin
User prompt
her 1 saniyede bir 2 sinek gelsin
User prompt
gittikçe sayısı artsın
User prompt
sinekler kaçmasın ve ekranda 20 taneden fazla sinek olursa oyun bitsin
User prompt
geri al
User prompt
skor 35 olduğu zaman ekranda shop açılsın
/**** * Classes ****/ // BigMosquito class: represents a large mosquito var BigMosquito = Container.expand(function () { var self = Container.call(this); // Attach mosquito asset, but scale up var mosquitoGfx = self.attachAsset('mosquito', { anchorX: 0.5, anchorY: 0.5, scaleX: 2.2, scaleY: 2.2 }); // Big mosquito speed (slower) self.speed = 4 + Math.random() * 2; // 4-6 px/tick // Direction in radians (random) self.direction = Math.random() * Math.PI * 2; self.changeDirTimer = 40 + Math.floor(Math.random() * 60); self.alive = true; // Big mosquito dies in 1 hit (default) self.update = function () { // If racket exists, home in on racket if (typeof racket !== "undefined" && racket !== null && racket.x !== undefined && racket.y !== undefined) { var dx = racket.x - self.x; var dy = racket.y - self.y; var angleToRacket = Math.atan2(dy, dx); // Smoothly turn toward racket var angleDiff = angleToRacket - self.direction; // Normalize angleDiff to [-PI, PI] while (angleDiff > Math.PI) angleDiff -= 2 * Math.PI; while (angleDiff < -Math.PI) angleDiff += 2 * Math.PI; // Turn speed: bigger = more aggressive var turnSpeed = 0.07; if (Math.abs(angleDiff) < turnSpeed) { self.direction = angleToRacket; } else { self.direction += turnSpeed * Math.sign(angleDiff); } } self.x += Math.cos(self.direction) * self.speed; self.y += Math.sin(self.direction) * self.speed; var margin = mosquitoGfx.width / 2 + 10; if (self.x < margin) { self.x = margin; self.direction = Math.PI - self.direction + (Math.random() - 0.5) * 0.5; } if (self.x > 2048 - margin) { self.x = 2048 - margin; self.direction = Math.PI - self.direction + (Math.random() - 0.5) * 0.5; } if (self.y < margin + 100) { self.y = margin + 100; self.direction = -self.direction + (Math.random() - 0.5) * 0.5; } if (self.y > 2732 - margin) { self.y = 2732 - margin; self.direction = -self.direction + (Math.random() - 0.5) * 0.5; } self.changeDirTimer--; if (self.changeDirTimer <= 0) { self.direction += (Math.random() - 0.5) * Math.PI / 1.5; self.changeDirTimer = 40 + Math.floor(Math.random() * 60); } }; // When hit, play animation and destroy self.squash = function (_onFinish) { self.alive = false; self.scaleX = 2.5; self.scaleY = 0.7; self.alpha = 0; if (_onFinish) { _onFinish(); } }; return self; }); //var tween = LK.import("@upit/tween.v1"); // Mosquito class: represents a single mosquito var Mosquito = Container.expand(function () { var self = Container.call(this); // Attach mosquito asset (ellipse, small, dark color) var mosquitoGfx = self.attachAsset('mosquito', { anchorX: 0.5, anchorY: 0.5 }); // Mosquito speed (pixels per tick) self.speed = 6 + Math.random() * 4; // 6-10 px/tick // Direction in radians (random) self.direction = Math.random() * Math.PI * 2; // Time until next direction change self.changeDirTimer = 30 + Math.floor(Math.random() * 60); // Mark as alive self.alive = true; // Update method: called every tick self.update = function () { // Move mosquito self.x += Math.cos(self.direction) * self.speed; self.y += Math.sin(self.direction) * self.speed; // Bounce off walls (game area: 0,0 to 2048,2732) var margin = mosquitoGfx.width / 2 + 10; if (self.x < margin) { self.x = margin; self.direction = Math.PI - self.direction + (Math.random() - 0.5) * 0.5; } if (self.x > 2048 - margin) { self.x = 2048 - margin; self.direction = Math.PI - self.direction + (Math.random() - 0.5) * 0.5; } if (self.y < margin + 100) { // leave top 100px for menu self.y = margin + 100; self.direction = -self.direction + (Math.random() - 0.5) * 0.5; } if (self.y > 2732 - margin) { self.y = 2732 - margin; self.direction = -self.direction + (Math.random() - 0.5) * 0.5; } // Change direction randomly self.changeDirTimer--; if (self.changeDirTimer <= 0) { self.direction += (Math.random() - 0.5) * Math.PI / 1.5; self.changeDirTimer = 30 + Math.floor(Math.random() * 60); } }; // When hit, play animation and destroy self.squash = function (_onFinish) { self.alive = false; // Instantly squash and fade out (no tween) self.scaleX = 1.7; self.scaleY = 0.5; self.alpha = 0; if (_onFinish) { _onFinish(); } }; return self; }); // Racket class: represents the player's racket var Racket = Container.expand(function () { var self = Container.call(this); // Attach racket asset (rectangle, bright color) var racketGfx = self.attachAsset('racket', { anchorX: 0.5, anchorY: 0.5 }); // Optionally, add a little shadow for visibility racketGfx.alpha = 0.95; // Racket size for collision self.radius = racketGfx.width * 0.5; // For touch feedback self.flash = function () { // Instantly flash racket (no tween) racketGfx.tint = 0xffff00; LK.setTimeout(function () { racketGfx.tint = 0xffffff; }, 80); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x888888 // Gray background }); /**** * Game Code ****/ // --- Asset Initialization --- // --- Game Variables --- // --- Game Variables --- var mosquitoes = []; var racket = null; var score = 0; var scoreTxt = null; // Player health (3 lives) var playerHealth = 3; var healthTxt = null; // Timer removed: no time limit var maxMosquitoes = 5; // Reverted to previous value // Removed mosquitoesEscaped and maxEscaped (kaçan sayısı) as requested var gameActive = true; var dragNode = null; game.bigMosquitoSpawned = false; // Track big mosquito approach timers var bigMosquitoApproachTimers = []; // --- UI Elements --- // Skor text scoreTxt = new Text2('0', { size: 120, fill: "#222" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Health text (hearts) healthTxt = new Text2('❤❤❤', { size: 100, fill: "#c00" }); // Anchor to center-top, so it aligns with score healthTxt.anchor.set(0.5, 0); // Position health exactly centered below score healthTxt.x = LK.gui.top.width / 2; healthTxt.y = scoreTxt.height + 10; LK.gui.top.addChild(healthTxt); function updateHealthUI() { var hearts = ""; for (var i = 0; i < playerHealth; i++) { hearts += "❤"; } healthTxt.setText(hearts); } // --- Helper Functions --- function spawnMosquito() { if (!gameActive) { return; } var m = new Mosquito(); // Random position, not too close to top (menu) var margin = 80; m.x = margin + Math.random() * (2048 - 2 * margin); m.y = 150 + Math.random() * (2732 - 250); mosquitoes.push(m); game.addChild(m); } function updateScore() { scoreTxt.setText(score); } // updateTimer removed: no timer to update // Removed updateMissed function (kaçan sayısı) function endGame(win) { gameActive = false; // Show win or game over if (win) { LK.showYouWin(); } else { LK.showGameOver(); } } // --- Racket Setup --- racket = new Racket(); game.addChild(racket); // Start racket in center, lower half racket.x = 2048 / 2; racket.y = 2732 * 0.7; // --- Touch/Drag Controls --- game.down = function (x, y, obj) { // Don't allow drag in top left 100x100 if (x < 100 && y < 100) { return; } dragNode = racket; // Move racket instantly to touch racket.x = x; racket.y = y; }; game.move = function (x, y, obj) { if (!gameActive) { return; } if (dragNode) { // Clamp racket inside game area (leave top 100px) var rw = racket.width * 0.5; var rh = racket.height * 0.5; var nx = Math.max(rw, Math.min(2048 - rw, x)); var ny = Math.max(100 + rh, Math.min(2732 - rh, y)); racket.x = nx; racket.y = ny; } }; game.up = function (x, y, obj) { dragNode = null; }; // --- Main Game Loop --- game.update = function () { if (!gameActive) { return; } // Update mosquitoes for (var i = mosquitoes.length - 1; i >= 0; i--) { var m = mosquitoes[i]; if (!m.alive) { continue; } m.update(); // Check collision with racket var dx = m.x - racket.x; var dy = m.y - racket.y; var dist = Math.sqrt(dx * dx + dy * dy); var hitRadius = m.width * 0.5 + racket.width * 0.5 * 0.7; // --- Big Mosquito Approach Logic --- if (m instanceof BigMosquito) { // Track last and current approach state if (typeof m.lastApproaching === "undefined") m.lastApproaching = false; if (typeof m.sticking === "undefined") m.sticking = false; var approachRadius = m.width * 0.5 + racket.width * 0.5 * 1.1; // slightly larger than hit var isApproaching = dist < approachRadius; // If just started approaching, stick to racket and start timer if (!m.lastApproaching && isApproaching) { // Stick to racket m.sticking = true; m.stickOffsetX = m.x - racket.x; m.stickOffsetY = m.y - racket.y; // Start a 1s timer for this mosquito if not already started if (!m._approachTimerActive) { m._approachTimerActive = true; m._approachTimerId = LK.setTimeout(function (mosq, idx) { return function () { // Only lose health if still alive, still close, and still sticking if (mosq.alive && mosquitoes.indexOf(mosq) !== -1 && mosq.sticking) { var dx2 = mosq.x - racket.x; var dy2 = mosq.y - racket.y; var dist2 = Math.sqrt(dx2 * dx2 + dy2 * dy2); if (dist2 < approachRadius) { playerHealth -= 1; updateHealthUI(); racket.flash(); if (playerHealth <= 0) { endGame(false); return; } } } mosq._approachTimerActive = false; mosq._approachTimerId = null; mosq.sticking = false; }; }(m, i), 1000); bigMosquitoApproachTimers.push(m._approachTimerId); } } // If moved away, cancel timer if running and unstick if (m.lastApproaching && !isApproaching) { if (m._approachTimerActive && m._approachTimerId) { LK.clearTimeout(m._approachTimerId); m._approachTimerActive = false; m._approachTimerId = null; } m.sticking = false; } // If sticking, follow racket if (m.sticking) { m.x = racket.x + (typeof m.stickOffsetX === "number" ? m.stickOffsetX : 0); m.y = racket.y + (typeof m.stickOffsetY === "number" ? m.stickOffsetY : 0); } m.lastApproaching = isApproaching; } // --- End Big Mosquito Approach Logic --- if (dist < hitRadius) { // If big mosquito, destroy on first hit if (m instanceof BigMosquito) { // Cancel any pending approach timer if (m._approachTimerActive && m._approachTimerId) { LK.clearTimeout(m._approachTimerId); m._approachTimerActive = false; m._approachTimerId = null; } // Cancel any pending approach timer and unstick if (m._approachTimerActive && m._approachTimerId) { LK.clearTimeout(m._approachTimerId); m._approachTimerActive = false; m._approachTimerId = null; } m.sticking = false; racket.flash(); m.squash(function () { m.destroy(); }); mosquitoes.splice(i, 1); continue; } // Hit! m.squash(function () { m.destroy(); }); mosquitoes.splice(i, 1); score += 1; updateScore(); racket.flash(); // Spawn big mosquito every time score is a nonzero multiple of 5 if (score > 0 && score % 5 === 0) { var bigM = new BigMosquito(); // Random position, not too close to top (menu) var margin = 120; bigM.x = margin + Math.random() * (2048 - 2 * margin); bigM.y = 200 + Math.random() * (2732 - 400); mosquitoes.push(bigM); game.addChild(bigM); } // Show shop at score 35 // Win condition if (score >= 10000000000000000000000000000000000000000000000000000000) { endGame(true); return; } continue; } // Removed mosquito escape logic: mosquitoes no longer get destroyed at the edge } // End game if there are more than 20 mosquitoes on screen if (mosquitoes.length > 20 && gameActive) { endGame(false); return; } // Spawn new mosquitoes if needed if (mosquitoes.length < maxMosquitoes && gameActive) { if (Math.random() < 0.04) { // ~1 every 25 frames (reverted to previous value) spawnMosquito(); } } }; // Timer removed: no time-based lose condition // --- Game Start --- score = 0; updateScore(); playerHealth = 3; if (typeof updateHealthUI === "function") updateHealthUI(); for (var i = 0; i < maxMosquitoes; i++) { spawnMosquito(); }
===================================================================
--- original.js
+++ change.js
@@ -396,20 +396,15 @@
return;
}
continue;
}
- // If mosquito is at edge for too long, count as escaped
- var margin = m.width / 2 + 10;
- if (m.x <= margin + 2 || m.x >= 2048 - margin - 2 || m.y <= margin + 102 || m.y >= 2732 - margin - 2) {
- // Escaped!
- m.alive = false;
- // Instantly fade out and destroy mosquito (no tween)
- m.alpha = 0;
- m.destroy();
- mosquitoes.splice(i, 1);
- // Removed kaçan sayısı (escaped) logic and lose condition
- }
+ // Removed mosquito escape logic: mosquitoes no longer get destroyed at the edge
}
+ // End game if there are more than 20 mosquitoes on screen
+ if (mosquitoes.length > 20 && gameActive) {
+ endGame(false);
+ return;
+ }
// Spawn new mosquitoes if needed
if (mosquitoes.length < maxMosquitoes && gameActive) {
if (Math.random() < 0.04) {
// ~1 every 25 frames (reverted to previous value)
sivrisinek. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
racket sivriseinek için . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
arı. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat