commit 56a5cf1a9090b294e7418597de51a0da505df8ce
parent 68c0d2e58a6240a424b264471977f0a34ffacc07
Author: Matsuda Kenji <info@mtkn.jp>
Date: Wed, 11 Jan 2023 15:42:48 +0900
delete unused stuff
Diffstat:
3 files changed, 2 insertions(+), 43 deletions(-)
diff --git a/ex9/main.c b/ex9/main.c
@@ -18,7 +18,6 @@
enum {
FPS = 60,
SUB_TICK = 4,
- NUM_BLOCK = 200,
GRAVITY = 1000,
WIN_WIDTH = 800,
WIN_HEIGHT = 600,
@@ -67,7 +66,6 @@ void col_pb(struct Object *, struct Object *); // player-block
/* misc: these functions use interfaces from multiple header files */
/* TODO: I want to rewrite these more cleanly */
-void sort_list_dist(struct List *, struct Object *);
void draw_object(const struct Object *);
void draw_object_scroll(const struct Object *, int);
@@ -397,12 +395,6 @@ handle_inputs(enum key_state key_state[])
if (player->v.x < -200) player->v.x = -200;
if (player->v.x > 200) player->v.x = 200;
- /*
- if (key_state[KEY_S] == KEY_DOWN)
- player->v.y += 300;
- if (key_state[KEY_W] == KEY_DOWN)
- player->v.y += -300;
- */
if (!player_is_falling && key_state[KEY_SPACE] == KEY_DOWN) {
player->v.y = -450;
}
@@ -430,19 +422,6 @@ void col_pb(struct Object *op, struct Object *ob) {
void
-sort_list_dist(struct List *lp, struct Object *o)
-{
- struct List *p, *q;
- for (p = lp; p != NULL && p->next != NULL; p = p->next) {
- for (q = p->next; q != NULL; q = q->next) {
- if (object_dist((struct Object *)q->item, o) <
- object_dist((struct Object *)p->item, o))
- lswap(p, q);
- }
- }
-}
-
-void
draw_object(const struct Object *o)
{
if (o->shape == SRECTANGLE) {
diff --git a/ex9/object.c b/ex9/object.c
@@ -153,26 +153,6 @@ rect_handle_collision_mf(struct Object *om, struct Object *of)
}
-/*
- * Test if object o is not on top of one of fb (floor blocks).
- * o: object to be tested, fb: floor blocks, num_f: count of fb.
- */
-int
-object_is_falling(struct Object *o, struct Object *fb, int num_f)
-{
- struct Object p = *o;
-
- p.v.x = 0; p.v.y = 1;
- p.a.x = 0; p.a.y = 0;
-
- next_tick(&p, 1e9);
-
- for (int i = 0; i < num_f; i++)
- if (test_collision(&p, &fb[i]))
- return 0;
- return 1;
-}
-
int
object_dist(struct Object *o1, struct Object *o2)
{
diff --git a/ex9/object.h b/ex9/object.h
@@ -50,14 +50,14 @@ struct Object {
int m;
};
-extern void (* col_func[NUM_OBJ_TYPE][NUM_OBJ_TYPE])(struct Object *, struct Object *);
+extern void (* col_func[NUM_OBJ_TYPE][NUM_OBJ_TYPE])(struct Object *,
+ struct Object *);
int object_dist(struct Object *, struct Object *);
void ohandle_collision(struct Object *, struct Object *);
int test_collision(struct Object *, struct Object *); // 1 if collide, 0 if not
void next_tick(struct Object *o, long);
void handle_collision_mf(struct Object *, struct Object *);
-int object_is_falling(struct Object *o, struct Object *fb, int num_f);
struct Object *create_object(enum object_type, uint32_t,
float, float, float, float, float, float,
int, int, int);