Basic pathfinding
This commit is contained in:
17
game/main.c
17
game/main.c
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user