Code edit (7 edits merged)
Please save this source code
User prompt
in handleDrag ensure that self.currentViewCenter x & y are always integers and not floats
User prompt
in handleDrag, update the self.currentViewCenter gradually,
User prompt
in handleDrag, update the self.currentViewCenter gradually, but don't use floats in self.currentViewCenter x & y
User prompt
in handleDrag, update the self.currentViewCenter gradually, but ensure self.currentViewCenter x & y are integers, not floats !
User prompt
in handleDrag, update the self.currentViewCenter gradually
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'building')' in or related to this line: 'if (!cell.building && !cell.unit && deltaToSelection > 1) {' Line Number: 1009
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading '22.87842334540943')' in or related to this line: 'var cell = gameMap.cells[cellX][cellY];' Line Number: 1008
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading '20')' in or related to this line: 'var cell = gameMap.cells[cellX][cellY];' Line Number: 1008
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in or related to this line: 'if (cellX >= 0 && cellX < gameMap.cells.length && cellY >= 0 && cellY < gameMap.cells[cellX].length) {' Line Number: 1007
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in or related to this line: 'if (x >= 0 && x < self.cells.length && y >= 0 && y < self.cells[x].length) {' Line Number: 173
User prompt
in handleDrag, update the self.currentViewCenter gradually to make a smooth scroll
Code edit (1 edits merged)
Please save this source code
Code edit (16 edits merged)
Please save this source code
User prompt
in updateMovement, start by rotating in the direction of the movement (given that in assets units are heading -90° initially)
Code edit (1 edits merged)
Please save this source code
Code edit (21 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'cellW')' in or related to this line: 'var cX = (Math.floor(input.x / 100) + centerDeltaX + building.cellW / 2 + Math.floor(building.cellW / 2) - 5) * 100;' Line Number: 1100
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (15 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'addChild')' in or related to this line: 'self.addChild(unit.asset);' Line Number: 1241
Code edit (2 edits merged)
Please save this source code
User prompt
Fix Bug: 'Timeout.tick error: viewSize is not defined' in or related to this line: 'var screenX = (self.cellX - gameMap.currentViewCenter.x + viewSize) * self.asset.width;' Line Number: 452
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -215,15 +215,16 @@
}
return path;
};
self.lastInputPosition = null;
- self.handleInput = function (input) {
+ self.handleDrag = function (input) {
// Clamp the view center to the map boundaries
self.currentViewCenter.x = Math.max(14, Math.min(input.x, mapXSize - 7));
self.currentViewCenter.y = Math.max(14, Math.min(input.y, mapYSize - 9));
+ console.log("handling drag...", input, self.currentViewCenter.x, self.currentViewCenter.y);
// Update the Text2 object with the new coordinates
self.viewCenterText.setText(self.currentViewCenter.x + ', ' + self.currentViewCenter.y);
- selectionMarker.setOnElement(currentSelection);
+ //selectionMarker.setOnElement(currentSelection);
};
self.checkCollisions = function () {
// Handle collisions between units and obstacles
};
@@ -280,10 +281,10 @@
self.selectionCross.alpha = 1;
self.selectionCircle.alpha = 0;
}
if (element.isUnit) {
- elementDeltaX = -100;
- elementDeltaY = -100;
+ //elementDeltaX = -100;
+ //elementDeltaY = -100;
self.selectionCross.alpha = 0;
self.selectionCircle.alpha = 0.9;
}
var centerDeltaX = (gameMap.currentViewCenter.x - 15) * 100;
@@ -876,8 +877,9 @@
}
//#region Event listeners
var dragStart = null;
function handleDragStart(obj) {
+ console.log("Drag start...");
dragStart = obj.event.getLocalPosition(game);
}
function handleDragMove(obj) {
var currentPos = obj.event.getLocalPosition(game);
@@ -896,22 +898,25 @@
if (currentBuildingForPlacement && currentBuildingForPlacement.asset) {
currentBuildingForPlacement.asset.tint = isValidPlacement ? 0x00FF00 : 0xFF0000;
}
var cursorCellCoord = getCursorCellForMovement(input, currentBuildingForPlacement);
- //currentBuildingForPlacement.x = (cellX - 1 + currentBuildingForPlacement.cellW / 2) * 100;
- //currentBuildingForPlacement.y = (cellY - 1 - 5 + currentBuildingForPlacement.cellH / 2) * 100;
currentBuildingForPlacement.x = cursorCellCoord.cellX;
currentBuildingForPlacement.y = cursorCellCoord.cellY;
console.log("Follow coords : " + currentBuildingForPlacement.x + ',' + currentBuildingForPlacement.y);
} else if (dragStart) {
+ console.log("Drag move...");
var deltaX = currentPos.x - dragStart.x;
var deltaY = currentPos.y - dragStart.y;
dragStart = currentPos; // Update dragStart to the current position
- var inputPosition = {
+ /*var inputPosition = {
x: gameMap.currentViewCenter.x - Math.round(deltaX / 100),
y: gameMap.currentViewCenter.y - Math.round(deltaY / 100)
+ };*/
+ var inputPosition = {
+ x: Math.round(deltaX / 100),
+ y: Math.round(deltaY / 100)
};
- gameMap.handleInput(inputPosition);
+ gameMap.handleDrag(inputPosition);
}
}
function handleDragEnd(obj) {
var currentPos = obj.event.getLocalPosition(game);
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