xlib_playground

Xlib playground for experiments.
Log | Files | Refs

commit b4f731f69d4f3a8b5ababa66670dcab173ceb07d
parent 9d68312d4f3078785d1db73202b955289acf4ff9
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Tue, 10 Jan 2023 08:39:31 +0900

delete unused functions

Diffstat:
Mex9/main.h | 12------------
Mex9/util.c | 69---------------------------------------------------------------------
2 files changed, 0 insertions(+), 81 deletions(-)

diff --git a/ex9/main.h b/ex9/main.h @@ -51,20 +51,8 @@ struct Object { int m; }; -struct OL { - struct Object *o; - struct OL *next; -}; - extern void (* col_func[NUM_OBJ_TYPE][NUM_OBJ_TYPE])(struct Object *, struct Object *); -void free_ol(struct OL *); -void free_obj_and_ol(struct OL *); -struct OL *addfront_ol(struct OL *, struct Object *); -void swap_ol(struct OL *, struct OL *); -void sort_ol(struct OL *, struct Object *); -void print_ol(struct OL *); - int object_dist(struct Object *, struct Object *); void handle_collision(struct Object *, struct Object *); int test_collision(struct Object *, struct Object *); // 1 if collide, 0 if not diff --git a/ex9/util.c b/ex9/util.c @@ -162,68 +162,6 @@ object_is_falling(struct Object *o, struct Object *fb, int num_f) return 1; } -struct OL * -create_ol(void) -{ - struct OL *ol; - ol = (struct OL *)malloc(sizeof(struct OL)); - ol->next = NULL; - ol->o = NULL; - return ol; -} - -void -free_ol(struct OL *ol) -{ - struct OL *p, *q; - for (p = q = ol; q != NULL; p = q) { - q = p->next; - free(p); // asume that p->o is freed elsewhere - } -} - -void -free_obj_and_ol(struct OL *ol) -{ - struct OL *p, *q; - for (p = q = ol; q != NULL; p = q) { - q = p->next; - free(p->o); - free(p); - } -} - -struct OL * -addfront_ol(struct OL *ol, struct Object *o) -{ - struct OL *nol; - nol = (struct OL *)malloc(sizeof(struct OL)); - nol->next = ol; - nol->o = o; - return nol; -} - -void -swap_ol(struct OL *p, struct OL *q) -{ - struct Object *tmp; - tmp = p->o; - p->o = q->o; - q->o = tmp; -} - -void -sort_ol(struct OL *ol, struct Object *player) -{ - struct OL *p, *q; - for (p = ol; p != NULL && p->next != NULL; p = p->next) { - for (q = p->next; q != NULL; q = q->next) { - if (object_dist(q->o, player) < object_dist(p->o, player)) - swap_ol(p, q); - } - } -} - int object_dist(struct Object *o1, struct Object *o2) { @@ -246,10 +184,3 @@ is_on_floor_before(struct Object *player, struct Object *floor) void handle_collision(struct Object *o0, struct Object *o1) { (* col_func[o0->type][o1->type])(o0, o1); } - -void print_ol(struct OL *ol) { - for (; ol != NULL; ol = ol->next) { - printf("(%3.0f, %3.0f)%s", ol->o->p.x, ol->o->p.y, - ol->next == NULL ? "\n" : "->"); - } -}