User prompt
1- Add small green bar and statue 3/3 beside it on the top of each tree. 2- Make the bar and the statue decreasing 3 times only by 3 clicks on the tree to be in 0/3. 3- Add time 2:30 min for each 1/3 of the bar but show time when the bar is less then 3/3. 4- Start the time of increasing the bar only if the player didn't click the tree for 5 sec. 5- If the bar in 0/3 the tree can't be clicked and no wood can be collected from it. 6- Make 5 wood for each 1/3 of the tree bar. 7- Make the score of text1 for counting wood.
Code edit (6 edits merged)
Please save this source code
User prompt
Add another tree
User prompt
Add 2 trees
Code edit (3 edits merged)
Please save this source code
User prompt
Add tree object to the game
User prompt
Remove grass2 from game
User prompt
Make the sky background behind grass2 background
Code edit (1 edits merged)
Please save this source code
Code edit (12 edits merged)
Please save this source code
User prompt
Add another grass object below the house
User prompt
Add grass object below the house make it small
Code edit (2 edits merged)
Please save this source code
User prompt
Add crystal asset bellow the stone asset
Code edit (1 edits merged)
Please save this source code
User prompt
Add gold assets on the left side of text 5 that is below the wood asset
Code edit (4 edits merged)
Please save this source code
User prompt
Add silver asset to the right side of score text4
Code edit (1 edits merged)
Please save this source code
Code edit (10 edits merged)
Please save this source code
User prompt
Add bronze asset in the left side of score text3
Code edit (11 edits merged)
Please save this source code
User prompt
Add asset stone to left side of text2
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
/**** * Classes ****/ // House class representing upgradeable houses var House = Container.expand(function () { var self = Container.call(this); var houseGraphics = self.attachAsset('house', { anchorX: 0.5, anchorY: 0.5 }); self.upgrade = function (resource) { // Logic for upgrading house with a resource }; }); // Tree class representing trees with a green bar and statue var Tree = Container.expand(function () { var self = Container.call(this); var treeGraphics = self.attachAsset('tree', { anchorX: 0.5, anchorY: 0.5 }); // Initialize tree properties self.barValue = 3; // 3/3 initially self.clickCount = 0; self.lastClickTime = 0; self.canBeClicked = true; // Create green bar and statue text var barText = new Text2('3/3', { size: 20, fill: 0x00FF00 }); barText.anchor.set(0.5, 0); barText.x = treeGraphics.x; barText.y = treeGraphics.y - treeGraphics.height / 2 - 20; self.addChild(barText); // Update function for the tree self.update = function () { // Check if the tree can be clicked if (self.barValue > 0 && self.canBeClicked) { // Check if 5 seconds have passed since the last click if (Date.now() - self.lastClickTime > 5000) { // Increase the bar value if less than 3/3 if (self.barValue < 3) { self.barValue++; barText.setText(self.barValue + '/3'); } } } }; // Function to handle clicks on the tree self.click = function () { if (self.canBeClicked && self.barValue > 0) { self.barValue--; barText.setText(self.barValue + '/3'); self.lastClickTime = Date.now(); self.clickCount++; // Add wood to score score += 5; text1.setText(score); // Check if the bar is 0/3 if (self.barValue === 0) { self.canBeClicked = false; } } }; }); /**** * Initialize Game ****/ //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize arrays and variables var resources = []; var houses = []; var score = 0; var resources = []; var houses = []; var score = 0; // Function to create houses function createHouse(x, y) { var house = new House(); house.x = x; // Position the house at the given x coordinate house.y = y; // Position the house at the given y coordinate houses.push(house); game.addChild(house); } createHouse(1705, 1580); var bird = LK.getAsset('bird', { anchorX: 1.6, anchorY: 3.5, x: 1705, y: 1580 }); game.addChild(bird); var wall = LK.getAsset('wall1', { anchorX: 0.5, anchorY: 0, x: 1017, y: 0, scaleX: 2 }); game.addChild(wall); game.down = function (x, y, obj) { [tree1, tree2, tree3].forEach(function (tree) { if (tree.containsPoint({ x: x, y: y })) { tree.click(); } }); }; game.up = function (x, y, obj) {}; // Update game logic // Add a small text of score at the top middle of the screen var text1 = new Text2('0', { size: 33, fill: 0xad6d19 }); text1.anchor.set(22, -0.4); // Center the text horizontally at the top LK.gui.top.addChild(text1); // Add wood asset beside score of text one on the left side of it. var wood = LK.getAsset('wood', { anchorX: -3.8, anchorY: -0.7, x: text1.x - 20, // Position the wood asset to the left of text1 y: text1.y }); game.addChild(wood); var text2 = new Text2('0', { size: 33, fill: 0xad6d19 }); text2.anchor.set(4.4, -0.4); // Center the text horizontally at the top LK.gui.top.addChild(text2); // Add stone asset beside score of text2 on the left side of it. var stone = LK.getAsset('stone', { anchorX: -12.7, anchorY: -0.7, x: text2.x - 20, // Position the stone asset to the left of text2 y: text2.y }); game.addChild(stone); var text3 = new Text2('0', { size: 33, fill: 0xad6d19 }); text3.anchor.set(-13.3, -0.4); // Center the text horizontally at the top LK.gui.top.addChild(text3); // Add bronze asset beside score of text3 on the left side of it. var bronze = LK.getAsset('bronze', { anchorX: -21.7, anchorY: -0.7, x: text3.x - 20, // Position the bronze asset to the left of text3 y: text3.y }); game.addChild(bronze); var text4 = new Text2('0', { size: 33, fill: 0xad6d19 }); text4.anchor.set(-31.4, -0.4); // Center the text horizontally at the top LK.gui.top.addChild(text4); // Add silver asset beside score of text4 on the right side of it. var silver = LK.getAsset('silver', { anchorX: -30, anchorY: -0.7, x: text4.x + 20, // Position the silver asset to the right of text4 y: text4.y }); game.addChild(silver); var text5 = new Text2('0', { size: 33, fill: 0xad6d19 }); text5.anchor.set(22, -1.9); // Center the text horizontally at the top LK.gui.top.addChild(text5); // Add gold asset beside score of text5 on the left side of it. var gold = LK.getAsset('gold', { anchorX: -3.8, anchorY: -2.2, x: text5.x - 20, // Position the gold asset to the left of text5 y: text5.y }); game.addChild(gold); var text6 = new Text2('0', { size: 33, fill: 0xad6d19 }); text6.anchor.set(4.4, -1.9); // Center the text horizontally at the top LK.gui.top.addChild(text6); // Add crystal asset beside score of text6 on the left side of it. var crystal = LK.getAsset('crystal', { anchorX: -12.7, anchorY: -2.2, x: text6.x - 20, // Position the crystal asset to the left of text6 y: text6.y }); game.addChild(crystal); var text7 = new Text2('0', { size: 33, fill: 0xad6d19 }); text7.anchor.set(-13.3, -1.9); // Center the text horizontally at the top LK.gui.top.addChild(text7); var text8 = new Text2('0', { size: 33, fill: 0xad6d19 }); text8.anchor.set(-31.4, -1.9); // Center the text horizontally at the top LK.gui.top.addChild(text8); var grass = LK.getAsset('grass', { anchorX: 0.5, anchorY: -1, x: 1024, y: 1366, scaleX: 1, scaleY: 1 }); game.addChildAt(grass, 0); // Add sky asset to the game as background var sky = LK.getAsset('sky', { anchorX: 0.5, anchorY: 0.58, x: 1024, y: 1310, scaleX: 7, scaleY: 5.6 }); game.addChildAt(sky, 0); // Add dirt asset to the game as background var dirt = LK.getAsset('dirt', { anchorX: 0.06, anchorY: -1.66, x: 100, y: 500, scaleX: 19, scaleY: 3 }); game.addChildAt(dirt, 1); // Add first tree object to the game var tree1 = new Tree(); tree1.x = 1024; tree1.y = 1366; game.addChild(tree1); var tree2 = new Tree(); tree2.x = 1200; tree2.y = 1366; game.addChild(tree2); var tree3 = new Tree(); tree3.x = 1400; tree3.y = 1366; game.addChild(tree3); game.update = function () { houses.forEach(function (house) { // Logic for house updates }); [tree1, tree2, tree3].forEach(function (tree) { tree.update(); }); };
===================================================================
--- original.js
+++ change.js
@@ -11,8 +11,60 @@
self.upgrade = function (resource) {
// Logic for upgrading house with a resource
};
});
+// Tree class representing trees with a green bar and statue
+var Tree = Container.expand(function () {
+ var self = Container.call(this);
+ var treeGraphics = self.attachAsset('tree', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Initialize tree properties
+ self.barValue = 3; // 3/3 initially
+ self.clickCount = 0;
+ self.lastClickTime = 0;
+ self.canBeClicked = true;
+ // Create green bar and statue text
+ var barText = new Text2('3/3', {
+ size: 20,
+ fill: 0x00FF00
+ });
+ barText.anchor.set(0.5, 0);
+ barText.x = treeGraphics.x;
+ barText.y = treeGraphics.y - treeGraphics.height / 2 - 20;
+ self.addChild(barText);
+ // Update function for the tree
+ self.update = function () {
+ // Check if the tree can be clicked
+ if (self.barValue > 0 && self.canBeClicked) {
+ // Check if 5 seconds have passed since the last click
+ if (Date.now() - self.lastClickTime > 5000) {
+ // Increase the bar value if less than 3/3
+ if (self.barValue < 3) {
+ self.barValue++;
+ barText.setText(self.barValue + '/3');
+ }
+ }
+ }
+ };
+ // Function to handle clicks on the tree
+ self.click = function () {
+ if (self.canBeClicked && self.barValue > 0) {
+ self.barValue--;
+ barText.setText(self.barValue + '/3');
+ self.lastClickTime = Date.now();
+ self.clickCount++;
+ // Add wood to score
+ score += 5;
+ text1.setText(score);
+ // Check if the bar is 0/3
+ if (self.barValue === 0) {
+ self.canBeClicked = false;
+ }
+ }
+ };
+});
/****
* Initialize Game
****/
@@ -55,9 +107,18 @@
y: 0,
scaleX: 2
});
game.addChild(wall);
-game.down = function (x, y, obj) {};
+game.down = function (x, y, obj) {
+ [tree1, tree2, tree3].forEach(function (tree) {
+ if (tree.containsPoint({
+ x: x,
+ y: y
+ })) {
+ tree.click();
+ }
+ });
+};
game.up = function (x, y, obj) {};
// Update game logic
// Add a small text of score at the top middle of the screen
var text1 = new Text2('0', {
@@ -191,32 +252,24 @@
scaleY: 3
});
game.addChildAt(dirt, 1);
// Add first tree object to the game
-var tree1 = LK.getAsset('tree', {
- anchorX: 1,
- anchorY: 0,
- x: 1024,
- y: 1366
-});
+var tree1 = new Tree();
+tree1.x = 1024;
+tree1.y = 1366;
game.addChild(tree1);
-// Add second tree object to the game
-var tree2 = LK.getAsset('tree', {
- anchorX: 1.4,
- anchorY: 0,
- x: 1200,
- y: 1366
-});
+var tree2 = new Tree();
+tree2.x = 1200;
+tree2.y = 1366;
game.addChild(tree2);
-// Add third tree object to the game
-var tree3 = LK.getAsset('tree', {
- anchorX: 1,
- anchorY: 0,
- x: 1400,
- y: 1366
-});
+var tree3 = new Tree();
+tree3.x = 1400;
+tree3.y = 1366;
game.addChild(tree3);
game.update = function () {
houses.forEach(function (house) {
// Logic for house updates
});
+ [tree1, tree2, tree3].forEach(function (tree) {
+ tree.update();
+ });
};
\ No newline at end of file
2D wreckage of wood, square, HD colors. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
House from the front facing the screen with big sign above it have description "SHOP", Hd colors
coin, have "AD" not "$", hd colors. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows