daily pastebin goal
41%
SHARE
TWEET

Untitled

a guest Jan 29th, 2018 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function pointonslope(x,y)
  2.  --returns true if x,y overlaps
  3.  --some slope
  4.  if not fget(mget(flr8(x),flr8(y)),1) then
  5.   --tile isn't a slope
  6.   return false
  7.  end
  8.  
  9.  --define slope of tile
  10.  px1=flr8(x)*8
  11.  px2=px1+8
  12.  py1=flr8(y)*8+8
  13.  py2=py1-8
  14.  
  15.  if fget(mget(flr8(x),flr8(y)),2) then
  16.   --halfstep up
  17.   py2=py1-4
  18.  end
  19.  if fget(mget(flr8(x),flr8(y)),3) then
  20.   --halfstep up 2
  21.   py1-=4
  22.   py2-=1
  23.  end
  24.  if fget(mget(flr8(x),flr8(y)),4) then
  25.   --fullstep up
  26.   --this is default so eh
  27.   py2-=1
  28.  end
  29.  if fget(mget(flr8(x),flr8(y)),5) then
  30.   --fullstep down
  31.   py1=py2
  32.   py2+=8
  33.   py1-=1
  34.  end
  35.  if fget(mget(flr8(x),flr8(y)),6) then
  36.   --halfstep down 2
  37.   py1=py2
  38.   py2+=4
  39.   py1-=1
  40.  end
  41.  if fget(mget(flr8(x),flr8(y)),7) then
  42.   --halfstep down
  43.   py2=py1
  44.   py1-=4
  45.  end
  46.  
  47.  --now check if x,y is below
  48.  --the line between p1 and p2
  49.  
  50.  t=(px2-x)/8
  51.  
  52.  ly=lerp(py1,py2,1-t)
  53.  if (ly<=y) return true
  54.  
  55.  
  56.  return false
  57.  
  58. end
RAW Paste Data
Pastebin PRO WINTER Special!
Get 40% OFF Pastebin PRO accounts!
Top