From: rexim Date: Tue, 22 Jan 2019 03:38:41 +0000 (+0700) Subject: (#647) Commands for applying force to rigid bodies X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=049ff8f879492f8e99d1ee89d851d26cf6909ad1;p=nothing.git (#647) Commands for applying force to rigid bodies --- diff --git a/src/game/level.c b/src/game/level.c index 799ffd36..24d80367 100644 --- a/src/game/level.c +++ b/src/game/level.c @@ -451,6 +451,15 @@ struct EvalResult level_send(Level *level, Gc *gc, struct Scope *scope, struct E return labels_send(level->labels, gc, scope, rest); } else if (strcmp(target, "box") == 0) { return boxes_send(level->boxes, gc, scope, rest); + } else if (strcmp(target, "body") == 0) { + long int id = 0, x = 0, y = 0; + res = match_list(gc, "ddd", rest, &id, &x, &y); + if (res.is_error) { + return res; + } + + rigid_bodies_apply_force(level->rigid_bodies, (size_t) id, vec((float) x, (float) y)); + return eval_success(NIL(gc)); } return unknown_target(gc, "level", target);