Legacy GM Collision Checking With Direction

Hello everyone, this may be much easier then I'm making it, but I can't figure it out and I'm sure you guys can :)
I am creating a car in my game using the built-in direction and speed variables; the problem is that I don't know how to do collision checking.
this is my code: (the bottom is the collision detection)
Code:
if(Drive) {
UpKey = -(keyboard_check(ord("W")) || (gamepad_axis_value(0,gp_axislv) < 0))
DownKey = keyboard_check(ord("S")) || (gamepad_axis_value(0,gp_axislv) > 0)
LeftKey = -(keyboard_check(ord("A")) || gamepad_axis_value(0,gp_axislh) < 0)
RightKey = keyboard_check(ord("D")) || (gamepad_axis_value(0,gp_axislh) > 0)

if(UpKey = -1 || DownKey = 1) {
if(acceleration < Speed) {
acceleration += (UpKey+DownKey)*0.1
}
} else {
if(acceleration != 0) {
acceleration = MoveToValue(acceleration,0,0.4)
}
}

if(acceleration != 0) {
image_angle += (LeftKey+RightKey)*(acceleration/Speed)*Handling
}

direction = image_angle
speed = acceleration*-1
} else {
if(acceleration != 0) {
acceleration = MoveToValue(acceleration,0,0.4)
}
speed = acceleration*-1
}

if(place_meeting(x+lengthdir_x(speed,direction),y+lengthdir_y(speed,direction),objSolids)) {
while(!place_meeting(x+sign(lengthdir_x(speed,direction)),y,objSolids)) {
x+=sign(lengthdir_x(speed,direction))
}
while(!place_meeting(x,y+sign(lengthdir_y(speed,direction)),objSolids)) {
y+=sign(lengthdir_y(speed,direction))
}
acceleration = acceleration*-1
}
it all works find, but when I come in contact with "objSolid" the car freezes.
If you need more info or anything, just ask! :p
Thanks for the help!:bunny:
 
Top