Code edit (3 edits merged)
Please save this source code
User prompt
anchor the numberLabel centered in debugcell
User prompt
Add a number label to the debug cells
User prompt
I need to debug some A* path finding for this I need a debug cell type which shows a number + an arrow pointing in the direction of the A* grid.
Code edit (1 edits merged)
Please save this source code
User prompt
✅ Add a Grid class to manage the game grid for building mazes, This class is also the render class so should inherit from Container
User prompt
Add a grid class, as we want this tower defense game to be one where you can build your own maze
Initial prompt
Tower Defense Game
/**** * Classes ****/ // DebugCell class var DebugCell = Container.expand(function () { var self = Container.call(this); var cellGraphics = self.attachAsset('cell', { anchorX: 0.5, anchorY: 0.5 }); // Add a number label to the debug cells var numberLabel = new Text2('0', { size: 50, fill: "#ffffff", anchorX: 0.5, anchorY: 0.5 }); self.addChild(numberLabel); numberLabel.x = cellGraphics.width / 2; numberLabel.y = cellGraphics.height / 2; self.update = function () { // DebugCell logic goes here }; }); // Defense class var Defense = Container.expand(function () { var self = Container.call(this); var defenseGraphics = self.attachAsset('defense', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Defense logic goes here }; }); // Enemy class var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Enemy logic goes here }; }); // Grid class var Grid = Container.expand(function () { var self = Container.call(this); self.cells = []; for (var i = 0; i < 26; i++) { self.cells[i] = []; for (var j = 0; j < 22; j++) { self.cells[i][j] = new DebugCell(); self.addChild(self.cells[i][j]); self.cells[i][j].x = i * 100; self.cells[i][j].y = j * 100; } } self.update = function () { // Grid logic goes here }; }); // Assets will be automatically created and loaded by the LK engine // Tower class var Tower = Container.expand(function () { var self = Container.call(this); var towerGraphics = self.attachAsset('tower', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Tower logic goes here }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize game variables var tower = game.addChild(new Tower()); tower.x = 2048 / 2; tower.y = 2732 / 2; var enemies = []; var defenses = []; var grid = new Grid(); game.addChild(grid); game.update = function () { // Game logic goes here // Spawn enemies, update defenses, check for collisions, etc. };
===================================================================
--- original.js
+++ change.js
@@ -10,11 +10,15 @@
});
// Add a number label to the debug cells
var numberLabel = new Text2('0', {
size: 50,
- fill: "#ffffff"
+ fill: "#ffffff",
+ anchorX: 0.5,
+ anchorY: 0.5
});
self.addChild(numberLabel);
+ numberLabel.x = cellGraphics.width / 2;
+ numberLabel.y = cellGraphics.height / 2;
self.update = function () {
// DebugCell logic goes here
};
});
White circle with two eyes, seen from above.. In-Game asset. 2d. High contrast. No shadows
White simple circular enemy seen from above, black outline. Black eyes, with a single shield in-font of it. Black and white only. Blue background.
White circle with black outline. Blue background.. In-Game asset. 2d. High contrast. No shadows