P
piksil_demon
Guest
so with my current code, the player will completely stop moving if encountering a wall, and cannot move away. the code im using dosnt use hspeed or vspeed so that all 8 directions are the same speed (google pythagorean theorem if you dont understand why).
so, without switching to hspeed and vspeed- how do i make a collision program for the code bellow?
//variables
var up, down, left, right, arrow;
up = keyboard_check (ord('W'));
down = keyboard_check (ord('S'));
left = keyboard_check (ord('A'));
right = keyboard_check (ord('D'));
//player movemnt
image_angle = point_direction(x, y, mouse_x, mouse_y);
if! up and !down and !left and !right {speed=0};
else {speed=spd;}
if right {
direction = 0;
}
if up {
direction = 90;
}
if left {
direction = 180;
}
if down {
direction = 270;
}
if up and right {
direction = 45;
}
if up and left {
direction = 135;
}
if down and left {
direction = 225;
}
if down and right {
direction = 315;
}
//collision
if instance_place (x,y, obj_wall)speed = 0;
i asked for help on this earlier but got no helpful advice
p.s. i dont need to be told what the problem with the code is. i need to be told the solution
so, without switching to hspeed and vspeed- how do i make a collision program for the code bellow?
//variables
var up, down, left, right, arrow;
up = keyboard_check (ord('W'));
down = keyboard_check (ord('S'));
left = keyboard_check (ord('A'));
right = keyboard_check (ord('D'));
//player movemnt
image_angle = point_direction(x, y, mouse_x, mouse_y);
if! up and !down and !left and !right {speed=0};
else {speed=spd;}
if right {
direction = 0;
}
if up {
direction = 90;
}
if left {
direction = 180;
}
if down {
direction = 270;
}
if up and right {
direction = 45;
}
if up and left {
direction = 135;
}
if down and left {
direction = 225;
}
if down and right {
direction = 315;
}
//collision
if instance_place (x,y, obj_wall)speed = 0;
i asked for help on this earlier but got no helpful advice
p.s. i dont need to be told what the problem with the code is. i need to be told the solution