Code edit (14 edits merged)
Please save this source code
User prompt
in the game update function, arrange clouds so that the ones with higher Y value appear in front of the other ones.
Code edit (8 edits merged)
Please save this source code
User prompt
please fix this code so it adds a new rtainshower instance as intended: rainshowerGraphics = self.add(new RainShower(), { anchorX: 0.5, anchorY: 0 });
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
where it says '// flip the rainshower asset horizontally.', please flip the rainshower graphics horizontally
Code edit (10 edits merged)
Please save this source code
User prompt
where it says self.rainshower.flip.x *= -1; please make the rainshower asset of the waterballon flip horizontally
Code edit (8 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: self.attachAssetAt is not a function' in or related to this line: 'self.attachAssetAt('rainpour', self.children.length - 1);' Line Number: 109
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
the particles in the pop function should make a regular circular explosion with width 500px
Code edit (7 edits merged)
Please save this source code
User prompt
the waterbaloon pop function should replace the waterballoon with a particle effect of water droplets spraying down, darkening the field below.
Code edit (11 edits merged)
Please save this source code
User prompt
igive each balloon a random rotation on spawn
Code edit (1 edits merged)
Please save this source code
Code edit (10 edits merged)
Please save this source code
User prompt
the balloons should spawn anywhere outside the visible area and have a random movement vector assigned that bring them on stage
User prompt
after spawning the seeds, also spawn 5 waterballoons at random offscreen-positions, and make them all float into the visible area.
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
spawn a aseed in all positions in the positionsarray, not just the first five
/**** * Classes ****/ // BigRedButton class var BigRedButton = Container.expand(function () { var self = Container.call(this); var buttonGraphics = self.attachAsset('bigRedButton', { anchorX: 0.5, anchorY: 0.5 }); }); // OldFarmer class var OldFarmer = Container.expand(function () { var self = Container.call(this); var farmerGraphics = self.attachAsset('oldFarmer', { anchorX: 0.5, anchorY: 0.5 }); }); // Seed class var Seed = Container.expand(function () { var self = Container.call(this); self.watered = false; self.water = function () { self.watered = true; // Change color to indicate watering seedGraphics.tint = 0x00FF00; }; }); //<Assets used in the game will automatically appear here> // WaterBalloon class var WaterBalloon = Container.expand(function () { var self = Container.call(this); var balloonGraphics = self.attachAsset('waterBalloon', { anchorX: 0.5, anchorY: 0.5 }); self.speed = { x: (Math.random() - 0.5) * 6, y: Math.random() * 3 + 2 }; self.update = function () { self.x += self.speed.x; self.y += self.speed.y; if (self.y > 2732 || self.x < 0 || self.x > 2048) { self.destroy(); } }; self.pop = function () { //self.destroy(); }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB // Light blue background to represent the sky }); /**** * Game Code ****/ var background = game.attachAsset('background', { anchorX: 0.5, anchorY: 0, scaleX: 1, scaleY: 1 }); background.x = 1024; //background.width / 2; // Create a semi-transparent black window behind the instruction text var instructionWindow = LK.getAsset('blackWindow', { width: 2048, height: 2732, color: 0x000000, alpha: 0.7, shape: 'box', anchorX: 0.5 }); game.addChild(instructionWindow); // Add instruction text var instructionText = new Text2("The weather's been dry lately, but we finally got our new WATER BALLOON SYSTEM in place!\n\nJust tap when the BALLOONS are over the SEEDS, and we'll have a GREAT harvest!", { size: 62, weight: 800, font: 'Verdana, sans-serif', fill: "#aaffaa", align: "center", wordWrap: true, wordWrapWidth: 1948, stroke: '#000000', strokeThickness: 15 }); instructionText.anchor.set(0.5, 0); instructionText.x = 1024; instructionText.y = 400; instructionWindow.width = instructionText.width + 100; instructionWindow.height = instructionText.height + 100; instructionWindow.x = instructionText.x; instructionWindow.y = instructionText.y - 50; game.addChild(instructionText); var seedTypes = ['pumpkin1']; var seedPositions = [[150, 700], [270, 1200], [270, 1600], [270, 2300], [525, 800], [800, 2000], [920, 820], [1300, 750], [1550, 500], [1800, 750], [1600, 1100], [1625, 1550], [1700, 2000], [1700, 2350]]; var seeds = []; var waterBalloons = []; var score = 0; var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); // Add the big red button to the game var bigRedButton = new BigRedButton(); bigRedButton.x = 1024; // Center of the screen bigRedButton.y = 2632 - bigRedButton.height / 2; // Bottom of the screen game.addChild(bigRedButton); // Add the old farmer to the game var oldFarmer = new OldFarmer(); oldFarmer.x = instructionText.x - oldFarmer.width - 500; // Left side of the instructions oldFarmer.y = instructionText.y - oldFarmer.height / 2 - 50; // Above the instructions game.addChild(oldFarmer); scoreTxt.anchor.set(0.5, 0); var seeds = []; LK.gui.top.addChild(scoreTxt); // Handle touch events bigRedButton.down = function (x, y, obj) { bigRedButton.attachAsset('buttonPressed', { anchorX: 0.5, anchorY: 0.5 }); if (seeds.length === 0) { oldFarmer.alpha = 0; instructionText.alpha = 0; instructionWindow.alpha = 0; for (var i = 0; i < seedPositions.length; i++) { var seedType = seedTypes[Math.floor(Math.random() * seedTypes.length)]; var seed = new Seed(); seed.attachAsset(seedType, { anchorX: 0.5, anchorY: 0.5 }); seed.x = seedPositions[i][0]; // Position from seedPositions array seed.y = seedPositions[i][1]; // Position from seedPositions array seeds.push(seed); game.addChild(seed); } } // Spawn 5 waterballoons at random offscreen-positions for (var i = 0; i < 5; i++) { var waterBalloon = new WaterBalloon(); // Random x position outside the visible area waterBalloon.x = Math.random() * 2048 * (Math.random() > 0.5 ? 1 : -1); // Random y position outside the visible area waterBalloon.y = Math.random() * 2732 * (Math.random() > 0.5 ? 1 : -1); waterBalloons.push(waterBalloon); game.addChild(waterBalloon); } // Switch back to unpressed state of button after 1 second. LK.setTimeout(function () { bigRedButton.attachAsset('bigRedButton', { anchorX: 0.5, anchorY: 0.5 }); }, 1000); }; // Update game state game.update = function () { for (var i = 0; i < waterBalloons.length; i++) { waterBalloons[i].update(); } };
===================================================================
--- original.js
+++ change.js
@@ -34,12 +34,16 @@
var balloonGraphics = self.attachAsset('waterBalloon', {
anchorX: 0.5,
anchorY: 0.5
});
- self.speed = 3;
+ self.speed = {
+ x: (Math.random() - 0.5) * 6,
+ y: Math.random() * 3 + 2
+ };
self.update = function () {
- self.y += self.speed;
- if (self.y > 2732) {
+ self.x += self.speed.x;
+ self.y += self.speed.y;
+ if (self.y > 2732 || self.x < 0 || self.x > 2048) {
self.destroy();
}
};
self.pop = function () {
@@ -141,10 +145,12 @@
}
// Spawn 5 waterballoons at random offscreen-positions
for (var i = 0; i < 5; i++) {
var waterBalloon = new WaterBalloon();
- waterBalloon.x = Math.random() * 2048; // Random x position
- waterBalloon.y = -300; // Offscreen position
+ // Random x position outside the visible area
+ waterBalloon.x = Math.random() * 2048 * (Math.random() > 0.5 ? 1 : -1);
+ // Random y position outside the visible area
+ waterBalloon.y = Math.random() * 2732 * (Math.random() > 0.5 ? 1 : -1);
waterBalloons.push(waterBalloon);
game.addChild(waterBalloon);
}
// Switch back to unpressed state of button after 1 second.
A straight top down perspective illustration of a large empty field with fertile, plowed but unplanted brown soil.There should be a farmhouse near the top.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An ungerminated plant seed.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A fluffy white cloud. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A lush pumpkin at the foot of its green stalk.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Erase the inpainted area.
A corn seed.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A single yellow corn seed.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A corn plant in early stage of growth.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A young, unripe corn plant.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A Delicious strawberry.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Delete the inpainted area.
A nice green pea pod.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An interface element which is a gray circle with a question mark inside it.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A little golden star.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
erase the white outline parts in the image.