Code edit (7 edits merged)
Please save this source code
User prompt
at the start of the game, add 8 questionMark instances on a single row along the top right edge of the screen.
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: cropsHarvested is not defined' in or related to this line: 'instructionText.setText('Good job!\n\nYou harvested ' + cropsHarvested + ' crops.\n\nNew Seed type unlocked!\n\nTry to get XX crops this year.');' Line Number: 527
Code edit (1 edits merged)
Please save this source code
Code edit (6 edits merged)
Please save this source code
User prompt
in spawnclouds, please set speed.x and speed.y to normalized vector2 values indicating their approach towards the cloudTargets[i] position.
Code edit (10 edits merged)
Please save this source code
User prompt
please turn the wateredGraphic slightly blue
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (5 edits merged)
Please save this source code
User prompt
update the scorelabel whenever lk.setscore is caled
User prompt
Please fix the bug: 'ReferenceError: Lk is not defined' in or related to this line: 'Lk.setScore(Lk.getScore() + 1);' Line Number: 101
Code edit (1 edits merged)
Please save this source code
Code edit (9 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: seedGraphics is not defined' in or related to this line: 'seedGraphics.tint = 0x00FF00;' Line Number: 82
Code edit (1 edits merged)
Please save this source code
Code edit (10 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'destroy')' in or related to this line: 'self.destroy();' Line Number: 153
Code edit (1 edits merged)
Please save this source code
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
/**** * 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 }); }); // Particle class var Particle = Container.expand(function () { var self = Container.call(this); var particleGraphics = self.attachAsset('waterDroplet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = { x: 0, y: 0 }; self.update = function () { self.x += self.speed.x; self.y += self.speed.y; if (self.y > 2732) { self.destroy(); } }; }); var RainShower = Container.expand(function () { var self = Container.call(this); var rainGraphics = self.attachAsset('rainwater', { 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 }); var rainshowerGraphics; self.speed = { x: 0, y: 0 }; //self.alpha = 0.7; self.hw = self.width / 2; self.hh = self.height / 2; self.fullyEnteredStage = false; self.popped = false; self.update = function () { if (!self.popped) { self.x += self.speed.x; self.y += self.speed.y; if (self.fullyEnteredStage) { if (self.x < self.hw) { self.speed.x *= -1; self.x = self.hw; } else if (self.x > 2048 - self.hw) { self.x = 2048 - self.hw; self.speed.x *= -1; } if (self.y < self.hh) { self.y = self.hh; self.speed.y *= -1; } else if (self.y > 2732 - self.hh) { self.y = 2732 - self.hh; self.speed.y *= -1; } } else { if (self.x > self.hw && self.x < 2048 - self.hw) { if (self.y > self.hh && self.y < 2732 - self.hw) { self.fullyEnteredStage = true; } } } } else { // flip the rainshower asset horizontally. //rainshowerGraphics.scale.x *= -1; rainshowerGraphics.scale.x *= -1; } }; self.pop = function () { self.popped = true; /*self.attachAsset('rainshower', { anchorX: 0.5, anchorY: 0 });*/ rainshowerGraphics = self.addChild(new RainShower(), { anchorX: 0.5, anchorY: 0 }); balloonGraphics = self.attachAsset('waterBalloon', { anchorX: 0.5, anchorY: 0.5 }); // Destroy the water balloon //self.destroy(); }; /* self.pop = function () { // Create a circular explosion of particles for (var i = 0; i < 360; i += 18) { var particle = new Particle(); var angle = i * Math.PI / 180; var radius = 250; // Half of the desired explosion width particle.x = self.x + 20 * Math.cos(angle); particle.y = self.y + 20 * Math.sin(angle); particle.speed.x = radius / 100 * Math.cos(angle); particle.speed.y = radius / 100 * Math.sin(angle) + 2; game.addChild(particle); } // Destroy the water balloon 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 push THE RED BUTTON when the BALLOONS are over the SEEDS, and we'll have a GREAT harvest!\n\nTap once to begin.", { 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 balloonSpeedMaster = 3; 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); } } if (waterBalloons.length === 0) { // Spawn 5 waterballoons at random offscreen-positions for (var i = 0; i < 5; i++) { var waterBalloon = new WaterBalloon(); //waterBalloon.rotation = Math.random() * Math.PI * 2; // Assign a random rotation between 0 and 2PI radians //waterBalloon.rotation = Math.PI / 3 - Math.PI / 2; if (Math.random() > 0.5) { if (Math.random() > 0.5) { waterBalloon.x = -400; waterBalloon.speed.x = 1; } else { waterBalloon.x = 2048 + 400; waterBalloon.speed.x = -1; } waterBalloon.y = Math.random() * 2732; waterBalloon.speed.y = waterBalloon.y > 1366 ? -1 : 1; } else { if (Math.random() > 0.5) { waterBalloon.y = -400; waterBalloon.speed.y = 1; } else { waterBalloon.y = 2732 + 400; waterBalloon.speed.y = -1; } waterBalloon.x = Math.random() * 2048; waterBalloon.speed.x = waterBalloon.x > 1024 ? -1 : 1; } var diff = Math.random() * 0.5; if (Math.random() > 0.5) { waterBalloon.speed.x += diff; waterBalloon.speed.y -= diff; } else { waterBalloon.speed.x -= diff; waterBalloon.speed.y += diff; } waterBalloon.speed.x *= balloonSpeedMaster; waterBalloon.speed.y *= balloonSpeedMaster; waterBalloons.push(waterBalloon); game.addChild(waterBalloon); } } else { for (var i = 0; i < waterBalloons.length; i++) { waterBalloons[i].pop(); } } // 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(); } };
/****
* 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
});
});
// Particle class
var Particle = Container.expand(function () {
var self = Container.call(this);
var particleGraphics = self.attachAsset('waterDroplet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = {
x: 0,
y: 0
};
self.update = function () {
self.x += self.speed.x;
self.y += self.speed.y;
if (self.y > 2732) {
self.destroy();
}
};
});
var RainShower = Container.expand(function () {
var self = Container.call(this);
var rainGraphics = self.attachAsset('rainwater', {
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
});
var rainshowerGraphics;
self.speed = {
x: 0,
y: 0
};
//self.alpha = 0.7;
self.hw = self.width / 2;
self.hh = self.height / 2;
self.fullyEnteredStage = false;
self.popped = false;
self.update = function () {
if (!self.popped) {
self.x += self.speed.x;
self.y += self.speed.y;
if (self.fullyEnteredStage) {
if (self.x < self.hw) {
self.speed.x *= -1;
self.x = self.hw;
} else if (self.x > 2048 - self.hw) {
self.x = 2048 - self.hw;
self.speed.x *= -1;
}
if (self.y < self.hh) {
self.y = self.hh;
self.speed.y *= -1;
} else if (self.y > 2732 - self.hh) {
self.y = 2732 - self.hh;
self.speed.y *= -1;
}
} else {
if (self.x > self.hw && self.x < 2048 - self.hw) {
if (self.y > self.hh && self.y < 2732 - self.hw) {
self.fullyEnteredStage = true;
}
}
}
} else {
// flip the rainshower asset horizontally.
//rainshowerGraphics.scale.x *= -1;
rainshowerGraphics.scale.x *= -1;
}
};
self.pop = function () {
self.popped = true;
/*self.attachAsset('rainshower', {
anchorX: 0.5,
anchorY: 0
});*/
rainshowerGraphics = self.addChild(new RainShower(), {
anchorX: 0.5,
anchorY: 0
});
balloonGraphics = self.attachAsset('waterBalloon', {
anchorX: 0.5,
anchorY: 0.5
});
// Destroy the water balloon
//self.destroy();
};
/*
self.pop = function () {
// Create a circular explosion of particles
for (var i = 0; i < 360; i += 18) {
var particle = new Particle();
var angle = i * Math.PI / 180;
var radius = 250; // Half of the desired explosion width
particle.x = self.x + 20 * Math.cos(angle);
particle.y = self.y + 20 * Math.sin(angle);
particle.speed.x = radius / 100 * Math.cos(angle);
particle.speed.y = radius / 100 * Math.sin(angle) + 2;
game.addChild(particle);
}
// Destroy the water balloon
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 push THE RED BUTTON when the BALLOONS are over the SEEDS, and we'll have a GREAT harvest!\n\nTap once to begin.", {
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 balloonSpeedMaster = 3;
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);
}
}
if (waterBalloons.length === 0) {
// Spawn 5 waterballoons at random offscreen-positions
for (var i = 0; i < 5; i++) {
var waterBalloon = new WaterBalloon();
//waterBalloon.rotation = Math.random() * Math.PI * 2; // Assign a random rotation between 0 and 2PI radians
//waterBalloon.rotation = Math.PI / 3 - Math.PI / 2;
if (Math.random() > 0.5) {
if (Math.random() > 0.5) {
waterBalloon.x = -400;
waterBalloon.speed.x = 1;
} else {
waterBalloon.x = 2048 + 400;
waterBalloon.speed.x = -1;
}
waterBalloon.y = Math.random() * 2732;
waterBalloon.speed.y = waterBalloon.y > 1366 ? -1 : 1;
} else {
if (Math.random() > 0.5) {
waterBalloon.y = -400;
waterBalloon.speed.y = 1;
} else {
waterBalloon.y = 2732 + 400;
waterBalloon.speed.y = -1;
}
waterBalloon.x = Math.random() * 2048;
waterBalloon.speed.x = waterBalloon.x > 1024 ? -1 : 1;
}
var diff = Math.random() * 0.5;
if (Math.random() > 0.5) {
waterBalloon.speed.x += diff;
waterBalloon.speed.y -= diff;
} else {
waterBalloon.speed.x -= diff;
waterBalloon.speed.y += diff;
}
waterBalloon.speed.x *= balloonSpeedMaster;
waterBalloon.speed.y *= balloonSpeedMaster;
waterBalloons.push(waterBalloon);
game.addChild(waterBalloon);
}
} else {
for (var i = 0; i < waterBalloons.length; i++) {
waterBalloons[i].pop();
}
}
// 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();
}
};
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.