Code edit (15 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: round is not defined' in this line: 'mouseSpawnTimer = Math.max(round(mouseSpawnTimer * 0.97), 60);' Line Number: 221
Code edit (2 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: moseSpawnTimer is not defined' in this line: 'if (tickCounter % moseSpawnTimer * 10 == 0) {' Line Number: 214
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: fecalBalls[i] is undefined' in this line: 'if (fecalBalls[i].x < 1400) {' Line Number: 265
Code edit (1 edits merged)
Please save this source code
Code edit (15 edits merged)
Please save this source code
User prompt
if (fecalBalls[i].x < 1400) { nutcrackers[j].x += 200; } instead to push the nutcracker x-position simply by 200, make a smotth animation.
Code edit (6 edits merged)
Please save this source code
User prompt
when a fecalBall collide with a nutcracker, which isReady is true, the nutcrackers x-position is pushed to the left by 200. the fecalBall is destroyed and a usual mouse is spawned on its position.
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: fecalsBalls is not defined' in this line: 'for (var i = fecalsBalls.length - 1; i >= 0; i--) {' Line Number: 257
Code edit (22 edits merged)
Please save this source code
User prompt
make a new class called fecalBall. Spawn it every 60 ticks on a random ylevel, add them to the fecalBalls-array and let it move from the left to the right.
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (18 edits merged)
Please save this source code
User prompt
make a tail animation for the mouse. rotate it smoothly from -15 degrres to 15 degrres and back
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
when a nutcrackers x-position is >2048, move it to x= 2000
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: max is not defined' in this line: 'mouseSpawnTimer = max(mouseSpawnTimer--, 30);' Line Number: 166
Code edit (2 edits merged)
Please save this source code
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.move = function () { 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 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 FecalBall = Container.expand(function () { var self = Container.call(this); var fecalBallGraphics = self.createAsset('fecalBall', 'Fecal Ball Graphics', .5, .5); self.move = function () { self.x += 2; }; }); 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); 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; 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(mouseSpawnTimer -= 2, 60); } if (tickCounter % 60 == 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); } 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 > 2000) { nutcrackers[j].x = 2000; } 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])) { mice[i].destroy(); mice.splice(i, 1); nutcrackers[j].freeMouth = false; nutcrackers[j].mouthTimer = 180; break; } } if (mice[i] && mice[i].x > 2048 + mice[i].width) { mice[i].destroy(); mice.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); } } for (var i = fecalBalls.length - 1; i >= 0; i--) { fecalBalls[i].move(); if (fecalBalls[i] && fecalBalls[i].x > 2048 + fecalBalls[i].width) { fecalBalls[i].destroy(); fecalBalls.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); if (pos.x >= 1700) { draggedObject.x = pos.x - 1300; } else if (pos.x <= 300) { draggedObject.x = pos.x - 650; } else { draggedObject.x = pos.x - 900; } draggedObject.y = pos.y - 600; } }); });
===================================================================
--- original.js
+++ change.js
@@ -254,12 +254,12 @@
rollingNuts.splice(i, 1);
}
}
for (var i = fecalBalls.length - 1; i >= 0; i--) {
- fecalsBalls[i].move();
- if (fecalBalls[i] && fecalBalls[i].x > 2048 + fecalsBalls[i].width) {
- fecalsBalls[i].destroy();
- fecalsBalls.splice(i, 1);
+ fecalBalls[i].move();
+ if (fecalBalls[i] && fecalBalls[i].x > 2048 + fecalBalls[i].width) {
+ fecalBalls[i].destroy();
+ fecalBalls.splice(i, 1);
}
}
});
stage.on('up', function (obj) {
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