xlib_playground

Xlib playground for experiments.
Log | Files | Refs

commit a44eea6345f61879e8707742f7a0dcf70b37f167
parent 5a910155ad5dccced72eb8a502a66d91c21145ec
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Wed, 11 Jan 2023 15:24:26 +0900

change is_on_floor_before() method

Diffstat:
Mex9/object.c | 13+++++--------
1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/ex9/object.c b/ex9/object.c @@ -181,15 +181,12 @@ object_dist(struct Object *o1, struct Object *o2) } int -is_on_floor_before(struct Object *player, struct Object *floor) +is_on_floor_before(struct Object *p, struct Object *f) { - struct Object o = *player; - o.p.x = o.pp.x; o.p.y = o.pp.y; - o.v.x = 0; o.v.y = 5; - o.a.x = 0; o.a.y = 0; - next_tick(&o, 1e9); - int col = test_collision(&o, floor); - return col; + if (p->pp.x + p->body.rectangle.w < f->pp.x || + f->pp.x + f->body.rectangle.w < p->pp.x) + return 0; + return p->pp.y + p->body.rectangle.h == f->pp.y; } void