P
piksil_demon
Guest
honestly with how much i use this forum i might aswell have you guys program the whole damn game lol.
anyways, heres my problem. when my characters sprite hits the wall, i cant move until the sprite is no longer hitting it.. however, if i touch it at a certain angle, it makes movement impossible. here it my character code so you can play around with it a bit
//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'));
(ps, in this case spd is = 3)
//player movemnt
image_angle = point_direction(x, y, mouse_x, mouse_y);
if right {
speed = spd; direction = 0;
}
if up {
speed = spd; direction = 90;
}
if left {
speed = spd; direction = 180;
}
if down {
speed = spd; direction = 270;
}
if up and right {
speed = spd; direction = 45;
}
if up and left {
speed = spd; direction = 135;
}
if down and left {
speed = spd; direction = 225;
}
if down and right {
speed = spd; direction = 315;
}
if! up and !down and !left and !right {speed=0};
//collision
if instance_place (x,y,obj_enemy_parent) {hp -= global.enatk;}
if instance_place (x,y, obj_wall)speed = 0;
i know that in theory i need to make it be able to detect where the wall is, and only prevent movement in that direction, but i cant figure out howto do that without rewriting the whole thing.
anyways, heres my problem. when my characters sprite hits the wall, i cant move until the sprite is no longer hitting it.. however, if i touch it at a certain angle, it makes movement impossible. here it my character code so you can play around with it a bit
//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'));
(ps, in this case spd is = 3)
//player movemnt
image_angle = point_direction(x, y, mouse_x, mouse_y);
if right {
speed = spd; direction = 0;
}
if up {
speed = spd; direction = 90;
}
if left {
speed = spd; direction = 180;
}
if down {
speed = spd; direction = 270;
}
if up and right {
speed = spd; direction = 45;
}
if up and left {
speed = spd; direction = 135;
}
if down and left {
speed = spd; direction = 225;
}
if down and right {
speed = spd; direction = 315;
}
if! up and !down and !left and !right {speed=0};
//collision
if instance_place (x,y,obj_enemy_parent) {hp -= global.enatk;}
if instance_place (x,y, obj_wall)speed = 0;
i know that in theory i need to make it be able to detect where the wall is, and only prevent movement in that direction, but i cant figure out howto do that without rewriting the whole thing.