Collision_line

T

Toxicosis

Guest
Hello,

does anyone know the workings of collision_line? I need a line_in_rectangle collision, which is egregiously missing from the functions. I need to be able to check if a line collides with rectangles, but I can't just have an instance everywhere I need to look; I'm going to be using thousands of those rectangles.

I had something that worked, but it required pretty much end-to-end penetration.

Help plz?
 
T

Toxicosis

Guest
I needed to do a tile collision, but I was going to use absurdly huge levels, and absurdly large numbers of tiles, so I made myself a binary tree search algorhitm for each block size. In it, every block is not a tile, but simply an x,y pair that denotes its top left corner, stored within a ds_grid.

I need to check line of sight between an object and the player, see whether there's any blocks in the way: line_collision would've been extremely useful, but I can't use it if what blocks line of sight isn't objects. I need a collision between a line and an arbitrary rectangle, because that's the only way I'll be able to use the ds_grid to check for line of sight.
 

RangerX

Member
Isn't there a function in the "tile" family where you can detect what tile is at a given coordinate? Maybe you could loop that function (forming a line?)
 
T

Toxicosis

Guest
Actually, nevermind, I figured out a fix. I'll just amend my function to add two point_in_rectangle calls in it, one at the start and one at the end of the line, before the rest of the function is evaluated. If either returns a positive, then the whole function will return a positive.
 
Top