User prompt
sb tıklandığında tüm ant objelerinin speed değerleri 10 artsın
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'ant.speed += 10;' Line Number: 106
Code edit (1 edits merged)
Please save this source code
User prompt
sb tıklandığında money 20 eksilsin
User prompt
Please fix the bug: 'undefined is not an object (evaluating 'sb.down = function (x, y, obj) { __$(46); Ant.prototype.speed += 10; }')' in or related to this line: 'sb.down = function (x, y, obj) {' Line Number: 98
User prompt
sb ye tıklandığında speed değeri 10 artsın
User prompt
Please fix the bug: 'undefined is not an object (evaluating 'sb.down = function (x, y, obj) { __$(46); LK.showGameOver(); }')' in or related to this line: 'sb.down = function (x, y, obj) {' Line Number: 98
User prompt
sb ye tıklandığında oyun bitsin
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'var ant = game.getChildByClass(Ant); // Get the ant object' Line Number: 106
User prompt
sb ye tıklayınca ant nesnesinin speed değeri 10 artsın
User prompt
Please fix the bug: 'undefined is not an object (evaluating 'sb.down = function (x, y, obj) { __$(46); this.tint = 0x008000; // Change color to green }')' in or related to this line: 'sb.down = function (x, y, obj) {' Line Number: 98
User prompt
sb nesnesine tıklayınca rengi yeşil olsun
User prompt
Ekranın altına sb nesnesini konumlandır
User prompt
Powerb ye basınca rengi yeşil olsun
User prompt
Ekranın en altına 400x400px gri bir kare koy. Adı powerb olsun.
User prompt
Powerb nesnesine basınca ant nesnesinin speed değeri 10 artsın
User prompt
Ekranın en altına 200x200px gri bir kare koy. Adı powerb olsun. İçine de $20 yaz
User prompt
Powerbutton nesnesine basınca money 20 sayı azalsın. Ant nesnesinin speed değeri 10 sayı artsın
User prompt
Powerbutton nesnesine basınca money 20 sayı azalsın
User prompt
Ekranın en altına 200x200px gri bir kare koy. Adı powerbutton olsun. İçine de $20 yaz
User prompt
Powerbutton nesnesine tıklandığında Ant nesnesinin power ve speed değerlerini ekranın sağ üstünde text olarak göster
User prompt
Powerbutton her basıldığında Ant nesnesinin power ve speed değerlerini ekranın sağ üstünde text olarak göster
User prompt
Ant nesnesinin power ve speed değerlerini ekranın sağ üstünde anlık göster
User prompt
Poweractive true iken powerbutton basılırsa ant nesnesinin speed sayısı 10 artsın
/**** * Classes ****/ var Ant = Container.expand(function () { var self = Container.call(this); var antGraphics = self.attachAsset('ant', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; // Default speed value self.power = 0.05; // Default power value self.wait = 3; // Default wait value self.returning = false; // State variable to track whether the ant is returning to the hole or not self.revenue = 5; // Default revenue value self.update = function () { var targetX, targetY; // If the ant is returning, set the target to the hole if (self.returning) { targetX = hole.x; targetY = hole.y; } else { // Otherwise, set the target to the food targetX = food.x; targetY = food.y; } // Calculate the direction vector towards the target var directionX = targetX - self.x; var directionY = targetY - self.y; var magnitude = Math.sqrt(directionX * directionX + directionY * directionY); directionX /= magnitude; directionY /= magnitude; // Move the ant towards the target self.x += directionX * self.speed; self.y += directionY * self.speed; // If the ant intersects with the food and is not returning, stop the ant and start waiting if (self.intersects(food) && !self.returning) { self.speed = 0; // Decrease the size of the food object by 5px food.scale.x -= self.power; food.scale.y -= self.power; LK.setTimeout(function () { // After waiting, start returning to the hole self.returning = true; self.speed = 10; // Set the speed to its default value // Flip the ant image vertically antGraphics.scale.y = -1; }, self.wait * 1000); } // If the ant is returning and intersects with the hole, destroy the ant and increase the 'money' value if (self.returning && self.intersects(hole)) { self.destroy(); money += self.revenue; } }; }); var Food = Container.expand(function () { var self = Container.call(this); var foodGraphics = self.attachAsset('food', { anchorX: 0.5, anchorY: 0.5 }); }); var Hole = Container.expand(function () { var self = Container.call(this); var holeGraphics = self.attachAsset('hole', { anchorX: 0.5, anchorY: 0.5 }); }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEFA }); /**** * Game Code ****/ var money = 0; var moneyText = new Text2('$' + money, { size: 140, fill: 0x008000, font: "'GillSans-Bold',Impact,'Arial Black',Tahoma" }); moneyText.anchor.set(0.5, 0); moneyText.y += 100; LK.gui.top.addChild(moneyText); var sb = game.addChild(LK.getAsset('sb', { anchorX: 0.5, anchorY: 0.5 })); sb.x = 2048 / 2; sb.y = 2732 - sb.height / 2; sb.down = function (x, y, obj) { money -= 20; game.children.forEach(function (child) { if (child instanceof Ant) { child.speed += 10; } }); var ant = game.addChild(new Ant()); }; //<Write imports for supported plugins here> ; var food = game.addChild(new Food()); food.x = 2048 / 2; food.y = 2732 / 4; var hole = game.addChild(new Hole()); hole.x = food.x; hole.y = food.y + 1100; var sb = game.addChild(LK.getAsset('sb', { anchorX: 0.5, anchorY: 0.5 })); sb.x = 2048 / 2; sb.y = 2732 - sb.height / 2; LK.setInterval(function () { var ant = game.addChild(new Ant()); // Randomize the x position of the ant within the width of the hole ant.x = hole.x + Math.random() * hole.width - hole.width / 2; ant.y = hole.y; }, 3000); game.update = function () { moneyText.setText('$' + money); }; ;
===================================================================
--- original.js
+++ change.js
@@ -94,8 +94,13 @@
sb.x = 2048 / 2;
sb.y = 2732 - sb.height / 2;
sb.down = function (x, y, obj) {
money -= 20;
+ game.children.forEach(function (child) {
+ if (child instanceof Ant) {
+ child.speed += 10;
+ }
+ });
var ant = game.addChild(new Ant());
};
//<Write imports for supported plugins here>
;
donut cartoon 2d, blank background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
hole cartoon 2d, blank background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Cartoon Pizza, 2d, blank background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
strong button, cartoon, blank background, 2d. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
speed button, 2d, cartoon, blank background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
hamburger,2d,cartoon,blank background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
topdown 2d ant, blank background, no shadows. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
red apple,cartoon,2d,blank background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
dollar,cartoon,2d,blank background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
watermelon,cartoon,2d,blank background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
candy,cartoon,2d,blank background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
strawberry,cartoon,2d,blank background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
honey,cartoon,2d,blank background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
bread,cartoon,2d,blank background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
hafif taşlı zemin. üstten görünüm. cartoon