Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function pointonslope(x,y)
- --returns true if x,y overlaps
- --some slope
- spriteid=mget(flr8(x),flr8(y))
- if not fget(spriteid,1) then
- --tile isn't a slope
- return false
- end
- --define slope of tile
- x1=flr8(x)*8
- x2=x1+8
- y1=flr8(y)*8+8
- y2=y1-8
- if fget(spriteid,2) then
- --halfstep up
- y2=y1-4
- end
- if fget(spriteid,3) then
- --halfstep up 2
- y1-=4
- y2-=1
- end
- if fget(spriteid,4) then
- --fullstep up
- --this is default so eh
- y2-=1
- end
- if fget(spriteid,5) then
- --fullstep down
- y1=y2
- y2+=8
- y1-=1
- end
- if fget(spriteid,6) then
- --halfstep down 2
- y1=y2
- y2+=4
- y1-=1
- end
- if fget(spriteid,7) then
- --halfstep down
- y2=y1
- y1-=4
- end
- --now check if x,y is below
- --the line between p1 and p2
- t=(x2-x)/8
- height=lerp(y2,y1,t)
- if (height<=y) return true
- return false
- end
- function flr8(v)
- --converts a position from
- --game space to map space
- return flr(v/8)
- end
- function lerp(a,b,t)
- return (1-t)*a+t*b
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement