User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading '7')' in or related to this line: 'if (self.harvestingMode == 1 && self.harvestedSpiceOnCellCounter < 200 && gameMap.cells[self.cellX][self.cellY].spice) {' Line Number: 833
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading '6')' in or related to this line: 'if (self.harvestingMode == 1 && self.harvestedSpiceOnCellCounter < 200 && gameMap.cells[self.cellX][self.cellY].spice) {' Line Number: 833
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'spice')' in or related to this line: 'if (self.harvestingMode == 1 && self.harvestedSpiceOnCellCounter < 200 && gameMap.cells[self.cellX][self.cellY].spice) {' Line Number: 833
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'spice')' in or related to this line: 'if (self.harvestingMode == 1 && self.harvestedSpiceOnCellCounter < 200 && gameMap.cells[self.cellX][self.cellY].spice) {' Line Number: 833
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot set properties of undefined (setting 'unit')' in or related to this line: 'gameMap.cells[self.cellX][self.cellY].unit = self;' Line Number: 747
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'spice')' in or related to this line: 'if (self.harvestingMode == 1 && self.harvestedSpiceOnCellCounter < 200 && gameMap.cells[self.cellX][self.cellY].spice) {' Line Number: 833
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'spice')' in or related to this line: 'if (self.harvestingMode == 1 && self.harvestedSpiceOnCellCounter < 200 && gameMap.cells[self.cellX][self.cellY].spice) {' Line Number: 833
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading '9.366666666666676')' in or related to this line: 'if (self.harvestingMode == 1 && self.harvestedSpiceOnCellCounter < 200 && gameMap.cells[self.cellX][self.cellY].spice) {' Line Number: 833
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'spice')' in or related to this line: 'if (self.harvestingMode == 1 && self.harvestedSpiceOnCellCounter < 200 && gameMap.cells[self.cellX][self.cellY].spice) {' Line Number: 833
Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'spice')' in or related to this line: 'if (self.harvestingMode == 1 && self.harvestedSpiceOnCellCounter < 200 && gameMap.cells[self.cellX][self.cellY].spice) {' Line Number: 833
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (17 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: screenCoordsToWorldCell is not defined' in or related to this line: 'var cellElt = screenCoordsToWorldCell(element.x, element.y);' Line Number: 645
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -616,13 +616,16 @@
self.selectionCircle.alpha = 0.9;
}
var centerDeltaX = (gameMap.currentViewCenter.x - 15) * 100;
var centerDeltaY = (gameMap.currentViewCenter.y - 15) * 100;
- var cellElt = screenCoordToWorldCell(element.x, element.y);
+ //var cellElt = screenCoordToWorldCell(element.x, element.y);
+ var cellElt = worldCoordToScreenCell(element.x, element.y);
+ console.log("element at : " + element.x + ',' + element.y);
//self.x = element.x - centerDeltaX + elementDeltaX;
//self.y = element.y - centerDeltaY + elementDeltaY;
- self.x = cellElt.wCellX + elementDeltaX;
- self.y = cellElt.wCellY + elementDeltaY;
+ self.x = cellElt.cellX * tileSize + elementDeltaX;
+ self.y = cellElt.cellY * tileSize + elementDeltaY;
+ console.log("SelectionMarker at : " + cellElt.wCellX + ',' + cellElt.wCellY + ' => ' + self.x + ',' + self.y);
self.visible = true;
};
self.hide = function () {
console.log('SelectionMarker hidden');
@@ -1254,8 +1257,9 @@
}
}
//#region Event listeners
var dragStart = null;
+var dragDelta = 0;
function handleDragStart(obj) {
console.log("Drag start...");
dragStart = obj.event.getLocalPosition(game);
}
@@ -1304,8 +1308,10 @@
unit.x += deltaX * tileSize;
unit.y += deltaY * tileSize;
});
gameMap.handleDrag(inputPosition);
+ dragDelta = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
+ //selectionMarker.setOnElement(currentSelection);
}
}
function handleDragEnd(obj) {
var currentPos = obj.event.getLocalPosition(game);
@@ -1316,8 +1322,9 @@
console.log("Clicked at " + input.x + ',' + input.y);
if (input.y > game.height * 0.80) {
console.log("Clicked on board at " + input.x + ',' + input.y);
dragStart = null;
+ dragDelta = 0;
return;
}
if (currentUserActionState === UserActionState.PLACING_BUILDINGS) {
var cellCoord = getCellForPlacement(input.x, input.y, currentBuildingForPlacement);
@@ -1330,8 +1337,9 @@
console.log("Placing building ", currentBuildingForPlacement, " at " + cellX + ',' + cellY);
handleBuildingPlacement(currentBuildingForPlacement, cellX, cellY);
currentUserActionState = UserActionState.NAVIGATING;
dragStart = null;
+ dragDelta = 0;
} else if (currentUserActionState === UserActionState.SET_ORDER_TARGET) {
if (currentSelection && currentSelection.isUnit) {
var cellCoord = convertCoordsToCell(input.x, input.y);
currentSelection.destinationTarget = {
@@ -1355,8 +1363,9 @@
}
highlightBorder();
currentUserActionState = UserActionState.NAVIGATING;
dragStart = null;
+ dragDelta = 0;
} else {
// Normal click
var clickCell = screenCoordToWorldCell(input.x, input.y);
var cellX = clickCell.wCellX;
@@ -1373,9 +1382,9 @@
if (!cell.building && !cell.unit && deltaToSelection > 1) {
currentSelection = null;
selectionMarker.setOnElement();
selectionMarker.hide();
- console.log("Nothing selected at " + cellX + ',' + cellY, " deltaToSelection=" + deltaToSelection);
+ console.log("Nothing selected at " + cellX + ',' + cellY, " deltaToSelection=" + deltaToSelection, " dragDelta=", dragDelta);
updateActionBoard();
} else if (cell.building) {
console.log("Selected building at " + cellX + ',' + cellY);
currentSelection = cell.building;
@@ -1386,8 +1395,9 @@
console.log("unit at " + cell.unit.x + ',' + cell.unit.y);
}
}
dragStart = null;
+ dragDelta = 0;
}
}
game.on('down', handleDragStart);
game.on('move', handleDragMove);
a tileable sand terrain tile.
A square tileable rock terrain tile WITHOUT BBORDER. Single Game Texture. In-Game asset. 2d. No shadows. No Border
Zenith view of Dune's Wind Trap power facility square fence. Ressembles a bit to Sydney's Opera. Zenith view Directly from above.
grey cancel icon. UI
thin white circle empty.
0x5e86ff
Zenith view of a white rectangular Harvester shape of a garbage truck with a triangular head. Harvesting on sand, with flowing spice in the back. inside a square fence. Zenith view. Directly overhead. Plumb view.
Minimal Ui icon of an right sign aside with an icon of a target. sand background
Minimal icon of a home with direction icon pointing to the home. sand background
3 white flat isometric concentric circles like a target.
Remove background
Gray background
Minimal Ui icon of target sign on a fire icon.. sand background
top view of an explosion effect.
Simple heavy army tank factory buiding a tank with a crane. Square fence... Zenith view Directly overhead. Plumb view.
an empty black popup UI. UI