Code edit (1 edits merged)
Please save this source code
User prompt
rework mouse jumper completely. He have to use a smooth jump animation. But he stay on its ylevel.
Code edit (3 edits merged)
Please save this source code
User prompt
mouse jumper have to jump very smoothly and not instant
Code edit (2 edits merged)
Please save this source code
User prompt
use a smooth jumpinganimation for the mousejumper, when he is jumping
Code edit (13 edits merged)
Please save this source code
User prompt
mouse jumpers can smoothly jump every 3 seconds 200 x and with a high till - 500y to the right and change their yLevel by doing so.
Code edit (1 edits merged)
Please save this source code
User prompt
give nutcrackers an extra asset, when they have deadlyFallSpeed and remove it, when they dont have deadlyFallSpeed anymore.
Code edit (11 edits merged)
Please save this source code
User prompt
when a nutcracker is falling at least 60 ticks, increase its fallspeed by 3 till he reach a ylevel.
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (6 edits merged)
Please save this source code
User prompt
create right of the mouseKill counter a graphical mousetail asset
User prompt
self.animateTick = function () { if (self.tickCounter < consumptionDuration) { var shiverAngle = 10 * Math.sin(self.tickCounter * 0.2); self.mouseTail.rotation = shiverAngle * (Math.PI / 180); self.tickCounter++; } else if (self.tickFallCounter < 60) { self.mouseTail.rotation += Math.PI / 60 * Math.random() * 3; self.y += 2.5 + Math.random() * 0.5; self.tickFallCounter++; } else { LK.off('tick', self.animateTick); } }; every final rotation should be possible and have the same chances
Code edit (1 edits merged)
Please save this source code
Code edit (15 edits merged)
Please save this source code
User prompt
self.animateTick = function () { if (self.tickCounter < consumptionDuration) {} else if (self.tickFallCounter < 60) {} else { LK.off('tick', self.animateTick); } }; I want a shivering animation between 25 and -25 degrees. Then I want the tail to fall down and stay there.
Code edit (1 edits merged)
Please save this source code
User prompt
destroy the tick Listener of MouseTail, when the tickCounter is above 60
User prompt
when a MouseTail is spawned, make a tick animation for it for 60 ticks
Code edit (6 edits merged)
Please save this source code
User prompt
give muosetail a random rotation.
var MouseTail = Container.expand(function (x, y) { var self = Container.call(this); self.mouseTail = self.createAsset('mouseTail', 'Mouse Tail Graphics', .5, .5); self.mouseTail.rotation = Math.random() * Math.PI * 2; self.x = x; self.y = y - 75; }); 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.resourceIncrementTimer && self.resourceIncrementTimer > 0) { self.resourceIncrementTimer--; if (self.resourceIncrementTimer === 0) { ressourcesNuts++; } } 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 -= 1; 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 TurtleMouse = Container.expand(function () { var self = Container.call(this); self.mouseTail = self.createAsset('turtleMouseTail', 'Turtle Mouse Graphics', .5, .5); self.MouseBody = self.createAsset('turtleMouseBody', 'Turtle Mouse Graphics', .5, .5); self.mouseTail.x -= 75; self.mouseTail.y -= 25; self.reachedCheese = false; self.turtleMouse = true; self.move = function () { if (self.reachedCheese) { self.x -= 1; if (self.width > 0) { self.width = -200; } } else { self.x += 1; } 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; }; }); 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.mouseTail.y -= 25; self.move = function () { self.x += 5; self.fecalBall.rotation += 0.1; 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; }; }); 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); 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 royalCheeses = []; var nutcrackerButton = self.addChild(new NutcrackerButton(nutcrackers)); LK.gui.topCenter.addChild(nutcrackerButton); var tickCounter = 0; 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 mouseSpawnTimer = 360; var mouseSpawnTimer2 = 25200; var mouseTurtleSpawnTimer = 3600; var fecalBallSpawnTimer = 3600; if (Math.random() > 0.5) { mouseTurtleSpawnTimer = 14400; } else { fecalBallSpawnTimer = 14400; } var miceKills = 0; var miceTickCounter = new Text2(miceKills.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(mouseSpawnTimer - 3, 90); } if (tickCounter % mouseSpawnTimer2 == 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); if (mouseSpawnTimer2 > 3600) { mouseSpawnTimer2 = 600; } mouseSpawnTimer2 = Math.max(mouseSpawnTimer2 - 3, 90); } 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); if (fecalBallSpawnTimer > 3600) { fecalBallSpawnTimer = 3600; } fecalBallSpawnTimer = Math.max(Math.round(fecalBallSpawnTimer * 0.9), 300); } if (tickCounter % mouseTurtleSpawnTimer * 10 == 0) { var newMouseTurtle = new TurtleMouse(); newMouseTurtle.x = 0 - newMouseTurtle.width; newMouseTurtle.y = yLevels[Math.floor(Math.random() * yLevels.length)]; mice.push(newMouseTurtle); self.addChild(newMouseTurtle); if (mouseTurtleSpawnTimer > 3600) { mouseTurtleSpawnTimer = 3600; } mouseTurtleSpawnTimer = Math.max(Math.round(mouseTurtleSpawnTimer * 0.9), 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; } nutcrackers[j].freeMouth = false; nutcrackers[j].mouthTimer = mice[i].turtleMouse ? 300 : 180; miceKills++; miceTickCounter.setText(miceKills.toString()); var mouseTail = new MouseTail(mice[i].x, mice[i].y); self.addChild(mouseTail); mice[i].destroy(); mice.splice(i, 1); break; } } for (var c = 0; c < royalCheeses.length; c++) { if (mice[i] && mice[i].intersects(royalCheeses[c])) { 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); } else if (mice[i] && mice[i].reachedCheese && mice[i] && mice[i].x + 100 < 0) { LK.showGameOver(); break; } } 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; animateNutcrackerPushedBack(nutcrackers[j], 300); 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; nutcrackers[j].resourceIncrementTimer = 300; break; } } if (rollingNuts[i] && rollingNuts[i].x > 2048 + rollingNuts[i].width) { rollingNuts[i].destroy(); rollingNuts.splice(i, 1); } } }); function animateNutcrackerPushedBack(nutcracker, distance) { var animationStep = distance / 30; var targetX = nutcracker.x + distance; nutcracker.isReady = false; var animationTick; var animationInterval = LK.setInterval(function () { animationTick++; if (animationTick < 30 || nutcracker.x < targetX) { nutcracker.x += animationStep; } else { nutcracker.x = targetX; nutcracker.isReady = true; LK.clearInterval(animationInterval); } }, 1000 / 60); } 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
@@ -2,9 +2,9 @@
var self = Container.call(this);
self.mouseTail = self.createAsset('mouseTail', 'Mouse Tail Graphics', .5, .5);
self.mouseTail.rotation = Math.random() * Math.PI * 2;
self.x = x;
- self.y = y;
+ self.y = y - 75;
});
var Nutcracker = Container.expand(function () {
var self = Container.call(this);
self.freeMouth = true;
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