Better formation placement
This commit is contained in:
34
game/main.c
34
game/main.c
@@ -250,8 +250,10 @@ bool init(void *userData) {
|
||||
game->BTs.moveTo = root;
|
||||
|
||||
// Just a single action for now
|
||||
node = bzBTAction(nodePool, root, (BzBTActionFn) aiMoveTo);
|
||||
BzBTNode *seq = bzBTCompSequence(nodePool, root);
|
||||
node = bzBTAction(nodePool, seq, (BzBTActionFn) aiMoveTo);
|
||||
bzBTNodeSetName(node, "moveTo");
|
||||
bzBTDecorDelay(nodePool, seq, 6.0f);
|
||||
}
|
||||
// evade
|
||||
BzBTNode *evade = NULL;
|
||||
@@ -547,36 +549,6 @@ static void renderGame(Game *game, float dt) {
|
||||
}
|
||||
ecs_defer_end(ECS);
|
||||
|
||||
|
||||
#if 0
|
||||
Vector2 target = GetMousePosition();
|
||||
target = GetScreenToWorld2D(target, game->camera);
|
||||
static f32 elapsed = 0;
|
||||
static bool attack = false;
|
||||
static Vector2 lockedTarget;
|
||||
if (!attack && IsMouseButtonPressed(0)) {
|
||||
attack = true;
|
||||
lockedTarget = target;
|
||||
elapsed = 0;
|
||||
}
|
||||
elapsed += dt * 2;
|
||||
elapsed = Clamp(elapsed, 0, 1.0f);
|
||||
attack = false;
|
||||
if (worker && false) {
|
||||
Position *pos = ecs_get_mut(ECS, worker, Position);
|
||||
DrawCircle(pos->x, pos->y, 2.0f, BLUE);
|
||||
Vector2 attackVector = Vector2Subtract(lockedTarget, *pos);
|
||||
attackVector = Vector2Normalize(attackVector);
|
||||
attackVector = Vector2Scale(attackVector, 2.0f);
|
||||
DrawLine(pos->x, pos->y, pos->x + attackVector.x, pos->y + attackVector.y, RED);
|
||||
Rotation *rot = ecs_get_mut(ECS, worker, Rotation);
|
||||
f32 targetRot = Vector2Angle(*pos, lockedTarget);
|
||||
targetRot += 25 * DEG2RAD;
|
||||
*rot = targetRot * bzEase(BZ_EASE_IN_BACK, elapsed);
|
||||
bzLogInfo("%.2f", Vector2Angle(*pos, lockedTarget) * RAD2DEG);
|
||||
}
|
||||
#endif
|
||||
|
||||
ecs_progress(ECS, dt);
|
||||
ecs_enable(ECS, renderDebugPathSystem, game->debug.drawPath);
|
||||
ecs_enable(ECS, renderCollidersSystem, game->debug.drawEntityColliders);
|
||||
|
||||
Reference in New Issue
Block a user