static void draw(int digit, int location) { int16_t pix = pics[digit%32]; for(int8_t j = 0; j < 5; j++) for(int8_t i = 0; i < 3; i++) { put_map(maze, i + 1 + (location * 4) + ((location >= dp)?2:0), j + 1, 35, (((pix & 1)==0)?31:(digit&32))); pix >>= 1; } }
static void draw_dp(int bits, int location) { dp = location;//remember int8_t tmp = bits; for(int8_t j = 0; j < 5; j++) { put_map(maze, 1 + location * 4, j + 1, 35, (((bits & 1)==0)?31:(tmp&32)));//top to bottom from lsb to msb bits >>= 1; } }
void draw_again(t_map *map) { map->image->image = mlx_new_image(map->mlx, map->x_win, map->y_win); put_map(map); mlx_put_image_to_window(map->mlx, map->win, map->image->image, 0, 0); mlx_destroy_image(map->mlx, map->image->image); mlx_key_hook(map->win, &ft_keyhook, map); mlx_loop(map->mlx); }
void ft_put_map(t_pos *wolf, int y) { t_jojo *first; char **tab; first = wolf->head; wolf->map = (int**)malloc(sizeof(int*) * y); while (wolf->head) { tab = ft_strsplit(wolf->head->read, ' '); free(wolf->head->read); wolf->map[wolf->i] = (int*)malloc(sizeof(int) * first->len_rd); put_map(wolf, tab); wolf->head = wolf->head->next; } wolf->map[wolf->i] = NULL; wolf->head = first; wolf->i = 0; wolf->j = 0; }
static void clear() { for(int8_t j = 0; j < 5; j++) for(int8_t i = 0; i < 4 * 8 + 2; i++) { put_map(maze, i + 1, j + 1, 35, 31); } }