Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'toString')' in or related to this line: 'var text4 = new Text2(score.toString(), {' Line Number: 49
User prompt
Set the 0 of each text as scor number for count the ressource
Code edit (5 edits merged)
Please save this source code
User prompt
Please fix the bug: 'grid4 is not defined' in or related to this line: 'zeroTextGrid4.x = grid4.x + grid4.width * grid4.scaleX / 2;' Line Number: 123
User prompt
Remove all grids 1-8 and name its text 1 2 3 4 5 6 7 8
User prompt
Please fix the bug: 'grid4 is not defined' in or related to this line: 'zeroTextGrid4.x = grid4.x + grid4.width * grid4.scaleX / 2;' Line Number: 153
User prompt
Remove grids let only the text
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (22 edits merged)
Please save this source code
User prompt
Add grass to the game again
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (9 edits merged)
Please save this source code
User prompt
Make text of grid1 & 2 smaller
User prompt
Make the text smaller
Code edit (1 edits merged)
Please save this source code
Code edit (8 edits merged)
Please save this source code
User prompt
Add 0 score for other grids
Code edit (1 edits merged)
Please save this source code
User prompt
Add 0 text score for the other grids
User prompt
Remove 0 for grid3
User prompt
Make the 0 text in the front of all objects
/**** * 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 }; }); /**** * 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 ****/ // Add a '0' in the middle of grid1 var zeroText = new Text2('0', { size: 50, fill: 0xFFFFFF }); zeroText.anchor.set(0.5, 0.5); zeroText.x = 0 + 101 * 5.1 / 2; zeroText.y = 0 + 30 * 5 / 2; game.addChildAt(zeroText, game.children.length); // Add a '0' in the middle of grid2 var zeroTextGrid2 = new Text2('0', { size: 50, fill: 0xFFFFFF }); zeroTextGrid2.anchor.set(-10.6, 0.5); zeroTextGrid2.x = 101 + 101 * 5.1 / 2; zeroTextGrid2.y = 0 + 30 * 5 / 2; game.addChildAt(zeroTextGrid2, game.children.length); // Initialize arrays and variables 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 wall = LK.getAsset('wall1', { anchorX: 0.5, anchorY: -2, x: 1017, y: 0, scaleX: 2 }); game.addChild(wall); game.down = function (x, y, obj) {}; game.up = function (x, y, obj) {}; // Update game logic // Create grid1 and position it on the top left var grid1 = LK.getAsset('grid', { anchorX: 0.0, anchorY: 0.0, x: 0, y: 0, scaleX: 5.1, scaleY: 5 }); game.addChild(grid1); // Add a '0' in the middle of grid1 var zeroText = new Text2('0', { size: 50, fill: 0xFFFFFF }); zeroText.anchor.set(-6.7, 0.6); zeroText.x = grid1.x + grid1.width * grid1.scaleX / 2; zeroText.y = grid1.y + grid1.height * grid1.scaleY / 2; game.addChild(zeroText); // Create grid2 and position it next to grid1 var grid2 = LK.getAsset('grid', { anchorX: -0.8, anchorY: 0.0, x: grid1.width, y: 0, scaleX: 5.1, scaleY: 5 }); game.addChild(grid2); // Add a '0' in the middle of grid2 var zeroTextGrid2 = new Text2('0', { size: 50, fill: 0xFFFFFF }); zeroTextGrid2.anchor.set(-22, 0.6); zeroTextGrid2.x = grid2.x + grid2.width * grid2.scaleX / 2; zeroTextGrid2.y = grid2.y + grid2.height * grid2.scaleY / 2; game.addChild(zeroTextGrid2); // Create grid3 and position it next to grid2 var grid3 = LK.getAsset('grid', { anchorX: -1.6, anchorY: 0.0, x: grid1.width + grid2.width, y: 0, scaleX: 5.1, scaleY: 5 }); game.addChild(grid3); // Add a '0' in the middle of grid3 var zeroTextGrid3 = new Text2('0', { size: 50, fill: 0xFFFFFF }); zeroTextGrid3.anchor.set(-37.3, 0.6); zeroTextGrid3.x = grid3.x + grid3.width * grid3.scaleX / 2; zeroTextGrid3.y = grid3.y + grid3.height * grid3.scaleY / 2; game.addChildAt(zeroTextGrid3, game.children.length); // Add a '0' in the middle of grid4 var zeroTextGrid4 = new Text2('0', { size: 50, fill: 0xFFFFFF }); zeroTextGrid4.anchor.set(-52.5, 0.6); zeroTextGrid4.x = grid4.x + grid4.width * grid4.scaleX / 2; zeroTextGrid4.y = grid4.y + grid4.height * grid4.scaleY / 2; game.addChildAt(zeroTextGrid4, game.children.length); // Add a '0' in the middle of grid5 var zeroTextGrid5 = new Text2('0', { size: 50, fill: 0xFFFFFF }); zeroTextGrid5.anchor.set(-6.7, -2.1); zeroTextGrid5.x = grid5.x + grid5.width * grid5.scaleX / 2; zeroTextGrid5.y = grid5.y + grid5.height * grid5.scaleY / 2; game.addChildAt(zeroTextGrid5, game.children.length); // Add a '0' in the middle of grid6 var zeroTextGrid6 = new Text2('0', { size: 50, fill: 0xFFFFFF }); zeroTextGrid6.anchor.set(-22, -2.1); zeroTextGrid6.x = grid6.x + grid6.width * grid6.scaleX / 2; zeroTextGrid6.y = grid6.y + grid6.height * grid6.scaleY / 2; game.addChildAt(zeroTextGrid6, game.children.length); // Add grass asset to the game as background 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.55, x: 1024, y: 1200, scaleX: 7, scaleY: 6 }); game.addChildAt(sky, 0); // Add dirt asset to the game as background var dirt = LK.getAsset('dirt', { anchorX: 0.10, anchorY: -1.66, x: 100, y: 500, scaleX: 19, scaleY: 3 }); game.addChildAt(dirt, 1); // Add a '0' in the middle of grid7 var zeroTextGrid7 = new Text2('0', { size: 50, fill: 0xFFFFFF }); zeroTextGrid7.anchor.set(-37.3, -2.1); zeroTextGrid7.x = grid7.x + grid7.width * grid7.scaleX / 2; zeroTextGrid7.y = grid7.y + grid7.height * grid7.scaleY / 2; game.addChildAt(zeroTextGrid7, game.children.length); // Add a '0' in the middle of grid8 var zeroTextGrid8 = new Text2('0', { size: 50, fill: 0xFFFFFF }); zeroTextGrid8.anchor.set(-52.5, -2.1); zeroTextGrid8.x = grid8.x + grid8.width * grid8.scaleX / 2; zeroTextGrid8.y = grid8.y + grid8.height * grid8.scaleY / 2; game.addChildAt(zeroTextGrid8, game.children.length); game.update = function () { houses.forEach(function (house) { // Logic for house updates }); };
===================================================================
--- original.js
+++ change.js
@@ -24,55 +24,26 @@
/****
* Game Code
****/
-// Create grid1 and position it on the top left
-var grid1 = LK.getAsset('grid', {
- anchorX: 0.0,
- anchorY: 0.0,
- x: 0,
- y: 0,
- scaleX: 5.1,
- scaleY: 5
-});
-game.addChild(grid1);
// Add a '0' in the middle of grid1
var zeroText = new Text2('0', {
size: 50,
fill: 0xFFFFFF
});
zeroText.anchor.set(0.5, 0.5);
-zeroText.x = grid1.x + grid1.width * grid1.scaleX / 2;
-zeroText.y = grid1.y + grid1.height * grid1.scaleY / 2;
+zeroText.x = 0 + 101 * 5.1 / 2;
+zeroText.y = 0 + 30 * 5 / 2;
game.addChildAt(zeroText, game.children.length);
-// Create grid2 and position it next to grid1
-var grid2 = LK.getAsset('grid', {
- anchorX: -0.8,
- anchorY: 0.0,
- x: grid1.width,
- y: 0,
- scaleX: 5.1,
- scaleY: 5
-});
-game.addChild(grid2);
// Add a '0' in the middle of grid2
var zeroTextGrid2 = new Text2('0', {
size: 50,
fill: 0xFFFFFF
});
zeroTextGrid2.anchor.set(-10.6, 0.5);
-zeroTextGrid2.x = grid2.x + grid2.width * grid2.scaleX / 2;
-zeroTextGrid2.y = grid2.y + grid2.height * grid2.scaleY / 2;
+zeroTextGrid2.x = 101 + 101 * 5.1 / 2;
+zeroTextGrid2.y = 0 + 30 * 5 / 2;
game.addChildAt(zeroTextGrid2, game.children.length);
-var grid3 = LK.getAsset('grid', {
- anchorX: -1.6,
- anchorY: 0.0,
- x: grid1.width + grid2.width,
- y: 0,
- scaleX: 5.1,
- scaleY: 5
-});
-game.addChild(grid3);
// Initialize arrays and variables
var resources = [];
var houses = [];
var score = 0;
@@ -83,9 +54,9 @@
house.y = y; // Position the house at the given y coordinate
houses.push(house);
game.addChild(house);
}
-createHouse(1690, 1580);
+createHouse(1705, 1580);
var wall = LK.getAsset('wall1', {
anchorX: 0.5,
anchorY: -2,
x: 1017,
@@ -152,18 +123,8 @@
zeroTextGrid3.anchor.set(-37.3, 0.6);
zeroTextGrid3.x = grid3.x + grid3.width * grid3.scaleX / 2;
zeroTextGrid3.y = grid3.y + grid3.height * grid3.scaleY / 2;
game.addChildAt(zeroTextGrid3, game.children.length);
-// Create grid4 and position it next to grid3
-var grid4 = LK.getAsset('grid', {
- anchorX: -2.4,
- anchorY: 0.0,
- x: grid1.width + grid2.width + grid3.width,
- y: 0,
- scaleX: 5.1,
- scaleY: 5
-});
-game.addChild(grid4);
// Add a '0' in the middle of grid4
var zeroTextGrid4 = new Text2('0', {
size: 50,
fill: 0xFFFFFF
@@ -171,18 +132,8 @@
zeroTextGrid4.anchor.set(-52.5, 0.6);
zeroTextGrid4.x = grid4.x + grid4.width * grid4.scaleX / 2;
zeroTextGrid4.y = grid4.y + grid4.height * grid4.scaleY / 2;
game.addChildAt(zeroTextGrid4, game.children.length);
-// Create grid5 and position it below grid1
-var grid5 = LK.getAsset('grid', {
- anchorX: 0.0,
- anchorY: -0.8,
- x: 0,
- y: grid1.height,
- scaleX: 5.1,
- scaleY: 5
-});
-game.addChild(grid5);
// Add a '0' in the middle of grid5
var zeroTextGrid5 = new Text2('0', {
size: 50,
fill: 0xFFFFFF
@@ -190,18 +141,8 @@
zeroTextGrid5.anchor.set(-6.7, -2.1);
zeroTextGrid5.x = grid5.x + grid5.width * grid5.scaleX / 2;
zeroTextGrid5.y = grid5.y + grid5.height * grid5.scaleY / 2;
game.addChildAt(zeroTextGrid5, game.children.length);
-// Create grid6 and position it below grid2
-var grid6 = LK.getAsset('grid', {
- anchorX: -0.8,
- anchorY: -0.8,
- x: grid1.width,
- y: grid2.height,
- scaleX: 5.1,
- scaleY: 5
-});
-game.addChild(grid6);
// Add a '0' in the middle of grid6
var zeroTextGrid6 = new Text2('0', {
size: 50,
fill: 0xFFFFFF
@@ -239,18 +180,8 @@
scaleX: 19,
scaleY: 3
});
game.addChildAt(dirt, 1);
-// Create grid7 and position it below grid3
-var grid7 = LK.getAsset('grid', {
- anchorX: -1.6,
- anchorY: -0.8,
- x: grid1.width + grid2.width,
- y: grid3.height,
- scaleX: 5.1,
- scaleY: 5
-});
-game.addChild(grid7);
// Add a '0' in the middle of grid7
var zeroTextGrid7 = new Text2('0', {
size: 50,
fill: 0xFFFFFF
@@ -258,18 +189,8 @@
zeroTextGrid7.anchor.set(-37.3, -2.1);
zeroTextGrid7.x = grid7.x + grid7.width * grid7.scaleX / 2;
zeroTextGrid7.y = grid7.y + grid7.height * grid7.scaleY / 2;
game.addChildAt(zeroTextGrid7, game.children.length);
-// Create grid8 and position it below grid4
-var grid8 = LK.getAsset('grid', {
- anchorX: -2.4,
- anchorY: -0.8,
- x: grid1.width + grid2.width + grid3.width,
- y: grid4.height,
- scaleX: 5.1,
- scaleY: 5
-});
-game.addChild(grid8);
// Add a '0' in the middle of grid8
var zeroTextGrid8 = new Text2('0', {
size: 50,
fill: 0xFFFFFF
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
Flat cleared desert from the top, square Images only no diagonal, with one area of water, no text, no pixels of colors, no grids lines H/V. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
coin, have "AD" not "$", hd colors. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows