Advertisement
Dr_Davenstein

Raycast node technique

Oct 23rd, 2021
3,146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. #include once "fbgfx.bi"
  3. screenres 640,480, 32
  4.  
  5.  
  6. dim as integer mx, my, mb
  7.  
  8. dim as single posX, posY, dx,dy,steps
  9. dim as integer x1, x2, y1, y2
  10.  
  11.  
  12. do
  13.    
  14.     getmouse(mx,my,,mb)
  15.    
  16.     if mb and fb.button_left then
  17.        
  18.         x1 = mx
  19.         y1 = my
  20.        
  21.     end if
  22.    
  23.     if mb and fb.button_right then
  24.        
  25.         x2 = mx
  26.         y2 = my
  27.        
  28.     end if
  29.    
  30.    
  31.     dx = (x2 - x1)
  32.     dy = (y2 - y1)
  33.  
  34.     if abs(dx)>=abs(dy) then
  35.  
  36.         steps = abs(dx)
  37.  
  38.     else
  39.  
  40.         steps = abs(dy)
  41.  
  42.     end if
  43.  
  44.     dx = dx / steps
  45.     dy = dy / steps
  46.     posX = x1
  47.     posY = y1
  48.    
  49.     screenlock
  50.    
  51.     cls
  52.    
  53.     for i as integer = 1 to steps
  54.  
  55.         pset(posX, posY)
  56.  
  57.         posX += dx
  58.  
  59.         posY += dy
  60.        
  61.     next
  62.    
  63.     screenunlock
  64.  
  65.     sleep(3, 1)
  66.    
  67. loop until multikey(fb.sc_escape)
  68.  
  69. sleep
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement