User prompt
update game.on('down', startViewMovement); game.on('up', stopViewMovement); to make a drag system
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: isPressing is not defined' in or related to this line: 'if (isPressing && gameMap.lastInputPosition) {' Line Number: 213
User prompt
switch to a drag system
User prompt
Fix Bug: 'TypeError: Cannot read properties of null (reading 'x')' in or related to this line: 'var deltaX = input.x - self.lastInputPosition.x;' Line Number: 75
User prompt
Still not good on mobile. Th view should follow the 'drag' movement of the user finger
User prompt
fix pressing system as you said : // Since 'tick' does not provide an event object, we cannot call 'handleContinuousMovement' // Instead, we should handle the continuous movement logic here if needed
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'event')' in or related to this line: 'var pos = obj.event.getLocalPosition(game);' Line Number: 202
User prompt
Fix Bug: 'ReferenceError: obj is not defined' in or related to this line: 'var pos = obj.event.getLocalPosition(game);' Line Number: 202
Code edit (2 edits merged)
Please save this source code
User prompt
fix function handleContinuousMovement(obj) { if (isPressing) { var pos = obj.event.getLocalPosition(game); gameMap.handleInput(pos); LK.on('tick', function () { if (isPressing) { handleContinuousMovement(obj); } }); } }
User prompt
Fix Bug: 'TypeError: requestAnimationFrame is not a function' in or related to this line: 'requestAnimationFrame(function () {' Line Number: 190
User prompt
keep moving the view while user is pressing
User prompt
move the view on 'down' not 'move'
User prompt
change the handle input to be more mobile friendly : Now When the user clicks on an empty cell of the map (sand or rock) move the view in the direction clicked relative to the center of the screen. Keep the current limits, just change the input style
Code edit (2 edits merged)
Please save this source code
User prompt
add another ilot (rockIlot2) at the center right
User prompt
Fix Bug: 'Uncaught ReferenceError: rockIlotCenter is not defined' in or related to this line: 'for (var x = rockIlotCenter.x - rockIlotRadius; x <= rockIlotCenter.x + rockIlotRadius; x++) {' Line Number: 164
Code edit (3 edits merged)
Please save this source code
User prompt
instead of random rocks, add a fixed rock ilot near the center left of the map
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
fix the tiles of the left border are never removed, even when scolling to the right
User prompt
on line 158, Add some rocks to the terrain
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -20,9 +20,9 @@
}
}
};
self.currentViewCenter = {
- x: 30,
+ x: 15,
y: 20
};
// Create a Text2 object to display the currentViewCenter coordinates
self.viewCenterText = new Text2(self.currentViewCenter.x + ', ' + self.currentViewCenter.y, {
@@ -62,25 +62,14 @@
// Implement A* pathfinding algorithm
// Return the path from start to end
};
self.handleInput = function (input) {
- var borderThreshold = 100; // Distance from edge to trigger scroll
+ var centerX = game.width / 2;
+ var centerY = game.height / 2;
var direction = {
- x: 0,
- y: 0
+ x: input.x < centerX ? -1 : input.x > centerX ? 1 : 0,
+ y: input.y < centerY ? -1 : input.y > centerY ? 1 : 0
};
- if (input.x < borderThreshold) {
- direction.x = -1;
- }
- if (input.x > game.width - borderThreshold) {
- direction.x = 1;
- }
- if (input.y < borderThreshold) {
- direction.y = -1;
- }
- if (input.y > game.height * 0.75 - borderThreshold) {
- direction.y = 1;
- }
self.currentViewCenter.x += direction.x;
self.currentViewCenter.y += direction.y;
// Clamp the view center to the map boundaries
self.currentViewCenter.x = Math.max(14, Math.min(self.currentViewCenter.x, self.cells.length - 7));
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