Advertisement
Guest User

Untitled

a guest
May 27th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.24 KB | None | 0 0
  1. void    init_visible(t_map *m)
  2. {
  3.     int         i;
  4.     int         d;
  5.  
  6.     i = 0;
  7.     d = 0;
  8.     m->visible = malloc(sizeof(t_visible) * m->sector_count);
  9.     while (i < m->sector_count)
  10.     {
  11.         m->visible[i].wall = malloc(sizeof(int) * m->sector[i].wall_count);
  12.         i++;
  13.     }
  14.     i = 0;
  15.     while (i < m->sector_count)
  16.     {
  17.         while (d < m->sector[i].wall_count)
  18.         {
  19.             m->visible[i].wall[d] = 0;
  20.             d++;
  21.         }
  22.         d = 0;
  23.         i++;
  24.     }
  25. }
  26.  
  27. void    draw(t_env *w, t_map *m)
  28. {
  29.     int         x;
  30.     t_draw      d;
  31.     t_reader    read;
  32.     int         renderedsectors[m->sector_count];
  33.  
  34.     x = -1;
  35.     init_visible(m);
  36.     while (x++ < WIDTH)
  37.     {
  38.         d.ytop[x] = 0;
  39.         d.ybot[x] = HEIGHT - 1;
  40.         if (x < m->sector_count)
  41.             renderedsectors[x] = 0;
  42.     }
  43.     w->i = init_draw(&d, &read, m);
  44.     while (read.head != read.tail)
  45.     {
  46.         read.now = *read.tail;
  47.         if (++read.tail == read.queue + m->maxrenderedsector)
  48.             read.tail = read.queue;
  49.         if (renderedsectors[read.now.sectorno]++ & (m->maxrenderedsector + 1))
  50.             continue;
  51.         wall_to_wall(&d, &read, m, w);
  52.         ++renderedsectors[read.now.sectorno];
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement