User prompt
when a building is selected, display icons of the buildable items on the board
Code edit (2 edits merged)
Please save this source code
User prompt
in SelectionMarker.updatePosition add offset due to currentViewCenter
Code edit (1 edits merged)
Please save this source code
User prompt
add console logs in selectionMarker.updatePosition() and hide
Code edit (2 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: selectionMarker is not defined' in or related to this line: 'selectionMarker.hide();' Line Number: 319
User prompt
when a building is selected show the selectionCross at its center
User prompt
add a new building class called WindTrap ()
User prompt
add a new property to building to store what they can build
Code edit (2 edits merged)
Please save this source code
User prompt
Fix Bug: 'Timeout.tick error: self.graphics.drawRect is not a function' in or related to this line: 'self.graphics.drawRect(0, 0, width, height);' Line Number: 27
User prompt
Fix Bug: 'Timeout.tick error: self.graphics.lineStyle is not a function' in or related to this line: 'self.graphics.lineStyle(4, 0xffd700, 1);' Line Number: 26
User prompt
Fix Bug: 'Timeout.tick error: Graphics is not a constructor' in or related to this line: 'self.graphics = new Graphics();' Line Number: 14
User prompt
is it possible to highlight currently selected element by adding a border ?
User prompt
is it possible to highlight currently selected element ?
Code edit (9 edits merged)
Please save this source code
User prompt
in updateActionBoard update currentSelectionText with currentSelection type or empty if currentSelection is null
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
add a new text 'currentSelectionText' at the top of the board
Code edit (1 edits merged)
Please save this source code
User prompt
in applyCellOccupation() copy the reference the building at gameMap.cells[cellX][cellY] to adjacent cells depending on building cellW and cellH
Code edit (2 edits merged)
Please save this source code
User prompt
Currently building creation is done like that : gameMap.cells[rockIlot1Center.x][rockIlot1Center.y].building = new ConstructionYard(rockIlot1Center.x, rockIlot1Center.y, 1); How to make this 2x2 buliding occupy 2x2 cells ?
===================================================================
--- original.js
+++ change.js
@@ -1,7 +1,22 @@
/****
* Classes
****/
+var BuildableItemIcon = Container.expand(function (type, x, y) {
+ var self = Container.call(this);
+ self.type = type;
+ self.asset = self.attachAsset(type, {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: x,
+ y: y
+ });
+ self.asset.on('down', function () {
+ console.log('Buildable item ' + type + ' selected.');
+ // Add logic to handle the building of the selected item
+ });
+ return self;
+});
// Initialize game elements
// Map class to represent the grid-based map system
var Map = Container.expand(function () {
var self = Container.call(this);
@@ -76,14 +91,11 @@
// Return the path from start to end
};
self.lastInputPosition = null;
self.handleInput = function (input) {
- console.log("Clicked " + input.x + ',' + input.y);
- self.currentViewCenter.x = input.x;
- self.currentViewCenter.y = input.y;
// Clamp the view center to the map boundaries
- self.currentViewCenter.x = Math.max(14, Math.min(self.currentViewCenter.x, self.cells.length - 7));
- self.currentViewCenter.y = Math.max(14, Math.min(self.currentViewCenter.y, self.cells[0].length - 9));
+ self.currentViewCenter.x = Math.max(14, Math.min(input.x, mapXSize - 7));
+ self.currentViewCenter.y = Math.max(14, Math.min(input.y, mapYSize - 9));
// Update the Text2 object with the new coordinates
self.viewCenterText.setText(self.currentViewCenter.x + ', ' + self.currentViewCenter.y);
};
self.checkCollisions = function () {
@@ -117,14 +129,15 @@
self.asset = self.attachAsset('selectionCross', {
anchorX: 0.5,
anchorY: 0.5
});
+ self.alpha = 0.6;
self.visible = false;
self.updatePosition = function (x, y) {
console.log('SelectionMarker updated to position:', x, y);
var viewSize = Math.ceil(Math.max(game.width, game.height) / 2 / 100);
- self.x = (x - gameMap.currentViewCenter.x) * 100;
- self.y = (y - gameMap.currentViewCenter.y) * 100;
+ self.x = x - (gameMap.currentViewCenter.x - 15) * 100;
+ self.y = y - (gameMap.currentViewCenter.y - 15) * 100;
self.visible = true;
};
self.hide = function () {
console.log('SelectionMarker hidden');
@@ -157,8 +170,9 @@
self.asset.on('down', function () {
currentSelection = self;
selectionMarker.updatePosition(self.x, self.y);
console.log("Building selected: P" + self.playerId + ' ' + self.type + " at cell " + self.cellX + "," + self.cellY);
+ displayBuildableItems();
updateActionBoard();
});
return self;
});
@@ -206,8 +220,21 @@
/****
* Game Code
****/
+function displayBuildableItems() {
+ if (!currentSelection || !currentSelection.buildable) {
+ return;
+ }
+ var buildableItems = currentSelection.buildable;
+ var iconX = 100; // Starting X position for the first icon
+ var iconY = game.height - 150; // Y position for all icons
+ buildableItems.forEach(function (itemType) {
+ var icon = new BuildableItemIcon(itemType, iconX, iconY);
+ game.addChild(icon);
+ iconX += 100; // Increment X position for the next icon
+ });
+}
var applyCellOccupation = function applyCellOccupation(cellX, cellY) {
var building = gameMap.cells[cellX][cellY].building;
if (building) {
for (var w = 0; w < building.cellW; w++) {
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