Basic pathfinding

This commit is contained in:
2023-11-14 08:25:55 +01:00
parent b3f3d269ee
commit ab817ee03d
9 changed files with 198 additions and 39 deletions

View File

@@ -8,6 +8,7 @@
#include "map_layers.h"
#include "buildings.h"
#include "utils/pathfinding.h"
Game *GAME = NULL;
@@ -152,6 +153,22 @@ void render(float dt, Game *game) {
bzTileMapDraw(&game->map);
bzTileMapDrawColliders(&game->map);
Vector2 worldPos = GetScreenToWorld2D(GetMousePosition(), game->camera);
int tileX = (int) worldPos.x / 16;
int tileY = (int) worldPos.y / 16;
static PathNode *heap = NULL;
if (!heap)
heap = bzHeapNew(PathNode, game->map.width * game->map.height);
findPath(&(PathfindingDesc) {
.start=(TilePosition){57, 24},
.target=(TilePosition){tileX, tileY},
.map=&game->map,
.heap=heap,
});
ecs_progress(ECS, dt);
EndMode2D();