Code edit (7 edits merged)
Please save this source code
User prompt
first time the bigredbutton is pressed, the seeds should spawn raomky across the fields
User prompt
don't spawn the seeds beofre first click
Code edit (1 edits merged)
Please save this source code
User prompt
place the old farmer above and on the left sideof the instructions
User prompt
create an old farmer object
User prompt
on bigredbutton down, rest to original sprite after 1 second
Code edit (5 edits merged)
Please save this source code
User prompt
when bigredbutton is clicked, change it'sgraphic to buttonpressed graphic
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: 'Uncaught TypeError: Graphics is not a constructor' in or related to this line: 'var instructionWindow = new Graphics();' Line Number: 72
User prompt
make a semitransparent black window behind the instruction text
User prompt
make a bigredbutton at the bottom center of the screen
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
add outline to the instruction text
Code edit (13 edits merged)
Please save this source code
User prompt
make an instruction text at the start of the game saying: the weather's been dry, but wefinally got our new water balloon system in place. just tap when they're over the seeds, and we'll have great harvest!
Code edit (1 edits merged)
Please save this source code
User prompt
make a fullscreen background graphic
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: waterBalloons[i].containsPoint is not a function' in or related to this line: 'if (waterBalloons[i].containsPoint({' Line Number: 97
Initial prompt
One Button Farming
/**** * Classes ****/ // Seed class var Seed = Container.expand(function () { var self = Container.call(this); var seedGraphics = self.attachAsset('seed', { anchorX: 0.5, anchorY: 0.5 }); 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 = 3; self.update = function () { self.y += self.speed; if (self.y > 2732) { 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 seeds = []; var waterBalloons = []; var score = 0; var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Create seeds for (var i = 0; i < 5; i++) { var seed = new Seed(); seed.x = 2048 / 6 * (i + 1); seed.y = 2500; seeds.push(seed); game.addChild(seed); } // Spawn water balloons at random positions function spawnWaterBalloon() { var balloon = new WaterBalloon(); balloon.x = Math.random() * 2048; balloon.y = 0; waterBalloons.push(balloon); game.addChild(balloon); } // Check for collisions between water balloons and seeds function checkCollisions() { for (var i = waterBalloons.length - 1; i >= 0; i--) { for (var j = 0; j < seeds.length; j++) { if (waterBalloons[i].intersects(seeds[j])) { seeds[j].water(); waterBalloons[i].pop(); waterBalloons.splice(i, 1); score++; scoreTxt.setText(score); break; } } } } // Handle touch events game.down = function (x, y, obj) { for (var i = waterBalloons.length - 1; i >= 0; i--) { if (waterBalloons[i].intersects({ x: x, y: y, width: 1, height: 1 })) { waterBalloons[i].pop(); waterBalloons.splice(i, 1); break; } } }; // Update game state game.update = function () { for (var i = 0; i < waterBalloons.length; i++) { waterBalloons[i].update(); } checkCollisions(); if (LK.ticks % 60 == 0) { spawnWaterBalloon(); } };
===================================================================
--- original.js
+++ change.js
@@ -1,110 +1,112 @@
-/****
+/****
* Classes
-****/
+****/
// Seed class
var Seed = Container.expand(function () {
- var self = Container.call(this);
- var seedGraphics = self.attachAsset('seed', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.watered = false;
- self.water = function () {
- self.watered = true;
- // Change color to indicate watering
- seedGraphics.tint = 0x00FF00;
- };
+ var self = Container.call(this);
+ var seedGraphics = self.attachAsset('seed', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ 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 = 3;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732) {
- self.destroy();
- }
- };
- self.pop = function () {
- self.destroy();
- };
+ var self = Container.call(this);
+ var balloonGraphics = self.attachAsset('waterBalloon', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 3;
+ self.update = function () {
+ self.y += self.speed;
+ if (self.y > 2732) {
+ self.destroy();
+ }
+ };
+ self.pop = function () {
+ self.destroy();
+ };
});
-/****
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x87CEEB // Light blue background to represent the sky
+ backgroundColor: 0x87CEEB // Light blue background to represent the sky
});
-/****
+/****
* Game Code
-****/
+****/
var seeds = [];
var waterBalloons = [];
var score = 0;
var scoreTxt = new Text2('0', {
- size: 150,
- fill: "#ffffff"
+ size: 150,
+ fill: "#ffffff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Create seeds
for (var i = 0; i < 5; i++) {
- var seed = new Seed();
- seed.x = 2048 / 6 * (i + 1);
- seed.y = 2500;
- seeds.push(seed);
- game.addChild(seed);
+ var seed = new Seed();
+ seed.x = 2048 / 6 * (i + 1);
+ seed.y = 2500;
+ seeds.push(seed);
+ game.addChild(seed);
}
// Spawn water balloons at random positions
function spawnWaterBalloon() {
- var balloon = new WaterBalloon();
- balloon.x = Math.random() * 2048;
- balloon.y = 0;
- waterBalloons.push(balloon);
- game.addChild(balloon);
+ var balloon = new WaterBalloon();
+ balloon.x = Math.random() * 2048;
+ balloon.y = 0;
+ waterBalloons.push(balloon);
+ game.addChild(balloon);
}
// Check for collisions between water balloons and seeds
function checkCollisions() {
- for (var i = waterBalloons.length - 1; i >= 0; i--) {
- for (var j = 0; j < seeds.length; j++) {
- if (waterBalloons[i].intersects(seeds[j])) {
- seeds[j].water();
- waterBalloons[i].pop();
- waterBalloons.splice(i, 1);
- score++;
- scoreTxt.setText(score);
- break;
- }
- }
- }
+ for (var i = waterBalloons.length - 1; i >= 0; i--) {
+ for (var j = 0; j < seeds.length; j++) {
+ if (waterBalloons[i].intersects(seeds[j])) {
+ seeds[j].water();
+ waterBalloons[i].pop();
+ waterBalloons.splice(i, 1);
+ score++;
+ scoreTxt.setText(score);
+ break;
+ }
+ }
+ }
}
// Handle touch events
game.down = function (x, y, obj) {
- for (var i = waterBalloons.length - 1; i >= 0; i--) {
- if (waterBalloons[i].containsPoint({
- x: x,
- y: y
- })) {
- waterBalloons[i].pop();
- waterBalloons.splice(i, 1);
- break;
- }
- }
+ for (var i = waterBalloons.length - 1; i >= 0; i--) {
+ if (waterBalloons[i].intersects({
+ x: x,
+ y: y,
+ width: 1,
+ height: 1
+ })) {
+ waterBalloons[i].pop();
+ waterBalloons.splice(i, 1);
+ break;
+ }
+ }
};
// Update game state
game.update = function () {
- for (var i = 0; i < waterBalloons.length; i++) {
- waterBalloons[i].update();
- }
- checkCollisions();
- if (LK.ticks % 60 == 0) {
- spawnWaterBalloon();
- }
+ for (var i = 0; i < waterBalloons.length; i++) {
+ waterBalloons[i].update();
+ }
+ checkCollisions();
+ if (LK.ticks % 60 == 0) {
+ spawnWaterBalloon();
+ }
};
\ No newline at end of file
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.