User prompt
Add a very special cheese. This cheese should be very rare. When we eat it, we can pass through obsactles and traps. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
add as an asset that I can change the ground
User prompt
If we stand still, the cat can't catch us. Fix this
User prompt
delete speedrun timer
User prompt
put a speedrun counter in the bottom right ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Put obsactles more often but don't let it prevent you from going to the exitzone
User prompt
The cat should look in the direction it is running and not be red.
User prompt
The mouse should look in the direction of the mouse that it is on.
User prompt
Increase the speed of the cat to make it harder
User prompt
Increase the cat's speed a little bit to make it harder
User prompt
When the cat detects obsactles, it jumps once. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
When a cat perceives an obsactles, it jumps over it directly and does not wait. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Reduce mouse trap hitbox
User prompt
can jump over obsactles in one jump ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Only jump when there are obsactles in front of him, otherwise he will continue to chase the mouse.
User prompt
The cat can jump over the obsactles every 5 seconds ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
When we touch the mouse traps, instead of dying, we get stuck and the cat comes and catches us.
User prompt
make tunnels into mouse traps
User prompt
tunnels should act as portals for cats but not for mouse
User prompt
delete platforms
User prompt
im stuck in obstacles
User prompt
doğduğumuzda hareket etmezsek yapay zeka bizi öldüremiyor. bunu düzelt
Code edit (1 edits merged)
Please save this source code
User prompt
Mouse Escape - AI Cat Chase
Initial prompt
biz bir fareyiz. kedi ise bir yapay zeka. bir parkurun içerisinde kediden kaçmaya çalışıyoruz
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Cat = Container.expand(function () { var self = Container.call(this); var catGraphics = self.attachAsset('cat', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 4; self.baseSpeed = 4; self.targetX = 0; self.targetY = 0; self.adaptationLevel = 0; self.stuckCounter = 0; self.lastX = 0; self.lastY = 0; self.update = function () { // Check if cat is stuck if (Math.abs(self.x - self.lastX) < 1 && Math.abs(self.y - self.lastY) < 1) { self.stuckCounter++; if (self.stuckCounter > 30) { // Try alternative path when stuck self.targetX = mouse.x + (Math.random() - 0.5) * 200; self.targetY = mouse.y + (Math.random() - 0.5) * 200; self.stuckCounter = 0; } } else { self.stuckCounter = 0; } self.lastX = self.x; self.lastY = self.y; // AI pathfinding with adaptation var dx = self.targetX - self.x; var dy = self.targetY - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 5) { var moveX = dx / distance * self.speed; var moveY = dy / distance * self.speed; var newX = self.x + moveX; var newY = self.y + moveY; // Simple collision avoidance var canMove = true; for (var i = 0; i < obstacles.length; i++) { var obstacle = obstacles[i]; if (newX > obstacle.x - obstacle.width / 2 - 60 && newX < obstacle.x + obstacle.width / 2 + 60 && newY > obstacle.y - obstacle.height / 2 - 60 && newY < obstacle.y + obstacle.height / 2 + 60) { canMove = false; break; } } if (canMove) { self.x = newX; self.y = newY; } } }; self.adaptBehavior = function () { self.adaptationLevel++; self.speed = self.baseSpeed + self.adaptationLevel * 0.5; catGraphics.tint = 0xFF0000 + self.adaptationLevel * 0x001100; }; return self; }); var Cheese = Container.expand(function () { var self = Container.call(this); var cheeseGraphics = self.attachAsset('cheese', { anchorX: 0.5, anchorY: 0.5 }); self.collected = false; self.update = function () { if (!self.collected) { cheeseGraphics.rotation += 0.1; } }; return self; }); var ExitZone = Container.expand(function () { var self = Container.call(this); var exitGraphics = self.attachAsset('exitZone', { anchorX: 0.5, anchorY: 0.5, alpha: 0.6 }); self.update = function () { exitGraphics.alpha = 0.4 + Math.sin(LK.ticks * 0.1) * 0.2; }; return self; }); var Mouse = Container.expand(function () { var self = Container.call(this); var mouseGraphics = self.attachAsset('mouse', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8; self.isHidden = false; self.speedBoost = 1; self.boostTimer = 0; self.update = function () { if (self.boostTimer > 0) { self.boostTimer--; if (self.boostTimer === 0) { self.speedBoost = 1; mouseGraphics.tint = 0xFFFFFF; } } }; self.applySpeedBoost = function () { self.speedBoost = 2; self.boostTimer = 180; // 3 seconds at 60fps mouseGraphics.tint = 0xFFFF00; }; return self; }); var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); return self; }); var Tunnel = Container.expand(function () { var self = Container.call(this); var tunnelGraphics = self.attachAsset('tunnel', { anchorX: 0.5, anchorY: 0.5 }); return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x2F4F2F }); /**** * Game Code ****/ var mouse; var cat; var obstacles = []; var tunnels = []; var cheeses = []; var exitZone; var level = 1; var gameStarted = false; var escapeTimer = 0; var maxEscapeTime = 1800; // 30 seconds at 60fps // UI Elements var levelTxt = new Text2('Level: 1', { size: 80, fill: 0xFFFFFF }); levelTxt.anchor.set(0.5, 0); LK.gui.top.addChild(levelTxt); var timerTxt = new Text2('Time: 30', { size: 60, fill: 0xFFFF00 }); timerTxt.anchor.set(1, 0); LK.gui.topRight.addChild(timerTxt); var instructionTxt = new Text2('Touch to move the mouse!\nAvoid the cat and reach the green exit!', { size: 50, fill: 0xFFFFFF }); instructionTxt.anchor.set(0.5, 0.5); instructionTxt.x = 1024; instructionTxt.y = 1366; game.addChild(instructionTxt); // Create mouse mouse = game.addChild(new Mouse()); mouse.x = 200; mouse.y = 2500; // Create cat cat = game.addChild(new Cat()); cat.x = 1800; cat.y = 2500; cat.targetX = mouse.x; cat.targetY = mouse.y; // Create level function createLevel() { // Clear existing level elements for (var i = obstacles.length - 1; i >= 0; i--) { obstacles[i].destroy(); obstacles.splice(i, 1); } for (var i = tunnels.length - 1; i >= 0; i--) { tunnels[i].destroy(); tunnels.splice(i, 1); } for (var i = cheeses.length - 1; i >= 0; i--) { cheeses[i].destroy(); cheeses.splice(i, 1); } if (exitZone) { exitZone.destroy(); } // Create obstacles var numObstacles = 5 + level * 2; for (var i = 0; i < numObstacles; i++) { var obstacle = game.addChild(new Obstacle()); obstacle.x = Math.random() * 1800 + 200; obstacle.y = Math.random() * 2000 + 400; obstacles.push(obstacle); } // Create tunnels (mouse can pass through, cat cannot) var numTunnels = 3 + level; for (var i = 0; i < numTunnels; i++) { var tunnel = game.addChild(new Tunnel()); tunnel.x = Math.random() * 1800 + 200; tunnel.y = Math.random() * 2000 + 400; tunnels.push(tunnel); } // Create cheese power-ups var numCheeses = 2 + Math.floor(level / 2); for (var i = 0; i < numCheeses; i++) { var cheese = game.addChild(new Cheese()); cheese.x = Math.random() * 1600 + 300; cheese.y = Math.random() * 1800 + 600; cheeses.push(cheese); } // Create exit zone exitZone = game.addChild(new ExitZone()); exitZone.x = Math.random() * 1000 + 500; exitZone.y = Math.random() * 800 + 200; // Reset positions mouse.x = 200; mouse.y = 2500; cat.x = 1800; cat.y = 2500; // Reset timer escapeTimer = 0; // Update UI levelTxt.setText('Level: ' + level); } // Initialize first level createLevel(); // Game controls var targetX = mouse.x; var targetY = mouse.y; var isMoving = false; game.down = function (x, y, obj) { if (!gameStarted) { gameStarted = true; instructionTxt.visible = false; } targetX = x; targetY = y; isMoving = true; }; game.move = function (x, y, obj) { if (isMoving) { targetX = x; targetY = y; } }; game.up = function (x, y, obj) { isMoving = false; }; game.update = function () { if (!gameStarted) return; // Update timer escapeTimer++; var timeLeft = Math.max(0, Math.ceil((maxEscapeTime - escapeTimer) / 60)); timerTxt.setText('Time: ' + timeLeft); // Check if time is up if (escapeTimer >= maxEscapeTime) { LK.getSound('caught').play(); LK.showGameOver(); return; } // Move mouse towards target with collision prevention if (isMoving) { var dx = targetX - mouse.x; var dy = targetY - mouse.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 5) { var moveSpeed = mouse.speed * mouse.speedBoost; var newX = mouse.x + dx / distance * moveSpeed; var newY = mouse.y + dy / distance * moveSpeed; // Check if new position would collide with obstacles var canMoveX = true; var canMoveY = true; for (var i = 0; i < obstacles.length; i++) { var obstacle = obstacles[i]; // Check X movement if (newX > obstacle.x - obstacle.width / 2 - 50 && newX < obstacle.x + obstacle.width / 2 + 50 && mouse.y > obstacle.y - obstacle.height / 2 - 50 && mouse.y < obstacle.y + obstacle.height / 2 + 50) { canMoveX = false; } // Check Y movement if (mouse.x > obstacle.x - obstacle.width / 2 - 50 && mouse.x < obstacle.x + obstacle.width / 2 + 50 && newY > obstacle.y - obstacle.height / 2 - 50 && newY < obstacle.y + obstacle.height / 2 + 50) { canMoveY = false; } } // Apply movement only if no collision if (canMoveX) { mouse.x = newX; } if (canMoveY) { mouse.y = newY; } } } // Update cat AI target cat.targetX = mouse.x; cat.targetY = mouse.y; // Check mouse collision with obstacles - prevent movement into obstacles var newMouseX = mouse.x; var newMouseY = mouse.y; var collisionDetected = false; for (var i = 0; i < obstacles.length; i++) { var obstacle = obstacles[i]; // Check if mouse would collide with obstacle if (newMouseX > obstacle.x - obstacle.width / 2 - 50 && newMouseX < obstacle.x + obstacle.width / 2 + 50 && newMouseY > obstacle.y - obstacle.height / 2 - 50 && newMouseY < obstacle.y + obstacle.height / 2 + 50) { collisionDetected = true; // Find the closest edge to push mouse away var leftDist = Math.abs(newMouseX - (obstacle.x - obstacle.width / 2 - 50)); var rightDist = Math.abs(newMouseX - (obstacle.x + obstacle.width / 2 + 50)); var topDist = Math.abs(newMouseY - (obstacle.y - obstacle.height / 2 - 50)); var bottomDist = Math.abs(newMouseY - (obstacle.y + obstacle.height / 2 + 50)); var minDist = Math.min(leftDist, rightDist, topDist, bottomDist); if (minDist === leftDist) { mouse.x = obstacle.x - obstacle.width / 2 - 50; } else if (minDist === rightDist) { mouse.x = obstacle.x + obstacle.width / 2 + 50; } else if (minDist === topDist) { mouse.y = obstacle.y - obstacle.height / 2 - 50; } else { mouse.y = obstacle.y + obstacle.height / 2 + 50; } break; } } // Check mouse in tunnels (safe from cat) mouse.isHidden = false; for (var i = 0; i < tunnels.length; i++) { var tunnel = tunnels[i]; if (mouse.intersects(tunnel)) { mouse.isHidden = true; break; } } // Cat cannot enter tunnels if (!mouse.isHidden) { for (var i = 0; i < tunnels.length; i++) { var tunnel = tunnels[i]; if (cat.intersects(tunnel)) { var dx = cat.x - tunnel.x; var dy = cat.y - tunnel.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 0) { cat.x = tunnel.x + dx / distance * (tunnel.width / 2 + 70); cat.y = tunnel.y + dy / distance * (tunnel.height / 2 + 70); } } } } // Check cheese collection for (var i = cheeses.length - 1; i >= 0; i--) { var cheese = cheeses[i]; if (!cheese.collected && mouse.intersects(cheese)) { cheese.collected = true; cheese.visible = false; mouse.applySpeedBoost(); LK.getSound('collect').play(); LK.setScore(LK.getScore() + 10); cheeses.splice(i, 1); cheese.destroy(); } } // Check if mouse reached exit if (mouse.intersects(exitZone)) { LK.getSound('escape').play(); LK.setScore(LK.getScore() + 100 * level); level++; if (level > 10) { LK.showYouWin(); } else { cat.adaptBehavior(); createLevel(); } return; } // Check if cat caught mouse (only if not hidden and mouse is moving) if (!mouse.isHidden && isMoving && cat.intersects(mouse)) { LK.getSound('caught').play(); LK.effects.flashScreen(0xFF0000, 500); LK.showGameOver(); } // Keep entities within bounds mouse.x = Math.max(50, Math.min(1998, mouse.x)); mouse.y = Math.max(50, Math.min(2682, mouse.y)); cat.x = Math.max(50, Math.min(1998, cat.x)); cat.y = Math.max(50, Math.min(2682, cat.y)); };
===================================================================
--- original.js
+++ change.js
@@ -125,16 +125,8 @@
anchorY: 0.5
});
return self;
});
-var Platform = Container.expand(function () {
- var self = Container.call(this);
- var platformGraphics = self.attachAsset('platform', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- return self;
-});
var Tunnel = Container.expand(function () {
var self = Container.call(this);
var tunnelGraphics = self.attachAsset('tunnel', {
anchorX: 0.5,
@@ -156,9 +148,8 @@
var mouse;
var cat;
var obstacles = [];
var tunnels = [];
-var platforms = [];
var cheeses = [];
var exitZone;
var level = 1;
var gameStarted = false;
@@ -205,12 +196,8 @@
for (var i = tunnels.length - 1; i >= 0; i--) {
tunnels[i].destroy();
tunnels.splice(i, 1);
}
- for (var i = platforms.length - 1; i >= 0; i--) {
- platforms[i].destroy();
- platforms.splice(i, 1);
- }
for (var i = cheeses.length - 1; i >= 0; i--) {
cheeses[i].destroy();
cheeses.splice(i, 1);
}
@@ -232,16 +219,8 @@
tunnel.x = Math.random() * 1800 + 200;
tunnel.y = Math.random() * 2000 + 400;
tunnels.push(tunnel);
}
- // Create platforms
- var numPlatforms = 4 + level;
- for (var i = 0; i < numPlatforms; i++) {
- var platform = game.addChild(new Platform());
- platform.x = Math.random() * 1600 + 300;
- platform.y = Math.random() * 1800 + 600;
- platforms.push(platform);
- }
// Create cheese power-ups
var numCheeses = 2 + Math.floor(level / 2);
for (var i = 0; i < numCheeses; i++) {
var cheese = game.addChild(new Cheese());
çizgi film peyniri. In-Game asset. 2d. High contrast. No shadows
çizgi film fare yuvası. In-Game asset. 2d. High contrast. No shadows
çizgi filmdeki fare jerry kaçıyor. In-Game asset. 2d. High contrast. No shadows
çizgi film fare tuzağı. In-Game asset. 2d. High contrast. No shadows
just a green field viewed from above. In-Game asset. 2d. High contrast. No shadows
rainbow cartoon cheese. In-Game asset. 2d. High contrast. No shadows