Code edit (1 edits merged)
Please save this source code
User prompt
add the fps update
Code edit (3 edits merged)
Please save this source code
User prompt
display the fps in the bottom right in black
Code edit (1 edits merged)
Please save this source code
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
===================================================================
--- original.js
+++ change.js
@@ -145,9 +145,9 @@
self.render = function () {
// Move tiles instead of the view
for (var x = self.currentViewCenter.x - viewSize - 1; x <= self.currentViewCenter.x + viewSize; x++) {
for (var y = self.currentViewCenter.y - viewSize - 1; y <= self.currentViewCenter.y + viewSize; y++) {
- if (x >= 0 && x < self.cells.length && y >= 0 && self.cells[x] && y < self.cells[x].length) {
+ if (x >= 0 && x < self.cells.length && y >= 0 && y < self.cells[x].length) {
var cell = self.cells[x][y];
var asset = cell.asset;
var screenX = (x - self.currentViewCenter.x + viewSize) * asset.width;
var screenY = (y - self.currentViewCenter.y + viewSize) * asset.height;
@@ -223,9 +223,9 @@
self.currentViewCenter.x += (targetViewCenterX - self.currentViewCenter.x) * 0.1;
self.currentViewCenter.y += (targetViewCenterY - self.currentViewCenter.y) * 0.1;
console.log("handling drag...", input, self.currentViewCenter.x, self.currentViewCenter.y);
// Update the Text2 object with the new coordinates
- self.viewCenterText.setText(Math.round(self.currentViewCenter.x) + ', ' + Math.round(self.currentViewCenter.y));
+ self.viewCenterText.setText(self.currentViewCenter.x + ', ' + self.currentViewCenter.y);
//selectionMarker.setOnElement(currentSelection);
};
self.checkCollisions = function () {
// Handle collisions between units and obstacles
@@ -978,21 +978,21 @@
var selCell = getCellForUnit(currentSelection);
console.log("currentSelection = " + currentSelection.name + " at " + selCell.cellX + ',' + selCell.cellY);
deltaToSelection = Math.sqrt(Math.pow(Math.abs(selCell.cellX - cellX), 2) + Math.pow(Math.abs(selCell.cellY - cellY), 2));
}
- if (cellX >= 0 && cellX < mapXSize && cellY >= 0 && cellY < mapYSize) {
- var cell = gameMap.cells[cellX] ? gameMap.cells[cellX][cellY] : undefined;
- if (cell && !cell.building && !cell.unit && deltaToSelection > 1) {
+ if (cellX >= 0 && cellX < gameMap.cells.length && cellY >= 0 && cellY < gameMap.cells[cellX].length) {
+ var cell = gameMap.cells[cellX][cellY];
+ if (!cell.building && !cell.unit && deltaToSelection > 1) {
currentSelection = null;
selectionMarker.hide();
console.log("Nothing selected at " + cellX + ',' + cellY, " deltaToSelection=" + deltaToSelection);
updateActionBoard();
- } else if (cell && cell.building) {
+ } else if (cell.building) {
console.log("Selected building at " + cellX + ',' + cellY);
currentSelection = cell.building;
selectionMarker.setOnElement(currentSelection);
updateActionBoard();
- } else if (cell && cell.unit) {
+ } else if (cell.unit) {
console.log("Selected cell with unit at " + cellX + ',' + cellY);
console.log("unit at " + cell.unit.x + ',' + cell.unit.y);
}
}
@@ -1009,12 +1009,8 @@
if (!gameMap.cells[cellX] || !gameMap.cells[cellX][cellY]) {
console.log('Invalid cell for building placement.');
return;
}
- if (!gameMap.cells[cellX] || !gameMap.cells[cellX][cellY]) {
- console.log('Invalid cell for building placement.');
- return;
- }
var cell = gameMap.cells[cellX][cellY];
if (cell.building) {
console.log('Cell is already occupied.');
return;
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