User prompt
debug the selected tile variable
User prompt
save in a variable the tile that im touching
Code edit (1 edits merged)
Please save this source code
User prompt
debug selected tile name
User prompt
if selected tile is a floor tile highlight it in yellow
User prompt
check if pos is inside the grid and save the selected tile on a variable
Code edit (1 edits merged)
Please save this source code
User prompt
place a circle where the touch position happen
Code edit (2 edits merged)
Please save this source code
User prompt
only floor tiles can be highlighted
User prompt
take in consideration the offset of the grid when checking for the tiles
User prompt
highlight the touched tile
Code edit (1 edits merged)
Please save this source code
User prompt
rebuild
Code edit (1 edits merged)
Please save this source code
User prompt
debug touch position
User prompt
highlight the tile on yellow
Code edit (1 edits merged)
Please save this source code
User prompt
highlight the floor tile that is under the screen touch position
User prompt
highlight floor tiles when touched
User prompt
highlight the tile that is touched
Code edit (1 edits merged)
Please save this source code
User prompt
replace all empty tile grids with floor tiles
User prompt
add a hole to randomWallTile
User prompt
select a random wall tile and save it on a variable
/**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Add event listener for touch events; var selectedTile; game.on('down', function (obj) { var pos = obj.event.getLocalPosition(game); var x = Math.floor((pos.x - (2048 - gridSize * 100) / 2) / 100); var y = Math.floor((pos.y - (2732 - gridSize * 100) / 2) / 100); if (x >= 0 && x < gridSize && y >= 0 && y < gridSize) { selectedTile = grid[x][y]; console.log("Selected Tile: ", selectedTile); } }); var gridSize = 20; // Create a 2D array to represent the grid var grid = new Array(gridSize); for (var i = 0; i < gridSize; i++) { grid[i] = new Array(gridSize); } // Initialize the grid with empty tiles and surround it with wall tiles var wallTiles = []; for (var x = 0; x < gridSize; x++) { for (var y = 0; y < gridSize; y++) { var tile; if (x === 0 || y === 0 || x === gridSize - 1 || y === gridSize - 1) { tile = LK.getAsset('wallTile', { anchorX: 0.5, anchorY: 0.5, x: x * 100 + (2048 - gridSize * 100) / 2, y: y * 100 + (2732 - gridSize * 100) / 2 }); wallTiles.push(tile); } else { tile = LK.getAsset('floorTile', { anchorX: 0.5, anchorY: 0.5, x: x * 100 + (2048 - gridSize * 100) / 2, y: y * 100 + (2732 - gridSize * 100) / 2 }); } game.addChild(tile); grid[x][y] = tile; } } // Select a random wall tile and replace it with a hole tile var randomWallTileIndex = Math.floor(Math.random() * wallTiles.length); var randomWallTile = wallTiles[randomWallTileIndex]; var holeTile = LK.getAsset('holeTile', { anchorX: 0.5, anchorY: 0.5, x: randomWallTile.x, y: randomWallTile.y }); game.addChild(holeTile); game.removeChild(randomWallTile); wallTiles[randomWallTileIndex] = holeTile; // Add event listener for touch events
===================================================================
--- original.js
+++ change.js
@@ -15,8 +15,9 @@
var x = Math.floor((pos.x - (2048 - gridSize * 100) / 2) / 100);
var y = Math.floor((pos.y - (2732 - gridSize * 100) / 2) / 100);
if (x >= 0 && x < gridSize && y >= 0 && y < gridSize) {
selectedTile = grid[x][y];
+ console.log("Selected Tile: ", selectedTile);
}
});
var gridSize = 20;
// Create a 2D array to represent the grid
grey square, black border. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
simple light yellow button front view game console, clean, rounded edges, high resolution, graphic. Single Game Texture. In-Game asset. 2d. Blank background. High contrast.
Worn out sticker for a video game, 90s style, cheese, simple, vintage. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
wall view from top-down, game asset videogame, black color, simple. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. worn out sticker. 90's style. vintage. simple. top-down view. poster. sticker
top-down view, videogame character enemy, roomba, 90s style sticker, flat, no perspective, silhouette, black and white, cartoon, fun, simple, from above. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
top-down view, videogame heart, 90s style sticker, flat, no perspective, silhouette, white, cartoon, fun, simple, from above. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Black square with white outline. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.