Advertisement
CaptainLepidus

RL LoS

Mar 18th, 2012
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //calc()
  2. //sx,sy is the top corner of the screen, dw,dh are the width&height of the screen
  3. //visi=0 represents invisible, visi=1 represents visible, tile=0 represents empty, tile=1 represents wall
  4. {
  5.     for(i=sx;i<sx+dw;i=i+1)
  6.     for(j=sy;j<sy+dh;j=j+1)
  7.     {
  8.         visi[ i , j ] = 0;
  9.     }
  10.     j = sy;
  11.     for(i=sx;i<sx+dw;i=i+1)
  12.     {
  13.         check();
  14.     }
  15.     j = sy + dh;
  16.     for(i=sx;i<sx+dw;i=i+1)
  17.     {
  18.         check();
  19.     }
  20.     i = sx;
  21.     for(j=sy;j<sy+dh;j=j+1)
  22.     {
  23.         check();
  24.     }
  25.     i = sx + dw;
  26.     for(j=sy;j<sy+dh;j=j+1)
  27.     {
  28.         check();
  29.     }
  30. }
  31. //check()
  32. {
  33.     cx = px;
  34.     cy = py;
  35.     d = point_direction( cx , cy , i , j );
  36.     for(k=0;k<point_distance( cx , cy , i , j );k=k+1)
  37.     {
  38.         fx = round( cx + lengthdir_x( k , d ) );
  39.         fy = round( cy + lengthdir_y( k , d ) );
  40.         visi[ fx , fy ] = 1;
  41.         if tile[ fx , fy ] == 1
  42.         {
  43.             exit;
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement