Code edit (3 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: mice[i] is undefined' in this line: 'nutcrackers[j].mouthTimer = mice[i].turtleMouse ? 300 : 180;' Line Number: 336
Code edit (5 edits merged)
Please save this source code
User prompt
add a new class names turtleMouse. give it everything you gave the mouse class
Code edit (4 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: mice[i] is undefined' in this line: 'if (mice[i].x > 2048 + mice[i].width) {' Line Number: 303
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: mice[i] is undefined' in this line: 'if (mice[i] && mice[i].x > 2048 + mice[i].width) {' Line Number: 307
Code edit (1 edits merged)
Please save this source code
User prompt
when any royal cheese x-position is lower then 0 -royalCheese.width: the game is over;
Code edit (3 edits merged)
Please save this source code
User prompt
Fix Bug: 'Error: getChildAt: Supplied index 3 does not exist in the child list, or the supplied DisplayObject must be a child of the caller' in this line: 'var cheese = mice[i].removeChildAt(3);' Line Number: 279
Code edit (5 edits merged)
Please save this source code
User prompt
if a royal Cheese got abducted by a mouse, let it move with the mouse, till the mouse is destroyed
Code edit (1 edits merged)
Please save this source code
User prompt
when a mouse reach cheese, change his x-movement to -2. dont forget to get the correct refrences!
User prompt
Fix Bug: 'ReferenceError: royalCheeses is not defined' in this line: 'var cheeseReached = royalCheeses.some(function (cheese) {' Line Number: 126
User prompt
when a mouse reach cheese, change his x-movement to -2. dont forget to get the correct refrences!
User prompt
Fix Bug: 'ReferenceError: royalCheeses is not defined' in this line: 'var cheeseReached = royalCheeses.some(function (cheese) {' Line Number: 126
User prompt
when a mouse reach cheese, change his x-movement to -2
User prompt
when a mouse reach cheese, he change his x-movement direction and take the cheese with it
User prompt
Fix Bug: 'ReferenceError: royalCheeses is not defined' in this line: 'for (var i = 0; i < royalCheeses.length; i++) {' Line Number: 127
User prompt
whe a mouse reach cheese, he change his x-movement direction and take the cheese with it
User prompt
create a new class named royalCheese, spawn on each yLevel a royalCheese at x = 2000
User prompt
Fix Bug: 'ReferenceError: FecalBall is not defined' in this line: 'var newFecalBall = new FecalBall();' Line Number: 228
var Nutcracker = Container.expand(function () { var self = Container.call(this); self.freeMouth = true; self.upperJaw = self.createAsset('upperJaw', 'Nutcracker Upper Jaw', .5, .5); self.lowerJaw = self.createAsset('lowerJaw', 'Nutcracker Lower Jaw', .5, .5); self.upperJaw.y -= 50; self.lowerJaw.y += 25; self.mouthUp = true; self.chewAnimation = function () { if (!self.freeMouth) { var chewRange = 75; var chewSpeed = 3; if (self.mouthUp) { if (self.upperJaw.y > -chewRange) { self.upperJaw.y -= chewSpeed; } else { self.mouthUp = false; } } else { if (self.upperJaw.y < -50) { self.upperJaw.y += chewSpeed; } else { self.mouthUp = true; } } } }; self.isDragged = false; self.isReady = false; var yLevels = [1710, 1530, 1310]; self.move = function () { if (self.mouthTimer && self.mouthTimer > 0) { self.mouthTimer--; self.chewAnimation(); if (self.mouthTimer === 0) { self.freeMouth = true; self.upperJaw.y = -50; } } if (!self.isDragged && !yLevels.includes(self.y)) { if (self.y < yLevels[0]) { self.y += 5; } else { self.y -= 5; } if (yLevels.some(level => self.y >= level && self.y - 5 < level)) { self.y = yLevels.find(level => self.y >= level && self.y - 5 < level); self.isReady = true; } } }; self.on('down', function (obj) { if (self.freeMouth) { var pos = obj.event.getLocalPosition(self.parent); self.y = pos.y; self.x = pos.x; self.isDragged = true; self.isReady = false; draggedObject = self; } }); }); var MouseTrap = Container.expand(function () { var self = Container.call(this); var mousetrapGraphics = self.createAsset('mousetrap', 'Mouse Trap Graphics', .5, .5); self.activate = function () {}; }); var BuildingMenu = Container.expand(function () { var self = Container.call(this); self.y = 0; self.x = 1024; var menuBackground = self.createAsset('menuBackground', 'Building Menu Background', 0.5, 0); self.addChild(menuBackground); }); var NutcrackerButton = Container.expand(function (nutcrackers) { var self = Container.call(this); var buttonGraphics = self.createAsset('nutcrackerButton', 'Nutcracker Build Button', 0.5, 0); self.addChild(buttonGraphics); self.y = 200; var dragObject = null; self.on('down', function (obj) { if (ressourcesNuts >= 3) { var pos = obj.event.getLocalPosition(self.parent); dragObject = new Nutcracker(); self.parent.addChild(dragObject); dragObject.y = pos.y + 200; dragObject.x = pos.x; } }); stage.on('up', function (obj) { var pos = obj.event.getLocalPosition(self); if (dragObject) { if (pos.y > 200) { var newNutcracker = new Nutcracker(); newNutcracker.x = pos.x; newNutcracker.y = pos.y + 200; self.parent.addChild(newNutcracker); nutcrackers.push(newNutcracker); dragObject.destroy(); dragObject = null; ressourcesNuts -= 3; } else { dragObject.destroy(); dragObject = null; } } }); stage.on('move', function (obj) { if (dragObject) { var pos = obj.event.getLocalPosition(self); dragObject.x = pos.x; dragObject.y = pos.y + 200; } }); }); var Mouse = Container.expand(function () { var self = Container.call(this); self.mouseTail = self.createAsset('mouseTail', 'Mouse Graphics', .5, .5); self.mouseBody = self.createAsset('mouseBody', 'Mouse Graphics', .5, .5); self.mouseHead = self.createAsset('mouseHead', 'Mouse Graphics', .5, .5); self.mouseHead.y -= 90; self.mouseHead.x += 10; self.mouseTail.x -= 50; self.mouseTail.y -= 10; self.reachedCheese = false; self.move = function () { if (self.reachedCheese) { self.x -= 2; if (self.width > 0) { self.width = -150; } } else { self.x += 2; } var tailRotationSpeed = 0.020; var tailRotationRange = 20 * (Math.PI / 180); if (self.tailRotationDirection === undefined) { self.tailRotationDirection = 1; } if (self.mouseTail.rotation > tailRotationRange) { self.tailRotationDirection = -1; } else if (self.mouseTail.rotation < -tailRotationRange) { self.tailRotationDirection = 1; } self.mouseTail.rotation += tailRotationSpeed * self.tailRotationDirection; self.mouseTail.y -= self.tailRotationDirection / 3; self.mouseHead.rotation += tailRotationSpeed * self.tailRotationDirection / 3; self.mouseHead.x += self.tailRotationDirection / 3; self.mouseHead.y += self.tailRotationDirection / 10; }; }); var FecalBall = Container.expand(function () { var self = Container.call(this); self.mouseTail = self.createAsset('mouseTail', 'Mouse Graphics', .5, .5); self.fecalBall = self.createAsset('fecalBall', 'Fecal Ball Graphics', .5, .5); self.mouseTail.x -= 50; self.move = function () { self.x += 5; self.fecalBall.rotation += 0.1; }; }); var RoyalCheese = Container.expand(function () { var self = Container.call(this); var cheeseGraphics = self.createAsset('royalCheese', 'Royal Cheese Graphics', .5, .5); self.abducted = false; }); var RollingNut = Container.expand(function () { var self = Container.call(this); var rollingNutGraphics = self.createAsset('rollingNut', 'Rolling Nut Graphics', .5, .5); self.move = function () { self.x += 2; self.rotation += 0.1; }; }); var draggedObject = null; var ressourcesNuts = 3; var Game = Container.expand(function () { var self = Container.call(this); function animateNutcracker(nutcracker, distance) { var animationStep = distance / 30; var targetX = nutcracker.x + distance; nutcracker.isReady = false; var animationInterval = LK.setInterval(function () { if (nutcracker.x < targetX) { nutcracker.x += animationStep; } else { nutcracker.x = targetX; nutcracker.isReady = true; LK.clearInterval(animationInterval); } }, 1000 / 60); } var yLevels = [2500, 2240, 1930]; var background = self.createAsset('background', 'Background Graphics', 0, 0); self.addChildAt(background, 0); var buildingMenu = self.addChild(new BuildingMenu()); self.addChild(buildingMenu); var nutsCounter = new Text2(ressourcesNuts.toString(), { size: 200, fill: "brown" }); nutsCounter.anchor.set(0.5, 0); nutsCounter.x = 1700; nutsCounter.y = 100; self.addChild(nutsCounter); var nutcrackers = []; var mousetraps = []; var mice = []; var rollingNuts = []; var fecalBalls = []; var nutcrackerButton = self.addChild(new NutcrackerButton(nutcrackers)); LK.gui.topCenter.addChild(nutcrackerButton); var tickCounter = 0; var updateCounter = 0; var mouseSpawnTimer = 360; var royalCheeses = []; var yLevels = [2500, 2240, 1930]; yLevels.forEach(function (yLevel) { var newCheese = new RoyalCheese(); newCheese.x = 2000; newCheese.y = yLevel; royalCheeses.push(newCheese); self.addChild(newCheese); }); var fecalBallSpawnTimer = 3600; var miceTickCounter = new Text2(ressourcesNuts.toString(), { size: 200, fill: "#ccc" }); miceTickCounter.anchor.set(0.5, 0); miceTickCounter.x = 500; miceTickCounter.y = 100; self.addChild(miceTickCounter); LK.on('tick', function () { tickCounter++; nutsCounter.setText(ressourcesNuts.toString()); if (tickCounter % mouseSpawnTimer == 0) { var newMouse = new Mouse(); newMouse.x = 0 - newMouse.width; newMouse.y = yLevels[Math.floor(Math.random() * yLevels.length)]; mice.push(newMouse); self.addChild(newMouse); mouseSpawnTimer = Math.max(Math.round(mouseSpawnTimer * 0.99), 120); miceTickCounter.setText(mouseSpawnTimer.toString()); } if (tickCounter % fecalBallSpawnTimer * 10 == 0) { var newFecalBall = new FecalBall(); newFecalBall.x = 0 - newFecalBall.width; newFecalBall.y = yLevels[Math.floor(Math.random() * yLevels.length)]; fecalBalls.push(newFecalBall); self.addChild(newFecalBall); fecalBallSpawnTimer = Math.max(Math.round(fecalBallSpawnTimer * 0.95), 300); } if (tickCounter % 1200 == 0) { var newRollingNut = new RollingNut(); newRollingNut.x = 0 - newRollingNut.width; newRollingNut.y = yLevels[Math.floor(Math.random() * yLevels.length)]; rollingNuts.push(newRollingNut); self.addChild(newRollingNut); } for (var j = 0; j < nutcrackers.length; j++) { if (nutcrackers[j].x > 575) { nutcrackers[j].x = 575; } else if (nutcrackers[j].x < -600) { nutcrackers[j].x = -600; } } for (var i = 0; i < nutcrackers.length; i++) { nutcrackers[i].move(); } for (var i = 0; i < mousetraps.length; i++) { mousetraps[i].activate(); } for (var i = mice.length - 1; i >= 0; i--) { mice[i].move(); for (var j = 0; j < nutcrackers.length; j++) { if (nutcrackers[j].isReady && nutcrackers[j].freeMouth && !nutcrackers[j].isDragged && mice[i].intersects(nutcrackers[j])) { if (mice[i].children.length > 3) { var cheese = mice[i].removeChildAt(3); self.addChild(cheese); cheese.x = mice[i].x; cheese.y = mice[i].y; cheese.abducted = false; } mice[i].destroy(); mice.splice(i, 1); nutcrackers[j].freeMouth = false; nutcrackers[j].mouthTimer = 180; break; } } for (var c = 0; c < royalCheeses.length; c++) { if (royalCheeses[c].x < -royalCheeses[c].width) { LK.showGameOver(); break; } if (mice[i] && mice[i].intersects(royalCheeses[c]) && !royalCheeses[c].abducted) { mice[i].reachedCheese = true; royalCheeses[c].abducted = true; royalCheeses[c].parent.removeChild(royalCheeses[c]); mice[i].addChild(royalCheeses[c]); royalCheeses[c].x = 0; royalCheeses[c].y = 0; break; } } if (mice[i] && mice[i].x > 2048 + mice[i].width) { mice[i].destroy(); mice.splice(i, 1); } } for (var i = fecalBalls.length - 1; i >= 0; i--) { fecalBalls[i].move(); for (var j = 0; j < nutcrackers.length; j++) { if (nutcrackers[j].isReady && fecalBalls[i].intersects(nutcrackers[j])) { var mousePosX = fecalBalls[i].x; var mousePosY = fecalBalls[i].y; if (fecalBalls[i].x < 1400) { animateNutcracker(nutcrackers[j], 200); } var newMouse = new Mouse(); newMouse.x = mousePosX; newMouse.y = mousePosY; mice.push(newMouse); self.addChild(newMouse); fecalBalls[i].destroy(); fecalBalls.splice(i, 1); break; } } if (fecalBalls[i] && fecalBalls[i].x > 2048 + fecalBalls[i].width) { fecalBalls[i].destroy(); fecalBalls.splice(i, 1); } } for (var i = rollingNuts.length - 1; i >= 0; i--) { rollingNuts[i].move(); for (var j = 0; j < nutcrackers.length; j++) { if (nutcrackers[j].isReady && nutcrackers[j].freeMouth && !nutcrackers[j].isDragged && rollingNuts[i].intersects(nutcrackers[j])) { rollingNuts[i].destroy(); rollingNuts.splice(i, 1); nutcrackers[j].freeMouth = false; nutcrackers[j].mouthTimer = 300; ressourcesNuts++; break; } } if (rollingNuts[i] && rollingNuts[i].x > 2048 + rollingNuts[i].width) { rollingNuts[i].destroy(); rollingNuts.splice(i, 1); } } }); stage.on('up', function (obj) { if (draggedObject) { var pos = obj.event.getLocalPosition(self); draggedObject.isDragged = false; draggedObject.isReady = false; draggedObject = null; } }); stage.on('move', function (obj) { if (draggedObject) { var pos = obj.event.getLocalPosition(self); draggedObject.x = pos.x - 1000; draggedObject.y = pos.y - 600; } }); });
===================================================================
--- original.js
+++ change.js
@@ -289,9 +289,13 @@
break;
}
}
for (var c = 0; c < royalCheeses.length; c++) {
- if (mice[i].intersects(royalCheeses[c]) && !royalCheeses[c].abducted) {
+ if (royalCheeses[c].x < -royalCheeses[c].width) {
+ LK.showGameOver();
+ break;
+ }
+ if (mice[i] && mice[i].intersects(royalCheeses[c]) && !royalCheeses[c].abducted) {
mice[i].reachedCheese = true;
royalCheeses[c].abducted = true;
royalCheeses[c].parent.removeChild(royalCheeses[c]);
mice[i].addChild(royalCheeses[c]);
Nut cracker, side view Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Mouse trap, side view, cartoon Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a rolling nut, cartoon Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a round giant snowball, cartoon Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
white background