xlib_playground

Xlib playground for experiments.
Log | Files | Refs

commit 145f0b2a5d747f1aced705f45215b66b8bab5793
parent 3374603c5434713983c4add2d29fb9a4dbb799b1
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Fri, 30 Dec 2022 19:33:01 +0900

fix segfalt

Diffstat:
Mex8/main.c | 13++++---------
1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/ex8/main.c b/ex8/main.c @@ -117,8 +117,8 @@ game_play(void) int fps_count = 0; #endif struct timespec ts; - struct ObjectList *blh[WORLD_WIDTH]; // block list header - struct ObjectList *blc[WORLD_WIDTH]; // block list cursor + struct ObjectList *blh[WORLD_WIDTH] = {0}; // block list header + struct ObjectList *blc[WORLD_WIDTH] = {0}; // block list cursor int bi[WORLD_WIDTH] = {0}; for (int xi = 0; xi < WORLD_WIDTH; xi++) { @@ -140,6 +140,7 @@ game_play(void) 0, 0, 0, 0, BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE * BLOCK_SIZE); + blc[xi]->next = NULL; bi[xi]++; } else if (world_map[i] == 'p') { player = *create_object(i % WORLD_WIDTH * BLOCK_SIZE, @@ -149,13 +150,7 @@ game_play(void) BLOCK_SIZE * BLOCK_SIZE); } } - for (int xi = 0; xi < WORLD_WIDTH; xi++) { - blc[xi] = blh[xi]; - while (blc[xi] != NULL) { - printf("%3d: (%f, %f)\n", xi, blc[xi]->o->p.x, blc[xi]->o->p.y); - blc[xi] = blc[xi]->next; - } - } + while (next_menu == GAME_PLAY){ clock_gettime(CLOCK_MONOTONIC, &ts);