xlib_playground

Xlib playground for experiments.
Log | Files | Refs

commit 17d223ab707ef78181b7e0901051194f33c4fe0b
parent 2b6d9e9f22b9fe2d981836465008e53c456df965
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Tue, 10 Jan 2023 10:36:26 +0900

rename variable

Diffstat:
Mex9/main.c | 44++++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/ex9/main.c b/ex9/main.c @@ -133,11 +133,11 @@ game_play(void) int fps_count = 0; #endif struct timespec ts; - struct List *bl; // block list - struct List *olp; + struct List *ol; // block list + struct List *olc; // cursor used to scan ol int scroll_dst = 0; - bl = NULL; + ol = NULL; for (int i = 0; i < NUM_OBJ_TYPE; i++) for (int j = 0; j < NUM_OBJ_TYPE; j++) @@ -145,20 +145,20 @@ game_play(void) col_func[TPLAYER][TFLAG] = col_func[TFLAG][TPLAYER] = &col_pf; col_func[TPLAYER][TBLOCK] = col_func[TBLOCK][TPLAYER] = &col_pb; - /* load world into bl */ + /* load world into ol */ for (int i = 0; i < WORLD_WIDTH * WORLD_HEIGHT; i++) { if (world_map[i] == 'b') { // TODO: don't forget to free these things. - olp = laddfront(bl, create_object(TBLOCK, 0x00FF00, + olc = laddfront(ol, create_object(TBLOCK, 0x00FF00, i % WORLD_WIDTH * BLOCK_SIZE, i / WORLD_WIDTH * BLOCK_SIZE, 0, 0, 0, 0, BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE * BLOCK_SIZE)); - if (olp == NULL) { - fprintf(stderr, "error: adding item to list bl\n"); + if (olc == NULL) { + fprintf(stderr, "error: adding item to list ol\n"); } else { - bl = olp; + ol = olc; } } else if (world_map[i] == 'p') { player = create_object(TPLAYER, 0x0000FF, @@ -167,28 +167,28 @@ game_play(void) 0, 0, 0, GRAVITY, BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE * BLOCK_SIZE); - olp = laddfront(bl, player); - if (player == NULL || olp == NULL) { + olc = laddfront(ol, player); + if (player == NULL || olc == NULL) { fprintf(stderr, "error: creating player\n"); exit(1); } else { - bl = olp; + ol = olc; } } else if (world_map[i] == 'f') { - olp = laddfront(bl, create_object(TFLAG, 0xFFFF00, + olc = laddfront(ol, create_object(TFLAG, 0xFFFF00, i % WORLD_WIDTH * BLOCK_SIZE, i / WORLD_WIDTH * BLOCK_SIZE, 0, 0, 0, 0, BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE * BLOCK_SIZE)); - if (olp == NULL) { + if (olc == NULL) { fprintf(stderr, "error: adding item to list fl\n"); } else { - bl = olp; + ol = olc; } } } - //lprint(bl, (void (*)(void *))&oprint); + //lprint(ol, (void (*)(void *))&oprint); while (next_menu == GAME_PLAY){ receive_events(key_state); handle_inputs(key_state); @@ -229,15 +229,15 @@ game_play(void) // TODO: state of object should be contained in object itself. player_is_falling = 1; - for (olp = bl; olp != NULL; olp = olp->next) { - if (olp->item == player) + for (olc = ol; olc != NULL; olc = olc->next) { + if (olc->item == player) continue; - if (is_on_floor_before(player, (struct Object *)olp->item)) { + if (is_on_floor_before(player, (struct Object *)olc->item)) { player_is_falling = 0; } } - lhandle_collision(bl); + lhandle_collision(ol); } // fix fps @@ -261,13 +261,13 @@ game_play(void) x_clear_area(); // TODO: disable drawing outside of window. - for (olp = bl; olp != NULL; olp = olp->next) { - draw_object_scroll((struct Object *)olp->item, scroll_dst); + for (olc = ol; olc != NULL; olc = olc->next) { + draw_object_scroll((struct Object *)olc->item, scroll_dst); } draw_object_scroll(player, scroll_dst); } - lfreei(bl, (void (*)(void *))&free_object); + lfreei(ol, (void (*)(void *))&free_object); } void