• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM collisions with arcs

Negastar

Member
I'm working on a line based collision system for a racing game, and I need the player object to be able to detect curved lines, as they will be part of the boundaries. So far, I've tried using collision_line along with some custom scripts, but to no avail, as it only recognizes the start of the arc in question. Any ideas? Here's the code in the finish line object:
Code:
draw_line_colour(x-1000,y,x+1000,y,c_red,c_red)
draw_line_colour(x-1000,y+offset,x+1000,y+offset,c_red,c_red)
draw_line_colour(x-1000,y-offset,x+1000,y-offset,c_red,c_red)

mDrawRsect(x+1000,y,offset,270,180,1,c_red)
And here's the script code that draws the arc:
Code:
if thi>0
{
 if deg>0
 {
  do
  {
    draw_line_width_colour(xx+(lengthdir_x(rad,aa+iter)-lengthdir_y(0,aa+iter)),yy+(lengthdir_y(rad,aa+iter)+lengthdir_x(0,aa+iter)),xx+(lengthdir_x(rad+thi,aa+iter)-lengthdir_y(0,aa+iter)),yy+(lengthdir_y(rad+thi,aa+iter)+lengthdir_x(0,aa+iter)),thi,color,color)
    iter+=1
  }
  until iter=deg
 }
 else exit;
}
else show_error('Thickness must be greater than zero',true)
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Collision_line should work fine as long as you have it in the loop and are checking each segment as you draw it.
 

Negastar

Member
Well, I tried... still having trouble, and found something different... when I pass through vertical roads, the collision with the line seems to fail every time. Maybe I'm missing something...
 

GMWolf

aka fel666
The other (computationally cheaper) option is to do a collision against a circle, then find where along the curve your collided. If it's within the arc section, then collide.

Not sure if the extra code is worth it. Maybe if you plan on running on mobile.
 

Negastar

Member
The other (computationally cheaper) option is to do a collision against a circle, then find where along the curve your collided. If it's within the arc section, then collide.

Not sure if the extra code is worth it. Maybe if you plan on running on mobile.
Thanks, I'll give it a try. As for the vertical lines not stopping the ship, I'll have to check into it more.
 
Top